lex 10 mesiacov pred
rodič
commit
3e145d034f

+ 69 - 22
src/views/courseware-config/add-teacher.vue

@@ -61,11 +61,12 @@
     <div class="tableWrap">
       <el-table
         :data="tableList"
-        ref="multipleTable"
+        ref="multipleSelection"
         :header-cell-style="{ background: '#EDEEF0', color: '#444' }"
         @selection-change="handleSelectionChange"
+        @select="onTableSelect"
       >
-        <el-table-column type="selection"  width="55" />
+        <el-table-column type="selection" width="55" />
         <el-table-column
           align="center"
           prop="id"
@@ -125,10 +126,11 @@ import {
 } from "./api";
 import { courseEmnuList, jobNature } from "@/utils/searchArray";
 import { teacherQueryPage } from "@/api/teacherManager";
+import deepClone from "@/helpers/deep-clone/";
 export default {
   name: "add-courseware",
   components: { pagination },
-  props: ['list'],
+  props: ["list"],
   data() {
     return {
       jobNature, // 工作类型
@@ -151,6 +153,7 @@ export default {
     };
   },
   async mounted() {
+    this.activeChiose = this.list || [];
     await this.$store.dispatch("setBranchs");
     this.getList();
   },
@@ -163,9 +166,40 @@ export default {
       this.$refs.searchForm.resetFields();
       this.search();
     },
-    handleSelectionChange(val) {
-      console.log(val, 'val')
-      this.activeChiose = val;
+    onTableSelect(arr) {
+      try {
+        let currentPageList = [];
+        const otherPageList = [];
+        this.activeChiose.forEach(item => {
+          if (item.currentPage == this.pageInfo.page) {
+            currentPageList.push(item);
+          } else {
+            otherPageList.push(item);
+          }
+        });
+
+        const lastPage = [];
+        if (arr.length > 0) {
+          arr.forEach(item => {
+            const index = currentPageList.findIndex(
+              child => child.id === item.id
+            );
+            if (index === -1) {
+              lastPage.push(item);
+            }
+          });
+        } else {
+          currentPageList = [];
+        }
+        this.activeChiose = [
+          ...lastPage,
+          ...otherPageList,
+          ...currentPageList
+        ].sort((a, b) => a.id - b.id);
+      } catch (e) {}
+    },
+    handleSelectionChange(arr) {
+      // console.log(val, 'val')
     },
     async getList() {
       //
@@ -178,21 +212,35 @@ export default {
         teacherQueryPage(params).then(res => {
           if (res.code == 200) {
             //  (res)
-            console.log(res, 'data')
-            this.tableList = res.data.rows;
+            console.log(res, "data");
+            const rows = res.data.rows || [];
+            rows.forEach(row => {
+              row.currentPage = this.pageInfo.page;
+            });
+            this.tableList = rows;
             this.pageInfo.total = res.data.total;
 
             // 反选对应数据
-            console.log(this.list, 'this.list')
+            const activeChiose = deepClone(this.activeChiose);
+            console.log(activeChiose, "this.list");
             this.$nextTick(() => {
               this.tableList.forEach(item => {
-                const index = this.list.findIndex(child => child.id === item.id);
-                console.log(index, 'tableList')
-                if(index > -1) {
-                  this.$refs.multipleTable.toggleRowSelection(item);
+                const index = activeChiose.findIndex(
+                  child => child.id == item.id
+                );
+                if (index > -1) {
+                  console.log(index, "tableList", item.id);
+                  this.activeChiose[index].currentPage = item.currentPage;
+                  this.$refs.multipleSelection.toggleRowSelection(item, true);
                 }
-              })
-            })
+
+                //     this.tableList.forEach(course => {
+                //   if (idList.indexOf(course.skuStockId) != -1) {
+                //     this.$refs.multipleSelection.toggleRowSelection(course, true);
+                //   }
+                // });
+              });
+            });
           }
         });
       } catch {
@@ -200,16 +248,15 @@ export default {
       }
     },
     async onSubmit() {
-      
-      const userList = []
+      const userList = [];
       this.activeChiose.forEach(item => {
         userList.push({
-          name: item.realName,
+          name: item.realName || item.name,
           id: item.id
-        })
-      })
-      console.log(userList, 'this.activeChiose')
-      this.$emit('confirm', userList)
+        });
+      });
+      console.log(userList, "this.activeChiose");
+      this.$emit("confirm", userList);
       this.$emit("close");
     }
   }

+ 29 - 15
src/views/courseware-config/index.vue

@@ -12,6 +12,20 @@
         @reset="onReSet"
         ref="searchForm"
       >
+        <el-form-item prop="search">
+          <el-input
+            v-model.trim="searchForm.search"
+            clearable
+            @keyup.enter.native="
+              e => {
+                e.target.blur();
+                $refs.searchForm.save();
+                search();
+              }
+            "
+            placeholder="课件名称"
+          ></el-input>
+        </el-form-item>
         <el-form-item prop="subjectId">
           <el-select
             v-model.trim="searchForm.subjectId"
@@ -19,12 +33,12 @@
             filterable
             placeholder="请选择声部"
           >
-           <el-option
-            v-for="item in selects.subjects"
-            :value="item.id"
-            :label="item.name"
-            :key="item.id"
-          ></el-option>
+            <el-option
+              v-for="item in selects.subjects"
+              :value="item.id"
+              :label="item.name"
+              :key="item.id"
+            ></el-option>
           </el-select>
         </el-form-item>
         <el-form-item prop="teacherRangeType">
@@ -112,10 +126,8 @@
             label="适用老师"
             prop="teacherRangeType"
           >
-             <template slot-scope="scope">
-              <span >{{
-                scope.row.teacherRangeType | rangeType
-              }}</span>
+            <template slot-scope="scope">
+              <span>{{ scope.row.teacherRangeType | rangeType }}</span>
             </template>
           </el-table-column>
           <el-table-column
@@ -124,9 +136,7 @@
             prop="studentRangeType"
           >
             <template slot-scope="scope">
-              <span >{{
-                scope.row.studentRangeType | rangeType
-              }}</span>
+              <span>{{ scope.row.studentRangeType | rangeType }}</span>
             </template>
           </el-table-column>
           <el-table-column
@@ -155,7 +165,10 @@
                 @click="coursewareOperation('update', scope.row)"
                 >修改</el-button
               >
-              <el-button v-permission="'lessonCourseware/updateRangeType'" type="text" @click="onAuth(scope.row)"
+              <el-button
+                v-permission="'lessonCourseware/updateRangeType'"
+                type="text"
+                @click="onAuth(scope.row)"
                 >适用权限</el-button
               >
               <el-button
@@ -261,6 +274,7 @@ export default {
     return {
       tableList: [],
       searchForm: {
+        search: null,
         subjectId: null,
         teacherRangeType: null,
         studentRangeType: null,
@@ -352,7 +366,7 @@ export default {
     },
     onAuth(row) {
       this.updateAuth = true;
-      this.rowDetail = row || {}
+      this.rowDetail = row || {};
     }
   }
 };