ZhangXianQiang
2024-05-17 9f5a532c9213a34c7da9271cffd0ec2eb90461b4
src/views/exam/personalRandomTemplate/edit.vue
@@ -2,8 +2,12 @@
  <div class="app-container">
    <el-form :model="form" ref="form" label-width="200px" v-loading="formLoading" :rules="rules">
      <el-form-item label="考生:" prop="menuIds" required>
        <el-cascader v-model="form.menuIds" :options="options" :props="props" clearable collapse-tags>
        </el-cascader>
<!--        <el-cascader v-model="form.menuIds"   :options="options" @change="cascaderChangeFun" :props="props" clearable collapse-tags>-->
<!--        </el-cascader>-->
        <all-cascader :options="options"
                      :optionsData = "optionsData"
                      @change="cascaderChangeFun"
                      :width="200"></all-cascader>
      </el-form-item>
      <el-form-item label="课目:" prop="subjectId" required >
        <el-select ref="subjectIdRef" v-model="form.subjectId" placeholder="课目" multiple
@@ -12,12 +16,18 @@
                     :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="试卷类型"  @visible-change="subjectIdEvent" disabled>
          <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">
      <el-form-item label="时间限制:">
        <el-date-picker v-model="form.limitDateTime" value-format="yyyy-MM-dd HH:mm:ss" type="datetimerange"
                        range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
        </el-date-picker>
@@ -85,6 +95,7 @@
      <el-form-item label="建议时长:" prop="suggestTime" required>
        <el-input v-model="form.suggestTime" placeholder="分钟"/>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">提交</el-button>
        <el-button @click="resetForm">重置</el-button>
@@ -130,9 +141,9 @@
import examPaperApi from '@/api/examPaper'
import questionApi from '@/api/question'
import departmentApi from '@/api/department'
import allCascader from '@/components/Cascader'
export default {
  components: { Pagination, QuestionShow },
  components: { Pagination, QuestionShow ,allCascader},
  data () {
    return {
@@ -151,16 +162,18 @@
        //   })
        // }
      },
      depts: [],
      options: [],
      optionsData:[],
      departCascaderProps:{
        multiple: true
      },
      subjectIdList:[],
      form: {
        aggregateSource:'',
        aggregateSource:'100',
        id: null,
        departmentIds: [],
        menuIds:[],
        subjectId: [],
        paperType: 7,
        limitDateTime: [],
@@ -173,9 +186,11 @@
      subjectFilter: null,
      formLoading: false,
      rules: {
        subjectId: [
          { required: true, message: '请选择课目', trigger: 'change' }
        ],
        deptId: [
          { required: true, message: '请选择部门', trigger: 'change' }
        ],
        paperType: [
          { required: true, message: '请选择试卷类型', trigger: 'change' }
@@ -209,6 +224,9 @@
      console.log(res)
      this.subjectFilter = res.response
    })
    departmentApi.getDeptAdmins().then(res => {
      this.depts = res.response
    })
  },
   async mounted () {
@@ -223,7 +241,9 @@
       await examPaperApi.selfselect(id).then(re => {
         _this.form = re.response
         _this.form.menuIds = JSON.parse(re.response.menuIds)
         _this.optionsData = _this.form.menuIds
         console.log(_this.form)
         _this.formLoading = false
       })
     }
@@ -242,6 +262,10 @@
     // this.subjectIdEvent(false)
   },
  methods: {
    cascaderChangeFun(event){
      console.log(event)
      this.form.menuIds = event
    },
    titlejs(val){
      console.log(val)
      let str = ''
@@ -318,6 +342,13 @@
          if (this.subjectIdList.length == 1){
            this.form.subjectId= this.form.subjectId
          };
          let lastHasAll = this.form.menuIds.find(arr => {
            return arr[0] === 'all';
          });
          if (lastHasAll){
            this.form.menuIds = this.form.menuIds.slice(1)
          }
          let op = [];
          for(var ele of this.form.menuIds){
            op.push(ele[1])