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>
@@ -145,8 +144,8 @@
          <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>
@@ -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;
      });
@@ -294,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);
@@ -381,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 = [];
@@ -438,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;
    },
@@ -513,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>