【修改】文件夹校验 名称和类型组合不能重复
This commit is contained in:
@@ -609,56 +609,63 @@ function setKao() {
|
||||
kaoDialogVisible.value = true
|
||||
}
|
||||
async function confirmKao() {
|
||||
|
||||
const contentSet = new Set<string>();
|
||||
const nameTypeSet = new Set<string>(); // 用于存储 文件名+考察类型 的组合
|
||||
|
||||
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
|
||||
}
|
||||
if (!item.contentIn || item.contentIn.trim() === '') {
|
||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`)
|
||||
return
|
||||
}
|
||||
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!contentIn) {
|
||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验 文件名 + 考察类型 的组合唯一性
|
||||
const combinedKey = `${content}|||${contentIn}`;
|
||||
if (nameTypeSet.has(combinedKey)) {
|
||||
ElMessage.warning(`第 ${index + 1} 行「文件名 + 考察类型」组合不能重复`);
|
||||
return;
|
||||
}
|
||||
nameTypeSet.add(combinedKey);
|
||||
}
|
||||
|
||||
// 构建 questionAnswerList
|
||||
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({
|
||||
|
@@ -609,56 +609,63 @@ function setKao() {
|
||||
kaoDialogVisible.value = true
|
||||
}
|
||||
async function confirmKao() {
|
||||
|
||||
const contentSet = new Set<string>();
|
||||
const nameTypeSet = new Set<string>(); // 用于存储 文件名+考察类型 的组合
|
||||
|
||||
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
|
||||
}
|
||||
if (!item.contentIn || item.contentIn.trim() === '') {
|
||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`)
|
||||
return
|
||||
}
|
||||
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!contentIn) {
|
||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 校验 文件名 + 考察类型 的组合唯一性
|
||||
const combinedKey = `${content}|||${contentIn}`;
|
||||
if (nameTypeSet.has(combinedKey)) {
|
||||
ElMessage.warning(`第 ${index + 1} 行「文件名 + 考察类型」组合不能重复`);
|
||||
return;
|
||||
}
|
||||
nameTypeSet.add(combinedKey);
|
||||
}
|
||||
|
||||
// 构建 questionAnswerList
|
||||
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({
|
||||
|
@@ -459,7 +459,8 @@ const kaodianData = ref({
|
||||
|
||||
const formRules = reactive<FormRules>({
|
||||
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
||||
tname: [{ required: true, message: '数据库库名称不能为空', trigger: 'blur' }]
|
||||
tname: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }]
|
||||
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
// 左侧试题描述
|
||||
|
Reference in New Issue
Block a user