Browse Source

频道管理 定制频道 修复内容选择多选交互bug

DESKTOP-O04BTUJ\muzen 3 years ago
parent
commit
b3dad3b330
1 changed files with 12 additions and 6 deletions
  1. 12 6
      src/views/channel/custom/detail.vue

+ 12 - 6
src/views/channel/custom/detail.vue

@@ -68,8 +68,8 @@
       </el-form>
       <!-- 列表 -->
       <el-table :data="dialogData" height="476" ref="table" :row-key="getRowKey"
-        @selection-change="getChange">
-        <el-table-column type="selection" />
+        @selection-change="getChange" lazy>
+        <el-table-column type="selection" align="center" reserve-selection />
         <el-table-column label="内容ID" prop="id" align="center" />
         <el-table-column label="音频名称" prop="audioName" align="center" />
         <el-table-column label="音频封面" align="center">
@@ -164,14 +164,15 @@ export default {
         if (res.code == 0) {
           this.dialogData = res.data[0].pageData.records
           this.total = res.data[0].pageData.total
-          this.$nextTick(() => {
+          this.$refs.table.clearSelection()
+          if (this.tableData.length > 0) {
             this.tableData.map(i => {
               let row = res.data[0].pageData.records.find(j => j.id === i.audioId)
               if (row) {
                 this.$refs.table.toggleRowSelection(row)
               }
             })
-          })
+          }
         }
       })
     },
@@ -226,8 +227,13 @@ export default {
     },
     // 表格多选
     getChange(row) {
-      this.ids = []
-      row.map(i => this.ids.push(i.id))
+      if (row.length > 0) {
+        row.map(i => {
+          if (this.ids.findIndex(j => j === i.id) === -1) {
+            this.ids.push(i.id)
+          }
+        })
+      }
     },
 
     // 添加频道内容