| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <el-form :model="form" ref="form" label-width="200px" v-loading="formLoading" :rules="rules"> |
| | | <el-form-item label="部门:" prop="departmentIds" required> |
| | | <el-select v-model="form.departmentIds" placeholder="部门" @change="levelChange" multiple |
| | | collapse-tags> |
| | | <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="menuIds" required> |
| | | <el-select v-model="form.menuIds" :collapse-tags="true" multiple placeholder="请选择" @focus="selectStudent"></el-select> |
| | | </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+' '"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="部门:" prop="deptId" required> |
| | | <el-select v-model="form.deptId" collapse-tags placeholder="部门"> |
| | | <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="试卷类型:" prop="paperType" required> |
| | | <el-select v-model="form.paperType" placeholder="试卷类型" > |
| | | <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> |
| | |
| | | <span>总数分:</span> |
| | | </el-col> |
| | | <el-col :span="9" v-if="form.paperType==7"> |
| | | <el-input v-model="form.name"/> |
| | | <el-input disabled v-model="form.aggregateSource"/> |
| | | </el-col> |
| | | </el-row> |
| | | </el-form-item> |
| | | <el-form-item :key="index" :label="titleItem.label+':'" required v-for="(titleItem,index) in subjectIdList" v-if="form.paperType ==7"> |
| | | <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> |
| | | <span>多选题:</span> |
| | | |
| | | </el-col> |
| | | <el-col :span="9"> |
| | | <el-input v-model="titleItem.name" style="width: 80%"/> |
| | | <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-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> |
| | |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="questionPage.showDialog = false">取 消</el-button> |
| | | <el-button type="primary" @click="confirmQuestionSelect">确定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | |
| | | <el-dialog :visible.sync="studentDialog" width="70%"> |
| | | <el-form :model="student" ref="queryForm" :inline="true"> |
| | | <el-form-item label="标签:"> |
| | | <el-select v-model="student.tagId" clearable> |
| | | <el-option v-for="item in tags" :key="item.id" :value="item.id" :label="item.name"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="部门:"> |
| | | <el-select v-model="student.deptId" clearable> |
| | | <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" @click="selectStudent">查询</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | | <el-table v-loading="student.listLoading" :data="tableData" border fit highlight-current-row style="width: 100%" @selection-change="handleSelection"> |
| | | <el-table-column type="selection"></el-table-column> |
| | | <el-table-column prop="realName" label="用户"/> |
| | | </el-table> |
| | | <pagination v-show="total > 0" :total="total" |
| | | :page.sync="student.pageIndex" :limit.sync="student.pageSize" |
| | | @pagination="selectStudent"/> |
| | | <span slot="footer" class="dialog-footer"> |
| | | <el-button @click="studentDialog = false">取 消</el-button> |
| | | <el-button type="primary" @click="confirmStudentSelect">确定</el-button> |
| | | </span> |
| | | </el-dialog> |
| | | </div> |
| | |
| | | import QuestionShow from '../question/components/Show' |
| | | import examPaperApi from '@/api/examPaper' |
| | | import questionApi from '@/api/question' |
| | | import departmentApi from '@/api/department' |
| | | import userApi from '@/api/user' |
| | | |
| | | export default { |
| | | components: { Pagination, QuestionShow }, |
| | | data () { |
| | | return { |
| | | tags: [], |
| | | depts: [], |
| | | student: {}, |
| | | studentDialog: false, |
| | | student: { |
| | | pageIndex: 1, |
| | | pageSize: 100, |
| | | listLoading: true, |
| | | multipleSelection: [] |
| | | }, |
| | | tableData: [], |
| | | total: 0, |
| | | props: { |
| | | multiple: true |
| | | }, |
| | | options: [], |
| | | departCascaderProps:{ |
| | | multiple: true |
| | | }, |
| | | subjectIdList:[], |
| | | form: { |
| | | menuIds: [], |
| | | aggregateSource:100, |
| | | id: null, |
| | | departmentIds: [], |
| | | userIds: [], |
| | | subjectId: [], |
| | | paperType: 1, |
| | | limitDateTime: [], |
| | | name: '', |
| | | suggestTime: null, |
| | | titleItems: [] |
| | | titleItems: [], |
| | | subjectSource:{}, |
| | | questionTypeVMS:[] |
| | | }, |
| | | subjectFilter: null, |
| | | formLoading: false, |
| | | rules: { |
| | | departmentIds: [ |
| | | { required: true, message: '请选择部门', trigger: 'change' } |
| | | menuIds: [ |
| | | { required: true, message: '请选择', trigger: 'change' } |
| | | ], |
| | | subjectId: [ |
| | | { required: true, message: '请选择课目', trigger: 'change' } |
| | | ], |
| | | deptId: [ |
| | | { required: true, message: '请选择部门', trigger: 'change' } |
| | | ], |
| | | paperType: [ |
| | | { required: true, message: '请选择试卷类型', trigger: 'change' } |
| | |
| | | _this.formLoading = true |
| | | examPaperApi.select(id).then(re => { |
| | | _this.form = re.response |
| | | _this.form.menuIds = JSON.parse(re.response.menuIds) |
| | | 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}})}}) |
| | | }) |
| | | departmentApi.getDeptAdmins().then(res => { |
| | | this.depts = res.response |
| | | }) |
| | | }, |
| | | methods: { |
| | | getTags () { |
| | | userApi.tagList(null).then(data => { |
| | | this.tags = data.response |
| | | }) |
| | | }, |
| | | selectStudent() { |
| | | this.getTags(); |
| | | this.studentDialog = true; |
| | | examPaperApi.selectStudent(this.student).then(res => { |
| | | this.tableData = res.response.list |
| | | this.total = res.response.total |
| | | this.student.listLoading = false |
| | | }) |
| | | }, |
| | | handleChange(val){ |
| | | console.log(val) |
| | | }, |
| | | 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 |
| | | 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 |
| | | this.$refs.form.validate((valid) => { |
| | | if (valid) { |
| | | this.formLoading = true |
| | | if (this.subjectIdList.length=1){ |
| | | this.formLoading = true; |
| | | if (this.subjectIdList.length == 1){ |
| | | this.form.subjectId= this.form.subjectId |
| | | }; |
| | | // let op = []; |
| | | // for(var ele of this.form.menuIds){ |
| | | // op.push(ele[1]) |
| | | // }; |
| | | this.form.userIds = this.form.menuIds; |
| | | this.form.menuIds = JSON.stringify(this.form.menuIds); |
| | | console.log("laks",this.form) |
| | | if(this.form.questionTypeVMS == null){ |
| | | this.form.questionTypeVMS = []; |
| | | } |
| | | examPaperApi.edit(this.form).then(re => { |
| | | if (re.code === 1) { |
| | |
| | | }) |
| | | }, |
| | | addQuestion (titleItem) { |
| | | console.log('titleItem', titleItem) |
| | | this.currentTitleItem = titleItem |
| | | this.questionPage.showDialog = true |
| | | this.search() |
| | |
| | | let _this = this |
| | | this.questionPage.multipleSelection.forEach(q => { |
| | | questionApi.select(q.id).then(re => { |
| | | _this.currentTitleItem.questionItems.push(re.response) |
| | | if (!_this.currentTitleItem.questionItems.some(obj => obj.id === re.response.id)) { |
| | | _this.currentTitleItem.questionItems.push(re.response) |
| | | } |
| | | }) |
| | | }) |
| | | this.questionPage.showDialog = false |
| | | }, |
| | | confirmStudentSelect () { |
| | | this.student.multipleSelection.forEach(q => { |
| | | if(this.form.menuIds.some(obj => obj !== q.id)) { |
| | | this.form.menuIds.push(q.id) |
| | | } |
| | | }) |
| | | this.studentDialog = false |
| | | }, |
| | | levelChange () { |
| | | this.form.subjectId = null |
| | | // this.form.subjectId = null |
| | | // this.subjectFilter = this.subjects.filter(data =>{ |
| | | // return this.form.departmentIds.forEach(item=>{data.level == item}) |
| | | // }) |
| | |
| | | handleSelectionChange (val) { |
| | | this.questionPage.multipleSelection = val |
| | | }, |
| | | handleSelection (val) { |
| | | this.student.multipleSelection = val |
| | | }, |
| | | questionTypeFormatter (row, column, cellValue, index) { |
| | | return this.enumFormat(this.questionTypeEnum, cellValue) |
| | | }, |
| | |
| | | resetForm () { |
| | | let lastId = this.form.id |
| | | this.$refs['form'].resetFields() |
| | | this.form = { |
| | | id: null, |
| | | departmentIds: [], |
| | | 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 |
| | | }, |