xiangpei
2024-05-27 d4b7d0ff020ff74e85f01ff272af6dafcbac5458
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>
@@ -101,8 +100,8 @@
    </el-form>
    <el-dialog :visible.sync="questionPage.showDialog" width="70%">
      <el-form :model="questionPage.queryParam" ref="queryForm" :inline="true">
        <el-form-item label="ID:">
          <el-input v-model="questionPage.queryParam.id" clearable></el-input>
        <el-form-item label="题干:">
          <el-input v-model="questionPage.queryParam.titleContent" clearable></el-input>
        </el-form-item>
        <el-form-item label="题型:">
          <el-select v-model="questionPage.queryParam.questionType" clearable>
@@ -132,7 +131,12 @@
    <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-select v-model="student.tagIds" clearable multiple>
            <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.excludeTagIds" clearable multiple>
            <el-option v-for="item in tags" :key="item.id" :value="item.id" :label="item.name"></el-option>
          </el-select>
        </el-form-item>
@@ -145,8 +149,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>
@@ -182,7 +186,8 @@
        pageIndex: 1,
        pageSize: 5,
        listLoading: true,
        multipleSelection: []
        multipleSelection: [],
        excludeTagIds: []
      },
      tableData: [],
      total: 0,
@@ -207,12 +212,13 @@
        suggestTime: null,
        titleItems: [],
        subjectSource: {},
        questionTypeVMS: []
        questionTypeVMS: [],
        examineeList: []
      },
      subjectFilter: null,
      formLoading: false,
      rules: {
        menuIds: [
        examineeList: [
          { required: true, message: '请选择', trigger: 'change' }
        ],
        subjectId: [
@@ -235,7 +241,7 @@
        multipleSelection: [],
        showDialog: false,
        queryParam: {
          id: null,
          titleContent: "",
          questionType: null,
          subjectId: 1,
          pageIndex: 1,
@@ -246,10 +252,6 @@
        total: 0
      },
      currentTitleItem: null,
      examineeList: [],
    };
  },
  created() {
@@ -262,7 +264,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 +297,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 +384,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 +441,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 +524,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>