lilei 1 éve
szülő
commit
ad2d846e4e

+ 1 - 1
src/api/dealer.js

@@ -237,7 +237,7 @@ export const dealerUpsList = (params) => {
 // 差价品类列表 
 export const dealerUpsPlTree = (params) => {
   return axios({
-    url: `/dealerScope/queryWaitingData`,
+    url: `/dealerUps/queryWaitingData`,
     data: params,
     method: 'post',
     headers:{

+ 71 - 20
src/views/dealerManagement/rebateBinding/categoryTree.vue

@@ -2,18 +2,21 @@
   <div class="categoryTree-wrap">
     <div style="padding-bottom:10px;" v-if="showTable">
       <span style="color:red;">*</span> 添加品类:
-      <a-radio-group name="radioGroup">
-        <a-radio :value="1">全选</a-radio>
-        <a-radio :value="2">自主品牌</a-radio>
-        <a-radio :value="3">代理品牌</a-radio>
-      </a-radio-group>
+      <a-checkbox v-model="check1" @change="(e)=> onAllChange(e,0)" v-show="!showEmpty">
+        全选
+      </a-checkbox>
+      <a-checkbox v-model="check2" @change="(e)=> onAllChange(e,1)" v-show="!showEmpty">
+        自主品牌
+      </a-checkbox>
+      <a-checkbox v-model="check3" @change="(e)=> onAllChange(e,2)" v-show="!showEmpty">
+        代理品牌
+      </a-checkbox>
     </div>
 
     <a-spin :spinning="spinning" tip="Loading..." v-if="showTable">
       <div v-show="showEmpty" class="empty-data"><a-empty description="暂无品类" :image="simpleImage"/></div>
-      <div style="height:350px;overflow: auto;">
+      <div v-show="!showEmpty" style="height:350px;overflow: auto;">
         <a-tree
-          v-show="!showEmpty"
           checkable
           v-model="checkedKeys"
           :tree-data="dataSource"
@@ -62,7 +65,11 @@ export default {
       parentDealerSn: undefined,
       checkedKeys: [],
       halfCheckedKeys: [],
-      allLeafKeys: []
+      allLeafKeys: [],
+      allBrands: [],
+      check1: false,
+      check2: false,
+      check3: false
     }
   },
   computed: {
@@ -73,8 +80,6 @@ export default {
       console.log('onCheck', checkedKeys, info)
       this.checkedKeys = checkedKeys
       this.halfCheckedKeys = info.halfCheckedKeys
-
-      this.getResult()
     },
     getResult () {
       // 所有已选叶子节点
@@ -93,7 +98,50 @@ export default {
           'productTypeSn3': d[1]
         })
       })
-      console.log(result)
+      return result
+    },
+    // 筛选并全选
+    onAllChange (e, type) {
+      console.log(e.target.checked, type)
+      if (type == 0) {
+        this.check2 = false
+        this.check3 = false
+        this.check1 = e.target.checked
+        this.allCheck(this.check1, type)
+      }
+      if (type == 1) {
+        this.check1 = false
+        this.check3 = false
+        this.check2 = e.target.checked
+        this.allCheck(this.check2, type)
+      }
+      if (type == 2) {
+        this.check1 = false
+        this.check2 = false
+        this.check3 = e.target.checked
+        this.allCheck(this.check3, type)
+      }
+    },
+    // 全选树
+    allCheck (checked, type) {
+      if (checked) {
+        this.checkedKeys = []
+        this.allLeafKeys.map(item => {
+          // 自主或代理
+          if (type) {
+            const psn = item.sn.split('_2_')[0]
+            const prow = this.dataSource.find(k => k.sn == psn)
+            if (prow && prow.productBrandType == type) {
+              this.checkedKeys.push(item.sn)
+            }
+          } else {
+            // 全品类
+            this.checkedKeys.push(item.sn)
+          }
+        })
+      } else {
+        this.checkedKeys = []
+      }
     },
     // 获取所有叶子结节
     getLeafKeys (tree) {
@@ -122,16 +170,19 @@ export default {
       this.dataSource = []
       this.allLeafKeys = []
       this.spinning = true
-      const params = { ...this.detailData }
-      params.dealerScope = { dealerSn: this.dealerSn }
+      const params = { dealerSn: this.dealerSn, upsDealerSn: this.parentDealerSn }
       // 品类列表
-      const listData = await dealerUpsPlTree({}).then(res => res.data)
-      this.dataSource = listData
-      // 获取所有叶子节点
-      this.dataSource.map(item => {
-        this.allLeafKeys = this.allLeafKeys.concat(this.getLeafKeys(item))
-      })
-      this.showEmpty = this.dataSource.length <= 0
+      const listData = await dealerUpsPlTree(params).then(res => res.data)
+      if (listData) {
+        this.dataSource = listData.sort((a, b) => a.productBrandType - b.productBrandType)
+        // 获取所有叶子节点
+        this.dataSource.map(item => {
+          this.allLeafKeys = this.allLeafKeys.concat(this.getLeafKeys(item))
+          // 获取所有品牌sn
+          this.allBrands.push(item.sn)
+        })
+        this.showEmpty = this.dataSource.length <= 0
+      }
       this.spinning = false
     },
     pageInit (detailData, parentDealerSn, dealerSn) {

+ 11 - 3
src/views/dealerManagement/rebateBinding/priceDiffModal.vue

@@ -56,7 +56,7 @@
           <a-form-model-item label="指定经销商" v-if="zdDealearList.length">
             <a-row :gutter="10" v-for="(item,index) in zdDealearList" :key="item.id">
               <a-col :span="17">
-                <custList :ref="'custList'+index" :notDealerSn="notZdDealer" @change="(v)=>custChange(v,index)" placeholder="请输入经销商名称搜索"></custList>
+                <custList :ref="'custList'+index" :notDealerSn="notZdDealer" @change="(v,r)=>custChange(v,r,index)" placeholder="请输入经销商名称搜索"></custList>
               </a-col>
               <a-col :span="4">
                 <a-input-number :min="0" :max="100" v-model="item.allotRate" @change="(v)=>rateChange(v,index)" placeholder="请输入比例"/> %
@@ -177,7 +177,7 @@ export default {
       }
     },
     // 上级经销商修改
-    custSupChange (val) {
+    custSupChange (val, row) {
       this.form.rebateDealerList[0]['parentDealerSn'] = val.key
       this.getCategoryList()
     },
@@ -196,7 +196,7 @@ export default {
       this.form.rebateDealerList[1]['allotRate'] = val
     },
     // 指定经销商变更
-    custChange (val, index) {
+    custChange (val, row, index) {
       console.log(val, index)
       this.zdDealearList[index]['parentDealerSn'] = val.key
     },
@@ -327,6 +327,14 @@ export default {
               return
             }
 
+            if (this.showTable) {
+              formData.rebateScopeList = this.$refs.categoryTree.getResult()
+              if (formData.rebateScopeList.length == 0) {
+                _this.$message.error('请选择品类')
+                return
+              }
+            }
+
             _this.spinning = true
             dealerUpsCreate(formData).then(res => {
               if (res.status == 200) {