|
@@ -23,7 +23,6 @@
|
|
|
</u-form-item>
|
|
|
<u-form-item label="价格类型" required >
|
|
|
<v-select ref="priceType" :disabled="true" placeholder="请选择价格类型" @itemChange="chooseType" code="PRICE_TYPE" style="width: 100%"></v-select>
|
|
|
- <u-icon name="arrow-right" color="#C0C4CC" slot="right"></u-icon>
|
|
|
</u-form-item>
|
|
|
<u-form-item label="收款方式" required prop="settleStyleSn">
|
|
|
<u-input v-model="settleStyleName" input-align="right" :disabled="true" placeholder="请选择收款方式" @click="showSettle=true"/>
|
|
@@ -43,7 +42,6 @@
|
|
|
</u-form-item>
|
|
|
<u-form-item label="配送方式" >
|
|
|
<v-select ref="dispatchType" :disabled="true" placeholder="请选择配送方式" @itemChange="choosedispatchType" code="DISPATCH_TYPE" style="width: 100%"></v-select>
|
|
|
- <u-icon name="arrow-right" color="#C0C4CC" slot="right" @click="chooseType(0)"></u-icon>
|
|
|
</u-form-item>
|
|
|
<u-form-item label="业务员">
|
|
|
<u-input v-model="userName" input-align="right" :disabled="true" placeholder="请选择业务员" @click="showUser=true"/>
|
|
@@ -55,8 +53,7 @@
|
|
|
</u-form>
|
|
|
</view>
|
|
|
<view class="form-footer-btn">
|
|
|
- <u-button v-if="!itemId" class="handle-btn" size="medium" shape="circle" hover-class="none" @click="customerSubmit" :custom-style="customBtnStyle">保存</u-button>
|
|
|
- <u-button v-else class="handle-btn" size="medium" shape="circle" hover-class="none" @click="salesSbmit" :custom-style="customBtnStyle">新增销售单</u-button>
|
|
|
+ <u-button class="handle-btn" size="medium" shape="circle" hover-class="none" @click="handleSaveCust" :custom-style="customBtnStyle">保存</u-button>
|
|
|
</view>
|
|
|
<!-- 省市区 -->
|
|
|
<Address ref="applyAddress" @onConfirm="areaConfirm"></Address>
|
|
@@ -70,9 +67,8 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import {customerDetail,settleStyleQueryAll,custType,custSave,employeeAllList,salesSave} from '@/api/sales.js'
|
|
|
- import { getLookUpDatas } from '@/api/data'
|
|
|
- import { getArea } from '@/api/data'
|
|
|
+ import {settleStyleQueryAll,salesSave} from '@/api/sales.js'
|
|
|
+ import {customerDetail,custType,employeeAllList,updateByCustomerSn} from '@/api/customer.js'
|
|
|
import Address from '@/components/address.vue'
|
|
|
import vSelect from '@/components/select/v-select.vue'
|
|
|
export default{
|
|
@@ -86,8 +82,6 @@
|
|
|
margin:0
|
|
|
},
|
|
|
showDispatch:false,// 配送方式下拉弹窗初始值
|
|
|
- dispatchTypeList:[], // 配送方式列表
|
|
|
- dispatchTypeName:'', // 配送方式名称
|
|
|
showSettle:false,//结算方式初始值
|
|
|
settleTypeList:[],//收款方式列表
|
|
|
settleStyleName:'',//收款方式名称
|
|
@@ -141,80 +135,50 @@
|
|
|
this.$refs.uForm.setRules(this.rules);
|
|
|
},
|
|
|
onLoad(option) {
|
|
|
- // uni.$on('setFun',this.setFun)
|
|
|
console.log(option.nowId,'option')
|
|
|
- // this.form = this.$store.state.vuex_OrderAddress
|
|
|
- // this.areaIdArr = this.form.receiveAreas.split(',')
|
|
|
- // this.areaInfo.label = this.form.receiveAreasName.replace(/\,/g,'-')
|
|
|
if(option.nowId){
|
|
|
+ if(option.pageType=='edit'){
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title:'编辑销售单'
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
+ title:'新增销售单'
|
|
|
+ })
|
|
|
+ }
|
|
|
this.itemId=option.nowId
|
|
|
this.getCustomerData(this.itemId)
|
|
|
this.getUserAllList()
|
|
|
setTimeout(()=>{
|
|
|
+ // 回显收款方式并下拉数据默认高亮选中
|
|
|
const ind=this.settleTypeList.findIndex((item)=>{
|
|
|
return item.settleStyleSn==this.customerData.settleStyleSn
|
|
|
})
|
|
|
console.log(ind,'ind')
|
|
|
this.settleStyleName=this.settleTypeList[ind].name
|
|
|
this.defaultSettleIndex=[ind]
|
|
|
- // if(this.customerData.customerSn){
|
|
|
- // const settleInd=this.custTypeList.findIndex((item)=>{
|
|
|
- // return item.customerSn==this.customerData.customerSn
|
|
|
- // })
|
|
|
- // this.custTypeName=this.custTypeList[settleInd].name
|
|
|
- // this.defaultCustIndex=[settleInd]
|
|
|
- // }
|
|
|
+ // 回显业务员并下拉数据默认高亮选中
|
|
|
+ if(this.customerData.salesManSn){
|
|
|
+ const userInd=this.userList.findIndex((item)=>{
|
|
|
+ return item.customerSn==this.customerData.salesManSn
|
|
|
+ })
|
|
|
+ this.defaultUserIndex=[userInd]
|
|
|
+ this.form.salesManName=this.userList[userInd].name
|
|
|
+ this.form.salesManSn=this.userList[userInd].salesManSn
|
|
|
+ }
|
|
|
console.log(ind,'a',JSON.parse(JSON.stringify(this.defaultSettleIndex)) )
|
|
|
},200)
|
|
|
}
|
|
|
this.getSettleStyle()
|
|
|
this.getCustomerList()
|
|
|
},
|
|
|
- onUnload() {
|
|
|
- this.$u.vuex("vuex_OrderAddress",{})
|
|
|
- // uni.$off('setFun',this.setFun)
|
|
|
- },
|
|
|
methods:{
|
|
|
- // 新增完客户将客户数据传过来
|
|
|
- // setFun(data){
|
|
|
- // console.log(data,'========页面传参')
|
|
|
- // // if(data){
|
|
|
- // // this.form = Object.assign(this.form, {
|
|
|
- // // buyerName: data.customerName, // 客户名称
|
|
|
- // // buyerSn: data.customerSn, // 客户sn
|
|
|
- // // consigneeTel: data.contactTel, // 联系电话
|
|
|
- // // contactMobile: data.contactMobile,
|
|
|
- // // consigneeName: data.contactName, // 联系人
|
|
|
- // // shippingAddressProvinceSn: data.provinceSn, // 省
|
|
|
- // // shippingAddressProvinceName: data.provinceName,
|
|
|
- // // shippingAddressCitySn: data.citySn, // 市
|
|
|
- // // shippingAddressCityName: data.cityName,
|
|
|
- // // shippingAddressCountySn: data.countySn, // 区
|
|
|
- // // shippingAddressCountyName: data.countyName,
|
|
|
- // // shippingAddress: data.customerAddr, // 详细地址
|
|
|
- // // fax: data.fax, // 客户传真
|
|
|
- // // dispatchType: data.dispatchType, // 配送方式
|
|
|
- // // satelliteFlag: data.satelliteFlag, // 是否卫星仓客户
|
|
|
- // // priceType: data.priceType, // 价格类型
|
|
|
- // // settleStyleSn: data.settleStyleSn // 收款方式
|
|
|
- // // })
|
|
|
- // // }
|
|
|
- // },
|
|
|
- getCodeList(code){
|
|
|
- getLookUpDatas({type:code}).then(res=>{
|
|
|
- if(res.status==200){
|
|
|
- this.dispatchTypeList=res.data
|
|
|
- this.showDispatch=true
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
getCustomerData(val){
|
|
|
customerDetail({id:val}).then(res=>{
|
|
|
if(res.status==200){
|
|
|
this.customerData=res.data
|
|
|
- if (this.customerData.provinceSn) { this.getArea('city', this.customerData.provinceSn) }
|
|
|
- if (this.customerData.citySn) { this.getArea('district', this.customerData.citySn) }
|
|
|
-
|
|
|
+ this.areaIdArr=[this.customerData.provinceSn,this.customerData.citySn,this.customerData.countySn]
|
|
|
+ this.areaInfo={label:this.customerData.provinceName+'-'+this.customerData.cityName+'-'+this.customerData.countyName}
|
|
|
// this.setFun(res.data)
|
|
|
this.form = Object.assign(this.form, {
|
|
|
buyerName: this.customerData.customerName, // 客户名称
|
|
@@ -238,9 +202,12 @@
|
|
|
if(this.customerData.priceType || this.customerData.dispatchType){
|
|
|
setTimeout(()=>{
|
|
|
this.$refs.priceType.setVal(this.customerData.priceType)
|
|
|
+ },200)
|
|
|
+ }
|
|
|
+ if(this.customerData.dispatchType){
|
|
|
+ setTimeout(()=>{
|
|
|
this.$refs.dispatchType.setVal(this.customerData.dispatchType)
|
|
|
},200)
|
|
|
-
|
|
|
}
|
|
|
this.form=Object.assign(this.form,res.data)
|
|
|
}else{
|
|
@@ -248,77 +215,39 @@
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- // 获取城市列表
|
|
|
- getCityList (val) {
|
|
|
- this.addrCityList = []
|
|
|
- this.addrDistrictList = []
|
|
|
- this.form.shippingAddressCitySn = undefined
|
|
|
- this.form.shippingAddressCityName = ''
|
|
|
- this.form.shippingAddressCountySn = undefined
|
|
|
- this.form.shippingAddressCountyName = ''
|
|
|
- if (val) {
|
|
|
- this.getArea('city', val)
|
|
|
- this.form.shippingAddressProvinceName = this.addrProvinceList.find(item => item.areaSn == val).name
|
|
|
- } else {
|
|
|
- this.form.shippingAddressProvinceName = ''
|
|
|
- }
|
|
|
- },
|
|
|
- // 获取区县列表
|
|
|
- getAreaList (val) {
|
|
|
- this.addrDistrictList = []
|
|
|
- this.form.shippingAddressCountySn = undefined
|
|
|
- this.form.shippingAddressCountyName = ''
|
|
|
- if (val) {
|
|
|
- this.getArea('district', val)
|
|
|
- this.form.shippingAddressCityName = this.addrCityList.find(item => item.areaSn == val).name
|
|
|
- } else {
|
|
|
- this.form.shippingAddressCityName = ''
|
|
|
- }
|
|
|
- },
|
|
|
- // 区县变更
|
|
|
- areaCharged (val) {
|
|
|
- if (val) {
|
|
|
- this.form.shippingAddressCountyName = this.addrDistrictList.find(item => item.areaSn == val).name
|
|
|
- } else {
|
|
|
- this.form.shippingAddressCountyName = ''
|
|
|
- }
|
|
|
- },
|
|
|
- // 省/市/区
|
|
|
- getArea (leve, sn) {
|
|
|
- let params
|
|
|
- if (leve == 'province') {
|
|
|
- params = { type: '2' }
|
|
|
- } else {
|
|
|
- params = { parentId: sn, type: leve == 'city' ? '3' : '4' }
|
|
|
+ // 客户信息信息更改后先保存
|
|
|
+ handleSaveCust () {
|
|
|
+ const params = {
|
|
|
+ customerName: this.form.buyerName,
|
|
|
+ customerSn: this.form.buyerSn,
|
|
|
+ contactTel: this.form.consigneeTel, // 联系电话
|
|
|
+ contactMobile: this.form.contactMobile,
|
|
|
+ contactName: this.form.consigneeName, // 联系人
|
|
|
+ provinceSn: this.form.shippingAddressProvinceSn, // 省
|
|
|
+ provinceName: this.form.shippingAddressProvinceName,
|
|
|
+ citySn: this.form.shippingAddressCitySn, // 市
|
|
|
+ cityName: this.form.shippingAddressCityName,
|
|
|
+ countySn: this.form.shippingAddressCountySn, // 区
|
|
|
+ countyName: this.form.shippingAddressCountyName,
|
|
|
+ customerAddr: this.form.shippingAddress, // 详细地址
|
|
|
+ dispatchType: this.form.dispatchType, // 配送方式
|
|
|
+ priceType: this.form.priceType, // 价格类型
|
|
|
+ settleStyleSn: this.form.settleStyleSn // 收款方式
|
|
|
}
|
|
|
- getArea(params).then(res => {
|
|
|
+ updateByCustomerSn(params).then(res => {
|
|
|
if (res.status == 200) {
|
|
|
- if (leve == 'province') {
|
|
|
- this.addrProvinceList = res.data || []
|
|
|
- } else if (leve == 'city') {
|
|
|
- this.addrCityList = res.data || []
|
|
|
- } else if (leve == 'district') {
|
|
|
- this.addrDistrictList = res.data || []
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (leve == 'province') {
|
|
|
- this.addrProvinceList = []
|
|
|
- } else if (leve == 'city') {
|
|
|
- this.addrCityList = []
|
|
|
- } else if (leve == 'district') {
|
|
|
- this.addrDistrictList = []
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- getCodeByName (dispName) {
|
|
|
- return this.dispatchTypeList.find((item) => {
|
|
|
- return item.dispName == dispName
|
|
|
+ // 保存销售单
|
|
|
+ this.salesSbmit()
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
// 重新选择
|
|
|
goBack(){
|
|
|
- uni.navigateBack({})
|
|
|
+ uni.$emit('clear')
|
|
|
+ setTimeout(()=>{
|
|
|
+ uni.navigateBack({})
|
|
|
+ },500)
|
|
|
+
|
|
|
},
|
|
|
radioChange(e) {
|
|
|
console.log(e);
|
|
@@ -350,10 +279,6 @@
|
|
|
// console.log(this.areaIdArr,'this.areaIdArr')
|
|
|
this.$refs.applyAddress.open(this.areaIdArr)
|
|
|
},
|
|
|
- brandClean(){
|
|
|
- this.settleStyleName=''
|
|
|
- this.form.settleStyleSn=undefined
|
|
|
- },
|
|
|
// 获取业务员列表数据
|
|
|
getUserAllList () {
|
|
|
employeeAllList({}).then(res => {
|
|
@@ -389,76 +314,19 @@
|
|
|
console.log(e,'data')
|
|
|
this.defaultSettleIndex=[e]
|
|
|
this.settleStyleName=this.settleTypeList[e].name
|
|
|
- if(this.itemId){
|
|
|
- this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
|
|
|
- }else{
|
|
|
- this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
+ this.form.settleStyleSn=this.settleTypeList[e].settleStyleSn
|
|
|
},
|
|
|
+ // 客户类型change
|
|
|
custTypeChange(e){
|
|
|
this.defaultCustIndex=[e]
|
|
|
this.custTypeName=this.custTypeList[e].name
|
|
|
this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
|
|
|
},
|
|
|
+ // 业务员change
|
|
|
userChange(e){
|
|
|
this.defaultUserIndex=[e]
|
|
|
- this.custTypeName=this.custTypeList[e].name
|
|
|
- this.form.customerTypeSn=this.custTypeList[e].customerTypeSn
|
|
|
- },
|
|
|
- // 保存 (新增客户)
|
|
|
- customerSubmit(){
|
|
|
- console.log('保存===========')
|
|
|
- this.$refs.uForm.validate(valid => {
|
|
|
- if (valid) {
|
|
|
- console.log('验证通过');
|
|
|
- if (this.form.customerName ==='') {
|
|
|
- uni.showToast({
|
|
|
- title: '请输入客户名称',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
- // 省市区
|
|
|
- if(this.areaIdArr.length == 0){
|
|
|
- uni.showToast({icon: 'none',title: '请选择省市区'})
|
|
|
- return
|
|
|
- }
|
|
|
- if (this.form.priceType ==undefined ) {
|
|
|
- uni.showToast({
|
|
|
- title: '请选择价格类型',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
- if (this.form.settleStyleSn ==undefined) {
|
|
|
- uni.showToast({
|
|
|
- title: '请选择收款方式',
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- return false
|
|
|
- }
|
|
|
- const params=Object.assign({},this.form,this.areaIdArr)
|
|
|
- console.log(params,'params')
|
|
|
- if(this.form.id) {
|
|
|
- params.id = this.form.id
|
|
|
- }
|
|
|
- custSave(params).then(res=>{
|
|
|
- if(res.status == 200) {
|
|
|
- uni.showToast({
|
|
|
- title: res.message,
|
|
|
- icon: 'none'
|
|
|
- })
|
|
|
- setTimeout(()=>{
|
|
|
- uni.navigateBack()
|
|
|
- },300)
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log('验证失败');
|
|
|
- }
|
|
|
- })
|
|
|
+ this.form.salesManName=this.userList[e].name
|
|
|
+ this.form.salesManSn=this.userList[e].salesManSn
|
|
|
},
|
|
|
// 保存 (新增销售单)
|
|
|
salesSbmit(){
|
|
@@ -478,7 +346,7 @@
|
|
|
uni.showToast({icon: 'none',title: '请选择省市区'})
|
|
|
return
|
|
|
}
|
|
|
- if (this.form.priceType ==undefined ||this.form.priceType =='') {
|
|
|
+ if (this.form.priceType ==undefined) {
|
|
|
uni.showToast({
|
|
|
title: '请选择价格类型',
|
|
|
icon: 'none'
|
|
@@ -510,9 +378,9 @@
|
|
|
satelliteFlag: 0, // 是否卫星仓客户
|
|
|
priceType:this.form.priceType?this.form.priceType: this.customerData.priceType, // 价格类型
|
|
|
settleStyleSn:this.form.settleStyleSn?this.form.settleStyleSn: this.customerData.settleStyleSn, // 收款方式
|
|
|
- salesManSn:this.salesManSn ||undefined, // 业务员
|
|
|
+ salesManSn:this.form.salesManSn ||undefined, // 业务员
|
|
|
salesManName: '',
|
|
|
- distributionFlag: '0', // 铺货出库
|
|
|
+ distributionFlag: this.form.distributionFlag, // 铺货出库
|
|
|
salesTragetType: 'CUSTOMER',
|
|
|
remarks: this.remarks // 备注
|
|
|
}
|