lilei 1 year ago
parent
commit
d234ec14ed

+ 31 - 5
src/views/dealerManagement/rebateBinding/categoryList.vue

@@ -88,8 +88,14 @@ export default {
       },
       expandOption: {
         defaultExpandAllRows: false,
+        trigger: 'row',
+        expandedRowKeys: [],
         render: ({ row, column, rowIndex }, h) => {
           return <ChildTableComp row={row} />
+        },
+        // 重新赋值处理
+        afterExpandRowChange: ({ afterExpandedRowKeys, row, rowIndex }) => {
+          this.changeExpandedRowKeys(afterExpandedRowKeys)
         }
       },
       showEmpty: true,
@@ -122,13 +128,13 @@ export default {
               size="small"
               type="link"
               class="button-info"
-              onClick={() => _this.handleEdit(record)}
+              onClick={(e) => _this.handleEdit(record, e)}
             >编辑</a-button>
             <a-button
               size="small"
               type="link"
               class="button-error"
-              onClick={() => _this.handleDel(record)}
+              onClick={(e) => _this.handleDel(record, e)}
             >删除</a-button>
           </div>
         )
@@ -138,6 +144,12 @@ export default {
         if (_this.isTeyue) {
           return (<span>-</span>)
         }
+        const hasExpend = _this.expandOption.expandedRowKeys.indexOf(record.id)
+        if (hasExpend >= 0) {
+          return (
+            <span style="cursor:pointer;">收起</span>
+          )
+        }
         return (
           <span style="cursor:pointer;">展开</span>
         )
@@ -153,6 +165,18 @@ export default {
     }
   },
   methods: {
+    // 给可控属性重新赋值
+    changeExpandedRowKeys (keys) {
+      this.expandOption.expandedRowKeys = keys
+    },
+    // 展开全部
+    expandAll () {
+      this.expandOption.expandedRowKeys = this.list.map((x) => x.id)
+    },
+    // 折叠全部
+    foldAll () {
+      this.expandOption.expandedRowKeys = []
+    },
     // 筛选数据
     filterData (data, queryParam) {
       return data.filter(s => {
@@ -230,13 +254,15 @@ export default {
         this.disabled = false
       })
     },
-    handleEdit (record) {
+    handleEdit (record, e) {
+      console.log(e)
+      e.stopPropagation()
       const row = this.dataSource.find(item => item.dealerUpsSn == record.dealerUpsSn && item.dealerSn == record.dealerSn)
       this.$emit('edit', row)
     },
-    handleDel (record) {
+    handleDel (record, e) {
+      e.stopPropagation()
       const _this = this
-      console.log(record)
       this.$confirm({
         title: '提示',
         content: '删除后,将解除该品类差价设置归属关系。确定删除吗?',

+ 14 - 2
src/views/dealerManagement/rebateBinding/list.vue

@@ -53,8 +53,11 @@
           </a-form-model>
         </div>
         <!-- 操作按钮 -->
-        <div class="table-operator" v-if="showBtns">
+        <div class="table-operator" style="display: flex;align-items: center;justify-content: space-between;" v-if="showBtns">
           <a-button id="rebateBinding-brand" type="primary" class="button-error" @click="openGlModal">差价设置</a-button>
+          <div>
+            <a-button type="default" @click="expandAllRow">{{ expandAll?'收起全部':'展开全部' }}</a-button>
+          </div>
         </div>
         <!-- 列表 -->
         <categoryList ref="categoryList" @loaded="loadList" @del="delOk" @edit="handleEdit" :maxHeight="tableHeight"></categoryList>
@@ -96,7 +99,8 @@ export default {
         productTypeSn3: undefined,
         dealerName: ''
       },
-      showBtns: true
+      showBtns: true,
+      expandAll: false
     }
   },
   computed: {
@@ -129,6 +133,14 @@ export default {
       this.queryParam.productTypeSn2 = val[1] ? val[1] : undefined
       this.queryParam.productTypeSn3 = val[2] ? val[2] : undefined
     },
+    expandAllRow () {
+      if (this.expandAll) {
+        this.$refs.categoryList.foldAll()
+      } else {
+        this.$refs.categoryList.expandAll()
+      }
+      this.expandAll = !this.expandAll
+    },
     // 重置表单
     resetSearchForm () {
       this.queryParam.dealerName = ''