|
@@ -19,23 +19,25 @@
|
|
|
>
|
|
|
<a-row :gutter="15">
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="客户名称" prop="customerName">
|
|
|
+ <a-form-model-item label="客户名称" prop="buyerSn">
|
|
|
<a-auto-complete
|
|
|
- id="chooseCustom-customerName"
|
|
|
+ id="chooseCustom-buyerSn"
|
|
|
placeholder="请选择客户"
|
|
|
allowClear
|
|
|
- v-model="form.customerName"
|
|
|
+ v-model="form.buyerSn"
|
|
|
:filter-option="filterOption"
|
|
|
@select="custSelect"
|
|
|
@change="custChange">
|
|
|
<template slot="dataSource">
|
|
|
- <a-select-option v-for="item in custAllList" :key="item.id" :title="item.id">{{ item.customerName }}</a-select-option>
|
|
|
+ <a-select-option v-for="item in custAllList" :key="item.customerSn" :title="item.id">{{ item.customerName }}</a-select-option>
|
|
|
</template>
|
|
|
</a-auto-complete>
|
|
|
- </a-form-model-item>
|
|
|
+ </a-button></a-form-model-item>
|
|
|
</a-col>
|
|
|
- <a-col :span="8">
|
|
|
- <a-form-model-item>(未搜索到客户时为新增客户)</a-form-model-item>
|
|
|
+ <a-col :span="16">
|
|
|
+ <a-form-model-item><a-button type="dashed" icon="plus">
|
|
|
+ 新增
|
|
|
+ </a-button>(未搜索到客户时点击新增按钮)</a-form-model-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
|
<a-row :gutter="15">
|
|
@@ -68,11 +70,11 @@
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="详细地址" prop="customerAddr">
|
|
|
+ <a-form-model-item label="" prop="shippingAddress">
|
|
|
<a-input
|
|
|
- id="chooseCustom-customerAddr"
|
|
|
+ id="chooseCustom-shippingAddress"
|
|
|
:maxLength="60"
|
|
|
- v-model="form.customerAddr"
|
|
|
+ v-model="form.shippingAddress"
|
|
|
placeholder="请输入详细地址(最多60个字符)"
|
|
|
allowClear />
|
|
|
</a-form-model-item>
|
|
@@ -80,21 +82,21 @@
|
|
|
</a-row>
|
|
|
<a-row :gutter="15">
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="联系人" prop="contactName">
|
|
|
+ <a-form-model-item label="联系人" prop="consigneeName">
|
|
|
<a-input
|
|
|
- id="chooseCustom-contactName"
|
|
|
+ id="chooseCustom-consigneeName"
|
|
|
:maxLength="30"
|
|
|
- v-model="form.contactName"
|
|
|
+ v-model="form.consigneeName"
|
|
|
placeholder="请输入联系人(最多30个字符)"
|
|
|
allowClear />
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="联系电话" prop="contactTel">
|
|
|
+ <a-form-model-item label="联系电话" prop="consigneeTel">
|
|
|
<a-input
|
|
|
- id="chooseCustom-contactTel"
|
|
|
+ id="chooseCustom-consigneeTel"
|
|
|
:maxLength="30"
|
|
|
- v-model="form.contactTel"
|
|
|
+ v-model="form.consigneeTel"
|
|
|
placeholder="请输入联系电话(最多30个字符)"
|
|
|
allowClear />
|
|
|
</a-form-model-item>
|
|
@@ -122,33 +124,33 @@
|
|
|
</a-row>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
- <a-col :span="8">
|
|
|
+ <!-- <a-col :span="8">
|
|
|
<a-form-model-item label="支付方式" prop="payType">
|
|
|
<v-select code="PAY_TYPE" id="chooseCustom-payType" v-model="form.payType" allowClear placeholder="请选择支付方式" />
|
|
|
</a-form-model-item>
|
|
|
- </a-col>
|
|
|
+ </a-col> -->
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="收款方式" prop="payment">
|
|
|
- <v-select code="SETTLE_STYLE_NAME" id="chooseCustom-payment" v-model="form.settleStyleSn" allowClear placeholder="请选择收款方式"></v-select>
|
|
|
+ <a-form-model-item label="收款方式" prop="settleStyle">
|
|
|
+ <v-select code="SETTLE_STYLE_NAME" id="chooseCustom-settleStyle" v-model="form.settleStyle" allowClear placeholder="请选择收款方式"></v-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
- </a-row>
|
|
|
- <a-row :gutter="15">
|
|
|
<a-col :span="8">
|
|
|
<a-form-model-item label="配送方式" prop="dispatchType">
|
|
|
<v-select code="DISPATCH_TYPE" id="chooseCustom-dispatchType" v-model="form.dispatchType" allowClear placeholder="请选择配送方式"></v-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
+ </a-row>
|
|
|
+ <a-row :gutter="15">
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="业务员" prop="tenantId">
|
|
|
- <a-select id="chooseCustom-tenantId" v-model="form.tenantId" placeholder="请选择业务员">
|
|
|
- <a-select-option v-for="item in tenantList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
|
|
|
+ <a-form-model-item label="业务员" prop="salesManSn">
|
|
|
+ <a-select id="chooseCustom-salesManSn" @change="salesManChange" v-model="form.salesManSn" placeholder="请选择业务员">
|
|
|
+ <a-select-option v-for="item in userList" :value="item.id" :key="item.id + 'c'">{{ item.name }}</a-select-option>
|
|
|
</a-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
<a-col :span="8">
|
|
|
- <a-form-model-item label="铺货出库" prop="salesman">
|
|
|
- <v-select code="FLAG" id="chooseCustom-salesman" v-model="form.salesman" allowClear placeholder="请选择"></v-select>
|
|
|
+ <a-form-model-item label="铺货出库" prop="distributionFalg">
|
|
|
+ <v-select code="FLAG" id="chooseCustom-distributionFalg" v-model="form.distributionFalg" allowClear placeholder="请选择"></v-select>
|
|
|
</a-form-model-item>
|
|
|
</a-col>
|
|
|
</a-row>
|
|
@@ -178,7 +180,9 @@
|
|
|
|
|
|
<script>
|
|
|
import { getArea } from '@/api/data'
|
|
|
-import { custAllList, custFindById } from '@/api/customer'
|
|
|
+import { custAllList, custFindById, custSave } from '@/api/customer'
|
|
|
+import { salesInsert } from '@/api/sales'
|
|
|
+import { getUserAllList } from '@/api/power-user'
|
|
|
import { VSelect } from '@/components'
|
|
|
export default {
|
|
|
name: 'ChooseCustomModal',
|
|
@@ -195,31 +199,36 @@ export default {
|
|
|
wrapperCol: { span: 16 }
|
|
|
},
|
|
|
form: {
|
|
|
- customerName: '', // 客户名称
|
|
|
- contactTel: '', // 联系电话
|
|
|
- contactName: '', // 联系人
|
|
|
+ buyerName: '', // 客户名称
|
|
|
+ buyerSn: '', // 客户sn
|
|
|
+ consigneeTel: '', // 联系电话
|
|
|
+ consigneeName: '', // 联系人
|
|
|
provinceSn: undefined, // 省
|
|
|
- provinceName: '',
|
|
|
+ shippingAddressProvinceName: '',
|
|
|
citySn: undefined, // 市
|
|
|
- cityName: '',
|
|
|
+ shippingAddressCityName: '',
|
|
|
countySn: undefined, // 区
|
|
|
- countyName: '',
|
|
|
- customerAddr: '', // 详细地址
|
|
|
+ shippingAddressCountyName: '',
|
|
|
+ shippingAddress: '', // 详细地址
|
|
|
fax: '', // 客户传真
|
|
|
dispatchType: '', // 配送方式
|
|
|
satelliteFlag: 0, // 是否卫星仓客户
|
|
|
customerTypeSn: undefined, // 客户类型
|
|
|
priceType: '', // 价格类型
|
|
|
- payType: '', // 支付方式
|
|
|
- settleStyleSn: '', // 收款方式
|
|
|
- tenantId: undefined, // 业务员
|
|
|
+ // payType: '', // 支付方式
|
|
|
+ settleStyle: '', // 收款方式
|
|
|
+ salesManSn: undefined, // 业务员
|
|
|
+ salesManName: '',
|
|
|
+ distributionFalg: '0', // 铺货出库
|
|
|
+ salesTragetType: 'C',
|
|
|
remarks: '' // 备注
|
|
|
},
|
|
|
+ custInfo: {}, // 客户信息
|
|
|
rules: {
|
|
|
- customerName: [
|
|
|
+ buyerSn: [
|
|
|
{ required: true, message: '请输入客户名称', trigger: ['change', 'blur'] }
|
|
|
],
|
|
|
- contactTel: [
|
|
|
+ consigneeTel: [
|
|
|
{ required: true, message: '请输入联系电话', trigger: 'blur' }
|
|
|
],
|
|
|
provinceSn: [
|
|
@@ -231,70 +240,139 @@ export default {
|
|
|
countySn: [
|
|
|
{ required: true, message: '请选择区/县', trigger: 'change' }
|
|
|
],
|
|
|
- contactPhone: [
|
|
|
- { required: true, message: '请输入联系电话', trigger: 'blur' }
|
|
|
+ shippingAddress: [
|
|
|
+ { required: true, message: '请输入详细地址', trigger: 'blur' }
|
|
|
],
|
|
|
priceType: [
|
|
|
{ required: true, message: '请选择价格类型', trigger: 'change' }
|
|
|
],
|
|
|
- payType: [
|
|
|
- { required: true, message: '请选择支付方式', trigger: 'change' }
|
|
|
- ],
|
|
|
- settleStyleSn: [
|
|
|
+ // payType: [
|
|
|
+ // { required: true, message: '请选择支付方式', trigger: 'change' }
|
|
|
+ // ],
|
|
|
+ settleStyle: [
|
|
|
{ required: true, message: '请选择收款方式', trigger: 'change' }
|
|
|
+ ],
|
|
|
+ distributionFalg: [
|
|
|
+ { required: true, message: '请选择是否铺货出库', trigger: 'change' }
|
|
|
]
|
|
|
+ // salesManSn: [
|
|
|
+ // { required: true, message: '请选择业务员', trigger: 'change' }
|
|
|
+ // ]
|
|
|
},
|
|
|
custAllList: [], // 客户 下拉数据
|
|
|
addrProvinceList: [], // 省下拉
|
|
|
addrCityList: [], // 市下拉
|
|
|
addrDistrictList: [], // 区下拉
|
|
|
- tenantList: [], // 业务员 下拉
|
|
|
+ userList: [], // 业务员 下拉
|
|
|
custId: undefined, // 客户id
|
|
|
isEdit: true // 是否可编辑
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ // 业务员
|
|
|
+ salesManChange (id) {
|
|
|
+ this.form.salesManName = this.userList.find(item => item.id == id).name
|
|
|
+ },
|
|
|
// 客户 select
|
|
|
- custSelect (id) {
|
|
|
- this.custId = id
|
|
|
+ custSelect (v) {
|
|
|
+ const cust = this.custAllList.find(item => item.customerSn == v)
|
|
|
+ this.custId = cust.id
|
|
|
+ this.form.buyerName = cust.customerName
|
|
|
this.isEdit = false
|
|
|
this.getDetail()
|
|
|
},
|
|
|
// 客户 change
|
|
|
custChange (val) {
|
|
|
+ if (val == undefined || val == '') {
|
|
|
+ this.$refs.ruleForm.resetFields()
|
|
|
+ }
|
|
|
this.custId = undefined
|
|
|
this.isEdit = true
|
|
|
},
|
|
|
+ // 编辑客户信息
|
|
|
+ editCust (data) {
|
|
|
+ console.log(data)
|
|
|
+ if (data.provinceSn) { this.getArea('city', data.provinceSn) }
|
|
|
+ if (data.citySn) { this.getArea('district', data.citySn) }
|
|
|
+ this.form = data
|
|
|
+ },
|
|
|
// 获取详情
|
|
|
getDetail () {
|
|
|
custFindById({ id: this.custId }).then(res => {
|
|
|
- if (res.status == 200) {
|
|
|
- if (res.data.provinceSn) { this.getArea('city', res.data.provinceSn) }
|
|
|
- if (res.data.citySn) { this.getArea('district', res.data.citySn) }
|
|
|
- this.form = Object.assign(this.form, res.data)
|
|
|
+ const data = res.data
|
|
|
+ if (res.status == 200 && data) {
|
|
|
+ if (data.provinceSn) { this.getArea('city', data.provinceSn) }
|
|
|
+ if (data.citySn) { this.getArea('district', data.citySn) }
|
|
|
+ this.form = Object.assign(this.form, {
|
|
|
+ buyerName: data.customerName, // 客户名称
|
|
|
+ buyerSn: data.customerSn, // 客户sn
|
|
|
+ consigneeTel: data.contactTel, // 联系电话
|
|
|
+ consigneeName: data.contactName, // 联系人
|
|
|
+ provinceSn: data.provinceSn, // 省
|
|
|
+ shippingAddressProvinceName: data.provinceName,
|
|
|
+ citySn: data.citySn, // 市
|
|
|
+ shippingAddressCityName: data.cityName,
|
|
|
+ countySn: data.countySn, // 区
|
|
|
+ shippingAddressCountyName: data.countyName,
|
|
|
+ shippingAddress: data.customerAddr, // 详细地址
|
|
|
+ fax: data.fax, // 客户传真
|
|
|
+ dispatchType: data.dispatchType, // 配送方式
|
|
|
+ satelliteFlag: data.satelliteFlag, // 是否卫星仓客户
|
|
|
+ customerTypeSn: data.customerTypeSn, // 客户类型
|
|
|
+ priceType: data.priceType, // 价格类型
|
|
|
+ settleStyle: data.settleStyleSn // 收款方式
|
|
|
+ })
|
|
|
+ // 临时存储客户信息
|
|
|
+ this.custInfo = data
|
|
|
} else {
|
|
|
+ this.$message.error('获取客户信息失败')
|
|
|
this.$refs.ruleForm.resetFields()
|
|
|
}
|
|
|
+ this.$refs.ruleForm.clearValidate()
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 保存客户信息
|
|
|
+ handleSaveCust () {
|
|
|
+ custSave({
|
|
|
+ id: this.custInfo.id,
|
|
|
+ customerName: this.form.buyerName,
|
|
|
+ contactTel: this.form.consigneeTel, // 联系电话
|
|
|
+ contactName: this.form.consigneeName, // 联系人
|
|
|
+ provinceSn: this.form.provinceSn, // 省
|
|
|
+ provinceName: this.form.shippingAddressProvinceName,
|
|
|
+ citySn: this.form.citySn, // 市
|
|
|
+ cityName: this.form.shippingAddressCityName,
|
|
|
+ countySn: this.form.countySn, // 区
|
|
|
+ countyName: this.form.shippingAddressCountyName,
|
|
|
+ customerAddr: this.form.shippingAddress, // 详细地址
|
|
|
+ dispatchType: this.form.dispatchType, // 配送方式
|
|
|
+ customerTypeSn: this.form.customerTypeSn, // 客户类型
|
|
|
+ priceType: this.form.priceType, // 价格类型
|
|
|
+ settleStyleSn: this.form.settleStyle // 收款方式
|
|
|
+ }).then(res => {
|
|
|
+ if (res.status != 200) {
|
|
|
+ this.$message.error(res.message)
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
// 保存
|
|
|
handleSubmit (e) {
|
|
|
e.preventDefault()
|
|
|
const _this = this
|
|
|
- this.$emit('ok', { id: 1000, customName: '车领主常青二路店' })
|
|
|
- this.cancel()
|
|
|
this.$refs.ruleForm.validate(valid => {
|
|
|
if (valid) {
|
|
|
- console.log('-------------提交信息', _this.form)
|
|
|
- // const form = values.form
|
|
|
- // form.desc = _this.form.desc
|
|
|
- // form.id = this.isEdit ? this.$route.params.id : null
|
|
|
- // console.log(form,'-----提交信息')
|
|
|
- // // goodsSave(form).then(res => {
|
|
|
- // // if (res.status == 200) {
|
|
|
- // // _this.$message.success(res.message)
|
|
|
- // // }
|
|
|
- // // })
|
|
|
+ // 保存客户信息
|
|
|
+ _this.handleSaveCust()
|
|
|
+ // 新建销售单
|
|
|
+ const form = this.form
|
|
|
+ console.log(form, 'save data')
|
|
|
+ salesInsert(form).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$message.success(res.message)
|
|
|
+ _this.$emit('ok', res.data)
|
|
|
+ _this.cancel()
|
|
|
+ }
|
|
|
+ })
|
|
|
} else {
|
|
|
console.log('error submit!!')
|
|
|
return false
|
|
@@ -317,25 +395,42 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
+ // 获取业务员列表数据
|
|
|
+ getUserAllList () {
|
|
|
+ getUserAllList({}).then(res => {
|
|
|
+ if (res.status == 200) {
|
|
|
+ this.userList = res.data || []
|
|
|
+ } else {
|
|
|
+ this.userList = []
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
// 获取城市列表
|
|
|
getCityList (val) {
|
|
|
+ console.log(val, '-------------')
|
|
|
this.addrCityList = []
|
|
|
this.addrDistrictList = []
|
|
|
this.form.citySn = undefined
|
|
|
+ this.form.shippingAddressCityName = ''
|
|
|
this.form.countySn = undefined
|
|
|
- this.form.customerAddr = ''
|
|
|
+ this.form.shippingAddressCountyName = ''
|
|
|
+ this.form.shippingAddress = ''
|
|
|
+ this.form.shippingAddressCountyName = this.addrProvinceList.find(item => item.id == val).name
|
|
|
this.getArea('city', val)
|
|
|
},
|
|
|
// 获取区县列表
|
|
|
getAreaList (val) {
|
|
|
this.addrDistrictList = []
|
|
|
this.form.countySn = undefined
|
|
|
- this.form.customerAddr = ''
|
|
|
+ this.form.shippingAddressCountyName = ''
|
|
|
+ this.form.shippingAddress = ''
|
|
|
+ this.form.shippingAddressCityName = this.addrCityList.find(item => item.id == val).name
|
|
|
this.getArea('district', val)
|
|
|
},
|
|
|
// 区县变更
|
|
|
areaCharged (val) {
|
|
|
- this.form.customerAddr = ''
|
|
|
+ this.form.shippingAddress = ''
|
|
|
+ this.form.shippingAddressCountyName = this.addrDistrictList.find(item => item.id == val).name
|
|
|
},
|
|
|
// 省/市/区
|
|
|
getArea (type, sn) {
|
|
@@ -377,6 +472,7 @@ export default {
|
|
|
if (newValue) {
|
|
|
this.getArea('province')
|
|
|
this.getCustAllList()
|
|
|
+ this.getUserAllList()
|
|
|
}
|
|
|
}
|
|
|
}
|