| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="form" ref="form" label-width="200px" v-loading="formLoading" :rules="rules"> |
| | | <el-form-item label="部门:" prop="level" required> |
| | | <el-select v-model="form.level" placeholder="部门" @change="levelChange"> |
| | | <el-option v-for="item in levelEnum" :key="item.key" :value="item.key" :label="item.value"></el-option> |
| | | </el-select> |
| | | <el-form-item label="考生:" prop="userIds" required> |
| | | <el-cascader v-model="form.userIds" :options="options" :props="props" clearable collapse-tags> |
| | | </el-cascader> |
| | | </el-form-item> |
| | | <el-form-item label="课目:" prop="subjectId" required> |
| | | <el-select ref="subjectIdRef" v-model="form.subjectId" placeholder="课目" multiple |
| | | collapse-tags @visible-change="subjectIdEvent" > |
| | | collapse-tags > |
| | | <el-option v-for="item in subjectFilter" :key="item.id" :value="item.id" |
| | | :label="item.name+' ( '+item.levelName+' )'"></el-option> |
| | | :label="item.name+' '"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="试卷类型:" prop="paperType" required> |
| | | <el-select v-model="form.paperType" placeholder="试卷类型" :disabled="subjectIdList.length>1"> |
| | | <el-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key" :label="item.value" :disabled="item.disabled"></el-option> |
| | | <el-select v-model="form.paperType" placeholder="试卷类型" @visible-change="subjectIdEvent"> |
| | | <el-option v-for="item in paperTypeEnum" :key="item.key" :value="item.key" :label="item.value" ></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="时间限制:" required v-show="form.paperType===4"> |
| | |
| | | range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="试卷名称:" prop="name" required> |
| | | <el-input v-model="form.name"/> |
| | | </el-form-item> |
| | | <el-form-item :key="index" :label="titleItem.label+':'" required v-for="(titleItem,index) in subjectIdList"> |
| | | <el-row> |
| | | <el-col :span="3"> |
| | | <span>题目数量:</span> |
| | | </el-col> |
| | | <el-form-item label="试卷名称:" prop="name" required > |
| | | <el-row :gutter="20"> |
| | | <el-col :span="9"> |
| | | <el-input v-model="titleItem.name" style="width: 80%"/> |
| | | <el-input v-model="form.name"/> |
| | | </el-col> |
| | | <el-col :span="3"> |
| | | <span>题目分数:</span> |
| | | <el-col :span="2" v-if="form.paperType==7"> |
| | | <span>总数分:</span> |
| | | </el-col> |
| | | <el-col :span="9"> |
| | | <el-input v-model="titleItem.name" style="width: 80%"/> |
| | | <el-col :span="9" v-if="form.paperType==7"> |
| | | <el-input disabled v-model="form.aggregateSource"/> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form-item> |
| | | <el-form-item :key="item.subjectId" :label="item.label" required v-for="(item,key,index) in form.questionTypeVMS" v-if="form.paperType ==7"> |
| | | <el-row > |
| | | <el-col :span="3" > |
| | | <span>多选题:</span> |
| | | |
| | | </el-col> |
| | | <el-col :span="3"> |
| | | <el-input v-model="form.questionTypeVMS[key].multipleChoice" style="width: 80%"/> |
| | | </el-col> |
| | | <el-col :span="3" > |
| | | <span>单选题:</span> |
| | | </el-col> |
| | | <el-col :span="3"> |
| | | <el-input v-model="form.questionTypeVMS[key].singleChoice" style="width: 80%"/> |
| | | </el-col> |
| | | <el-col :span="3" > |
| | | <span>判断题:</span> |
| | | </el-col> |
| | | <el-col :span="3"> |
| | | <el-input v-model="form.questionTypeVMS[key].trueFalse" style="width: 80%"/> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form-item> |
| | | <el-form-item label="总数分:" v-if="subjectIdList.length>1" prop="name" required> |
| | | <el-input v-model="form.name"/> |
| | | </el-form-item> |
| | | <!-- <el-form-item label="总数分:" v-if="form.paperType==7" prop="name" required>--> |
| | | <!-- <el-input v-model="form.name"/>--> |
| | | <!-- </el-form-item>--> |
| | | <el-form-item :key="index" :label="'标题'+(index+1)+':'" required v-for="(titleItem,index) in form.titleItems"> |
| | | <el-input v-model="titleItem.name" style="width: 80%"/> |
| | | <el-button type="text" class="link-left" style="margin-left: 20px" size="mini" @click="addQuestion(titleItem)"> |
| | | <el-button v-if="form.paperType!=7" type="text" class="link-left" style="margin-left: 20px" size="mini" @click="addQuestion(titleItem)"> |
| | | 添加题目 |
| | | </el-button> |
| | | <el-button type="text" class="link-left" size="mini" @click="form.titleItems.splice(index,1)">删除</el-button> |
| | | <el-card class="exampaper-item-box" v-if="titleItem.questionItems.length!==0"> |
| | | <el-card class="exampaper-item-box" v-if="titleItem.questionItems.length!==0&&subjectIdList.length<2"> |
| | | <el-form-item :key="questionIndex" :label="'题目'+(questionIndex+1)+':'" |
| | | v-for="(questionItem,questionIndex) in titleItem.questionItems" style="margin-bottom: 15px"> |
| | | <el-row> |
| | |
| | | <el-table v-loading="questionPage.listLoading" :data="questionPage.tableData" |
| | | @selection-change="handleSelectionChange" border fit highlight-current-row style="width: 100%"> |
| | | <el-table-column type="selection" width="35"></el-table-column> |
| | | <el-table-column prop="id" label="Id" width="60px"/> |
| | | <el-table-column prop="questionType" label="题型" :formatter="questionTypeFormatter" width="70px"/> |
| | | <el-table-column prop="shortTitle" label="题干" show-overflow-tooltip/> |
| | | </el-table> |
| | |
| | | import QuestionShow from '../question/components/Show' |
| | | import examPaperApi from '@/api/examPaper' |
| | | import questionApi from '@/api/question' |
| | | import departmentApi from '@/api/department' |
| | | |
| | | export default { |
| | | components: { Pagination, QuestionShow }, |
| | | data () { |
| | | return { |
| | | props: { |
| | | multiple: true |
| | | // lazy: true, |
| | | // lazyLoad (node, resolve) { |
| | | // console.log(node,"node"); |
| | | // var that = this; |
| | | // departmentApi.selectUser(node.value).then(re=>{ |
| | | // console.log(re,"re"); |
| | | // const nodes = re.response.map(xxx=>{ |
| | | // return {value: xxx.id,label: xxx.realName,leaf: node.level >= 1} |
| | | // }); |
| | | // resolve(nodes); |
| | | // }) |
| | | // } |
| | | }, |
| | | options: [], |
| | | departCascaderProps:{ |
| | | multiple: true |
| | | }, |
| | | subjectIdList:[], |
| | | form: { |
| | | aggregateSource:100, |
| | | id: null, |
| | | level: null, |
| | | departmentIds: [], |
| | | userIds: [], |
| | | subjectId: [], |
| | | paperType: 1, |
| | | limitDateTime: [], |
| | | name: '', |
| | | suggestTime: null, |
| | | titleItems: [] |
| | | titleItems: [], |
| | | subjectSource:{}, |
| | | questionTypeVMS:[] |
| | | }, |
| | | subjectFilter: null, |
| | | formLoading: false, |
| | | rules: { |
| | | level: [ |
| | | { required: true, message: '请选择部门', trigger: 'change' } |
| | | userIds: [ |
| | | { required: true, message: '请选择', trigger: 'change' } |
| | | ], |
| | | subjectId: [ |
| | | { required: true, message: '请选择课目', trigger: 'change' } |
| | |
| | | _this.formLoading = true |
| | | examPaperApi.select(id).then(re => { |
| | | _this.form = re.response |
| | | _this.form.userIds = re.response.userId |
| | | console.log(_this.form) |
| | | _this.formLoading = false |
| | | }) |
| | | } |
| | | departmentApi.selectDepartmentUser().then(res => { |
| | | console.log("res",res); |
| | | |
| | | _this.options = res.response.map(x=>{return{value:x.department.id,label:x.department.name,children:x.userList.map(xx=>{return{value: xx.id,label: xx.realName}})}}) |
| | | }) |
| | | }, |
| | | methods: { |
| | | titlejs(val){ |
| | | console.log(val) |
| | | let str = '' |
| | | this.subjectFilter.forEach(item=>{ |
| | | if (item.id == val){ |
| | | str = item.name |
| | | } |
| | | }) |
| | | return str |
| | | }, |
| | | subjectIdEvent(e){ |
| | | console.log(e,this.$refs.subjectIdRef.selected) |
| | | let arr=[] |
| | |
| | | this.$refs.subjectIdRef.selected.forEach(item=>{ |
| | | arr.push({ |
| | | label:item.label, |
| | | id:item.value |
| | | subjectId:item.value, |
| | | singleChoice:'', |
| | | multipleChoice:'', |
| | | trueFalse:'' |
| | | }) |
| | | }) |
| | | console.log(arr) |
| | | this.form.questionTypeVMS = arr |
| | | } |
| | | |
| | | if (arr.length>1){ |
| | | if (this.form.paperType ==7){ |
| | | //說明是隨機 |
| | | this.subjectIdList = arr |
| | | this.form.paperType = 7 |
| | | let obj1={} |
| | | let arr1 = [] |
| | | arr.forEach((item,index)=>{ |
| | | // obj1[item.id]='' |
| | | arr1.push({ |
| | | subjectId:item.id, |
| | | singleChoice:'', |
| | | multipleChoice:'', |
| | | trueFalse:'' |
| | | }) |
| | | // let obj={ |
| | | // item |
| | | // } |
| | | |
| | | // for (let i in obj) { |
| | | // i=item.id |
| | | // obj[i]= '' |
| | | // obj1[i] = '' |
| | | // console.log('键名:', i); |
| | | // console.log('键值:', obj[i]); |
| | | // } |
| | | }) |
| | | this.form.subjectSource = obj1 |
| | | |
| | | console.log(this.form.subjectSource) |
| | | console.log(this.form.questionTypeVMS) |
| | | // this.form.paperType = 7 |
| | | this.form.titleItems = [] |
| | | }else { |
| | | this.form.subjectSource={} |
| | | this.subjectIdList = [] |
| | | this.form.paperType = 1 |
| | | this.form.questionTypeVMS=[] |
| | | // this.form.paperType = 1 |
| | | } |
| | | }, |
| | | submitForm () { |
| | | let _this = this |
| | | console.log(this.subjectIdList) |
| | | console.log(this.form.subjectSource) |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | this.formLoading = true |
| | | this.formLoading = true; |
| | | if (this.subjectIdList.length == 1){ |
| | | this.form.subjectId= this.form.subjectId |
| | | }; |
| | | let op = []; |
| | | for(var ele of this.form.userIds){ |
| | | op.push(ele[1]) |
| | | }; |
| | | this.form.userIds = op; |
| | | console.log("laks",this.form) |
| | | if(this.form.questionTypeVMS == null){ |
| | | this.form.questionTypeVMS = []; |
| | | } |
| | | examPaperApi.edit(this.form).then(re => { |
| | | if (re.code === 1) { |
| | | _this.$message.success(re.message) |
| | |
| | | this.questionPage.showDialog = false |
| | | }, |
| | | levelChange () { |
| | | this.form.subjectId = null |
| | | this.subjectFilter = this.subjects.filter(data => data.level === this.form.level) |
| | | // this.form.subjectId = null |
| | | // this.subjectFilter = this.subjects.filter(data =>{ |
| | | // return this.form.departmentIds.forEach(item=>{data.level == item}) |
| | | // }) |
| | | // |
| | | // this.subjectFilter = [] |
| | | // this.form.departmentIds.forEach(item=>{ |
| | | // this.subjects.forEach(jectitem=>{ |
| | | // if (item==jectitem.level){ |
| | | // this.subjectFilter.push(jectitem) |
| | | // } |
| | | // }) |
| | | // }) |
| | | console.log(this.subjects,this.form.departmentIds) |
| | | // this.subjectFilter = this.subjects |
| | | }, |
| | | search () { |
| | | this.questionPage.queryParam.subjectId = this.form.subjectId |
| | | if (this.subjectIdList.length=1){ |
| | | this.questionPage.queryParam.subjectId = this.form.subjectId |
| | | } |
| | | |
| | | this.questionPage.listLoading = true |
| | | questionApi.pageList(this.questionPage.queryParam).then(data => { |
| | | const re = data.response |
| | |
| | | resetForm () { |
| | | let lastId = this.form.id |
| | | this.$refs['form'].resetFields() |
| | | this.form = { |
| | | id: null, |
| | | level: null, |
| | | subjectId: null, |
| | | paperType: 1, |
| | | limitDateTime: [], |
| | | name: '', |
| | | suggestTime: null, |
| | | titleItems: [] |
| | | this.form= { |
| | | aggregateSource:100, |
| | | id: null, |
| | | departmentIds: [], |
| | | subjectId: [], |
| | | paperType: 1, |
| | | limitDateTime: [], |
| | | name: '', |
| | | suggestTime: null, |
| | | titleItems: [], |
| | | subjectSource:null, |
| | | questionTypeVMS:[] |
| | | } |
| | | this.form.id = lastId |
| | | }, |