|
@@ -10,7 +10,7 @@
|
|
|
@cancel="isShow=false"
|
|
|
:width="960">
|
|
|
<a-spin :spinning="spinning" tip="Loading...">
|
|
|
- <div>
|
|
|
+ <div style="min-height:100px;">
|
|
|
<a-form-model
|
|
|
id="dealerAccountEdit-form"
|
|
|
ref="ruleForm"
|
|
@@ -19,79 +19,96 @@
|
|
|
:label-col="formItemLayout.labelCol"
|
|
|
:wrapper-col="formItemLayout.wrapperCol"
|
|
|
>
|
|
|
- <a-form-model-item label="差价归属方" prop="cjgsf">
|
|
|
+ <!-- <a-form-model-item label="差价归属方" prop="rebateParentType">
|
|
|
<a-row :gutter="10">
|
|
|
<a-col :span="17">
|
|
|
<a-select
|
|
|
- v-model="form.cjgsf"
|
|
|
+ v-model="form.rebateParentType"
|
|
|
+ :disabled="detailData&&detailData.dealerType1 == 'special'"
|
|
|
placeholder="请选择差价归属方"
|
|
|
mode="multiple"
|
|
|
- allowClear
|
|
|
@change="cjgsgChange"
|
|
|
style="width: 100%">
|
|
|
- <a-select-option v-for="item in cjgsfList" :key="item.code" :value="item.code">{{ item.name }}</a-select-option>
|
|
|
+ <a-select-option v-for="item in cjgsfList" :key="item.code" :value="item.code">{{ item.dispName }}</a-select-option>
|
|
|
</a-select>
|
|
|
</a-col>
|
|
|
<a-col :span="6">
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
- </a-form-model-item>
|
|
|
- <a-form-model-item label="上级经销商" v-if="form.cjgsf.indexOf('0')>=0">
|
|
|
+ </a-form-model-item> -->
|
|
|
+ <a-form-model-item label="上级经销商" required>
|
|
|
<a-row :gutter="10">
|
|
|
- <a-col :span="13">
|
|
|
- <custList ref="custList" @change="custChange" placeholder="请输入经销商名称搜索"></custList>
|
|
|
+ <a-col :span="17">
|
|
|
+ <custList ref="custList" :notDealerSn="notZdDealer" :notDealerType="['special']" @change="custSupChange" placeholder="请输入经销商名称搜索"></custList>
|
|
|
</a-col>
|
|
|
- <a-col :span="5">
|
|
|
- <v-select code="DEALER_GOODS_TYPE" allowClear placeholder="请选择价格类型"></v-select>
|
|
|
+ <a-col :span="4">
|
|
|
+ <a-input-number :min="0" :max="100" v-model="parentAllotRate" @change="rateSupChange" placeholder="请输入比例"/> %
|
|
|
</a-col>
|
|
|
- <a-col :span="4" v-if="showPercent||showPercent1">
|
|
|
- <a-input-number :min="0" :max="100" placeholder="请输入比例"/> %
|
|
|
+ <a-col :span="2" v-if="zdDealearList.length==0">
|
|
|
+ <a-button
|
|
|
+ type="primary"
|
|
|
+ ghost
|
|
|
+ @click="addItem()"
|
|
|
+ >添加指定</a-button>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</a-form-model-item>
|
|
|
- <a-form-model-item label="指定经销商" v-if="form.cjgsf.indexOf('1')>=0">
|
|
|
+ <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="13">
|
|
|
- <custList ref="custList" @change="custChange" placeholder="请输入经销商名称搜索"></custList>
|
|
|
- </a-col>
|
|
|
- <a-col :span="5">
|
|
|
- <v-select code="DEALER_GOODS_TYPE" allowClear placeholder="请选择价格类型"></v-select>
|
|
|
+ <a-col :span="17">
|
|
|
+ <custList :ref="'custList'+index" :notDealerSn="notZdDealer" @change="(v)=>custChange(v,index)" placeholder="请输入经销商名称搜索"></custList>
|
|
|
</a-col>
|
|
|
- <a-col :span="4" v-if="showPercent||showPercent1">
|
|
|
- <a-input-number :min="0" :max="100" placeholder="请输入比例"/> %
|
|
|
+ <a-col :span="4">
|
|
|
+ <a-input-number :min="0" :max="100" v-model="item.allotRate" @change="(v)=>rateChange(v,index)" placeholder="请输入比例"/> %
|
|
|
</a-col>
|
|
|
<a-col :span="2">
|
|
|
- <a-button @click="addOrDel(item,index)" size="small" shape="circle" :icon="index==zdDealearList.length-1?'plus':'minus'" style="margin-left: 10px;" />
|
|
|
+ <a-button
|
|
|
+ style="margin-right:5px;"
|
|
|
+ v-if="index==zdDealearList.length-1 && zdDealearList.length<3"
|
|
|
+ @click="addItem(item,index)"
|
|
|
+ title="添加"
|
|
|
+ size="small"
|
|
|
+ shape="circle"
|
|
|
+ icon="plus" />
|
|
|
+ <a-button
|
|
|
+ @click="delItem(item,index)"
|
|
|
+ type="primary"
|
|
|
+ title="删除"
|
|
|
+ size="small"
|
|
|
+ shape="circle"
|
|
|
+ ghost
|
|
|
+ icon="minus"/>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</a-form-model-item>
|
|
|
- <a-form-model-item label="箭冠总公司" v-if="form.cjgsf.indexOf('2')>=0">
|
|
|
+ <a-form-model-item label="箭冠总公司">
|
|
|
<a-row :gutter="10">
|
|
|
- <a-col :span="13">
|
|
|
+ <a-col :span="17">
|
|
|
<a-input value="箭冠总公司" disabled />
|
|
|
</a-col>
|
|
|
- <a-col :span="5">
|
|
|
- <v-select code="DEALER_GOODS_TYPE" allowClear placeholder="请选择价格类型"></v-select>
|
|
|
- </a-col>
|
|
|
- <a-col :span="4" v-if="showPercent">
|
|
|
- <a-input-number :min="0" :max="100" placeholder="请输入比例"/> %
|
|
|
+ <a-col :span="4">
|
|
|
+ <a-input-number :min="0" :max="100" v-model="hAllotRate" @change="rateHChange" placeholder="请输入比例"/> %
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
</a-form-model-item>
|
|
|
</a-form-model>
|
|
|
</div>
|
|
|
- <div style="padding:10px 10px 10px 90px;">
|
|
|
- <div style="padding-bottom:10px;">选择品类:</div>
|
|
|
- <!-- 品类表格 -->
|
|
|
- <categoryList ref="categoryList"></categoryList>
|
|
|
+ <div style="padding:10px 10px 10px 40px;">
|
|
|
+ <div style="padding-bottom:10px;">
|
|
|
+ <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>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
<div class="btn-cont">
|
|
|
<a-button size="large" @click="isShow = false" style="font-size: 12px;">取消</a-button>
|
|
|
<a-button
|
|
|
size="large"
|
|
|
type="primary"
|
|
|
- class="button-primary"
|
|
|
- style="margin-left: 50px;"
|
|
|
+ style="margin-left: 30px;"
|
|
|
@click="handleSave"
|
|
|
>确定</a-button>
|
|
|
</div>
|
|
@@ -102,11 +119,12 @@
|
|
|
<script>
|
|
|
import custList from '@/views/common/custList.vue'
|
|
|
import { VSelect } from '@/components'
|
|
|
-import categoryList from './categoryList.vue'
|
|
|
+import { dealerUpsCreate } from '@/api/dealer'
|
|
|
+import { cloneObj } from '@/libs/tools'
|
|
|
|
|
|
export default {
|
|
|
name: 'PriceDiffModal',
|
|
|
- components: { VSelect, custList, categoryList },
|
|
|
+ components: { VSelect, custList },
|
|
|
props: {
|
|
|
openModal: { // 弹框显示状态
|
|
|
type: Boolean,
|
|
@@ -119,83 +137,213 @@ export default {
|
|
|
isShow: this.openModal, // 是否打开弹框
|
|
|
title: '差价设置',
|
|
|
formItemLayout: {
|
|
|
- labelCol: { span: 4 },
|
|
|
- wrapperCol: { span: 18 }
|
|
|
+ labelCol: { span: 3 },
|
|
|
+ wrapperCol: { span: 20 }
|
|
|
},
|
|
|
form: {
|
|
|
dealerSn: undefined,
|
|
|
- cjgsf: []
|
|
|
+ rebateParentType: [], // 差价归属
|
|
|
+ rebateDealerList: [], // 经销商列表
|
|
|
+ rebateScopeList: [] // 品类列表
|
|
|
},
|
|
|
+ parentAllotRate: '', // 上级经销商分配比例
|
|
|
+ hAllotRate: '', // 总部分配比例
|
|
|
rules: {
|
|
|
- cjgsf: [{ required: true, message: '请选择差价归属方', trigger: 'change' }]
|
|
|
+ rebateParentType: [{ required: true, message: '请选择差价归属方', trigger: 'change' }]
|
|
|
},
|
|
|
- cjgsfList: [
|
|
|
- { code: '0', name: '上级经销商' },
|
|
|
- { code: '1', name: '指定经销商' },
|
|
|
- { code: '2', name: '箭冠总公司' }
|
|
|
- ],
|
|
|
- zdDealearList: []
|
|
|
+ cjgsfList: [],
|
|
|
+ zdDealearList: [],
|
|
|
+ detailData: null
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
showPercent () {
|
|
|
- return this.form.cjgsf.length > 1
|
|
|
+ return this.form.rebateParentType.length > 1
|
|
|
},
|
|
|
showPercent1 () {
|
|
|
return this.zdDealearList.length > 1
|
|
|
+ },
|
|
|
+ notZdDealer () {
|
|
|
+ return this.form.rebateDealerList.concat(this.zdDealearList).concat([{ 'parentDealerSn': this.form.dealerSn }])
|
|
|
+ },
|
|
|
+ showTable () {
|
|
|
+ return this.form.rebateParentType.indexOf('SUPERIORS') >= 0
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- // 关联经销商变更
|
|
|
- custChange (val) {
|
|
|
- this.form.dealerSn = val.key
|
|
|
+ setData (list, dealerSn, detail) {
|
|
|
+ this.detailData = detail
|
|
|
+ this.form.dealerSn = dealerSn
|
|
|
+ this.cjgsfList = list
|
|
|
+ // 如果当前经销商是特约经销商
|
|
|
+ if (this.detailData.dealerType1 == 'special') {
|
|
|
+ // 默认只有上级经销商
|
|
|
+ this.form.rebateParentType = ['SUPERIORS']
|
|
|
+ this.cjgsgChange(['SUPERIORS'])
|
|
|
+ } else {
|
|
|
+ this.cjgsgChange(['SUPERIORS', 'HEAD'])
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 上级经销商修改
|
|
|
+ custSupChange (val) {
|
|
|
+ this.form.rebateDealerList[0]['parentDealerSn'] = val.key
|
|
|
+ this.getCategoryList()
|
|
|
+ },
|
|
|
+ rateSupChange (val) {
|
|
|
+ this.form.rebateDealerList[0]['allotRate'] = val
|
|
|
+ },
|
|
|
+ // 刷新品类列表
|
|
|
+ getCategoryList () {
|
|
|
+ const a = this.form.rebateDealerList[0]['parentDealerSn']
|
|
|
+ if (a) {
|
|
|
+ // 查询品类树
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rateHChange (val) {
|
|
|
+ this.form.rebateDealerList[1]['allotRate'] = val
|
|
|
+ },
|
|
|
+ // 指定经销商变更
|
|
|
+ custChange (val, index) {
|
|
|
+ console.log(val, index)
|
|
|
+ this.zdDealearList[index]['parentDealerSn'] = val.key
|
|
|
+ },
|
|
|
+ rateChange (val, index) {
|
|
|
+ console.log(val, index)
|
|
|
+ this.zdDealearList[index]['allotRate'] = val
|
|
|
},
|
|
|
// 差价归属变更
|
|
|
cjgsgChange (val) {
|
|
|
- if (val.indexOf('1') >= 0) {
|
|
|
+ console.log(val)
|
|
|
+ this.form.rebateParentType = val
|
|
|
+ // 指定经销商
|
|
|
+ if (val.indexOf('ASSIGN') >= 0) {
|
|
|
if (this.zdDealearList.length == 0) {
|
|
|
- this.zdDealearList.push({ id: new Date().getTime(), dealerSn: '', percent: '' })
|
|
|
+ this.addItem()
|
|
|
}
|
|
|
} else {
|
|
|
this.zdDealearList = []
|
|
|
}
|
|
|
- },
|
|
|
- // 增加或删除指定经销商
|
|
|
- addOrDel (row, index) {
|
|
|
- // 加
|
|
|
- if ((this.zdDealearList.length - 1) == index) {
|
|
|
- this.zdDealearList.push({ id: new Date().getTime(), dealerSn: '', percent: '' })
|
|
|
+ // 上级经销商
|
|
|
+ if (val.indexOf('SUPERIORS') >= 0) {
|
|
|
+ if (!this.form.rebateDealerList[0]) {
|
|
|
+ this.form.rebateDealerList[0] = {
|
|
|
+ 'id': new Date().getTime(),
|
|
|
+ 'dealerSn': this.form.dealerSn,
|
|
|
+ 'parentDealerSn': undefined,
|
|
|
+ 'rebateParentType': 'SUPERIORS',
|
|
|
+ 'allotRate': 100
|
|
|
+ }
|
|
|
+ this.parentAllotRate = 100
|
|
|
+ }
|
|
|
} else {
|
|
|
- const i = this.zdDealearList.findIndex(item => item.id == row.id)
|
|
|
- if (i >= 0) {
|
|
|
- this.zdDealearList.splice(i, 1)
|
|
|
+ this.form.rebateDealerList[0] = null
|
|
|
+ this.parentAllotRate = ''
|
|
|
+ }
|
|
|
+ // 总部经销商
|
|
|
+ if (val.indexOf('HEAD') >= 0) {
|
|
|
+ if (!this.form.rebateDealerList[1]) {
|
|
|
+ this.form.rebateDealerList[1] = {
|
|
|
+ 'id': new Date().getTime() - 100,
|
|
|
+ 'dealerSn': this.form.dealerSn,
|
|
|
+ 'parentDealerSn': 1,
|
|
|
+ 'rebateParentType': 'HEAD',
|
|
|
+ 'allotRate': 0
|
|
|
+ }
|
|
|
+ this.hAllotRate = 0
|
|
|
}
|
|
|
+ } else {
|
|
|
+ this.form.rebateDealerList[1] = null
|
|
|
+ this.hAllotRate = ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 增加指定经销商
|
|
|
+ addItem (row, index) {
|
|
|
+ const sn = new Date().getTime()
|
|
|
+ this.zdDealearList.push({
|
|
|
+ 'id': sn,
|
|
|
+ 'dealerSn': this.form.dealerSn,
|
|
|
+ 'parentDealerSn': undefined,
|
|
|
+ 'rebateParentType': 'ASSIGN',
|
|
|
+ 'allotRate': ''
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 删除指定经销商
|
|
|
+ delItem (row, index) {
|
|
|
+ const i = this.zdDealearList.findIndex(item => item.id == row.id)
|
|
|
+ if (i >= 0) {
|
|
|
+ this.zdDealearList.splice(i, 1)
|
|
|
}
|
|
|
},
|
|
|
// 重置表单
|
|
|
resetForm () {
|
|
|
this.form.dealerSn = undefined
|
|
|
- this.form.cjgsf = []
|
|
|
+ this.form.rebateParentType = []
|
|
|
+ this.form.rebateDealerList = []
|
|
|
+ this.form.rebateScopeList = []
|
|
|
this.zdDealearList = []
|
|
|
- if (this.showPercent1) {
|
|
|
- this.$refs.custList.resetForm()
|
|
|
+ this.hAllotRate = ''
|
|
|
+ this.parentAllotRate = 100
|
|
|
+ this.$refs.custList.resetForm()
|
|
|
+ },
|
|
|
+ // 校验数据
|
|
|
+ validateFormData (data) {
|
|
|
+ let row
|
|
|
+ let msg = ''
|
|
|
+ for (let i = 0; i < data.length; i++) {
|
|
|
+ row = data[i]
|
|
|
+ if (row) {
|
|
|
+ const rebateParentType = this.cjgsfList.find(item => item.code == row.rebateParentType)
|
|
|
+ const type = rebateParentType ? rebateParentType.dispName : ''
|
|
|
+ if (!row.parentDealerSn) {
|
|
|
+ msg = '请选择' + type
|
|
|
+ break
|
|
|
+ }
|
|
|
+ if (!row.allotRate && row.rebateParentType != 'HEAD') {
|
|
|
+ msg = '请输入' + type + '的分配比例'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return msg
|
|
|
},
|
|
|
// 保存
|
|
|
handleSave () {
|
|
|
const _this = this
|
|
|
_this.$refs.ruleForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
- const formData = _this.form
|
|
|
- _this.spinning = true
|
|
|
- dealerUserSave(formData).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- _this.$message.success(res.message)
|
|
|
- _this.$emit('ok')
|
|
|
- _this.isShow = false
|
|
|
+ const formData = JSON.parse(JSON.stringify(_this.form))
|
|
|
+ formData.rebateDealerList = formData.rebateDealerList.concat(JSON.parse(JSON.stringify(this.zdDealearList)))
|
|
|
+ console.log(formData)
|
|
|
+ // 校验数据
|
|
|
+ const errorMsg = this.validateFormData(formData.rebateDealerList)
|
|
|
+ console.log(errorMsg)
|
|
|
+ if (errorMsg) {
|
|
|
+ _this.$message.error(errorMsg)
|
|
|
+ } else {
|
|
|
+ // 处理数据并校验比例之和是否100
|
|
|
+ let pa = 0
|
|
|
+ formData.rebateDealerList = formData.rebateDealerList.filter(item => item)
|
|
|
+ formData.rebateDealerList.map(item => {
|
|
|
+ item.allotRate = item.allotRate ? (item.allotRate / 100) : 0
|
|
|
+ pa += item.allotRate
|
|
|
+ })
|
|
|
+ console.log(formData)
|
|
|
+ console.log(pa)
|
|
|
+ if (pa != 1) {
|
|
|
+ _this.$message.error('差价比例之和必须是100%')
|
|
|
+ return
|
|
|
}
|
|
|
- _this.spinning = false
|
|
|
- })
|
|
|
+
|
|
|
+ _this.spinning = true
|
|
|
+ dealerUpsCreate(formData).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.$emit('ok')
|
|
|
+ _this.isShow = false
|
|
|
+ }
|
|
|
+ _this.spinning = false
|
|
|
+ })
|
|
|
+ }
|
|
|
} else {
|
|
|
return false
|
|
|
}
|
|
@@ -227,7 +375,7 @@ export default {
|
|
|
text-align: center;
|
|
|
margin: 15px 0 10px;
|
|
|
button{
|
|
|
- width: 120px;
|
|
|
+ width: 80px;
|
|
|
}
|
|
|
}
|
|
|
}
|