You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
311 lines
8.7 KiB
311 lines
8.7 KiB
<template>
|
|
<view>
|
|
<view class="formBox">
|
|
<uni-forms ref="form" :modelValue="formData" :rules="rules" labelWidth="85px">
|
|
<uni-forms-item label="客户" name="name">
|
|
<uni-combox :candidates="candidates" placeholder="请选择客户" v-model="formData.name" @input="comboxInput"></uni-combox>
|
|
<u-icon name="plus-circle" size="28" @tap="addUser('add')"></u-icon>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="地址" name="address1">
|
|
<uni-easyinput type="text" v-model="formData.address1" disabled="" />
|
|
<u-icon name="edit-pen" size="28" @tap="addUser('edit')"></u-icon>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="详细地址" name="address">
|
|
<uni-easyinput type="textarea" v-model="formData.address" disabled />
|
|
</uni-forms-item>
|
|
<uni-forms-item label="销售员" name="createBy">
|
|
<uni-combox :candidates="createCandidates" placeholder="请选择销售员" v-model="formData.createBy"></uni-combox>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="配送方式" name="transportType">
|
|
<uni-combox :candidates="transportTypeCandidates" placeholder="请选择配送方式" v-model="formData.transportTypeVal" @input="transportTypeInput"></uni-combox>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="物流公司" name="transCompany" v-if="transCompanyCandidates.length > 0">
|
|
<uni-combox :candidates="transCompanyCandidates" placeholder="请选择物流公司" v-model="transCompany" @input="transCompanyInput"></uni-combox>
|
|
</uni-forms-item>
|
|
<uni-forms-item label="配送人员" name="orderByWorker" v-if="orderByWorkerCandidates.length > 0">
|
|
<uni-combox :candidates="orderByWorkerCandidates" placeholder="请选择配送人员" v-model="orderByWorker"></uni-combox>
|
|
</uni-forms-item>
|
|
</uni-forms>
|
|
<u-button @tap="submit">提交</u-button>
|
|
</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
data() {
|
|
return {
|
|
orderByWorkerList:[],
|
|
saleDetailList:[],
|
|
transCompany:'',
|
|
orderByWorker:'',
|
|
categoryList: [],
|
|
candidates: [],
|
|
createCandidates:[],
|
|
transportTypeCandidates:['物流','自提','快递','拼单'],
|
|
transCompanyCandidates:[],
|
|
orderByWorkerCandidates:[],
|
|
remark: '',
|
|
area: '',
|
|
userObj:{},
|
|
signCompany: '',
|
|
company:[],
|
|
purchase:{},
|
|
// 表单数据
|
|
formData: {
|
|
name: '',
|
|
manufacturer: '',
|
|
price: '',
|
|
single: '',
|
|
address:'',
|
|
transportType:'',
|
|
transportTypeVal:'',
|
|
createBy:'',
|
|
},
|
|
rules: {
|
|
// 对name字段进行必填验证
|
|
name: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择客户',
|
|
}
|
|
]
|
|
},
|
|
transportType: {
|
|
rules: [{
|
|
required: true,
|
|
errorMessage: '请选择配送方式',
|
|
}
|
|
]
|
|
},
|
|
},
|
|
};
|
|
},
|
|
onShow() {
|
|
this.tui.request("/app/customer/list", "get", {}, false, true).then((res) => {
|
|
if (res.code == 200) {
|
|
this.categoryList = res.result;
|
|
this.candidates = res.result.map(item =>{ return item.name})
|
|
this.formData.address1 = "";
|
|
this.formData.address = "";
|
|
|
|
}else{
|
|
this.tui.toast(res.message)
|
|
}
|
|
})
|
|
this.tui.request('/app/common/user/findAllUserByShopId', 'get', {}, false, false, true).then((res) => {
|
|
if (res.code !== 200) return
|
|
this.staffList = res.result;
|
|
this.createCandidates = res.result.map(item =>{ return item.nickname})
|
|
|
|
})
|
|
},
|
|
onLoad(options) {
|
|
this.purchase = JSON.parse(decodeURIComponent(options.purchase))
|
|
this.saleDetailList = JSON.parse(decodeURIComponent(options.saleDetailList))
|
|
},
|
|
methods:{
|
|
addUser( type ) {
|
|
if(type == 'add') {
|
|
uni.navigateTo({
|
|
url: "/pages/billing/addUser"
|
|
})
|
|
} else {
|
|
if(this.formData.address != '') {
|
|
uni.navigateTo({
|
|
url: "/pages/billing/addUser?info=" + encodeURIComponent(JSON.stringify(this.userObj))
|
|
})
|
|
}
|
|
|
|
}
|
|
},
|
|
comboxInput(e) {
|
|
let obj = this.categoryList.filter(item => {
|
|
return item.name == e
|
|
})
|
|
|
|
if(obj.length > 0) {
|
|
this.userObj = obj[0]
|
|
this.userObj.address1 = obj[0].province + obj[0].city + obj[0].area;
|
|
this.formData.address1 = this.userObj.address1
|
|
this.formData.address = this.userObj.address
|
|
this.formData.area = this.userObj.area
|
|
this.formData.city = this.userObj.city
|
|
this.formData.province = this.userObj.province,
|
|
this.formData.userId = this.userObj.id
|
|
} else {
|
|
this.userObj = {}
|
|
this.formData.address = '';
|
|
this.formData.address1 = ''
|
|
}
|
|
},
|
|
transportTypeInput(e) {
|
|
this.transCompany = '';
|
|
this.orderByWorkerCandidates = '';
|
|
if(e == '物流' || e =='快递') {
|
|
if( e == '物流') {
|
|
this.formData.transportType = 1;
|
|
this.signCompany = 1;
|
|
} else{
|
|
this.formData.transportType = 3;
|
|
this.signCompany = 2
|
|
}
|
|
this.tui.request("/app/logitics/getAll", "post", {
|
|
signCompany: this.signCompany
|
|
}, false, false).then((res) => {
|
|
if (res.code == 200) {
|
|
this.company = res.result;
|
|
this.transCompanyCandidates = res.result.map(item => {
|
|
return item.companyName
|
|
})
|
|
}else{
|
|
this.tui.toast(res.message)
|
|
}
|
|
})
|
|
} else if (e == "自提") {
|
|
this.formData.transportType = 2;
|
|
this.transCompanyCandidates = [];
|
|
} else if( e =='拼单') {
|
|
this.formData.transportType = 4;
|
|
this.transCompanyCandidates = [];
|
|
}
|
|
},
|
|
transCompanyInput(e) {
|
|
let newArr = this.company.filter(item => {
|
|
return item.companyName == e
|
|
})
|
|
this.tui.request("/worker/getWXByCondition", "post", {
|
|
ownerCompany: newArr[0].id,
|
|
region: 'A',
|
|
signPerson: this.signCompany
|
|
}, false, false).then((res) => {
|
|
if (res.code == 200) {
|
|
this.orderByWorkerList = res.result;
|
|
this.orderByWorkerCandidates = res.result.map(item => {
|
|
return item.workerName
|
|
})
|
|
}else{
|
|
this.tui.toast(res.message)
|
|
}
|
|
})
|
|
},
|
|
// 触发提交表单
|
|
submit() {
|
|
let companyId
|
|
if(this.transCompany) {
|
|
let newArr = this.company.filter(item => {
|
|
if (item.companyName == this.transCompany) return item.id
|
|
})
|
|
companyId = newArr[0].id;
|
|
} else {
|
|
companyId = '';
|
|
}
|
|
let workerId
|
|
if(this.orderByWorker) {
|
|
let newArr = this.orderByWorkerList.filter(item => {
|
|
if (item.workerName == this.orderByWorker) return item.workerId
|
|
})
|
|
workerId = newArr[0].workerId
|
|
} else {
|
|
workerId = ''
|
|
}
|
|
let payStatus
|
|
if( this.purchase.alreadyEarn * 1 > 0 ) {
|
|
if(this.purchase.alreadyEarn * 1 == this.purchase.realAmount ) {
|
|
payStatus = 1
|
|
} else {
|
|
payStatus = 2
|
|
}
|
|
} else {
|
|
payStatus = 0
|
|
}
|
|
|
|
let obj = {
|
|
orderByWorker: workerId,
|
|
sale: {
|
|
alreadyEarn: this.purchase.alreadyPay,
|
|
realAmount: this.purchase.realAmount,
|
|
noEarn:this.purchase.noPay,
|
|
area: this.formData.area,
|
|
city: this.formData.city,
|
|
province: this.formData.province,
|
|
payStatus:payStatus,
|
|
shopId:1,
|
|
receiveAddress:this.formData.address,
|
|
totalAmount:this.purchase.shouldPay,
|
|
transportType:this.formData.transportType,
|
|
discount: this.purchase.discount,
|
|
createBy: this.formData.createBy,
|
|
userId:this.formData.userId
|
|
},
|
|
saleDetailList: this.saleDetailList,
|
|
transCompany: companyId,
|
|
}
|
|
|
|
this.$refs.form.validate().then(res => {
|
|
|
|
this.tui.request("/app/sale/buyNew", "post", obj, false, false).then((res) => {
|
|
if (res.code == 200) {
|
|
uni.showToast({
|
|
title:res.message,
|
|
icon:'none'
|
|
})
|
|
setTimeout(res=> {
|
|
uni.switchTab({
|
|
url:"/pages/billing/billing"
|
|
})
|
|
},500)
|
|
|
|
}else{
|
|
this.tui.toast(res.message)
|
|
}
|
|
})
|
|
}).catch(err => {
|
|
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<style lang="scss" scoped>
|
|
.formBox {
|
|
margin: 20rpx;
|
|
padding: 20rpx 26rpx;
|
|
border-radius: 14rpx;
|
|
box-shadow: 0px 1px 10px 2px #e2e2e2;
|
|
background-color: #fff;
|
|
|
|
.uni-data-select {
|
|
width: 100%;
|
|
}
|
|
|
|
.tui-order-title {
|
|
position: relative;
|
|
font-size: 28upx;
|
|
line-height: 28upx;
|
|
padding-left: 16upx;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
.tui-order-title::before {
|
|
content: '';
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
border-left: 8upx solid $u-primary;
|
|
height: 120%;
|
|
border-radius: 4upx;
|
|
}
|
|
|
|
.u-cell {
|
|
.u-cell__body {
|
|
padding: 10px 0;
|
|
|
|
.u-input {
|
|
flex: 4;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|
|
|