浏览代码

fix:处理系统导出未选数据时候的报错,修改数据模板里selection值为所有已选择的数据id

liujiayin 2 年之前
父节点
当前提交
a7147476dc
共有 2 个文件被更改,包括 16 次插入1 次删除
  1. 6 0
      src/business/platform/data/templaterender/templates/list.vue
  2. 10 1
      src/components/ibps-crud/mixin/base.js

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

@@ -21,6 +21,7 @@
             :dynamic-params="dynamicParams"
             :form-name="template ? template.attrs.form_name : ''"
             :class="{ 'ibps-data-template-list__preview': preview }"
+            :selection_all="selectionAll"
             @display-field-change="handleDisplayField"
             @header-dragend="handleHeaderDragend"
             @selection-change="handleSelectionChange"
@@ -488,6 +489,7 @@ export default {
     watch: {
         value: {
             handler (val, oldVal) {
+                console.log('492 val', val)
                 this.selectionAll = val
             },
             immediate: true,
@@ -724,6 +726,9 @@ export default {
          */
         getSelectAllIds () {
             const selectAllIds = []
+            if (this.$utils.isEmpty(this.selectionAll)) {
+                return
+            }
             if (this.multiple) {
                 this.selectionAll.forEach((row) => {
                     selectAllIds.push(this.getPkValue(row))
@@ -1043,6 +1048,7 @@ export default {
                         this.exportActions(buttonType)
                         break
                     case 'exportSelected': // 导出选中
+
                         ActionUtils.selectedMultiRecord(this.getSelectAllIds()).then((ids) => {
                             this.selecteds = ids
                             this.exportActions(buttonType, ids)

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

@@ -95,6 +95,14 @@ export default {
         selectionType: {
             type: String,
             default: 'checkbox'
+        },
+        /**
+     * @description 所有列表已选择的数据id
+     *
+     */
+        selection_all: {
+            type: Array,
+            default: () => []
         }
     },
     methods: {
@@ -263,7 +271,8 @@ export default {
             const buttonKey = action.key
             let selection = null// 选中数据
             if (position === 'toolbar') { // 工具栏
-                selection = this.getSelectedIds()
+                // selection = this.getSelectedIds()
+                selection = this.selection_all.map(i => i.id_) // 默认给所有已选择的数据id
             } else { // 管理列
                 selection = data ? this.getPkValue(data) : null
             }