From c19bb5ac1b4013aa700c0a658f20375be9703ea3 Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期一, 08 七月 2024 18:45:47 +0800
Subject: [PATCH] feat:选择学生增加全选按钮

---
 src/views/exam/personalRandomTemplate/edit.vue |   16 +++++++++++++---
 src/views/exam/paper/edit.vue                  |   19 ++++++++++++++++++-
 2 files changed, 31 insertions(+), 4 deletions(-)

diff --git a/src/views/exam/paper/edit.vue b/src/views/exam/paper/edit.vue
index a269634..9936316 100644
--- a/src/views/exam/paper/edit.vue
+++ b/src/views/exam/paper/edit.vue
@@ -164,6 +164,7 @@
           <el-button type="primary" @click="selectStudent">鏌ヨ</el-button>
         </el-form-item>
       </el-form>
+      <el-button type="primary" @click="selectAllBoolean ? selectAll() : unselectAll()">{{ selectAllBoolean ? '鍏ㄩ��' : '鍙栨秷鍏ㄩ��' }}</el-button>
       <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>
@@ -194,6 +195,7 @@
   components: { Pagination, QuestionShow },
   data() {
     return {
+      selectAllBoolean: true,
       tags: [],
       depts: [],
       studentDialog: false,
@@ -324,7 +326,22 @@
       this.student.listLoading = true;
       this.getStudent();
     },
-
+    selectAll () {
+      this.selectAllBoolean = false;
+      let param = { ...this.student };
+      param.pageSize = 999999;
+      examPaperApi.selectStudent(param).then(res => {
+        this.handleSelection(res.response.list);
+        res.response.list.forEach(item => {
+          this.$refs.multipleTable.toggleRowSelection(item, true);
+        })
+        this.getStudent();
+      });
+    },
+    unselectAll () {
+      this.selectAllBoolean = true;
+      this.$refs.multipleTable.clearSelection();
+    },
     getStudent() {
       this.student.listLoading = true;
       examPaperApi.selectStudent(this.student).then(res => {
diff --git a/src/views/exam/personalRandomTemplate/edit.vue b/src/views/exam/personalRandomTemplate/edit.vue
index b559b0d..a2e4527 100644
--- a/src/views/exam/personalRandomTemplate/edit.vue
+++ b/src/views/exam/personalRandomTemplate/edit.vue
@@ -167,8 +167,9 @@
           <el-button type="primary" @click="selectStudent">鏌ヨ</el-button>
         </el-form-item>
       </el-form>
+      <el-button type="primary" @click="selectAllBoolean ? selectAll() : unselectAll()">{{ selectAllBoolean ? '鍏ㄩ��' : '鍙栨秷鍏ㄩ��' }}</el-button>
       <el-table ref="multipleTable" v-loading="student.listLoading" :data="tableData" border fit highlight-current-row
-        style="width: 100%" @selection-change="handleSelection" row-key="id" @select-all="selectAll">
+        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>
@@ -198,6 +199,7 @@
 
   data() {
     return {
+      selectAllBoolean: true,
       tags: [],
       studentDialog: false,
       student: {
@@ -349,16 +351,24 @@
       })
     },
     handleSelection(val) {
-      console.log('val', val);
       this.student.multipleSelection = val;
     },
-    selectAll() {
+    selectAll () {
+      this.selectAllBoolean = false;
       let param = { ...this.student };
       param.pageSize = 999999;
       examPaperApi.selectStudent(param).then(res => {
         this.handleSelection(res.response.list);
+        res.response.list.forEach(item => {
+          this.$refs.multipleTable.toggleRowSelection(item, true);
+        })
+        this.getStudent();
       });
     },
+    unselectAll () {
+      this.selectAllBoolean = true;
+      this.$refs.multipleTable.clearSelection();
+    },
     confirmStudentSelect() {
       this.form.userIds = this.student.multipleSelection.map((item) => item.id);
       this.form.examineeList = this.student.multipleSelection.map((item) => {

--
Gitblit v1.8.0