v2.6更新

This commit is contained in:
2026-05-29 21:35:27 +08:00
parent 69adb30fa0
commit 5805b11834
4 changed files with 14 additions and 22 deletions

View File

@@ -71,18 +71,18 @@ class SubjectModel:
@staticmethod
async def has_related_data(subject_id: int) -> bool:
"""检查科目是否有关联数据"""
return False
"""检查科目是否有关联的作业数据"""
sql = "SELECT COUNT(*) AS cnt FROM assignments WHERE subject_id = %s"
result = await execute_one(sql, (subject_id,))
return result and result.get("cnt", 0) > 0
@staticmethod
async def delete(subject_id: int) -> bool:
"""删除科目(设置 is_active = 0如果已禁用也返回成功"""
"""真正删除科目记录"""
subject = await SubjectModel.get_by_id(subject_id)
if not subject:
return False
if subject.get("is_active") == 0:
return True # 已禁用,视为成功
sql = "UPDATE subjects SET is_active = 0 WHERE subject_id = %s"
sql = "DELETE FROM subjects WHERE subject_id = %s"
result = await execute_update(sql, (subject_id,))
return result > 0

View File

@@ -67,7 +67,7 @@ class SubjectService:
@staticmethod
async def delete_subject(subject_id: int) -> Dict[str, Any]:
"""删除科目(软删除"""
"""删除科目(真正删除记录"""
# 检查科目是否有关联数据
has_data = await SubjectModel.has_related_data(subject_id)
if has_data:
@@ -76,7 +76,7 @@ class SubjectService:
result = await SubjectModel.delete(subject_id)
if result:
logger.info(f"禁用科目: {subject_id}")
logger.info(f"删除科目: {subject_id}")
return {"success": True}
else:
return {"success": False, "message": "禁用科目失败"}
return {"success": False, "message": "删除科目失败"}

View File

@@ -853,10 +853,6 @@ tr:hover {
.action-dropdown-menu {
display: none;
position: absolute;
bottom: 100%;
right: 0;
margin-bottom: 4px;
background: white;
border-radius: 8px;
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
@@ -899,12 +895,6 @@ tr:hover {
color: var(--color-danger-dark);
}
@media (max-width: 768px) {
.action-dropdown-menu {
right: auto;
left: 0;
}
}
/* ========== 链接 ========== */
.link {
@@ -937,11 +927,11 @@ tr:hover {
vertical-align: top;
}
/* 原因列每行最少7个字自动换行 */
.history-reason {
/* 原因列每行最少7个字自动换行使用td前缀提升优先级防止被preserve-newlines覆盖 */
td.history-reason {
min-width: 7em;
max-width: 200px;
white-space: normal;
white-space: normal !important;
word-break: break-word;
line-height: 1.5;
vertical-align: top;

View File

@@ -359,6 +359,8 @@ function closeAllDropdowns() {
m.style.position = '';
m.style.left = '';
m.style.top = '';
m.style.bottom = '';
m.style.right = '';
m.style.transform = '';
var toggle = m.closest('.action-dropdown');
if (toggle) {