<!-- 自主配送 -->
|
<template>
|
<view class="main">
|
<u-modal :show="selfDeliverShow"
|
title="选择产品"
|
showCancelButton
|
@confirm="selfDeliverConfirm"
|
@cancel="selfDeliverCancel">
|
<view class="slot-content">
|
<niceui-data-select-input v-model="deptId"
|
:localdata="deptList"
|
placeholder="请选择单位"
|
@change="deptChange"></niceui-data-select-input>
|
<niceui-data-select-input v-model="productName"
|
:localdata="productNameList"
|
label="产品选择"
|
placeholder="请选择产品"></niceui-data-select-input>
|
<niceui-data-select-input v-model="filedId"
|
:localdata="filedNameList"
|
label="煤场选择"
|
placeholder="请选择煤场"
|
@change="filedChange"></niceui-data-select-input>
|
</view>
|
</u-modal>
|
<!-- 司机选择的产品信息 -->
|
<view class="product-info">
|
<view class="product-info_block">
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择单位
|
</view>
|
<view class="selected-info_text">
|
{{deptName}}
|
</view>
|
</view>
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择产品
|
</view>
|
<view class="selected-info_text">
|
{{productName}}
|
</view>
|
|
</view>
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择煤场
|
</view>
|
<view class="selected-info_text">
|
{{filedName}}
|
</view>
|
</view>
|
<view class="re-select">
|
<u-button text="重新选择"
|
@click="reSelect"></u-button>
|
</view>
|
</view>
|
</view>
|
<!-- 选择发运时间 -->
|
<view class="send-date">
|
<view class="send-date_label">
|
发运时间
|
</view>
|
<uni-datetime-picker type="date"
|
:clear-icon="false"
|
v-model="sendDate"
|
:start="sendDateStart"
|
:end="sendDateEnd" />
|
</view>
|
<!-- 客户名称 -->
|
<view class="customer-name">
|
<view class="customer-name_label">
|
选择客户
|
</view>
|
<niceui-data-select-input v-model="customerId"
|
:localdata="customerNameList"
|
placeholder="请选择客户"
|
@change="customerNameChange"></niceui-data-select-input>
|
</view>
|
<!-- 提交 -->
|
<view class="re-select">
|
<view class="re-select_block">
|
<u-button text="确认创建"
|
@click="confirmBuild"
|
:loading="buildLoading"
|
:disabled="abledBuild"></u-button>
|
</view>
|
</view>
|
</view>
|
</template>
|
|
<script>
|
import NiceUIDataSelectInput from '@/uni_modules/niceui-data-select-input/components/niceui-data-select-input/niceui-data-select-input.vue'
|
const dayjs = require('dayjs')
|
export default {
|
components: {
|
NiceUIDataSelectInput
|
},
|
onLoad() {
|
this.getCarNoByVarieties()
|
this.getShipToList()
|
this.sendDate = this.sendDateStart = dayjs().format('YYYY-MM-DD')
|
this.sendDateEnd = dayjs().add(7, 'day').format('YYYY-MM-DD')
|
},
|
data() {
|
return {
|
selfDeliverShow: false,
|
deptId: '',
|
deptName: '',
|
deptList: [],
|
productName: '',
|
productNameList: [],
|
filedId: '',
|
filedName: '',
|
filedNameList: [],
|
sendDate: '',
|
sendDateStart: '',
|
sendDateEnd: '',
|
customerId: '',
|
customerName: '',
|
customerNameList: '',
|
buildLoading: false
|
}
|
},
|
computed: {
|
abledBuild() {
|
return !this.filedId || !this.deptId || !this.productName || !this.customerId
|
}
|
},
|
methods: {
|
// 获取客户
|
getShipToList() {
|
uni.showLoading({
|
title: "加载中"
|
})
|
this.$reqGet('getShipToList').then(res => {
|
uni.hideLoading()
|
if (res.code == 0) {
|
this.customerNameList = res.data
|
if (this.customerNameList.length !== 0) {
|
this.customerNameList = this.customerNameList.map(v => {
|
return {
|
value: v.customerId,
|
text: v.customerName
|
}
|
})
|
}
|
}
|
})
|
},
|
//查询相关单位
|
getCarNoByVarieties() {
|
uni.showLoading({
|
title: "加载中"
|
})
|
this.$reqGet('getCarNoByVarieties').then(res => {
|
uni.hideLoading()
|
if (res.code == 0) {
|
this.deptList = res.data.map(v => {
|
return {
|
value: v.deptId,
|
text: v.deptName
|
}
|
})
|
this.selfDeliverShow = true
|
} else {
|
this.$u.toast('加载失败')
|
}
|
|
})
|
},
|
deptChange(e) {
|
this.deptName = this.deptList.find(v => v.value === e).text
|
this.getDeptByProductName()
|
this.getDeptIdByFiledList()
|
},
|
// 根据部门获取产品名称
|
getDeptByProductName() {
|
this.$reqGet('getDeptByProductName', { deptId: this.deptId }).then(res => {
|
this.productNameList = res.data.map(v => {
|
return {
|
value: v.productName,
|
text: v.productName
|
}
|
})
|
this.productName = this.productNameList[0].value
|
})
|
},
|
// 根据部门获取煤场名称
|
getDeptIdByFiledList() {
|
this.$reqGet('getDeptIdByFiledList', { deptId: this.deptId }).then(res => {
|
this.filedNameList = res.data.map(v => {
|
return {
|
value: v.id,
|
text: v.name
|
}
|
})
|
this.filedId = this.filedNameList.length !== 0 ? this.filedNameList[0].value : ''
|
this.filedName = this.filedNameList.length !== 0 ? this.filedNameList[0].text : ''
|
})
|
},
|
filedChange(e) {
|
this.filedName = this.filedNameList.find(v => v.value === e).text
|
},
|
customerNameChange(e) {
|
this.customerName = this.customerNameList.find(v => v.value === e).text
|
},
|
reSelect() {
|
this.selfDeliverShow = true
|
},
|
selfDeliverConfirm() {
|
this.selfDeliverShow = false
|
},
|
selfDeliverCancel() {
|
this.selfDeliverShow = false
|
uni.navigateBack({
|
delta: 1
|
})
|
},
|
confirmBuild() {
|
let form = {
|
carNo: uni.getStorageSync('carNo'),
|
coalName: this.productName,
|
deptId: this.deptId,
|
deptName: this.deptName,
|
filedId: this.filedId,
|
filedName: this.filedName,
|
orderType: "外购",
|
sendDate: this.sendDate,
|
xsUserId1: uni.getStorageSync('userId'),
|
isPretendDischar: 1,
|
isSpecial: 1,
|
customerId: this.customerId,
|
customerName: this.customerName
|
}
|
this.buildLoading = true
|
this.$reqPost('saveDeliveryNote', form, 'json').then(res => {
|
this.buildLoading = false
|
if (res.code == 0) {
|
this.$u.toast('创建成功')
|
setTimeout(() => {
|
uni.navigateBack({
|
delta: 1
|
})
|
}, 1500)
|
} else {
|
this.$u.toast(res.msg ? res.msg : '创建失败')
|
}
|
}).catch(e => {
|
this.buildLoading = false
|
})
|
}
|
},
|
}
|
</script>
|
|
<style lang="scss"
|
scoped>
|
/deep/.u-button {
|
width: 100%;
|
height: 36px !important;
|
line-height: 40px;
|
padding: 0 12px;
|
font-size: 28rpx;
|
font-weight: 300;
|
color: #ffffff !important;
|
background: #497bfb !important;
|
letter-spacing: 4rpx;
|
border-radius: 37rpx 37rpx 37rpx 37rpx !important;
|
box-shadow: 2rpx 3rpx 13rpx 0rpx rgba(43, 98, 239, 0.5), 0rpx 0rpx 9rpx 0rpx rgba(247, 250, 253, 0.29);
|
}
|
|
@mixin flex {
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
}
|
|
.slot-content {
|
width: 100%;
|
height: vww(150);
|
@include flex;
|
flex-direction: column;
|
}
|
|
.main {
|
width: 100%;
|
|
.product-info {
|
width: 96%;
|
height: vww(200);
|
margin: vww(8);
|
margin-top: vww(20);
|
background: #ffffff;
|
box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
|
border-radius: 20rpx;
|
@include flex;
|
justify-content: center;
|
|
&_block {
|
width: 88%;
|
height: vww(150);
|
margin-left: vww(10);
|
@include flex;
|
flex-direction: column;
|
align-items: flex-start;
|
|
.selected-info {
|
width: 100%;
|
display: flex;
|
|
&_label {
|
margin-right: vww(8);
|
}
|
|
&_text {
|
font-weight: bold;
|
}
|
}
|
|
.re-select {
|
width: vww(100);
|
margin: 0 auto;
|
}
|
}
|
}
|
|
.send-date,
|
.customer-name {
|
height: vww(40);
|
margin: vww(40) vww(20);
|
position: relative;
|
|
&_label {
|
margin: vww(8);
|
}
|
}
|
|
.re-select {
|
width: 100%;
|
height: vww(80);
|
background-color: #ffffff;
|
position: fixed;
|
bottom: 0;
|
box-shadow: 0rpx 0rpx 14rpx 0rpx rgba(73, 120, 240, 0.14), 0rpx 7rpx 45rpx 0rpx rgba(73, 120, 240, 0.12);
|
border-radius: 20rpx;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
|
&_block {
|
width: 94%;
|
}
|
}
|
}
|
</style>
|