<!-- 自主配送 -->
|
<template>
|
<view class="main">
|
<!-- 司机选择的产品信息 -->
|
<view class="product-info">
|
<view class="product-info_block">
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择单位
|
</view>
|
<view class="selected-info_text">
|
<niceui-data-select-input v-model="deptId"
|
:localdata="deptList"
|
placeholder="请选择单位"
|
@change="deptChange"></niceui-data-select-input>
|
</view>
|
</view>
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择产品
|
</view>
|
<view class="selected-info_text">
|
<niceui-data-select-input v-model="productName"
|
:localdata="productNameList"
|
label="产品选择"
|
placeholder="请选择产品"
|
@change="productNameChange"></niceui-data-select-input>
|
</view>
|
|
</view>
|
<view class="selected-info">
|
<view class="selected-info_label">
|
当前选择场地
|
</view>
|
<view class="selected-info_text">
|
<niceui-data-select-input v-model="filedId"
|
:localdata="filedNameList"
|
label="场地选择"
|
placeholder="请选择场地"
|
@change="filedChange"></niceui-data-select-input>
|
</view>
|
</view>
|
</view>
|
</view>
|
<view class="bottom-block">
|
<!-- 选择发运时间 -->
|
<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>
|
<view class="customer-name_block"
|
@click="selfDeliver">
|
<input class="customer-name_block-input"
|
type="text"
|
placeholder="请选择客户"
|
v-model="customerName"
|
@focus="selfDeliver"
|
ref="selectCustomer" />
|
</view>
|
</view>
|
</view>
|
<!-- 提交 -->
|
<view class="confirm-build">
|
<view class="confirm-build_block">
|
<u-button text="确认创建"
|
@click="confirmBuild"
|
:loading="buildLoading"
|
:disabled="abledBuild"></u-button>
|
</view>
|
</view>
|
<view class="">
|
<u-popup :closeable='true'
|
:round="30"
|
mode='bottom'
|
:show="selfDeliverShow"
|
@close="selfDeliverClose"
|
@open="selfDeliverOpen">
|
<view class="name-list-section">
|
<view class="name-list_title">
|
选择客户
|
</view>
|
<view class="name-list_container">
|
<u-empty mode="data"
|
icon="http://cdn.uviewui.com/uview/empty/data.png"
|
text="暂无数据"
|
textSize="30"
|
iconSize="1000"
|
v-if="customerNameList.length===0"></u-empty>
|
<view class="name-list_container_item"
|
v-for="item in customerNameList"
|
@click="selectCustomer(item)">
|
<view class="item-image">
|
<image src="https://wrzs.czjlchem.com:9090/appimg/image/banner/address.png"
|
mode="widthFix"
|
style="width: 18px;"></image>
|
</view>
|
<view class="item-customerName">
|
{{item.customerName}}
|
</view>
|
</view>
|
</view>
|
</view>
|
</u-popup>
|
</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()
|
if (this.deptId && this.productName) {
|
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('getDeptAndProductNameByCustomer', { deptId: this.deptId, productName: this.productName })
|
.then(res => {
|
uni.hideLoading()
|
if (res.code == 0) {
|
this.customerNameList = res.data
|
}
|
})
|
},
|
//查询相关单位
|
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.deptId = Array.isArray(this.deptList) && this.deptList.length !== 0 ? this.deptList[0]
|
.value : ''
|
} else {
|
this.$u.toast('加载失败')
|
}
|
}).then(() => {
|
this.getDeptByProductName()
|
this.getDeptIdByFiledList()
|
})
|
},
|
deptChange(e) {
|
this.deptName = this.deptList.find(v => v.value === e).text
|
this.getDeptByProductName()
|
this.getDeptIdByFiledList()
|
if (this.deptId && this.productName) {
|
this.getShipToList()
|
}
|
},
|
// 根据部门获取产品名称
|
getDeptByProductName() {
|
this.$reqGet('getDeptByProductName', { deptId: this.deptId }).then(res => {
|
this.productNameList = res.data.map(v => {
|
return {
|
value: v.productName,
|
text: v.productName
|
}
|
})
|
this.productName = Array.isArray(this.productNameList) && this.productNameList.lenght !== 0 ?
|
this.productNameList[0].value : ''
|
}).then(() => {
|
this.getShipToList()
|
})
|
},
|
// 根据部门获取场地名称
|
getDeptIdByFiledList() {
|
this.$reqGet('getDeptIdByFiledList', { deptId: this.deptId }).then(res => {
|
this.filedNameList = res.data.map(v => {
|
return {
|
value: v.id,
|
text: v.name
|
}
|
})
|
if (Array.isArray(this.filedNameList) && this.filedNameList.length === 1) {
|
this.filedId = this.filedNameList[0].value
|
this.filedName = this.filedNameList[0].text
|
} else if (Array.isArray(this.filedNameList) && this.filedNameList.length > 1) {
|
this.filedId = ''
|
this.filedName = ''
|
}
|
})
|
},
|
filedChange(e) {
|
this.filedName = this.filedNameList.find(v => v.value === e).text
|
},
|
productNameChange(e) {
|
if (this.deptId && this.productName) {
|
this.getShipToList()
|
}
|
},
|
selfDeliver() {
|
this.selfDeliverShow = true
|
},
|
selfDeliverClose() {
|
this.selfDeliverShow = false
|
},
|
selfDeliverOpen() {
|
this.selfDeliverShow = true
|
},
|
selectCustomer(value) {
|
this.customerId = value.customerId
|
this.customerName = value.customerName
|
this.selfDeliverShow = false
|
},
|
confirmBuild() {
|
let form = {
|
carNo: uni.getStorageSync('carNo'),
|
coalName: this.productName,
|
deptId: this.deptId, //部门Id
|
deptName: this.deptName, //部门名称
|
filedId: this.filedId, //场地Id
|
filedName: this.filedName, //场地名称
|
orderType: "外购",
|
sendDate: this.sendDate, //发运时间
|
xsUserId1: uni.getStorageSync('userId'), //用户id
|
isPretendDischar: 1, //是否能装卸 1已经确认装卸 0不需要装卸
|
isSpecial: 1, //是否是特产品 1特殊产品 0不是特使产品
|
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;
|
}
|
|
|
.main {
|
width: 100%;
|
color: #232323;
|
|
.product-info {
|
width: 96%;
|
height: vww(250);
|
margin: vww(8);
|
margin-top: vww(20);
|
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;
|
position: relative;
|
@include flex;
|
justify-content: center;
|
|
&_block {
|
width: 88%;
|
height: vww(200);
|
margin-left: vww(10);
|
@include flex;
|
flex-direction: column;
|
align-items: flex-start;
|
|
.selected-info {
|
width: 100%;
|
display: flex;
|
align-items: center;
|
|
&_label {
|
margin-right: vww(8);
|
}
|
|
&_text {
|
font-weight: bold;
|
}
|
}
|
|
.re-select {
|
position: absolute;
|
width: vww(100);
|
bottom: vww(10);
|
}
|
}
|
}
|
|
.bottom-block {
|
height: vww(200);
|
}
|
|
.send-date,
|
.customer-name {
|
margin: vww(40) vww(20);
|
position: relative;
|
|
&_label {
|
margin: vww(8);
|
}
|
|
&_block {
|
width: 100%;
|
flex: 1;
|
height: vww(35);
|
border: 1px solid #e5e5e5;
|
box-sizing: border-box;
|
border-radius: 4px;
|
padding: 0 5px;
|
padding-left: 10px;
|
position: relative;
|
user-select: none;
|
@include flex;
|
|
&-input {
|
width: 96%;
|
height: 96%;
|
color: #333;
|
position: absolute;
|
left: vww(10);
|
z-index: -1;
|
white-space: nowrap;
|
text-overflow: ellipsis;
|
-o-text-overflow: ellipsis;
|
overflow: hidden;
|
}
|
}
|
}
|
|
.confirm-build {
|
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%;
|
}
|
}
|
|
.name-list-section {
|
width: 100%;
|
height: vww(600);
|
position: relative;
|
@include flex;
|
justify-content: center;
|
align-items: flex-start;
|
|
.name-list_title {
|
position: absolute;
|
top: vww(10);
|
font-size: vww(20);
|
}
|
|
.name-list_container {
|
width: 94%;
|
padding-top: vww(10);
|
overflow: scroll;
|
@include flex;
|
justify-content: flex-start;
|
flex-direction: column;
|
margin-top: vww(40);
|
|
&_item {
|
width: 100%;
|
height: vww(50);
|
@include flex;
|
justify-content: flex-start;
|
font-size: vww(18);
|
|
.item-image {
|
height: 100%;
|
display: flex;
|
align-items: center;
|
}
|
|
.item-customerName {
|
color: #252525;
|
margin-left: vww(8);
|
white-space: nowrap;
|
text-overflow: ellipsis;
|
overflow: hidden;
|
}
|
}
|
}
|
}
|
}
|
</style>
|