Bläddra i källkod

Merge branch 'develop_yh13' of http://git.chelingzhu.com/jianguan-web/jg-ocs-html into develop_yh13

lilei 2 år sedan
förälder
incheckning
a663c29fbc

+ 16 - 34
src/views/dealerManagement/businessOwnerSettings/chooseAreaModal.vue

@@ -19,7 +19,9 @@
             :auto-expand-parent="autoExpandParent"
             :tree-data="subregionData"
             :checkStrictly="true"
+            :expanded-keys="parentArr"
             @check="onCheck"
+            @expand="onExpand"
             :replaceFields="{children:'subareaAreaList', title:'name', key:'areaSn'}"
           />
         </div>
@@ -63,7 +65,7 @@ export default {
   },
   data () {
     return {
-      autoExpandParent: false,
+      autoExpandParent: true,
       checkAll: false, //  全选
       checkedKeys: {
         checked: [], halfChecked: []
@@ -71,10 +73,17 @@ export default {
       subregionData: null,
       tableHeight: 0,
       visible: false,
-      disabled: false
+      disabled: false,
+      parentArr: []
     }
   },
   methods: {
+    // 树  默认展开被选子级的父级
+    onExpand (expandedKeys) {
+      console.log('onExpand', expandedKeys)
+      this.parentArr = expandedKeys
+      this.autoExpandParent = false
+    },
     getArea () {
       subareaQueryAll().then(res => {
         if (res.status == 200) {
@@ -85,46 +94,19 @@ export default {
               item.subareaAreaList.map(cd => {
                 cd.name = cd.subareaAreaName
                 cd.areaSn = cd.subareaAreaSn + '_'
+                const falg = this.chooseData.checked.length > 0 ? this.chooseData.checked.includes(cd.subareaAreaSn + '_') : false
+                if (falg) {
+                  this.parentArr.push(cd.subareaSn)
+                }
               })
             }
           })
           this.subregionData = res.data
-          // if (this.chooseData && this.chooseData.checked && this.chooseData.checked.length > 0) {
-          //   this.handleChooseData(res.data)
-          // } else {
-          //   this.subregionData = res.data
-          // }
           this.checkedKeys = this.chooseData ? this.chooseData : []
         }
       })
     },
-    // 将选择过的禁用掉
-    // handleChooseData (subregionData) {
-    //   var area = [] // 区域
-    //   var zone = []// 分区
-    //   this.chooseData.checked.forEach(con => {
-    //     if (con.indexOf('_') == -1) {
-    //       area.push(con)
-    //     } else {
-    //       zone.push(con)
-    //     }
-    //   })
-    //   if (subregionData && subregionData.length > 0) {
-    //     subregionData.forEach(item => {
-    //       if (area && area.length > 0) {
-    //         item.disabled = area.includes(item.areaSn)
-    //         item.disableCheckbox = area.includes(item.areaSn)
-    //       }
-    //       if (item.subareaAreaList && item.subareaAreaList.length > 0) {
-    //         item.subareaAreaList.forEach(con => {
-    //           con.disabled = zone.includes(con.areaSn)
-    //           con.disableCheckbox = zone.includes(con.areaSn)
-    //         })
-    //       }
-    //     })
-    //   }
-    //   this.subregionData = subregionData
-    // },
+
     save () {
       this.$emit('ok', this.checkedKeys)
     },

+ 12 - 9
src/views/dealerManagement/businessOwnerSettings/chooseDealer.vue

@@ -54,7 +54,7 @@
       class="sTable"
       ref="table"
       size="small"
-      :rowKey="(record) => record.dealer.dealerSn"
+      :rowKey="(record) => record.dealerSn"
       rowKeyName="dealerSn"
       :row-selection="{ columnWidth: 40, getCheckboxProps: record => ({ props: { disabled: pageType=='viewDealers'?!!record.subareaAreaSn: !!record.chooseId} }) }"
       @rowSelection="rowSelectionFun"
@@ -121,6 +121,7 @@ export default {
         subareaAreaSn: undefined
       },
       userSn: '',
+      pageFlag: false,
       chooseInfo: [],
       tableHeight: 0,
       disabled: false, //  查询、重置按钮是否可操作
@@ -135,18 +136,20 @@ export default {
           if (res.status == 200) {
             data = res.data
             const no = 0
-            if (!_this.pageType && _this.chooseInfo && _this.chooseInfo.length > 0) {
-              const chooseData = []
-              for (var i = 0; i < data.list.length; i++) {
-                data.list[i].no = no + i + 1
+            const chooseData = []
+            for (var i = 0; i < data.list.length; i++) {
+              data.list[i].no = no + i + 1
+              data.list[i].dealerSn = data.list[i].dealer.dealerSn
+              if (!_this.pageType && _this.chooseInfo && _this.chooseInfo.length > 0) {
                 // 回显选中数据
                 const flag = _this.chooseInfo.includes(data.list[i].dealer.dealerSn)
                 if (flag) {
                   chooseData.push(data.list[i])
                 }
               }
-              console.log('111111:', chooseData)
-              console.log('222222:', _this.chooseInfo)
+            }
+            if (!this.pageFlag) {
+              this.pageFlag = true
               _this.$refs.table.setTableSelected(_this.chooseInfo, chooseData) // 设置表格选中项
             }
           }
@@ -192,7 +195,6 @@ export default {
     },
     searchForm (flag) {
       this.$refs.table.refresh(flag)
-      this.$refs.table.clearSelected()
       this.spinning = false
     },
     subareaChange (val) {
@@ -219,8 +221,9 @@ export default {
       } else {
         this.$refs.areaList.clearData()
       }
-      this.$refs.table.refresh(true)
       this.$refs.table.clearSelected()
+      this.$refs.table.refresh(true)
+      this.pageFlag = false
     },
     clearTable () {
       this.rowSelectionInfo = null