|
@@ -29,34 +29,27 @@
|
|
|
placeholder="请选择价格级别"></v-select>
|
|
|
</a-form-model-item>
|
|
|
<a-form-model-item label="添加品类" prop="typeVal">
|
|
|
- <a-radio-group v-model="form.typeVal" @change="onChangeType">
|
|
|
- <a-radio :value="1">
|
|
|
- 全选
|
|
|
- </a-radio>
|
|
|
- <a-radio :value="2">
|
|
|
- 自主品牌
|
|
|
- </a-radio>
|
|
|
- <a-radio :value="3">
|
|
|
- 代理品牌
|
|
|
- </a-radio>
|
|
|
- <a-radio :value="4">
|
|
|
+ <a-checkbox v-for="(con,i) in filterList" :checked="con.checked" :key="con.id" @change="e=>onChangeType(e.target.checked,i)">
|
|
|
+ <span v-show="con.id!=4">{{ con.name }}</span>
|
|
|
+ <span v-show="con.id==4">
|
|
|
<a-tooltip placement="rightTop">
|
|
|
<template slot="title">
|
|
|
<span>选择全品类后,未来新加入的品类也将自动默认为已选择状态,无需再次手动操作。</span>
|
|
|
</template>
|
|
|
- <span>全品类</span>
|
|
|
+ <span>{{ con.name }}</span>
|
|
|
<a-icon type="question-circle" style="margin-left:5px;" />
|
|
|
</a-tooltip>
|
|
|
- </a-radio>
|
|
|
- </a-radio-group>
|
|
|
+ </span>
|
|
|
+ </a-checkbox>
|
|
|
</a-form-model-item>
|
|
|
- <div class="typeListBox">
|
|
|
+ <div class="typeListBox" v-show="form.typeVal!=4">
|
|
|
<a-tree
|
|
|
v-model="checkedList"
|
|
|
checkable
|
|
|
:auto-expand-parent="autoExpandParent"
|
|
|
:tree-data="treeData"
|
|
|
:replaceFields="replaceObj"
|
|
|
+ :checkStrictly="true"
|
|
|
@check="onCheck"
|
|
|
/>
|
|
|
</div>
|
|
@@ -70,7 +63,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import { dealerScopeCreate, queryWaitingData } from '@/api/dealerScope'
|
|
|
+import { dealerScopeCreate, queryWaitingData, dealerScopeQueryList } from '@/api/dealerScope'
|
|
|
import chooseTypeList from './chooseTypeList.vue'
|
|
|
import { VSelect } from '@/components'
|
|
|
export default {
|
|
@@ -92,7 +85,7 @@ export default {
|
|
|
},
|
|
|
form: {
|
|
|
priceLevel: undefined, // 价格级别
|
|
|
- typeVal: ''
|
|
|
+ typeVal: '0'
|
|
|
},
|
|
|
rules: {
|
|
|
priceLevel: [
|
|
@@ -109,25 +102,85 @@ export default {
|
|
|
autoExpandParent: false, // 是否自动展开父节点
|
|
|
replaceObj: {
|
|
|
children: 'sonList', title: 'name', key: 'sn'
|
|
|
- }
|
|
|
+ },
|
|
|
+ disabledList: [], // 已选过禁用调的品类数据
|
|
|
+ filterList: [{ id: '1', name: '全选', checked: false }, { id: '2', name: '自主品牌', checked: false }, { id: '3', name: '代理品牌', checked: false }, { id: '4', name: '全品类', checked: false }],
|
|
|
+ allBarndSnList: [],
|
|
|
+ ownBarndSnList: [],
|
|
|
+ agentBarndSnList: []
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- onChangeType () {
|
|
|
-
|
|
|
+ onChangeType (val, pos) {
|
|
|
+ this.filterList.map(item => item.checked = false)
|
|
|
+ this.filterList[pos].checked = val
|
|
|
+ // 选择全品类 隐藏选择品类数据
|
|
|
+ this.form.typeVal = '0'
|
|
|
+ if (pos === 3 && val) {
|
|
|
+ this.form.typeVal = this.filterList[pos].id
|
|
|
+ }
|
|
|
+ this.checkedList = []
|
|
|
+ // 全选
|
|
|
+ if (pos === 0 && val) {
|
|
|
+ this.checkedList = this.allBarndSnList
|
|
|
+ }
|
|
|
+ // 自主
|
|
|
+ if (pos === 1 && val) {
|
|
|
+ this.checkedList = this.ownBarndSnList
|
|
|
+ }
|
|
|
+ if (pos === 2 && val) {
|
|
|
+ this.checkedList = this.agentBarndSnList
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 获取品牌sn
|
|
|
+ getLevel1Data () {
|
|
|
+ // 全选
|
|
|
+ const allBarndSn = []; const ownBarndSn = []; const agentBarndSn = []
|
|
|
+ this.treeData.forEach(con => {
|
|
|
+ allBarndSn.push(con.sn)
|
|
|
+ if (con.productBrandType === '1') {
|
|
|
+ ownBarndSn.push(con.sn)
|
|
|
+ }
|
|
|
+ if (con.productBrandType === '2') {
|
|
|
+ agentBarndSn.push(con.sn)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ // 全选
|
|
|
+ this.allBarndSnList = allBarndSn
|
|
|
+ // 自主品牌
|
|
|
+ this.ownBarndSnList = ownBarndSn
|
|
|
+ // 代理品牌
|
|
|
+ this.agentBarndSnList = agentBarndSn
|
|
|
},
|
|
|
// 保存
|
|
|
handleSave () {
|
|
|
const _this = this
|
|
|
- const checkedArr = _this.changeCheckedList()
|
|
|
- debugger
|
|
|
- const getTableList = _this.$refs.chooseTypeInfo.chooseDataList
|
|
|
- _this.form.productScopeList = getTableList
|
|
|
_this.$refs.ruleForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
const formData = JSON.parse(JSON.stringify(_this.form))
|
|
|
+ if (formData.typeVal != '4') {
|
|
|
+ const checkedArr = _this.changeCheckedList()
|
|
|
+ if (checkedArr.length == 0) {
|
|
|
+ _this.$message.warning('请选择添加品类!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const arr = []
|
|
|
+ checkedArr.forEach(item => {
|
|
|
+ const newArr = item.split('_')
|
|
|
+ arr.push({
|
|
|
+ productBrandSn: newArr[2],
|
|
|
+ productTypeSn1: newArr[4] ? newArr[4] : undefined,
|
|
|
+ productTypeSn2: newArr[6] ? newArr[6] : undefined,
|
|
|
+ productTypeSn3: newArr[8] ? newArr[8] : undefined
|
|
|
+ })
|
|
|
+ })
|
|
|
+ formData.scopeList = arr
|
|
|
+ } else {
|
|
|
+ formData.scopeList = []
|
|
|
+ }
|
|
|
formData.dealerSn = _this.$route.params.sn
|
|
|
_this.spinning = true
|
|
|
+ delete formData.typeVal
|
|
|
dealerScopeCreate(formData).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
_this.$message.success(res.message)
|
|
@@ -147,29 +200,70 @@ export default {
|
|
|
const _this = this
|
|
|
queryWaitingData({}).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
- _this.treeData = res.data
|
|
|
- _this.spinning = false
|
|
|
- } else {
|
|
|
- _this.spinning = false
|
|
|
+ if (_this.disabledList && _this.disabledList.length > 0) {
|
|
|
+ const newTreeData = _this.resetDisabledList(res.data, _this.disabledList)
|
|
|
+ _this.treeData = newTreeData
|
|
|
+ } else {
|
|
|
+ _this.treeData = res.data
|
|
|
+ }
|
|
|
+ _this.getLevel1Data()
|
|
|
}
|
|
|
+ _this.spinning = false
|
|
|
})
|
|
|
},
|
|
|
+ async getDisabledList () {
|
|
|
+ const res = await dealerScopeQueryList({ dealerSn: this.$route.params.sn })
|
|
|
+ // 重组数据
|
|
|
+ if (res.status === '200') {
|
|
|
+ const disabledList = res.data.map(item => {
|
|
|
+ return '-1_1_' + item.productBrandSn + (item.productTypeSn1 ? '_2_' + item.productTypeSn1 : '') + (item.productTypeSn2 ? '_3_' + item.productTypeSn2 : '') + (item.productTypeSn3 ? '_4_' + item.productTypeSn3 : '')
|
|
|
+ })
|
|
|
+ this.disabledList = disabledList
|
|
|
+ this.getDataList()
|
|
|
+ }
|
|
|
+ },
|
|
|
+ resetDisabledList (tree, arr) {
|
|
|
+ // 遍历树节点
|
|
|
+ function traverse (node) {
|
|
|
+ // 检查当前节点的 key 是否在 arr 中
|
|
|
+ if (arr.includes(node.sn)) {
|
|
|
+ // 如果在,则添加 disabled 属性
|
|
|
+ node.disableCheckbox = true
|
|
|
+ }
|
|
|
+
|
|
|
+ // 如果节点有子节点,则递归遍历子节点
|
|
|
+ if (node.sonList) {
|
|
|
+ node.sonList.forEach(child => traverse(child))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // 从树的根节点开始遍历
|
|
|
+ tree.forEach(node => traverse(node))
|
|
|
+
|
|
|
+ // 返回修改后的树
|
|
|
+ return tree
|
|
|
+ },
|
|
|
onCheck (checkedKeys) {
|
|
|
- console.log('onCheck', checkedKeys)
|
|
|
- this.checkedList = checkedKeys
|
|
|
+ this.checkedList = checkedKeys.checked
|
|
|
+ this.filterList[0].checked = this.checkedList.length === this.allBarndSnList.length
|
|
|
+ this.filterList[1].checked = this.checkedList.length === this.ownBarndSnList.length
|
|
|
+ this.filterList[2].checked = this.checkedList.length === this.agentBarndSnList.length
|
|
|
},
|
|
|
changeCheckedList () {
|
|
|
- const arr = this.checkedList.map(item => {
|
|
|
- const newArr = item.split('_')
|
|
|
- const obj = {
|
|
|
- productBrandSn: newArr[2],
|
|
|
- productTypeSn1: newArr[4] ? newArr[4] : undefined,
|
|
|
- productTypeSn2: newArr[6] ? newArr[6] : undefined,
|
|
|
- productTypeSn3: newArr[8] ? newArr[8] : undefined
|
|
|
+ const ret = []
|
|
|
+ this.checkedList.forEach((item, index) => {
|
|
|
+ var flag = true
|
|
|
+ this.checkedList.forEach(con => {
|
|
|
+ if (con.includes(item + '_')) {
|
|
|
+ flag = false
|
|
|
+ }
|
|
|
+ })
|
|
|
+ if (flag) {
|
|
|
+ ret.push(item)
|
|
|
}
|
|
|
- return obj
|
|
|
})
|
|
|
- return arr
|
|
|
+
|
|
|
+ return ret
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
@@ -181,17 +275,16 @@ export default {
|
|
|
isShow (newValue, oldValue) {
|
|
|
if (!newValue) {
|
|
|
this.$refs.ruleForm.resetFields()
|
|
|
+ this.filterList.map(item => item.checked = false)
|
|
|
this.$emit('close')
|
|
|
} else {
|
|
|
+ // 特约经销商 价格级别不能修改 省、市经销商时,不能选择特约价
|
|
|
if (this.$route.params.dealerLevel === 'special') {
|
|
|
this.form.priceLevel = 'SPECIAL'
|
|
|
this.notArrFlag = true
|
|
|
} else {
|
|
|
this.notArr = ['SPECIAL']
|
|
|
}
|
|
|
- this.$nextTick(() => {
|
|
|
- this.getDataList()
|
|
|
- })
|
|
|
}
|
|
|
}
|
|
|
}
|