理论题目管理调整

This commit is contained in:
dong 2022-10-13 18:14:56 +08:00
parent 8ceca6ba90
commit 3554c6c3c5
8 changed files with 166 additions and 104 deletions

View File

@ -3,16 +3,26 @@ import request from '@/utils/request';
// 分页查询理论试题 // 分页查询理论试题
export function listQuestionPage(params) { export function listQuestionPage(params) {
return request({ return request({
url: `/api/questionBank/questions/paging`, // url: `/api/questionBank/questions/paging`,
url: `/api/question/org/paging`,
method: 'get', method: 'get',
params params
}); });
} }
// 标签列表
export function getLableList() {
return request({
url: `/api/question/org/lable`,
method: 'get'
});
}
// 创建题目 // 创建题目
export function createQuestion(data) { export function createQuestion(data) {
return request({ return request({
url: `/api/questionBank/questions`, // url: `/api/questionBank/questions`,
url: `/api/question/org`,
method: 'post', method: 'post',
data data
}); });
@ -21,15 +31,18 @@ export function createQuestion(data) {
// 删除题目 // 删除题目
export function deleteQuestion(questionId) { export function deleteQuestion(questionId) {
return request({ return request({
url: `/api/questionBank/questions/${questionId}`, // url: `/api/questionBank/questions/${questionId}`,
method: 'delete' url: `/api/question/org`,
method: 'delete',
data: [questionId]
}); });
} }
// 更新题目 // 更新题目
export function updateOption(data) { export function updateOption(data) {
return request({ return request({
url: `/api/questionBank/questions/${data.id}`, // url: `/api/questionBank/questions/${data.id}`,
url: `/api/question/org/${data.id}`,
method: 'put', method: 'put',
data data
}); });
@ -38,8 +51,17 @@ export function updateOption(data) {
// 获取题目信息 // 获取题目信息
export function getQuestionInfo(questionId) { export function getQuestionInfo(questionId) {
return request({ return request({
url: `/api/questionBank/questions/${questionId}`, // url: `/api/questionBank/questions/${questionId}`,
url: `/api/question/org/${questionId}`,
method: 'get' method: 'get'
}); });
} }
// 题库批量导入
export function importQuestion(data) {
return request({
url: `/api/question/org/import`,
method: 'post',
data
});
}

View File

@ -1618,16 +1618,6 @@ export const asyncRouter = [
path: 'examManage', path: 'examManage',
component: OrgExamManage, component: OrgExamManage,
hidden: true hidden: true
},
{
path: 'questionCreate',
component: QuestionCreatePage,
hidden: true
},
{
path: 'questionUpdate/:questionId',
component: QuestionUpdatePage,
hidden: true
} }
] ]
}, },
@ -1641,6 +1631,11 @@ export const asyncRouter = [
component: QuestionUpdatePage, component: QuestionUpdatePage,
hidden: true hidden: true
}, },
{ // 理论题目管理-导入
path: 'preTheoryImport',
component: PreTheoryImport,
hidden: true
},
{ // 出题规则管理 { // 出题规则管理
path: 'questionsRuleManage', path: 'questionsRuleManage',
hidden: true, hidden: true,

View File

@ -28,7 +28,7 @@ export default {
queryForm: { queryForm: {
reset: true, reset: true,
labelWidth: '80px', labelWidth: '80px',
leftSpan: 16, leftSpan: 17,
queryObject: { queryObject: {
type: { type: {
type: 'select', type: 'select',
@ -40,14 +40,14 @@ export default {
topic: { topic: {
type: 'text', type: 'text',
label: '题 目' label: '题 目'
},
companyId: {
type: 'select',
label: '单位',
config: {
data: []
}
} }
// companyId: {
// type: 'select',
// label: '',
// config: {
// data: []
// }
// }
} }
}, },
queryList: { queryList: {
@ -59,6 +59,16 @@ export default {
title: '题 目', title: '题 目',
prop: 'topic' prop: 'topic'
}, },
{
title: '标 签',
prop: 'tags',
type: 'tagMore',
width: '200',
columnValue: (row) => { return this.lableTags(row); },
tagType: (row) => {
return '';
}
},
{ {
title: '类 型', title: '类 型',
prop: 'type', prop: 'type',
@ -84,7 +94,7 @@ export default {
prop: 'companyId', prop: 'companyId',
width: '100', width: '100',
type: 'tag', type: 'tag',
columnValue: (row) => { return this.getCompanyName(row.companyId); }, columnValue: (row) => { return this.getCompanyName(row.orgId); },
tagType: (row) => { return ''; } tagType: (row) => { return ''; }
}, },
{ {
@ -112,7 +122,7 @@ export default {
actions: [ actions: [
{ text: '添 加', handler: this.doCreate }, { text: '添 加', handler: this.doCreate },
{ text: '导 入', fileType: 'file', handler: this.importQuestionBank }, { text: '导 入', fileType: 'file', handler: this.importQuestionBank },
{ text: '试卷规则管理', handler: this.questionsRuleManage}, // { text: '', handler: this.questionsRuleManage},
{ text: '模板导出', handler: this.exportTemplate} { text: '模板导出', handler: this.exportTemplate}
] ]
} }
@ -127,7 +137,7 @@ export default {
this.companyList = []; this.companyList = [];
getCompanyList().then(resp => { getCompanyList().then(resp => {
resp.data.forEach(item => { resp.data.forEach(item => {
this.queryForm.queryObject.companyId.config.data.push({ value: item.id, label: item.name }); // this.queryForm.queryObject.companyId.config.data.push({ value: item.id, label: item.name });
this.companyMap[item.id] = item.name; this.companyMap[item.id] = item.name;
}); });
}); });
@ -163,6 +173,10 @@ export default {
this.$refs.detail.doShow({index, row}); this.$refs.detail.doShow({index, row});
}, },
lableTags(row) {
return row.tags ? row.tags.split(',') : '';
},
answerTags(row) { answerTags(row) {
const answer = []; const answer = [];
row.optionList.forEach((el, i) => { row.optionList.forEach((el, i) => {
@ -228,26 +242,29 @@ export default {
const dataList = convertSheetToList(wb.Sheets[index], true); const dataList = convertSheetToList(wb.Sheets[index], true);
let questionTypeIndex; let questionTypeIndex;
let topicIndex; let topicIndex;
let tagsIndex;
let option1Index; let option1Index;
let option2Index; let option2Index;
let option3Index; let option3Index;
let option4Index; let option4Index;
let answerIndex; let answerIndex;
dataList.forEach((item, index) => { dataList.forEach((item, ii) => {
if (item[0] === '题型') { if (item[0] === '题型') {
questionTypeIndex = index; questionTypeIndex = ii;
} else if (item[0] === '题目') { } else if (item[0] === '题目') {
topicIndex = index; topicIndex = ii;
} else if (item[0] === '标签') {
tagsIndex = ii;
} else if ( item[0] === '选项' && item[1] === 'A') { } else if ( item[0] === '选项' && item[1] === 'A') {
option1Index = index; option1Index = ii;
} else if (!item[0] && item[1] === 'B') { } else if (!item[0] && item[1] === 'B') {
option2Index = index; option2Index = ii;
} else if (!item[0] && item[1] === 'C') { } else if (!item[0] && item[1] === 'C') {
option3Index = index; option3Index = ii;
} else if (!item[0] && item[1] === 'D') { } else if (!item[0] && item[1] === 'D') {
option4Index = index; option4Index = ii;
} else if (item[0] === '答案') { } else if (item[0] === '答案') {
answerIndex = index; answerIndex = ii;
} }
}); });
if (questionTypeIndex || questionTypeIndex === 0) { if (questionTypeIndex || questionTypeIndex === 0) {
@ -256,6 +273,7 @@ export default {
const param = { const param = {
type: questionTypeMap[item], type: questionTypeMap[item],
topic: dataList[topicIndex][index], topic: dataList[topicIndex][index],
tags: dataList[tagsIndex][index],
optionList: [] optionList: []
}; };
if (param.type === 'fill') { if (param.type === 'fill') {
@ -283,7 +301,7 @@ export default {
} }
} }
that.$store.dispatch('race/setPreTheoryData', questionList).then(() => { that.$store.dispatch('race/setPreTheoryData', questionList).then(() => {
that.$router.push({ path: `/system/preTheoryImport`}); that.$router.push({ path: `/teaching/preTheoryImport`});
}).catch((e) => { }).catch((e) => {
that.$message.error('导入题库失败!'); that.$message.error('导入题库失败!');
}); });
@ -313,12 +331,12 @@ export default {
}, },
exportTemplate() { exportTemplate() {
const wb = XLSX.utils.book_new(); const wb = XLSX.utils.book_new();
const data1 = [{A: '序号', B: '题型', C:'题目', D:'答案', E: '', F: '', G: '', H: ''}]; const data1 = [{A: '序号', B: '题型', C:'题目', D:'标签', E:'答案', F: '选项', G: '', H: '', I: ''}];
const data2 = [{A: '', B: '', C:'', D:'', E: 'A', F: 'B', G: 'C', H: 'D'}]; const data2 = [{A: '', B: '', C:'', D:'', E: '', F: 'A', G: 'B', H: 'C', I: 'D'}];
const data3 = [{A: '1', B: '判断', C:'题目一', D:'√', E: '', F: '', G: '', H: ''}]; const data3 = [{A: '1', B: '判断', C:'题目一', D:'信号机,道岔', E:'√', F: '', G: '', H: '', I: ''}];
const data4 = [{A: '2', B: '判断', C:'题目二', D:'×', E: '', F: '', G: '', H: ''}]; const data4 = [{A: '2', B: '判断', C:'题目二', D:'重点', E:'×', F: '', G: '', H: '', I: ''}];
const data5 = [{A: '3', B: '单选', C:'题目三', D:'A', E: '选项A', F: '选项B', G: '选项C', H: '选项D'}]; const data5 = [{A: '3', B: '单选', C:'题目三', D:'测试,检验', E:'A', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
const data6 = [{A: '4', B: '多选', C:'题目四', D:'ABCD', E: '选项A', F: '选项B', G: '选项C', H: '选项D'}]; const data6 = [{A: '4', B: '多选', C:'题目四', D:'', E:'ABCD', F: '选项A', G: '选项B', H: '选项C', I: '选项D'}];
// const data7 = [{A: '5', B: '', C:'', D:'&&&&', E: '', F: '', G: '', H: ''}]; // const data7 = [{A: '5', B: '', C:'', D:'&&&&', E: '', F: '', G: '', H: ''}];
// const data8 = [{A: '6', B: '', C:'', D:'', E: '', F: '', G: '', H: ''}]; // const data8 = [{A: '6', B: '', C:'', D:'', E: '', F: '', G: '', H: ''}];
// const data = [...data1, ...data2, ...data3, ...data4, ...data5, ...data6, ...data7, ...data8]; // const data = [...data1, ...data2, ...data3, ...data4, ...data5, ...data6, ...data7, ...data8];
@ -326,8 +344,8 @@ export default {
const ws = XLSX.utils.json_to_sheet(data, {skipHeader:true}); const ws = XLSX.utils.json_to_sheet(data, {skipHeader:true});
ws['!merges'] = [ ws['!merges'] = [
{ {
s: {c: 4, r: 0}, s: {c: 5, r: 0},
e: {c: 7, r: 0} e: {c: 8, r: 0}
}, },
{ {
s: {c: 0, r: 0}, s: {c: 0, r: 0},
@ -344,6 +362,10 @@ export default {
{ {
s: {c: 3, r: 0}, s: {c: 3, r: 0},
e: {c: 3, r: 1} e: {c: 3, r: 1}
},
{
s: {c: 4, r: 0},
e: {c: 4, r: 1}
} }
]; ];
ws['!cols'] = [ ws['!cols'] = [
@ -354,6 +376,7 @@ export default {
{width: 15}, {width: 15},
{width: 15}, {width: 15},
{width: 15}, {width: 15},
{width: 15},
{width: 15} {width: 15}
]; ];
XLSX.utils.book_append_sheet(wb, ws, 'file'); XLSX.utils.book_append_sheet(wb, ws, 'file');

View File

@ -71,6 +71,7 @@ export default {
handler:function(newV, oldV) { handler:function(newV, oldV) {
if (this.type === 'judge' || this.type === 'select') { if (this.type === 'judge' || this.type === 'select') {
this.active = this.optionList.findIndex(ele => ele.correct); this.active = this.optionList.findIndex(ele => ele.correct);
this.$emit('change', this.active);
} else if (this.type === 'multi') { } else if (this.type === 'multi') {
this.activeList = []; this.activeList = [];
this.optionList.forEach((el, i) => { this.optionList.forEach((el, i) => {
@ -78,13 +79,16 @@ export default {
this.activeList.push(i); this.activeList.push(i);
} }
}); });
this.$emit('change', this.activeList);
} else if (this.type === 'fill') { } else if (this.type === 'fill') {
this.answerList = []; this.answerList = [];
this.optionList.forEach(el => { this.optionList.forEach(el => {
this.answerList.push(el.content); this.answerList.push(el.content);
}); });
this.$emit('change', this.answerList);
} else if (this.type === 'answer') { } else if (this.type === 'answer') {
this.answer = (this.optionList[0] || {content: ''}).content; this.answer = (this.optionList[0] || {content: ''}).content;
this.$emit('change', this.answer);
} }
} }
} }

View File

@ -1,62 +1,38 @@
<template> <template>
<div style="text-align: center;padding: 10px;"> <div style="text-align: center;padding: 10px;">
<div style="margin-top: 10px;margin-bottom: 10px;display: flex;justify-content: space-between;"> <div style="margin-top: 10px;margin-bottom: 10px;display: flex;justify-content: space-between;">
<div style="display: inline-block;font-size: 14px;"> <!-- <div style="display: inline-block;font-size: 14px;">
<span>单位</span> <span>单位</span>
<el-select v-model="companyId" placeholder="请选择单位" clearable size="mini" style="margin-left: 10px;"> <el-select v-model="companyId" placeholder="请选择单位" clearable size="mini" style="margin-left: 10px;">
<el-option v-for="it in companyList" :key="it.id" :label="it.name" :value="it.id" /> <el-option v-for="it in companyList" :key="it.id" :label="it.name" :value="it.id" />
</el-select> </el-select>
</div> </div> -->
<div style="display: inline-block;"> <div style="display: inline-block;">
<el-button <el-button v-loading="loading" size="mini" type="primary" @click="doSave">保存</el-button>
v-loading="loading" <el-button size="mini" type="danger" @click="doCancel">取消</el-button>
size="mini"
type="primary"
@click="doSave"
>保存</el-button>
<el-button
size="mini"
type="danger"
@click="doCancel"
>取消</el-button>
</div> </div>
</div> </div>
<el-table <el-table :data="tableData" border style="width: 100%">
:data="tableData" <el-table-column prop="topic" label="题目" />
border <el-table-column prop="tags" label="标签" width="200">
style="width: 100%"
>
<el-table-column
prop="topic"
label="题目"
/>
<el-table-column prop="type" label="类型" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag <el-tag v-for="item in getTagesArr(scope.row.tags)" :key="item" type="primary" disable-transitions style="margin-right: 10px;">{{ item }}</el-tag>
type="primary"
disable-transitions
>{{ $ConstSelect.translate(scope.row.type, 'QuestionTypeList') }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column prop="type" label="类型" width="100">
prop="answer" <template slot-scope="scope">
label="答案" <el-tag type="primary" disable-transitions>{{ $ConstSelect.translate(scope.row.type, 'QuestionTypeList') }}</el-tag>
> </template>
</el-table-column>
<el-table-column prop="answer" label="答案">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-for="(answer, index) in answerTags(scope.row)" :key="index" type="primary" style="margin-right: 10px;">{{ answer }}</el-tag> <el-tag v-for="(answer, index) in answerTags(scope.row)" :key="index" type="primary" style="margin-right: 10px;">{{ answer }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="200"> <el-table-column label="操作" width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button size="mini" @click="edit(scope.$index, scope.row)">编辑</el-button>
size="mini" <el-button size="mini" type="danger" @click="doDelete(scope.$index, scope.row)">删除</el-button>
@click="edit(scope.$index, scope.row)"
>编辑</el-button>
<el-button
size="mini"
type="danger"
@click="doDelete(scope.$index, scope.row)"
>删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -73,9 +49,10 @@
</template> </template>
<script> <script>
import { UrlConfig } from '@/scripts/ConstDic'; // import { UrlConfig } from '@/scripts/ConstDic';
import { importQuestionBand } from '@/api/race'; // import { importQuestionBand } from '@/api/race';
import { getCompanyList } from '@/api/company'; import { importQuestion } from '@/api/questionBank.js';
// import { getCompanyList } from '@/api/company';
export default { export default {
data() { data() {
return { return {
@ -98,14 +75,18 @@ export default {
mounted() { mounted() {
this.handlePreDataPaging(); this.handlePreDataPaging();
this.loading = false; this.loading = false;
getCompanyList().then(resp => { // getCompanyList().then(resp => {
this.companyList = resp.data; // this.companyList = resp.data;
}); // });
}, },
methods: { methods: {
getTagesArr(tags) {
return tags ? tags.split(',') : '';
},
edit(index, row) { edit(index, row) {
const number = (this.currentPage - 1) * this.pageSize + index; const number = (this.currentPage - 1) * this.pageSize + index;
this.$router.push({path: `${UrlConfig.bank.questionUpdate}/${number}`, query:{ draft: true }}); // this.$router.push({path: `${UrlConfig.bank.questionUpdate}/${number}`, query:{ draft: true }});
this.$router.push({path: `/teaching/questionUpdate/${number}`, query:{ draft: true }});
}, },
handlePreDataPaging() { handlePreDataPaging() {
const preData = this.$store.state.race.preTheoryData; const preData = this.$store.state.race.preTheoryData;
@ -193,7 +174,8 @@ export default {
break; break;
} }
}); });
importQuestionBand(this.$store.state.race.preTheoryData, this.companyId).then(resp => { // importQuestionBand(this.$store.state.race.preTheoryData, this.companyId).then(resp => {
importQuestion(this.$store.state.race.preTheoryData).then(resp => {
this.$store.dispatch('race/setPreTheoryData', []); this.$store.dispatch('race/setPreTheoryData', []);
// this.$message.success('!'); // this.$message.success('!');
this.$alert(`<strong>本次导入:</strong><br><strong>${judgeNum}道判断题;</strong><br><strong>${selectNum}道选择题;</strong><br><strong>${multiNum}道多选题;</strong><br>`, '导入题库成功!', { this.$alert(`<strong>本次导入:</strong><br><strong>${judgeNum}道判断题;</strong><br><strong>${selectNum}道选择题;</strong><br><strong>${multiNum}道多选题;</strong><br>`, '导入题库成功!', {

View File

@ -2,7 +2,7 @@
<div class="page"> <div class="page">
<div class="page__container"> <div class="page__container">
<el-card class="page__container-body"> <el-card class="page__container-body">
<question-form ref="info" :option="formModel" :remove="true" @modify="doModify" @companyIdChange="companyIdChange" /> <question-form ref="info" :option="formModel" :remove="true" @modify="doModify" @companyIdChange="companyIdChange" @tagsChange="tagsChange" />
</el-card> </el-card>
<div class="page__container-footer"> <div class="page__container-footer">
<el-button type="primary" :is-create="true" @click="create"> </el-button> <el-button type="primary" :is-create="true" @click="create"> </el-button>
@ -31,10 +31,12 @@ export default {
id: '', id: '',
topic: '', topic: '',
type: 'select', type: 'select',
answer: 0, tags: '',
answer: '',
optionList: [] optionList: []
}, },
companyId: null companyId: null,
tagsArr: []
}; };
}, },
computed: { computed: {
@ -62,10 +64,14 @@ export default {
companyIdChange(value) { companyIdChange(value) {
this.companyId = value; this.companyId = value;
}, },
tagsChange(list) {
this.tagsArr = list;
},
create() { create() {
this.$refs.info.validate().then(valid => { this.$refs.info.validate().then(valid => {
if (valid) { if (valid) {
this.formModel.companyId = parseInt(this.companyId); // this.formModel.companyId = parseInt(this.companyId);
this.formModel.tags = this.tagsArr.join(',');
createQuestion(this.formModel).then(resp => { createQuestion(this.formModel).then(resp => {
authUtils.setSessionStorage(this.path, JSON.stringify({ authUtils.setSessionStorage(this.path, JSON.stringify({
type: this.formModel.type type: this.formModel.type

View File

@ -11,6 +11,11 @@
<el-option v-for="it in QuestionTypeList" :key="it.value" :label="it.label" :value="it.value" /> <el-option v-for="it in QuestionTypeList" :key="it.value" :label="it.label" :value="it.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="标 签">
<el-select v-model="tagsArr" multiple filterable allow-create default-first-option placeholder="请选择标签" @change="tagsChange">
<el-option v-for="item in labelList" :key="item" :label="item" :value="item" />
</el-select>
</el-form-item>
<el-form-item label="问 题" prop="topic"> <el-form-item label="问 题" prop="topic">
<item-rich v-model="option.topic" @modify="onModify({model: option, prop: 'topic'})" /> <item-rich v-model="option.topic" @modify="onModify({model: option, prop: 'topic'})" />
</el-form-item> </el-form-item>
@ -32,6 +37,7 @@ import ItemOptions from './item-options';
import ItemAnswer from './item-answer'; import ItemAnswer from './item-answer';
import { getCompanyList } from '@/api/company'; import { getCompanyList } from '@/api/company';
import { getSessionStorage } from '@/utils/auth'; import { getSessionStorage } from '@/utils/auth';
import { getLableList } from '@/api/questionBank.js';
export default { export default {
components: { components: {
@ -60,7 +66,9 @@ export default {
data() { data() {
return { return {
companyList: [], companyList: [],
companyId: null companyId: null,
tagsArr: [],
labelList: []
}; };
}, },
computed: { computed: {
@ -111,7 +119,7 @@ export default {
return this.option.optionList; return this.option.optionList;
}, },
QuestionTypeList() { QuestionTypeList() {
return this.$ConstSelect.QuestionTypeList; return this.$ConstSelect.QuestionTypeList.filter(item => { return !['fill', 'answer'].includes(item.value); });
}, },
rules() { rules() {
return { return {
@ -119,10 +127,10 @@ export default {
{ required: true, message: '请输入试题内容', trigger: 'blur' } { required: true, message: '请输入试题内容', trigger: 'blur' }
], ],
type: [ type: [
{ required: true, message: '请输入试题类型', trigger: 'change' } { required: true, message: '请输入试题类型', trigger: 'blur' }
], ],
answer: [ answer: [
{ required: true, message: '请选择正确答案', trigger: 'change' } { required: true, message: '请选择正确答案', trigger: 'blur' }
] ]
}; };
} }
@ -133,6 +141,12 @@ export default {
this.companyList = resp.data; this.companyList = resp.data;
}); });
}, },
created() {
getLableList().then(res => {
this.labelList = res.data || [];
}).catch(err => {
});
},
methods: { methods: {
validate() { validate() {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -144,6 +158,9 @@ export default {
companyIdChange(e) { companyIdChange(e) {
this.$emit('companyIdChange', e); this.$emit('companyIdChange', e);
}, },
tagsChange(list) {
this.$emit('tagsChange', list);
},
onTypeChnage(type) { onTypeChnage(type) {
if (this.templateMap[type] && !this.update) { if (this.templateMap[type] && !this.update) {
this.option.optionList = this.templateMap[type](); this.option.optionList = this.templateMap[type]();
@ -171,6 +188,11 @@ export default {
this.option.optionList[0] = {content: answer, correct:true}; this.option.optionList[0] = {content: answer, correct:true};
} }
} }
if (Array.isArray(answer)) {
this.option.answer = answer.join(',');
} else {
this.option.answer = answer + '';
}
}, },
onModify(node) { onModify(node) {
this.$emit('modify', node); this.$emit('modify', node);

View File

@ -2,7 +2,7 @@
<div class="page"> <div class="page">
<div class="page__container"> <div class="page__container">
<el-card class="page__container-body"> <el-card class="page__container-body">
<question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" @companyIdChange="companyIdChange" /> <question-form ref="info" :option="formModel" :remove="true" :update="true" @modify="doModify" @companyIdChange="companyIdChange" @tagsChange="tagsChange" />
</el-card> </el-card>
</div> </div>
<div class="page__container-footer"> <div class="page__container-footer">
@ -30,10 +30,12 @@ export default {
id: '', id: '',
topic: '', topic: '',
type: 'select', type: 'select',
answer: 0, tags: '',
answer: '',
optionList: [] optionList: []
}, },
optionList: [] optionList: [],
tagsArr: []
}; };
}, },
computed: { computed: {
@ -55,11 +57,13 @@ export default {
setTimeout(() => { setTimeout(() => {
this.formModel = deepAssign({}, this.$store.state.race.preTheoryData[this.questionId]); this.formModel = deepAssign({}, this.$store.state.race.preTheoryData[this.questionId]);
this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct); this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
this.$refs.info.tagsArr = this.formModel.tags.split(',');
}, 500); }, 500);
} else { } else {
getQuestionInfo(this.questionId).then(resp => { getQuestionInfo(this.questionId).then(resp => {
this.formModel = resp.data; this.formModel = resp.data;
this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct); this.formModel.answer = this.formModel.optionList.findIndex(ele => ele.correct);
this.$refs.info.tagsArr = this.formModel.tags.split(',');
}); });
} }
}, },
@ -69,6 +73,9 @@ export default {
companyIdChange(value) { companyIdChange(value) {
this.companyId = value; this.companyId = value;
}, },
tagsChange(list) {
this.tagsArr = list;
},
doModify(node) { doModify(node) {
this.$refs.rich.doShow(node); this.$refs.rich.doShow(node);
}, },
@ -78,7 +85,8 @@ export default {
this.$store.state.race.preTheoryData[this.questionId] = this.formModel; this.$store.state.race.preTheoryData[this.questionId] = this.formModel;
this.doBack(); this.doBack();
} else if (valid) { } else if (valid) {
this.formModel.companyId = parseInt(this.companyId); // this.formModel.companyId = parseInt(this.companyId);
this.formModel.tags = this.tagsArr.join(',');
updateOption(this.formModel).then(resp => { updateOption(this.formModel).then(resp => {
this.doBack(); this.doBack();
}).catch(error => { }).catch(error => {