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

fix:列表选择器回填数据逻辑

liujiayin 2 лет назад
Родитель
Сommit
7e0c6bcc2e
1 измененных файлов с 14 добавлено и 2 удалено
  1. 14 2
      src/business/platform/org/position/panel.vue

+ 14 - 2
src/business/platform/org/position/panel.vue

@@ -35,6 +35,7 @@
                     node-key="id"
                     node-key="id"
                     pid-key="parentId"
                     pid-key="parentId"
                     :default-expanded-keys="defaultExpandedKeys"
                     :default-expanded-keys="defaultExpandedKeys"
+                    :default-checked-keys="defaultCheckedKeys"
                     :default-expand-all="defaultExpandAll"
                     :default-expand-all="defaultExpandAll"
                     highlight-current
                     highlight-current
                     check-on-click-node
                     check-on-click-node
@@ -126,13 +127,25 @@ export default {
         }
         }
     },
     },
     data () {
     data () {
+        let radio = ''
+        let defaultCheckedKeys = []
+        if (this.multiple) {
+            if (this.value.length !== 0) {
+                defaultCheckedKeys = this.value.map(i => i.id)
+            }
+        } else {
+            if (this.value) {
+                radio = this.value.id
+            }
+        }
         return {
         return {
             parentId: '0',
             parentId: '0',
             defaultExpandAll: true,
             defaultExpandAll: true,
+            defaultCheckedKeys,
             lazyTree: true,
             lazyTree: true,
             defaultExpandedKeys: ['0'],
             defaultExpandedKeys: ['0'],
             moreSearchParams: {},
             moreSearchParams: {},
-            radio: '',
+            radio,
             pkKey: 'id', // 主键  如果主键不是pk需要传主键
             pkKey: 'id', // 主键  如果主键不是pk需要传主键
             loading: false,
             loading: false,
             dialogFormVisible: false,
             dialogFormVisible: false,
@@ -285,7 +298,6 @@ export default {
                     } else if (type === '1') {
                     } else if (type === '1') {
                         this.disabledDotCount(arrList, type)
                         this.disabledDotCount(arrList, type)
                     }
                     }
-
                     resolve(this.toTree(arrList))
                     resolve(this.toTree(arrList))
                 }).catch(res => {
                 }).catch(res => {
                     this.loading = false
                     this.loading = false