Просмотр исходного кода

fix:修复列表翻页多选数据经过顶部按钮点击后会丢失问题

liujiayin 2 лет назад
Родитель
Сommit
40397e56b9

+ 6 - 6
src/business/platform/data/templaterender/templates/list.vue

@@ -635,7 +635,7 @@ export default {
                 this.selectionAll = this.selection ? JSON.parse(JSON.stringify(this.selection)) : []
                 return
             }
-
+            // 总选择里面的key集合
             // 标识当前行的唯一键的名称
             const { listData } = this
             // 总选择里面的key集合
@@ -646,7 +646,6 @@ export default {
             } else {
                 selectionAll.push(this.selectionAll)
             }
-
             // 获取当前页选中的id
             const selectIds = []
             if (this.multiple) {
@@ -660,8 +659,7 @@ export default {
                 })
             } else {
                 if (this.$utils.isNotEmpty(this.selection)) {
-                    const pkValue = this.getPkValue(this.selection)
-                    selectIds.push(pkValue)
+                    const pkValue = this.getPkValue(this.selection) 
                     if (selectAllIds.indexOf(pkValue) < 0) {
                         selectionAll = []
                         selectionAll.push(this.selection)
@@ -725,8 +723,10 @@ export default {
             const selectAllIds = this.getSelectAllIds()
             for (let i = 0; i < listData.length; i++) {
                 const row = listData[i]
+                
                 if (selectAllIds.indexOf(this.getPkValue(row)) >= 0) {
                     if (this.multiple) {
+                        
                         tableEl.toggleSelectionRow(row, true)
                     } else {
                         tableEl.setSelectionRadio(row)
@@ -970,8 +970,8 @@ export default {
             const buttonType = button.button_type || button.key
             this.action = buttonType
             this.position = position
-            this.selection = selection
-
+            this.selection = data
+            // 查询
             // 前置事件
             this.beforeScript(command, position, selection, data, () => {
                 let src = ''

+ 4 - 1
src/components/ibps-crud/mixin/base.js

@@ -143,6 +143,7 @@ export default {
             const pkValue = this.getPkValue(row)
             for (var i = 0; i < this.ibpsData.length; i++) {
                 const data = this.ibpsData[i]
+                
                 if (this.getPkValue(data) === pkValue) {
                     this.$refs.elTable.toggleRowSelection(data, selected)
                 }
@@ -279,7 +280,9 @@ export default {
             } else { // 管理列
                 selection = data ? this.getPkValue(data) : null
             }
-            this.$emit('action-event', buttonKey, position, selection, data, index, action)
+            this.$emit('action-event', buttonKey, position, selection, this.selectionAll, index, action)
+            // this.$emit('action-event', buttonKey, position, selection, data, index, action)
+
         },
 
         /**