Browse Source

bug修改

dev
zhaowenkang 5 months ago
parent
commit
5bf5a76272
  1. 23
      work/src/views/AddWork.vue
  2. 2
      work/src/views/HomeWork.vue
  3. 25
      work/src/views/UpdateWork.vue

23
work/src/views/AddWork.vue

@ -78,7 +78,7 @@
</div>
</div>
<div class="submit">
<el-button type="primary" :disabled="!form.Name||!form.picker" @click="onSubmit">确认</el-button>
<el-button type="primary" :disabled="!form.Name || !form.picker" @click="onSubmit">确认</el-button>
</div>
</el-form>
</div>
@ -132,6 +132,16 @@ const articleTitle = ref('');
const questions = ref([]);
const onSubmit = () => {
let hasEmptyDescription = false;
questions.value.forEach(question => {
if (question.description === '') {
hasEmptyDescription = true;
}
});
if (hasEmptyDescription) {
ElMessage.error('存在题目未填写描述内容,请填写完整后再提交!');
return;
}
// picker
if (form.value.picker && form.value.picker.length === 2) {
const startDate = dayjs(form.value.picker[0]).format('YYYY-MM-DD HH:mm:00');
@ -258,12 +268,19 @@ const addMultipleChoice = () => {
});
};
//const hasAddedBlank=ref(false);
const addBlank = () => {
// hasAddedBlanktrue
//if (!hasAddedBlank.value) {
questions.value.push({
type: 3, // 3
description: '',
content: [{ "id": "", "text": "" }]
});
// hasAddedBlank.value = true;
// }else {
// ElMessage.warning('');
// }
};
@ -277,9 +294,9 @@ const addOption = (questionIndex) => {
};
const removeOption = (questionIndex, optionIndex) => {
const currentQuestion = questions.value[questionIndex];
// 2
//
if (currentQuestion.type === 1) {
// 2
// 2
if (currentQuestion.content.length <= 1) {
ElMessage.warning('单选题至少需要保留一个选项,不能继续删除');
return;

2
work/src/views/HomeWork.vue

@ -58,7 +58,7 @@
</el-table-column>
<el-table-column prop="status" label="状态">
<template #default="{ row }">
<span v-if="row.status === 0">上架</span>
<span v-if="row.status === 0">发布</span>
<span v-else-if="row.status === 1">发布中</span>
<span v-else-if="row.status === 2">已下架</span>
</template>

25
work/src/views/UpdateWork.vue

@ -305,6 +305,16 @@ const articleTitle = ref("");
//
const questions = ref([]);
const onSubmit = () => {
let hasEmptyDescription = false;
questions.value.forEach(question => {
if (question.description === '') {
hasEmptyDescription = true;
}
});
if (hasEmptyDescription) {
ElMessage.error('存在题目未填写描述内容,请填写完整后再提交!');
return;
}
// picker
if (form.value.picker && form.value.picker.length === 2) {
const startDate = dayjs(form.value.picker[0]).format("YYYY-MM-DD HH:mm:00");
@ -464,16 +474,19 @@ const addMultipleChoice = () => {
}
};
//const hasAddedBlank=ref(false);
const addBlank = () => {
if (isPublished.value === 1) {
ElMessage.warning("处于发布中,不能添加新题目");
} else {
// hasAddedBlanktrue
//if (!hasAddedBlank.value) {
questions.value.push({
type: 3, // 3
description: "",
content: [{ id: "", text: "" }],
description: '',
content: [{ "id": "", "text": "" }]
});
}
// hasAddedBlank.value = true;
// }else {
// ElMessage.warning('');
// }
};
const addOption = (questionIndex) => {

Loading…
Cancel
Save