fix(xg): 操行分修改改为更新待审核记录,录入页保留审核中状态
同一月份再次修改不再因唯一约束失败,刷新后仍能看到待审分数。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
fcb695664b
commit
7f9d3830ad
7 files changed
+189
-58
No files matched your search
@@ -290,9 +290,12 @@
|
||||
<el-input v-model="scope.row.remark" size="small" placeholder="输入备注(可选)" maxlength="500" show-word-limit />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[6].visible" key="status" label="状态" align="center" width="120">
|
||||
<el-table-column v-if="columns[6].visible" key="status" label="状态" align="center" width="140">
|
||||
<template #default="scope">
|
||||
<el-tag :type="getStudentStatusTagType(scope.row)" size="small">{{ getStudentStatus(scope.row) }}</el-tag>
|
||||
<div v-if="scope.row.pendingAuditId" style="margin-top: 2px; font-size: 12px; line-height: 1.2; color: #e6a23c">
|
||||
待审 {{ Number(scope.row.pendingScore) }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column v-if="columns[7].visible" key="lastScore" label="上月分数" align="center" width="100">
|
||||
@@ -522,15 +525,17 @@ const getStudentStatus = (student) => {
|
||||
}
|
||||
|
||||
if (hasExistingScore && hasCurrentScore) {
|
||||
// 比较分数和备注是否变化
|
||||
// 比较分数和备注是否变化。未保存的改动显示待审核;已提交且尚未审完显示审核中
|
||||
const scoreChanged = Number(student.score) !== Number(student.existingScore.score);
|
||||
const remarkChanged = String(student.remark || '').trim() !== String(student.existingScore.remark || '').trim();
|
||||
|
||||
if (scoreChanged || remarkChanged) {
|
||||
return '待审核';
|
||||
} else {
|
||||
return '已录入';
|
||||
}
|
||||
if (student.pendingAuditId !== null && student.pendingAuditId !== undefined && student.pendingAuditId !== '') {
|
||||
return '审核中';
|
||||
}
|
||||
return '已录入';
|
||||
}
|
||||
|
||||
return '未录入';
|
||||
@@ -547,6 +552,7 @@ const getStudentStatusTagType = (student) => {
|
||||
case '已录入':
|
||||
return 'success';
|
||||
case '待审核':
|
||||
case '审核中':
|
||||
return 'warning';
|
||||
default:
|
||||
return 'info';
|
||||
@@ -772,17 +778,11 @@ const handleSaveAll = () => {
|
||||
type: auditStudents.length > 0 ? 'warning' : 'success',
|
||||
dangerouslyUseHTMLString: true
|
||||
}).then(() => {
|
||||
// 分批处理直接保存和审核
|
||||
if (directSaveStudents.length > 0) {
|
||||
saveBatchData(directSaveStudents, 'add');
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
saveBatchData(auditStudents, 'update');
|
||||
}
|
||||
submitScoreBatches(directSaveStudents, auditStudents);
|
||||
});
|
||||
};
|
||||
|
||||
const saveBatchData = async (students, operationType = 'add') => {
|
||||
const saveBatchData = async (students, operationType = 'add', refresh = true) => {
|
||||
try {
|
||||
const batchData = {
|
||||
academicYear: queryParams.academicYear,
|
||||
@@ -817,7 +817,9 @@ const saveBatchData = async (students, operationType = 'add') => {
|
||||
}
|
||||
}
|
||||
|
||||
getList();
|
||||
if (refresh) {
|
||||
await getList();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('保存数据失败:', error);
|
||||
const operationName = operationType === 'update' ? '提交审核' : '保存';
|
||||
@@ -825,6 +827,18 @@ const saveBatchData = async (students, operationType = 'add') => {
|
||||
}
|
||||
};
|
||||
|
||||
const submitScoreBatches = async (directStudents, auditStudents) => {
|
||||
const jobs = [];
|
||||
if (directStudents.length > 0) {
|
||||
jobs.push(saveBatchData(directStudents, 'add', false));
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
jobs.push(saveBatchData(auditStudents, 'update', false));
|
||||
}
|
||||
await Promise.allSettled(jobs);
|
||||
await getList();
|
||||
};
|
||||
|
||||
// 批量录入弹窗数据与确认保存
|
||||
const batchModalVisible = ref(false);
|
||||
const batchModalForm = reactive({
|
||||
@@ -888,34 +902,17 @@ const confirmBatchModalSave = () => {
|
||||
|
||||
batchModalVisible.value = false;
|
||||
|
||||
// 分批处理
|
||||
if (directSaveStudents.length > 0) {
|
||||
const directSaveData = directSaveStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
saveBatchData(directSaveData, 'add');
|
||||
}
|
||||
|
||||
if (auditStudents.length > 0) {
|
||||
const auditData = auditStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
saveBatchData(auditData, 'update');
|
||||
}
|
||||
|
||||
// 显示操作结果
|
||||
let message = '批量操作完成:';
|
||||
if (directSaveStudents.length > 0) {
|
||||
message += `保存 ${directSaveStudents.length} 个学生`;
|
||||
}
|
||||
if (auditStudents.length > 0) {
|
||||
message += `${directSaveStudents.length > 0 ? ',' : ''}提交 ${auditStudents.length} 个修改学生审核`;
|
||||
}
|
||||
ElMessage.success(message);
|
||||
const directSaveData = directSaveStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
const auditData = auditStudents.map((stu) => ({
|
||||
studentId: stu.studentId,
|
||||
score: batchModalForm.score,
|
||||
remark: batchModalForm.remark || ''
|
||||
}));
|
||||
submitScoreBatches(directSaveData, auditData);
|
||||
};
|
||||
|
||||
const handleRefresh = () => {
|
||||
|
||||
Reference in new issue
Block a user