|
|
@@ -8,11 +8,21 @@
|
|
|
<p class="top-4-p" @click="submitButton()">保存</p>
|
|
|
</div>
|
|
|
<div class="content-box scrollbar-box">
|
|
|
- <el-form class="add-form-box" :model="newData" ref="form" label-width="140px" :rules="rules">
|
|
|
+ <el-form class="add-form-box" :model="newData" ref="form" label-width="100px" :rules="rules">
|
|
|
<div class="top-content-box">
|
|
|
<div class="flex-content-box">
|
|
|
- <el-form-item label="试题类型" prop="data1">
|
|
|
- <el-select v-model="newData.data1" @change="answersScreening()" placeholder="试题类型" style="width: 180px">
|
|
|
+ <el-form-item label="是否共享" prop="shareStatus">
|
|
|
+ <el-switch
|
|
|
+ :active-value="1"
|
|
|
+ :inactive-value="0"
|
|
|
+ v-model="newData.shareStatus"
|
|
|
+ active-color="#0183FB"
|
|
|
+ inactive-color="#AAAAAA">
|
|
|
+ </el-switch>
|
|
|
+ <span style="margin-left:15px;line-height:40px;color:#999;">{{newData.shareStatus==1?'共享开启,全校所有学院单位都可见':'不共享,仅本学院单位及上级都可见'}}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="试题类型" prop="questionType" label-width="100px">
|
|
|
+ <el-select v-model="newData.questionType" @change="answersScreening()" placeholder="试题类型" style="width: 180px">
|
|
|
<el-option
|
|
|
v-for="dict in optionListA"
|
|
|
:key="dict.value"
|
|
|
@@ -21,12 +31,23 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="知识点" prop="data2">
|
|
|
+ <el-form-item label="难度" prop="difficulty" label-width="70px">
|
|
|
+ <el-select v-model="newData.difficulty" placeholder="难度" style="width: 180px">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in optionListC"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item label="知识点" prop="knowledgePointIds" label-width="90px">
|
|
|
<el-cascader
|
|
|
- style="width: 180px"
|
|
|
- v-model="newData.data2"
|
|
|
+ style="width: 490px"
|
|
|
+ v-model="newData.knowledgePointIds"
|
|
|
:options="optionListB"
|
|
|
:props="{
|
|
|
+ multiple:true,
|
|
|
emitPath:false,
|
|
|
checkStrictly: true,
|
|
|
value: 'id',
|
|
|
@@ -38,26 +59,6 @@
|
|
|
placeholder="知识点"
|
|
|
></el-cascader>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="难度" prop="data4">
|
|
|
- <el-select v-model="newData.data4" placeholder="难度" style="width: 180px">
|
|
|
- <el-option
|
|
|
- v-for="dict in optionListC"
|
|
|
- :key="dict.value"
|
|
|
- :label="dict.label"
|
|
|
- :value="dict.value"
|
|
|
- />
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="是否共享" prop="data3">
|
|
|
- <el-switch
|
|
|
- :active-value="true"
|
|
|
- :inactive-value="false"
|
|
|
- v-model="newData.data3"
|
|
|
- active-color="#0183FB"
|
|
|
- inactive-color="#AAAAAA">
|
|
|
- </el-switch>
|
|
|
- <span style="margin-left:15px;line-height:40px;color:#999;">{{newData.data3?'共享开启,全校所有学院单位都可见':'不共享,仅本学院单位及上级都可见'}}</span>
|
|
|
- </el-form-item>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="title-content-box">
|
|
|
@@ -66,9 +67,9 @@
|
|
|
<p></p>
|
|
|
</div>
|
|
|
<div class="editor-form-box">
|
|
|
- <el-form-item label="" prop="data5" label-width="0">
|
|
|
+ <el-form-item label="" prop="questionContent" label-width="0">
|
|
|
<tinymce-container
|
|
|
- v-model="newData.data5"
|
|
|
+ v-model="newData.questionContent"
|
|
|
:height="300"
|
|
|
:max-length="500"
|
|
|
:upload-url="editorUploadUrl"
|
|
|
@@ -76,15 +77,15 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
- <div class="title-content-box" v-if="newData.data1 == 1 || newData.data1 == 2">
|
|
|
+ <div class="title-content-box" v-if="newData.questionType == 1 || newData.questionType == 2">
|
|
|
<p></p>
|
|
|
<p>选项</p>
|
|
|
<p></p>
|
|
|
</div>
|
|
|
- <div class="max-big-for-box" v-if="newData.data1 == 1 || newData.data1 == 2">
|
|
|
+ <div class="max-big-for-box" v-if="newData.questionType == 1 || newData.questionType == 2">
|
|
|
<p class="position-p" @click="addItem()">添加选项</p>
|
|
|
<div class="for-editor-form-box"
|
|
|
- v-for="(item,index) in newData.data6" :index="index"
|
|
|
+ v-for="(item,index) in newData.options" :index="index"
|
|
|
draggable="true"
|
|
|
@dragstart="onBigDragStart($event, index)"
|
|
|
@dragover.prevent="onBigDragOver($event, index)"
|
|
|
@@ -93,9 +94,9 @@
|
|
|
>
|
|
|
<p class="index-p">{{getLetter(index)}}</p>
|
|
|
<div class="min-editor-form-box">
|
|
|
- <el-form-item label="" prop="data5" label-width="0">
|
|
|
+ <el-form-item label="" label-width="0">
|
|
|
<tinymce-container
|
|
|
- v-model="item.text"
|
|
|
+ v-model="item.optionContent"
|
|
|
:height="300"
|
|
|
:max-length="500"
|
|
|
:upload-url="editorUploadUrl"
|
|
|
@@ -104,26 +105,26 @@
|
|
|
</el-form-item>
|
|
|
</div>
|
|
|
<div class="editor-right-button-box">
|
|
|
- <p class="el-icon-delete-solid" v-if="newData.data6[4]" @click="delItem(index)"></p>
|
|
|
+ <p class="el-icon-delete-solid" v-if="newData.options[4]" @click="delItem(index)"></p>
|
|
|
<p class="el-icon-rank"></p>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="title-content-box" v-if="newData.data1">
|
|
|
+ <div class="title-content-box" v-if="newData.questionType">
|
|
|
<p></p>
|
|
|
<p>答案</p>
|
|
|
<p></p>
|
|
|
</div>
|
|
|
- <div class="answers-content-box" v-if="newData.data1 == 1 || newData.data1 == 2">
|
|
|
+ <div class="answers-content-box" v-if="newData.questionType == 1 || newData.questionType == 2">
|
|
|
<div class="for-answers-box" @click="checkAnswersButton(index)" v-for="(item,index) in newData.data7" :key="index" :class="item.checkItemType?'check-for-answers-box':''">
|
|
|
<p :class="item.checkItemType?'el-icon-circle-check':''"></p>
|
|
|
<p>{{getLetter(index)}}</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="answers-content-box" v-if="newData.data1 == 3">
|
|
|
+ <div class="answers-content-box" v-if="newData.questionType == 3">
|
|
|
<div class="for-answers-box" @click="checkAnswersButton(index)" v-for="(item,index) in newData.data8" :key="index" :class="item.checkItemType?'check-for-answers-box':''">
|
|
|
<p :class="item.checkItemType?'el-icon-circle-check':''"></p>
|
|
|
- <p>{{item.checkItemName}}</p>
|
|
|
+ <p>{{item.checkType=='Y'?'对':'错'}}</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="title-content-box">
|
|
|
@@ -132,9 +133,9 @@
|
|
|
<p></p>
|
|
|
</div>
|
|
|
<div class="editor-form-box">
|
|
|
- <el-form-item label="" prop="data9" label-width="0">
|
|
|
+ <el-form-item label="" prop="analysis" label-width="0">
|
|
|
<tinymce-container
|
|
|
- v-model="newData.data9"
|
|
|
+ v-model="newData.analysis"
|
|
|
:height="300"
|
|
|
:max-length="500"
|
|
|
:upload-url="editorUploadUrl"
|
|
|
@@ -150,7 +151,10 @@
|
|
|
<script>
|
|
|
//import { getDicts } from "@/api/commonality/noPermission";
|
|
|
//import { systemUserSelect } from "@/api/commonality/permission";
|
|
|
- import { examElKnowledgePointTreeList, } from "@/api/safetyEducationExaminationNew/index";
|
|
|
+ import {
|
|
|
+ examElKnowledgePointTreeList,examElQuestionBankDetail,
|
|
|
+ examElQuestionBankAdd,examElQuestionBankEdit,
|
|
|
+ } from "@/api/safetyEducationExaminationNew/index";
|
|
|
import TinymceContainer from "@/components/tinymceContainer/index.vue";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
export default {
|
|
|
@@ -165,15 +169,15 @@
|
|
|
optionListB:[],
|
|
|
optionListC:[{value:1,label:'简单'},{value:2,label:'一般'},{value:3,label:'较难'},{value:4,label:'极难'}],
|
|
|
newData: {
|
|
|
- data1:null,
|
|
|
- data2:null,
|
|
|
- data3:true,
|
|
|
- data4:null,
|
|
|
- data5:"",
|
|
|
- data6:[{text:''},{text:''},{text:''},{text:''}],
|
|
|
+ questionType:null,
|
|
|
+ knowledgePointIds:[],
|
|
|
+ shareStatus:1,
|
|
|
+ difficulty:null,
|
|
|
+ questionContent:"",
|
|
|
+ options:[{optionContent:''},{optionContent:''},{optionContent:''},{optionContent:''}],
|
|
|
data7:[{checkItemType:false},{checkItemType:false},{checkItemType:false},{checkItemType:false}],
|
|
|
- data8:[{checkItemName:'对',checkItemType:false},{checkItemName:'错',checkItemType:false}],
|
|
|
- data9:"",
|
|
|
+ data8:[{checkType:'Y',checkItemType:false},{checkType:'N',checkItemType:false}],
|
|
|
+ analysis:"",
|
|
|
},
|
|
|
// 编辑器图片/附件上传接口,按需修改
|
|
|
editorUploadUrl: this.uploadUrl(),
|
|
|
@@ -181,52 +185,112 @@
|
|
|
Authorization:getToken(),
|
|
|
},
|
|
|
rules:{
|
|
|
- data1: [
|
|
|
+ questionType: [
|
|
|
{ required: true, message: "请选择试题类型", trigger: "blur" },
|
|
|
{ required: true, message: "请选择试题类型", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
],
|
|
|
- data2: [
|
|
|
+ knowledgePointIds: [
|
|
|
{ required: true, message: "请选择知识点", trigger: "blur" },
|
|
|
{ required: true, message: "请选择知识点", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
],
|
|
|
- data4: [
|
|
|
+ difficulty: [
|
|
|
{ required: true, message: "请选择难度", trigger: "blur" },
|
|
|
{ required: true, message: "请选择难度", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
],
|
|
|
},
|
|
|
}
|
|
|
},
|
|
|
+ watch: {
|
|
|
+ 'newData.knowledgePointIds': {
|
|
|
+ handler(newVal, oldVal) {
|
|
|
+ // 假设最多只能选 2 个
|
|
|
+ if (newVal && newVal.length > 10) {
|
|
|
+ this.$message.error('最多只能选择 10 个知识点');
|
|
|
+ this.$nextTick(() => {
|
|
|
+ // 将值回退到上一次的状态
|
|
|
+ this.newData.knowledgePointIds = oldVal;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ deep: true, // 关键:必须开启深度监听
|
|
|
+ immediate: false // 初始化时不触发,防止默认值超限误报
|
|
|
+ }
|
|
|
+ },
|
|
|
created() {
|
|
|
|
|
|
},
|
|
|
mounted() {
|
|
|
- this.initialize()
|
|
|
+ if(this.propsData.id){
|
|
|
+ this.examElQuestionBankDetail();
|
|
|
+ }
|
|
|
this.examElKnowledgePointTreeList();
|
|
|
},
|
|
|
methods: {
|
|
|
- // 初始化
|
|
|
- initialize() {
|
|
|
-
|
|
|
+ examElQuestionBankDetail(){
|
|
|
+ examElQuestionBankDetail({id:this.propsData.id}).then(response => {
|
|
|
+ let obj = {
|
|
|
+ id:this.propsData.id,
|
|
|
+ questionType:response.data.questionType,
|
|
|
+ knowledgePointIds:response.data.knowledgePointIds,
|
|
|
+ shareStatus:response.data.shareStatus,
|
|
|
+ difficulty:response.data.difficulty,
|
|
|
+ questionContent:response.data.questionContent,
|
|
|
+ analysis:response.data.analysis,
|
|
|
+ options:[],
|
|
|
+ data7:[],
|
|
|
+ data8:[{checkType:'Y',checkItemType:false},{checkType:'N',checkItemType:false}],
|
|
|
+ }
|
|
|
+ if(response.data.questionType == 1 || response.data.questionType == 2){
|
|
|
+ for (let i=0;i<response.data.options.length;i++){
|
|
|
+ obj.options.push({optionContent:response.data.options[i].optionContent})
|
|
|
+ obj.data7.push({checkItemType:false})
|
|
|
+ }
|
|
|
+ if(response.data.questionType == 1){
|
|
|
+ console.log('this.getNumber(response.data.correctAnswer)',obj.options[this.getNumber(response.data.correctAnswer)])
|
|
|
+ obj.data7[this.getNumber(response.data.correctAnswer)].checkItemType = true;
|
|
|
+ }else if (response.data.questionType == 2){
|
|
|
+ let answerList = response.data.correctAnswer.split(',');
|
|
|
+ for(let i=0;i<answerList.length;i++){
|
|
|
+ obj.data7[this.getNumber(answerList[i])].checkItemType = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else if(response.data.questionType == 3){
|
|
|
+ for (let i=0;i<obj.data8.length;i++){
|
|
|
+ if(obj.data8[i].checkType == response.data.correctAnswer){
|
|
|
+ obj.data8[i].checkItemType = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$set(this,'newData',obj);
|
|
|
+ });
|
|
|
},
|
|
|
// 返回按钮
|
|
|
backPage() {
|
|
|
this.$parent.tableButton(6)
|
|
|
},
|
|
|
resetButton(){
|
|
|
-
|
|
|
+ let self = this;
|
|
|
+ this.$confirm('是否确认重置?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(function() {
|
|
|
+ }).then(() => {
|
|
|
+ self.examElQuestionBankDetail();
|
|
|
+ }).catch(() => {});
|
|
|
},
|
|
|
// 提交按钮
|
|
|
submitButton() {
|
|
|
let self = this;
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
- if(!self.newData.data5){
|
|
|
+ if(!self.newData.questionContent){
|
|
|
self.msgError('请输入题干')
|
|
|
return
|
|
|
}
|
|
|
- if(this.newData.data1 == 1 ||this.newData.data1 == 2){
|
|
|
- for(let i=0;i<self.newData.data6.length;i++){
|
|
|
- if(!self.newData.data6[i].text){
|
|
|
+ if(this.newData.questionType == 1 ||this.newData.questionType == 2){
|
|
|
+ for(let i=0;i<self.newData.options.length;i++){
|
|
|
+ if(!self.newData.options[i].optionContent){
|
|
|
self.msgError('第'+(i+1)+'个选项没有填写内容.')
|
|
|
return
|
|
|
}
|
|
|
@@ -241,7 +305,7 @@
|
|
|
self.msgError('没有选择答案.')
|
|
|
return
|
|
|
}
|
|
|
- }else if(this.newData.data1 == 3){
|
|
|
+ }else if(this.newData.questionType == 3){
|
|
|
let num = 0;
|
|
|
for(let i=0;i<self.newData.data8.length;i++){
|
|
|
if(self.newData.data8[i].checkItemType){
|
|
|
@@ -253,13 +317,76 @@
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
+ this.$confirm('是否确认保存?', "警告", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning"
|
|
|
+ }).then(function() {
|
|
|
+ }).then(() => {
|
|
|
+ self.dataIntegration();
|
|
|
+ }).catch(() => {});
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ dataIntegration(){
|
|
|
+ let self = this;
|
|
|
+ let obj ={
|
|
|
+ questionContent:this.newData.questionContent,
|
|
|
+ questionType:this.newData.questionType,
|
|
|
+ knowledgePointIds:this.newData.knowledgePointIds,
|
|
|
+ difficulty:this.newData.difficulty,
|
|
|
+ correctAnswer:'',
|
|
|
+ analysis:this.newData.analysis,
|
|
|
+ shareStatus:this.newData.shareStatus,
|
|
|
+ options:[],
|
|
|
+ }
|
|
|
+ if(obj.questionType == 1 || obj.questionType == 2){
|
|
|
+ for(let i=0;i<self.newData.options.length;i++){
|
|
|
+ obj.options.push(
|
|
|
+ {
|
|
|
+ optionTag:self.getLetter(i),
|
|
|
+ optionContent:self.newData.options[i].optionContent,
|
|
|
+ sortOrder:i,
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ let correctAnswer = [];
|
|
|
+ for (let i=0;i<self.newData.data7.length;i++){
|
|
|
+ if(self.newData.data7[i].checkItemType){
|
|
|
+ correctAnswer.push(self.getLetter(i))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ obj.correctAnswer = correctAnswer+'';
|
|
|
+ }else if(obj.questionType == 3){
|
|
|
+ for (let i=0;i<self.newData.data8.length;i++){
|
|
|
+ if(self.newData.data8[i].checkItemType){
|
|
|
+ obj.correctAnswer = self.newData.data8[i].checkType;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(this.newData.id){
|
|
|
+ obj.id = this.newData.id;
|
|
|
+ this.examElQuestionBankEdit(obj);
|
|
|
+ }else{
|
|
|
+ this.examElQuestionBankAdd(obj);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ examElQuestionBankAdd(obj){
|
|
|
+ examElQuestionBankAdd(obj).then(response => {
|
|
|
+ this.msgSuccess(response.message);
|
|
|
+ this.$parent.tableButton(6);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ examElQuestionBankEdit(obj){
|
|
|
+ examElQuestionBankEdit(obj).then(response => {
|
|
|
+ this.msgSuccess(response.message);
|
|
|
+ this.$parent.tableButton(6);
|
|
|
+ });
|
|
|
+ },
|
|
|
//添加选项
|
|
|
addItem(){
|
|
|
let self = this;
|
|
|
- if(this.newData.data6[7]){
|
|
|
+ if(this.newData.options[7]){
|
|
|
this.msgError('已达到数量上限,最多8个选项.')
|
|
|
return
|
|
|
}
|
|
|
@@ -269,7 +396,7 @@
|
|
|
type: "warning"
|
|
|
}).then(function() {
|
|
|
}).then(() => {
|
|
|
- self.newData.data6.push({text:''});
|
|
|
+ self.newData.options.push({optionContent:''});
|
|
|
self.newData.data7.push({checkItemType:false});
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
@@ -282,14 +409,14 @@
|
|
|
type: "warning"
|
|
|
}).then(function() {
|
|
|
}).then(() => {
|
|
|
- self.newData.data6.splice(index,1);
|
|
|
+ self.newData.options.splice(index,1);
|
|
|
self.newData.data7.splice(index,1);
|
|
|
}).catch(() => {});
|
|
|
},
|
|
|
//答案选中
|
|
|
checkAnswersButton(index){
|
|
|
let self = this;
|
|
|
- if(this.newData.data1 == 1){
|
|
|
+ if(this.newData.questionType == 1){
|
|
|
if(self.newData.data7[index].checkItemType){
|
|
|
this.$set(self.newData.data7[index],'checkItemType',false);
|
|
|
}else{
|
|
|
@@ -298,9 +425,9 @@
|
|
|
}
|
|
|
this.$set(self.newData.data7[index],'checkItemType',true);
|
|
|
}
|
|
|
- }else if(this.newData.data1 == 2){
|
|
|
+ }else if(this.newData.questionType == 2){
|
|
|
this.$set(self.newData.data7[index],'checkItemType',!self.newData.data7[index].checkItemType);
|
|
|
- }else if(this.newData.data1 == 3){
|
|
|
+ }else if(this.newData.questionType == 3){
|
|
|
if(self.newData.data8[index].checkItemType){
|
|
|
this.$set(self.newData.data8[index],'checkItemType',false);
|
|
|
}else{
|
|
|
@@ -314,7 +441,7 @@
|
|
|
//答案筛选器
|
|
|
answersScreening(){
|
|
|
let self = this;
|
|
|
- if(this.newData.data1 == 1){
|
|
|
+ if(this.newData.questionType == 1){
|
|
|
let num = 0;
|
|
|
let index = null;
|
|
|
for(let i=0;i<self.newData.data7.length;i++){
|
|
|
@@ -350,8 +477,8 @@
|
|
|
if (sourceIndex === targetIndex) return;
|
|
|
|
|
|
// 核心:交换数组元素
|
|
|
- const movedItem = this.newData.data6.splice(sourceIndex, 1)[0];
|
|
|
- this.newData.data6.splice(targetIndex, 0, movedItem);
|
|
|
+ const movedItem = this.newData.options.splice(sourceIndex, 1)[0];
|
|
|
+ this.newData.options.splice(targetIndex, 0, movedItem);
|
|
|
const movedItem2 = this.newData.data7.splice(sourceIndex, 1)[0];
|
|
|
this.newData.data7.splice(targetIndex, 0, movedItem2);
|
|
|
},
|
|
|
@@ -369,14 +496,23 @@
|
|
|
this.$set(this, 'optionListB', list);
|
|
|
});
|
|
|
},
|
|
|
- /**
|
|
|
- * 将下标转换为字母
|
|
|
- */
|
|
|
+ /** 将下标转换为字母*/
|
|
|
getLetter(index) {
|
|
|
if (typeof index !== 'number' || index < 0 || index >= 26) {
|
|
|
return '其他';
|
|
|
}
|
|
|
return String.fromCharCode(65 + index);
|
|
|
+ },
|
|
|
+ /** 将字母转下标 */
|
|
|
+ getNumber(letter) {
|
|
|
+ if (typeof letter !== 'string' || !letter) {
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ const code = letter.toUpperCase().charCodeAt(0);
|
|
|
+ if (code >= 65 && code <= 90) {
|
|
|
+ return code - 65;
|
|
|
+ }
|
|
|
+ return -1;
|
|
|
}
|
|
|
},
|
|
|
}
|