|
@@ -21,6 +21,7 @@
|
|
|
'content',
|
|
|
{
|
|
|
rules: [{ required: true, message: '请输入试题内容!' }],
|
|
|
+ initialValue: examQuestionDetail.content,
|
|
|
},
|
|
|
]"
|
|
|
/>
|
|
@@ -96,7 +97,10 @@
|
|
|
</div>
|
|
|
<div class="create-select-item">
|
|
|
<span>子类:</span>
|
|
|
- <a-select v-model="typeConditionChildrenValue">
|
|
|
+ <a-select
|
|
|
+ v-model="typeConditionChildrenValue"
|
|
|
+ :disabled="!typeConditionParentValue"
|
|
|
+ >
|
|
|
<a-select-option
|
|
|
v-for="(item, index) in typeConditionChildrenList"
|
|
|
:key="index"
|
|
@@ -157,6 +161,7 @@
|
|
|
<script>
|
|
|
import {
|
|
|
formatQuestionIndex,
|
|
|
+ formatQuestionLetter,
|
|
|
formateUrlParams,
|
|
|
formatePathParams,
|
|
|
} from '@/filters';
|
|
@@ -174,7 +179,7 @@ export default {
|
|
|
name: 'examQusetionAddPanDuan',
|
|
|
}),
|
|
|
questionType: 'PanDuan', // 试题类型:判断题
|
|
|
- optionsList: [{ value: '正确' }, { value: '错误' }], // 选项列表
|
|
|
+ optionsList: [{ value: '对' }, { value: '错' }], // 选项列表
|
|
|
typeConditionParentList: [], // 试题类型-父类列表
|
|
|
typeConditionParentValue: '', // 父类所选值
|
|
|
typeConditionChildrenList: [], // 试题类型-子类列表
|
|
@@ -182,6 +187,16 @@ export default {
|
|
|
engineeringWorkList: [], // 工种数据列表
|
|
|
engineeringWorkChooseValue: '', // 所选工种
|
|
|
finalAnswerIndexs: undefined, // 正确答案下标
|
|
|
+ examQuestionDetail: {
|
|
|
+ id: '', // key
|
|
|
+ content: '', // 内容
|
|
|
+ finalAnswer: [], // 正确答案
|
|
|
+ engineerTypes: [], // 信息集合:工种
|
|
|
+ type: '', // 试题类型ID
|
|
|
+ answers: [], // 选项
|
|
|
+ rootQuestionCategory: '', // 试题类型-父类
|
|
|
+ questionCategory: '', // 试题类型-子类
|
|
|
+ }, // 题目的信息
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
@@ -203,13 +218,58 @@ export default {
|
|
|
this.typeConditionParentList = [
|
|
|
...this.GET_EXAM_QUESTION_TYPE_CONDITION_PARENT,
|
|
|
];
|
|
|
- this.typeConditionParentValue = this.typeConditionParentList[0].id;
|
|
|
// 工种类别
|
|
|
this.engineeringWorkList = [
|
|
|
{ name: '不限', id: '' },
|
|
|
...this.GET_ENGINEERING_WORK_LIST,
|
|
|
];
|
|
|
- this.getTableChildrenListFun(); // 查询:试题类型列表-子类
|
|
|
+ if (this.$route.query.id) {
|
|
|
+ this.getExamQuestionDetailFun(this.$route.query.id); // 查询:试题的详情
|
|
|
+ } else {
|
|
|
+ this.typeConditionParentValue = this.typeConditionParentList[0].id; // 所选试题类型-父类
|
|
|
+ this.getTableChildrenListFun(); // 查询:试题类型列表-子类
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 查询:试题的详情
|
|
|
+ getExamQuestionDetailFun(id) {
|
|
|
+ if (!id) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.loading = true;
|
|
|
+ let params = {
|
|
|
+ questionId: id,
|
|
|
+ };
|
|
|
+ this.$_http
|
|
|
+ .get(
|
|
|
+ formatePathParams(
|
|
|
+ this.$_API.INTERFACE_GET_EXAMS_QUESTION_DETAIL,
|
|
|
+ params
|
|
|
+ )
|
|
|
+ )
|
|
|
+ .then((res) => {
|
|
|
+ this.examQuestionDetail = { ...res.data };
|
|
|
+ // 选项
|
|
|
+ // this.optionsList = this.examQuestionDetail.answers.map((item) => {
|
|
|
+ // return { value: item };
|
|
|
+ // });
|
|
|
+ // 正确答案
|
|
|
+ this.finalAnswerIndexs = formatQuestionLetter(
|
|
|
+ this.examQuestionDetail.finalAnswer[0]
|
|
|
+ )[0];
|
|
|
+ // 试题类型-父类
|
|
|
+ this.typeConditionParentValue =
|
|
|
+ this.examQuestionDetail.rootQuestionCategory || '';
|
|
|
+ this.selectTypeConditionParent(); // 查询:试题类型列表-子类
|
|
|
+ // 试题类型-子类
|
|
|
+ this.typeConditionChildrenValue =
|
|
|
+ this.examQuestionDetail.questionCategory || '';
|
|
|
+ // 工种
|
|
|
+ this.engineeringWorkChooseValue = this.examQuestionDetail.engineerTypes[0];
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
},
|
|
|
// 查询:试题类型列表-子类
|
|
|
getTableChildrenListFun() {
|
|
@@ -235,7 +295,12 @@ export default {
|
|
|
},
|
|
|
// 操作:选择了父类
|
|
|
selectTypeConditionParent() {
|
|
|
- this.getTableChildrenListFun(); // 查询:试题类型列表-子类
|
|
|
+ if (this.typeConditionParentValue) {
|
|
|
+ this.getTableChildrenListFun(); // 查询:试题类型列表-子类
|
|
|
+ } else {
|
|
|
+ this.typeConditionChildrenList = [];
|
|
|
+ this.typeConditionChildrenValue = '';
|
|
|
+ }
|
|
|
},
|
|
|
// 操作:表单提交
|
|
|
handleSubmitForm(e) {
|
|
@@ -257,7 +322,15 @@ export default {
|
|
|
type: this.questionType, // 试题类型ID
|
|
|
answers: this.formatQuestionAnswersArr(values), // 选项
|
|
|
};
|
|
|
- this.httpQuestFun(urlParams, params);
|
|
|
+ if (this.examQuestionDetail.id) {
|
|
|
+ params.id = this.examQuestionDetail.id;
|
|
|
+ let pathParams = {
|
|
|
+ questionId: this.examQuestionDetail.id,
|
|
|
+ };
|
|
|
+ this.httpQuestEditFun(urlParams, params, pathParams); // 编辑
|
|
|
+ } else {
|
|
|
+ this.httpQuestAddFun(urlParams, params); // 新建
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -276,8 +349,8 @@ export default {
|
|
|
}
|
|
|
return arr;
|
|
|
},
|
|
|
- // 表单提交请求
|
|
|
- httpQuestFun(urlParams, params) {
|
|
|
+ // 新建
|
|
|
+ httpQuestAddFun(urlParams, params) {
|
|
|
this.loading = true;
|
|
|
this.$_http
|
|
|
.post(
|
|
@@ -295,6 +368,28 @@ export default {
|
|
|
this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
+ // 编辑
|
|
|
+ httpQuestEditFun(urlParams, params, pathParams) {
|
|
|
+ this.loading = true;
|
|
|
+ this.$_http
|
|
|
+ .put(
|
|
|
+ formatePathParams(
|
|
|
+ formateUrlParams(
|
|
|
+ this.$_API.INTERFACE_POST_EXAMS_QUESTION_EDIT,
|
|
|
+ urlParams
|
|
|
+ ),
|
|
|
+ pathParams
|
|
|
+ ),
|
|
|
+ params
|
|
|
+ )
|
|
|
+ .then(() => {
|
|
|
+ this.loading = false;
|
|
|
+ this.$message.success('编辑判断题成功');
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
},
|
|
|
};
|
|
|
</script>
|