xiangpei
2024-12-03 8c3eaeddeff2c9c5a92352e6bf830e5000ff5882
src/views/exam/personalRandomTemplate/list.vue
@@ -8,12 +8,13 @@
      <el-cascader
        clearable
        v-model="queryParam.deptId"
        collapse-tags
        :options="depts"
        :props="{ emitPath: false, value: 'id', label: 'name',  checkStrictly: true, multiple: true }"
        ></el-cascader>
    </el-form-item>
     <el-form-item label="课目:" >
       <el-select v-model="queryParam.subjectId"  clearable multiple>
       <el-select v-model="queryParam.subjectId"  clearable multiple 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>
@@ -25,19 +26,18 @@
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        value-format="yyyy-MM-dd"
        :picker-options="pickerOptions">
      </el-date-picker>
    </el-form-item>
     <el-form-item>
       <el-button type="primary" @click="submitForm">查询</el-button>
       <!-- <router-link :to="{path:'/exam/personalSimulation/edit'}" class="link-left">
         <el-button type="primary">添加</el-button>
       </router-link> -->
       <el-button type="primary" @click="submitForm" size="small" style="margin-right: 5px">查询</el-button>
       <router-link :to="{path:'/exam/personalRandomTemplate/edit'}">
         <el-button type="success" size="small" style="margin-bottom: 5px">添加</el-button>
       </router-link>
     </el-form-item>
   </el-form>
    <router-link :to="{path:'/exam/personalRandomTemplate/edit'}">
      <el-button type="primary" size="small" style="margin-bottom: 5px">添加</el-button>
    </router-link>
    <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row style="width: 100%">
      <el-table-column prop="subjectNames" label="课目" />
      <el-table-column prop="name" label="名称"  />
@@ -62,7 +62,12 @@
      <el-form :model="form" ref="form">
        <el-form-item label="考生:" prop="menuIds" required>
          <!-- <el-cascader v-model="form.menuIds" :options="options" :props="{ multiple: true }" clearable collapse-tags></el-cascader> -->
          <el-select v-model="form.menuIds" multiple clearable placeholder="请选择">
          <el-select v-model="form.menuIds" multiple clearable placeholder="请选择" collapse-tags filterable @change="changeSelect">
            <div class="checkboxWrapper">
              <el-checkbox v-model="checked" @change.native="checkChange">
                全选
              </el-checkbox>
            </div>
            <el-option v-for="item in options" :key="item.id" :label="item.realName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
@@ -86,6 +91,7 @@
  components: { Pagination },
  data () {
    return {
      checked: false,
      pickerOptions: {
        shortcuts: [{
          text: '最近一周',
@@ -153,15 +159,37 @@
    }
  },
  created () {
    this.initSubject()
    this.search()
    this.queryParam.subjectId = null
    this.subjectFilter = this.subjects
    examPaperApi.selflist().then(res => {
      this.subjectFilter = res.response;
    });
    departmentApi.getDeptAdmins().then(res => {
      this.depts = res.response;
    })
  },
  methods: {
    checkChange() {
      let resValues = this.options.map(item => item.id);
      // 如果checkbox为false,则为反选,选择数组为空
      if (!this.checked) {
        this.form.menuIds = [];
      } else {
         // 如果checkbox为true,则为全选,选择数组添加所有数据
        let res = [...resValues];
        this.form.menuIds = res;
      }
    },
    changeSelect(val) {
      let resValues = this.options.map(item => item.value);
      // 如果选择数组长度等于options的长度,checkbox设为true,反之设为false
      if (val.length === resValues.length) {
        this.checked = true;
      } else {
        this.checked = false;
      }
      this.form.menuIds = val;
    },
    missExam(item) {
      this.form = {
        menuIds: [],
@@ -170,7 +198,7 @@
        limitDateTime: []
      }
      this.examPaper = item;
      userApi.getFailExamUser(item.id).then(res => {
      userApi.getFailTemplateUser(item.id).then(res => {
        this.options = res.response;
        this.dialogVisible = true;
      })
@@ -180,7 +208,7 @@
        if (valid) {
          let op = [];
          for(var ele of this.form.menuIds){
            op.push(ele[1])
            op.push(ele)
          };
          this.form.menuIds = JSON.stringify(this.form.menuIds);
          this.form.userIds = op;
@@ -253,6 +281,7 @@
    search () {
      this.listLoading = true
      this.queryParam.status = 0
      if (this.queryParam.period) this.queryParam.period[1] += ' 23:59:59'
      examPaperApi.pageselfList(this.queryParam).then(data => {
        const re = data.response
        this.tableData = re.list
@@ -292,3 +321,9 @@
  }
}
</script>
<style lang="scss" scoped>
.checkboxWrapper {
  padding: 8px 20px;
  border-bottom: 1px solid #ccc;
}
</style>