v2.6更新
This commit is contained in:
@@ -71,18 +71,18 @@ class SubjectModel:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def has_related_data(subject_id: int) -> bool:
|
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
|
@staticmethod
|
||||||
async def delete(subject_id: int) -> bool:
|
async def delete(subject_id: int) -> bool:
|
||||||
"""软删除科目(设置 is_active = 0),如果已禁用也返回成功"""
|
"""真正删除科目记录"""
|
||||||
subject = await SubjectModel.get_by_id(subject_id)
|
subject = await SubjectModel.get_by_id(subject_id)
|
||||||
if not subject:
|
if not subject:
|
||||||
return False
|
return False
|
||||||
if subject.get("is_active") == 0:
|
sql = "DELETE FROM subjects WHERE subject_id = %s"
|
||||||
return True # 已禁用,视为成功
|
|
||||||
sql = "UPDATE subjects SET is_active = 0 WHERE subject_id = %s"
|
|
||||||
result = await execute_update(sql, (subject_id,))
|
result = await execute_update(sql, (subject_id,))
|
||||||
return result > 0
|
return result > 0
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class SubjectService:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
async def delete_subject(subject_id: int) -> Dict[str, Any]:
|
async def delete_subject(subject_id: int) -> Dict[str, Any]:
|
||||||
"""删除科目(软删除)"""
|
"""删除科目(真正删除记录)"""
|
||||||
# 检查科目是否有关联数据
|
# 检查科目是否有关联数据
|
||||||
has_data = await SubjectModel.has_related_data(subject_id)
|
has_data = await SubjectModel.has_related_data(subject_id)
|
||||||
if has_data:
|
if has_data:
|
||||||
@@ -76,7 +76,7 @@ class SubjectService:
|
|||||||
result = await SubjectModel.delete(subject_id)
|
result = await SubjectModel.delete(subject_id)
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
logger.info(f"禁用科目: {subject_id}")
|
logger.info(f"删除科目: {subject_id}")
|
||||||
return {"success": True}
|
return {"success": True}
|
||||||
else:
|
else:
|
||||||
return {"success": False, "message": "禁用科目失败"}
|
return {"success": False, "message": "删除科目失败"}
|
||||||
@@ -853,10 +853,6 @@ tr:hover {
|
|||||||
|
|
||||||
.action-dropdown-menu {
|
.action-dropdown-menu {
|
||||||
display: none;
|
display: none;
|
||||||
position: absolute;
|
|
||||||
bottom: 100%;
|
|
||||||
right: 0;
|
|
||||||
margin-bottom: 4px;
|
|
||||||
background: white;
|
background: white;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
|
||||||
@@ -899,12 +895,6 @@ tr:hover {
|
|||||||
color: var(--color-danger-dark);
|
color: var(--color-danger-dark);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (max-width: 768px) {
|
|
||||||
.action-dropdown-menu {
|
|
||||||
right: auto;
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ========== 链接 ========== */
|
/* ========== 链接 ========== */
|
||||||
.link {
|
.link {
|
||||||
@@ -937,11 +927,11 @@ tr:hover {
|
|||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 原因列:每行最少7个字,自动换行 */
|
/* 原因列:每行最少7个字,自动换行(使用td前缀提升优先级,防止被preserve-newlines覆盖) */
|
||||||
.history-reason {
|
td.history-reason {
|
||||||
min-width: 7em;
|
min-width: 7em;
|
||||||
max-width: 200px;
|
max-width: 200px;
|
||||||
white-space: normal;
|
white-space: normal !important;
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
vertical-align: top;
|
vertical-align: top;
|
||||||
|
|||||||
@@ -359,6 +359,8 @@ function closeAllDropdowns() {
|
|||||||
m.style.position = '';
|
m.style.position = '';
|
||||||
m.style.left = '';
|
m.style.left = '';
|
||||||
m.style.top = '';
|
m.style.top = '';
|
||||||
|
m.style.bottom = '';
|
||||||
|
m.style.right = '';
|
||||||
m.style.transform = '';
|
m.style.transform = '';
|
||||||
var toggle = m.closest('.action-dropdown');
|
var toggle = m.closest('.action-dropdown');
|
||||||
if (toggle) {
|
if (toggle) {
|
||||||
|
|||||||
Reference in New Issue
Block a user