fix:评估管理-单选题-多选题-问答题-评分提编辑删除选项保存修改bug修复

This commit is contained in:
wyx
2023-03-08 23:25:01 +08:00
parent 06875c82fb
commit 003c3b0e00
4 changed files with 138 additions and 77 deletions

View File

@@ -56,7 +56,7 @@
<script>
import { ref } from "vue";
import ResearchAddItem from "./ResearchAddItem.vue";
import { deleteChoiceQuestion } from "@/api/indexResearch";
// import { deleteChoiceQuestion } from "@/api/indexResearch";
export default {
name: "ResearchAddSingle",
@@ -104,32 +104,44 @@ export default {
}
});
};
const del = ({ id, optionId }) => {
const del = ({ id, optionId}) => {
// 接口删除
// if (assessmentId.value && optionId) {
// deleteChoiceQuestion({
// assessmentId: assessmentId.value,
// questionType: "1",
// optionId,
// }).then((res) => {
// if (res.data.code === 200) {
// virtualDel(id);
// }
// });
// } else {
// virtualDel(id);
// }
if (assessmentId.value && optionId) {
deleteChoiceQuestion({
assessmentId: assessmentId.value,
questionType: "1",
optionId,
}).then((res) => {
if (res.data.code === 200) {
virtualDel(id);
}
});
virtualDel(id);
} else {
virtualDel(id);
}
};
const virtualDel = (id) => {
// 前端删除
// curItem.value.singleList.forEach((item, index) => {
// if (item.id === id) {
// curItem.value.singleList.splice(index, 1);
// }
// });
// curItem.value.singleList.map((item, index) => {
// item.id = index + 1;
// });
// 前端删除
curItem.value.singleList.forEach((item, index) => {
if (item.id === id) {
curItem.value.singleList.splice(index, 1);
curItem.value.singleList[index].deleted = true;
}
});
curItem.value.singleList.map((item, index) => {
item.id = index + 1;
});
};
return {