From ee2263e91e5f3cf8e5ab5614dff509d654e5f775 Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Tue, 24 Jun 2025 17:41:02 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=B9=E6=A0=A1=E9=AA=8C=20=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E5=92=8C=E7=B1=BB=E5=9E=8B=E7=BB=84=E5=90=88=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E9=87=8D=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/paper/audit/FileForm.vue | 63 ++++++++++++++------------ src/views/paper/question/FileForm.vue | 63 ++++++++++++++------------ src/views/paper/question/MysqlForm.vue | 3 +- 3 files changed, 72 insertions(+), 57 deletions(-) diff --git a/src/views/paper/audit/FileForm.vue b/src/views/paper/audit/FileForm.vue index f5d70f9..96165de 100644 --- a/src/views/paper/audit/FileForm.vue +++ b/src/views/paper/audit/FileForm.vue @@ -609,56 +609,63 @@ function setKao() { kaoDialogVisible.value = true } async function confirmKao() { - const contentSet = new Set(); + const nameTypeSet = new Set(); // 用于存储 文件名+考察类型 的组合 for (const [index, item] of kaodiaRefList.value.entries()) { - if (!item.content || item.content.trim() === '') { - ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`) - return + const content = item.content?.trim(); + const contentIn = item.contentIn?.trim(); + + if (!content) { + ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`); + return; } - if (contentSet.has(item.content.trim())) { - ElMessage.warning(`第 ${index + 1} 行「文件名」不能重复`) - return - } - contentSet.add(item.content.trim()) + + contentSet.add(content); if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) { - ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`) - return + ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`); + return; } - if (!item.contentIn || item.contentIn.trim() === '') { - ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`) - return - } - } - - // 构建 questionAnswerList + if (!contentIn) { + ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`); + return; + } + + // 校验 文件名 + 考察类型 的组合唯一性 + const combinedKey = `${content}|||${contentIn}`; + if (nameTypeSet.has(combinedKey)) { + ElMessage.warning(`第 ${index + 1} 行「文件名 + 考察类型」组合不能重复`); + return; + } + nameTypeSet.add(combinedKey); + } + const questionAnswerList = kaodiaRefList.value.map(item => ({ answerId: item.answerId, content: item.content, - quId:kaodianData.value.quId, - contentIn:item.contentIn, - scoreRate:item.scoreRate, - attribute:item.attribute + quId: kaodianData.value.quId, + contentIn: item.contentIn, + scoreRate: item.scoreRate, + attribute: item.attribute })); + const payload = { - quId:kaodianData.value.quId, + quId: kaodianData.value.quId, questionAnswerList }; + console.log('确认后的结果:', payload); - console.log('确认后的结果:', payload) - - await QuestionApi.setBrowserPoint(payload) + await QuestionApi.setBrowserPoint(payload); const res = await QuestionApi.getListByQuId(kaodianData.value.quId); kaodianList.value = res; - kaoDialogVisible.value= false; - + kaoDialogVisible.value = false; } + // 增加行 function addKaodianRow() { kaodiaRefList.value.push({ diff --git a/src/views/paper/question/FileForm.vue b/src/views/paper/question/FileForm.vue index f5d70f9..96165de 100644 --- a/src/views/paper/question/FileForm.vue +++ b/src/views/paper/question/FileForm.vue @@ -609,56 +609,63 @@ function setKao() { kaoDialogVisible.value = true } async function confirmKao() { - const contentSet = new Set(); + const nameTypeSet = new Set(); // 用于存储 文件名+考察类型 的组合 for (const [index, item] of kaodiaRefList.value.entries()) { - if (!item.content || item.content.trim() === '') { - ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`) - return + const content = item.content?.trim(); + const contentIn = item.contentIn?.trim(); + + if (!content) { + ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`); + return; } - if (contentSet.has(item.content.trim())) { - ElMessage.warning(`第 ${index + 1} 行「文件名」不能重复`) - return - } - contentSet.add(item.content.trim()) + + contentSet.add(content); if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) { - ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`) - return + ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`); + return; } - if (!item.contentIn || item.contentIn.trim() === '') { - ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`) - return - } - } - - // 构建 questionAnswerList + if (!contentIn) { + ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`); + return; + } + + // 校验 文件名 + 考察类型 的组合唯一性 + const combinedKey = `${content}|||${contentIn}`; + if (nameTypeSet.has(combinedKey)) { + ElMessage.warning(`第 ${index + 1} 行「文件名 + 考察类型」组合不能重复`); + return; + } + nameTypeSet.add(combinedKey); + } + const questionAnswerList = kaodiaRefList.value.map(item => ({ answerId: item.answerId, content: item.content, - quId:kaodianData.value.quId, - contentIn:item.contentIn, - scoreRate:item.scoreRate, - attribute:item.attribute + quId: kaodianData.value.quId, + contentIn: item.contentIn, + scoreRate: item.scoreRate, + attribute: item.attribute })); + const payload = { - quId:kaodianData.value.quId, + quId: kaodianData.value.quId, questionAnswerList }; + console.log('确认后的结果:', payload); - console.log('确认后的结果:', payload) - - await QuestionApi.setBrowserPoint(payload) + await QuestionApi.setBrowserPoint(payload); const res = await QuestionApi.getListByQuId(kaodianData.value.quId); kaodianList.value = res; - kaoDialogVisible.value= false; - + kaoDialogVisible.value = false; } + // 增加行 function addKaodianRow() { kaodiaRefList.value.push({ diff --git a/src/views/paper/question/MysqlForm.vue b/src/views/paper/question/MysqlForm.vue index c0576e8..8129a78 100644 --- a/src/views/paper/question/MysqlForm.vue +++ b/src/views/paper/question/MysqlForm.vue @@ -459,7 +459,8 @@ const kaodianData = ref({ const formRules = reactive({ // specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }] - tname: [{ required: true, message: '数据库库名称不能为空', trigger: 'blur' }] + tname: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }] + }) const formRef = ref() // 表单 Ref // 左侧试题描述