代码调整

This commit is contained in:
dong 2022-10-20 11:15:58 +08:00
parent 8dbc06409e
commit 66b6a7fbf9

View File

@ -55,7 +55,7 @@
<script>
// import { UrlConfig } from '@/scripts/ConstDic';
// import { importQuestionBand } from '@/api/race';
import { importQuestion } from '@/api/questionBank.js';
import { importQuestion, listQuestionAll } from '@/api/questionBank.js';
// import { getCompanyList } from '@/api/company';
export default {
data() {
@ -152,9 +152,9 @@ export default {
this.currentPage = val;
this.handlePreDataPaging();
},
doSave() {
const nameList = [];
const repetList = [];
async doSave() {
const nameMap = {};
const repetMap = {};
const mapType = {
select: '单选题',
multi: '多选题',
@ -162,20 +162,29 @@ export default {
fill: '填空题',
answer: '问答题'
};
const allRes = await listQuestionAll();
let banklist = [];
if (allRes.code == 200 && allRes.data) {
banklist = allRes.data;
}
banklist.forEach(item => {
const strName = `${mapType[item.type]}${item.topic}`;
nameMap[strName] = item;
});
this.$store.state.race.preTheoryData.forEach(item => {
const strName = `${mapType[item.type]}${item.topic}`;
if (nameList.includes(strName)) {
repetList.push(strName);
if (nameMap[strName]) {
repetMap[strName] = item;
} else {
nameList.push(strName);
nameMap[strName] = item;
}
});
if (repetList.length) {
const test = `以下题目重复,是否继续提交?`;
if (Object.keys(repetMap).length) {
const test = `以下题目重复或与题库有重复,是否继续提交?`;
const messageData = [test];
const h = this.$createElement;
repetList.forEach(item => {
messageData.push(h('p', null, item));
Object.keys(repetMap).forEach((item, index) => {
messageData.push(h('p', null, `${index + 1}.${item}`));
});
this.$confirm('有题目重复,是否继续提交?', '提 示', {
message: h('div', null, messageData),