|
@@ -2,18 +2,21 @@
|
|
<div class="categoryTree-wrap">
|
|
<div class="categoryTree-wrap">
|
|
<div style="padding-bottom:10px;" v-if="showTable">
|
|
<div style="padding-bottom:10px;" v-if="showTable">
|
|
<span style="color:red;">*</span> 添加品类:
|
|
<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>
|
|
</div>
|
|
|
|
|
|
<a-spin :spinning="spinning" tip="Loading..." v-if="showTable">
|
|
<a-spin :spinning="spinning" tip="Loading..." v-if="showTable">
|
|
<div v-show="showEmpty" class="empty-data"><a-empty description="暂无品类" :image="simpleImage"/></div>
|
|
<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
|
|
<a-tree
|
|
- v-show="!showEmpty"
|
|
|
|
checkable
|
|
checkable
|
|
v-model="checkedKeys"
|
|
v-model="checkedKeys"
|
|
:tree-data="dataSource"
|
|
:tree-data="dataSource"
|
|
@@ -62,7 +65,11 @@ export default {
|
|
parentDealerSn: undefined,
|
|
parentDealerSn: undefined,
|
|
checkedKeys: [],
|
|
checkedKeys: [],
|
|
halfCheckedKeys: [],
|
|
halfCheckedKeys: [],
|
|
- allLeafKeys: []
|
|
|
|
|
|
+ allLeafKeys: [],
|
|
|
|
+ allBrands: [],
|
|
|
|
+ check1: false,
|
|
|
|
+ check2: false,
|
|
|
|
+ check3: false
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
@@ -73,8 +80,6 @@ export default {
|
|
console.log('onCheck', checkedKeys, info)
|
|
console.log('onCheck', checkedKeys, info)
|
|
this.checkedKeys = checkedKeys
|
|
this.checkedKeys = checkedKeys
|
|
this.halfCheckedKeys = info.halfCheckedKeys
|
|
this.halfCheckedKeys = info.halfCheckedKeys
|
|
-
|
|
|
|
- this.getResult()
|
|
|
|
},
|
|
},
|
|
getResult () {
|
|
getResult () {
|
|
// 所有已选叶子节点
|
|
// 所有已选叶子节点
|
|
@@ -93,7 +98,50 @@ export default {
|
|
'productTypeSn3': d[1]
|
|
'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) {
|
|
getLeafKeys (tree) {
|
|
@@ -122,16 +170,19 @@ export default {
|
|
this.dataSource = []
|
|
this.dataSource = []
|
|
this.allLeafKeys = []
|
|
this.allLeafKeys = []
|
|
this.spinning = true
|
|
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
|
|
this.spinning = false
|
|
},
|
|
},
|
|
pageInit (detailData, parentDealerSn, dealerSn) {
|
|
pageInit (detailData, parentDealerSn, dealerSn) {
|