ZhangXianQiang
2024-05-24 2bddfa78e65f351d6cb81f670775e79620f684a6
src/views/exam/paper/edit.vue
@@ -1,10 +1,9 @@
<template>
  <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-select v-model="form.menuIds" :collapse-tags="true" multiple placeholder="请选择" @focus="selectStudent"
          popper-class="examinee-popper"
          >
      <el-form-item label="考生:" prop="examineeList" required>
        <el-select v-model="form.examineeList" :collapse-tags="true" multiple placeholder="请选择" @focus="selectStudent"
          popper-class="examinee-popper">
        </el-select>
      </el-form-item>
      <el-form-item label="课目:" prop="subjectId" required>
@@ -137,7 +136,7 @@
          </el-select>
        </el-form-item>
        <el-form-item label="部门:">
          <el-select v-model="student.deptId" clearable>
          <el-select v-model="student.deptIds" clearable multiple>
            <el-option v-for="item in depts" :key="item.id" :value="item.id" :label="item.name"></el-option>
          </el-select>
        </el-form-item>
@@ -145,10 +144,10 @@
          <el-button type="primary" @click="selectStudent">查询</el-button>
        </el-form-item>
      </el-form>
      <el-table ref="multipleTable" v-loading="student.listLoading" :data="tableData" border fit highlight-current-row style="width: 100%"
        @selection-change="handleSelection" row-key="id">
      <el-table ref="multipleTable" v-loading="student.listLoading" :data="tableData" border fit highlight-current-row
        style="width: 100%" @selection-change="handleSelection" row-key="id">
        <el-table-column type="selection" :reserve-selection="true"></el-table-column>
        <el-table-column prop="realName" label="用户" />
        <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" />
@@ -176,9 +175,9 @@
    return {
      tags: [],
      depts: [],
      student: {},
      studentDialog: false,
      student: {
        deptIds: [],
        pageIndex: 1,
        pageSize: 5,
        listLoading: true,
@@ -207,12 +206,13 @@
        suggestTime: null,
        titleItems: [],
        subjectSource: {},
        questionTypeVMS: []
        questionTypeVMS: [],
        examineeList: []
      },
      subjectFilter: null,
      formLoading: false,
      rules: {
        menuIds: [
        examineeList: [
          { required: true, message: '请选择', trigger: 'change' }
        ],
        subjectId: [
@@ -246,10 +246,6 @@
        total: 0
      },
      currentTitleItem: null,
      examineeList: [],
    };
  },
  created() {
@@ -262,7 +258,8 @@
      _this.formLoading = true;
      examPaperApi.select(id).then(re => {
        _this.form = re.response;
        _this.form.menuIds = JSON.parse(re.response.menuIds);
        // _this.form.menuIds = JSON.parse(re.response.menuIds);
        _this.examineeList = JSON.parse(re.response.userIds).map(item => item.realName);
        console.log(_this.form);
        _this.formLoading = false;
      });
@@ -286,6 +283,7 @@
      this.getTags();
      this.studentDialog = true;
      this.student.listLoading = true;
      examPaperApi.selectStudent(this.student).then(res => {
        this.tableData = res.response.list;
        this.total = res.response.total;
@@ -293,7 +291,7 @@
        this.$nextTick(() => {
          this.tableData.map(data => {
            if (this.form.menuIds.find(item => item === data.id)) {
            if (this.form.userIds.find(item => item === data.id)) {
              this.$refs.multipleTable.toggleRowSelection(data, true);
            } else {
              this.$refs.multipleTable.toggleRowSelection(data, false);
@@ -306,7 +304,6 @@
      console.log(val);
    },
    titlejs(val) {
      console.log(val);
      let str = '';
      this.subjectFilter.forEach(item => {
        if (item.id == val) {
@@ -316,7 +313,6 @@
      return str;
    },
    subjectIdEvent(e) {
      console.log(e, this.$refs.subjectIdRef.selected);
      let arr = [];
      if (e) {
@@ -382,7 +378,7 @@
            tempForm.subjectId = tempForm.subjectId;
          };
          tempForm.userIds = tempForm.menuIds;
          tempForm.menuIds = JSON.stringify(tempForm.menuIds);
          // tempForm.menuIds = JSON.stringify(tempForm.menuIds);
          if (tempForm.questionTypeVMS == null) {
            tempForm.questionTypeVMS = [];
@@ -439,7 +435,15 @@
      this.questionPage.showDialog = false;
    },
    confirmStudentSelect() {
      this.form.menuIds = this.student.multipleSelection.map((item) => item.id);
      // this.form.menuIds = this.student.multipleSelection.map((item) => item.id);
      this.form.userIds = this.student.multipleSelection.map((item) => {
        return {
          id: item.id,
          realName: item.realName
        };
      });
      this.form.examineeList = this.student.multipleSelection.map((item) => item.realName);
      this.studentDialog = false;
    },
@@ -514,7 +518,11 @@
      paperTypeEnum: state => state.exam.examPaper.paperTypeEnum,
      levelEnum: state => state.user.levelEnum
    }),
    ...mapState('exam', { subjects: state => state.subjects })
    ...mapState('exam', { subjects: state => state.subjects }),
    examineeFormat() {
      return this.examineeList.map(item => item.realName);
    }
  }
};
</script>