【修改】文件夹校验 名称和类型组合不能重复
This commit is contained in:
@@ -609,32 +609,39 @@ function setKao() {
|
|||||||
kaoDialogVisible.value = true
|
kaoDialogVisible.value = true
|
||||||
}
|
}
|
||||||
async function confirmKao() {
|
async function confirmKao() {
|
||||||
|
|
||||||
const contentSet = new Set<string>();
|
const contentSet = new Set<string>();
|
||||||
|
const nameTypeSet = new Set<string>(); // 用于存储 文件名+考察类型 的组合
|
||||||
|
|
||||||
for (const [index, item] of kaodiaRefList.value.entries()) {
|
for (const [index, item] of kaodiaRefList.value.entries()) {
|
||||||
if (!item.content || item.content.trim() === '') {
|
const content = item.content?.trim();
|
||||||
ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`)
|
const contentIn = item.contentIn?.trim();
|
||||||
return
|
|
||||||
|
if (!content) {
|
||||||
|
ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (contentSet.has(item.content.trim())) {
|
|
||||||
ElMessage.warning(`第 ${index + 1} 行「文件名」不能重复`)
|
contentSet.add(content);
|
||||||
return
|
|
||||||
}
|
|
||||||
contentSet.add(item.content.trim())
|
|
||||||
|
|
||||||
if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) {
|
if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) {
|
||||||
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`)
|
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`);
|
||||||
return
|
return;
|
||||||
}
|
|
||||||
if (!item.contentIn || item.contentIn.trim() === '') {
|
|
||||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`)
|
|
||||||
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 => ({
|
const questionAnswerList = kaodiaRefList.value.map(item => ({
|
||||||
answerId: item.answerId,
|
answerId: item.answerId,
|
||||||
content: item.content,
|
content: item.content,
|
||||||
@@ -643,22 +650,22 @@ async function confirmKao() {
|
|||||||
scoreRate: item.scoreRate,
|
scoreRate: item.scoreRate,
|
||||||
attribute: item.attribute
|
attribute: item.attribute
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
quId: kaodianData.value.quId,
|
quId: kaodianData.value.quId,
|
||||||
questionAnswerList
|
questionAnswerList
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('确认后的结果:', payload);
|
||||||
|
|
||||||
console.log('确认后的结果:', payload)
|
await QuestionApi.setBrowserPoint(payload);
|
||||||
|
|
||||||
await QuestionApi.setBrowserPoint(payload)
|
|
||||||
|
|
||||||
const res = await QuestionApi.getListByQuId(kaodianData.value.quId);
|
const res = await QuestionApi.getListByQuId(kaodianData.value.quId);
|
||||||
kaodianList.value = res;
|
kaodianList.value = res;
|
||||||
kaoDialogVisible.value = false;
|
kaoDialogVisible.value = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 增加行
|
// 增加行
|
||||||
function addKaodianRow() {
|
function addKaodianRow() {
|
||||||
kaodiaRefList.value.push({
|
kaodiaRefList.value.push({
|
||||||
|
@@ -609,32 +609,39 @@ function setKao() {
|
|||||||
kaoDialogVisible.value = true
|
kaoDialogVisible.value = true
|
||||||
}
|
}
|
||||||
async function confirmKao() {
|
async function confirmKao() {
|
||||||
|
|
||||||
const contentSet = new Set<string>();
|
const contentSet = new Set<string>();
|
||||||
|
const nameTypeSet = new Set<string>(); // 用于存储 文件名+考察类型 的组合
|
||||||
|
|
||||||
for (const [index, item] of kaodiaRefList.value.entries()) {
|
for (const [index, item] of kaodiaRefList.value.entries()) {
|
||||||
if (!item.content || item.content.trim() === '') {
|
const content = item.content?.trim();
|
||||||
ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`)
|
const contentIn = item.contentIn?.trim();
|
||||||
return
|
|
||||||
|
if (!content) {
|
||||||
|
ElMessage.warning(`第 ${index + 1} 行「文件名」不能为空`);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if (contentSet.has(item.content.trim())) {
|
|
||||||
ElMessage.warning(`第 ${index + 1} 行「文件名」不能重复`)
|
contentSet.add(content);
|
||||||
return
|
|
||||||
}
|
|
||||||
contentSet.add(item.content.trim())
|
|
||||||
|
|
||||||
if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) {
|
if (item.scoreRate === null || item.scoreRate === '' || item.scoreRate < 0) {
|
||||||
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`)
|
ElMessage.warning(`第 ${index + 1} 行「权值」不能为空且不能小于 0`);
|
||||||
return
|
return;
|
||||||
}
|
|
||||||
if (!item.contentIn || item.contentIn.trim() === '') {
|
|
||||||
ElMessage.warning(`第 ${index + 1} 行「考察类型」不能为空`)
|
|
||||||
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 => ({
|
const questionAnswerList = kaodiaRefList.value.map(item => ({
|
||||||
answerId: item.answerId,
|
answerId: item.answerId,
|
||||||
content: item.content,
|
content: item.content,
|
||||||
@@ -643,22 +650,22 @@ async function confirmKao() {
|
|||||||
scoreRate: item.scoreRate,
|
scoreRate: item.scoreRate,
|
||||||
attribute: item.attribute
|
attribute: item.attribute
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
quId: kaodianData.value.quId,
|
quId: kaodianData.value.quId,
|
||||||
questionAnswerList
|
questionAnswerList
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('确认后的结果:', payload);
|
||||||
|
|
||||||
console.log('确认后的结果:', payload)
|
await QuestionApi.setBrowserPoint(payload);
|
||||||
|
|
||||||
await QuestionApi.setBrowserPoint(payload)
|
|
||||||
|
|
||||||
const res = await QuestionApi.getListByQuId(kaodianData.value.quId);
|
const res = await QuestionApi.getListByQuId(kaodianData.value.quId);
|
||||||
kaodianList.value = res;
|
kaodianList.value = res;
|
||||||
kaoDialogVisible.value = false;
|
kaoDialogVisible.value = false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 增加行
|
// 增加行
|
||||||
function addKaodianRow() {
|
function addKaodianRow() {
|
||||||
kaodiaRefList.value.push({
|
kaodiaRefList.value.push({
|
||||||
|
@@ -459,7 +459,8 @@ const kaodianData = ref({
|
|||||||
|
|
||||||
const formRules = reactive<FormRules>({
|
const formRules = reactive<FormRules>({
|
||||||
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
// specialtyName: [{ required: true, message: '用户名称不能为空', trigger: 'blur' }]
|
||||||
tname: [{ required: true, message: '数据库库名称不能为空', trigger: 'blur' }]
|
tname: [{ required: true, message: '数据库名称不能为空', trigger: 'blur' }]
|
||||||
|
|
||||||
})
|
})
|
||||||
const formRef = ref() // 表单 Ref
|
const formRef = ref() // 表单 Ref
|
||||||
// 左侧试题描述
|
// 左侧试题描述
|
||||||
|
Reference in New Issue
Block a user