优化手动创建配送单的功能
This commit is contained in:
@@ -159,7 +159,7 @@
|
||||
|
||||
</el-table>
|
||||
</el-dialog>
|
||||
<el-dialog title="添加配送单" v-model="openBill" append-to-body width="80%" :close-on-click-modal="false">
|
||||
<el-dialog title="添加配送单" v-model="openBill" append-to-body width="80%" @close="cancel" :close-on-click-modal="false">
|
||||
<div class="container">
|
||||
<el-form :model="delieryData" ref="form" :rules="rules" label-width="100">
|
||||
<el-divider content-position="left">配送信息</el-divider>
|
||||
@@ -355,9 +355,9 @@
|
||||
</el-row>
|
||||
<el-row>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="推荐车型" prop="vehicleTypeId">
|
||||
<el-select v-model="delieryData.vehicleTypeId" placeholder="请选择推荐车型" clearable @change="changeCarType">
|
||||
<el-option v-for="dict in carTypeList" :key="dict.id" :label="dict.typeName" :value="dict.id" />
|
||||
<el-form-item label="推荐车型" v-for="(item, index) in delieryData.vehicleTypeNameList" :key="index">
|
||||
<el-select v-model="item.vehicleTypeId" placeholder="请选择推荐车型" @change="changeCarType($event, index)">
|
||||
<el-option v-for="dict in carTypeList" :key="dict.id" :label="dict.name" :value="dict.id" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
@@ -388,6 +388,7 @@
|
||||
import { listOrder,detailOrder,calcTotalWv,calculate,addDelivery } from "@/api/waitDelivery/waitDelivery"
|
||||
import { listType } from "@/api/document/type"
|
||||
import {listUser} from "@/api/system/user"; //理货员
|
||||
import { ref } from "vue";
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const orderList = ref([])
|
||||
@@ -406,7 +407,6 @@ const goodsList = ref([])
|
||||
const carTypeList = ref([]) //推荐车型下拉数据
|
||||
const personList = ref([]); //理货员下拉数据
|
||||
const data = reactive({
|
||||
form: {},
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
@@ -461,11 +461,12 @@ const data = reactive({
|
||||
delieryData:{
|
||||
deliveryTon:null, //重量
|
||||
goodsSize:null, //体积
|
||||
items:[]
|
||||
items:[],
|
||||
vehicleTypeNameList:[{}]
|
||||
},
|
||||
})
|
||||
|
||||
const { queryParams, form,delieryData,rules } = toRefs(data)
|
||||
const { queryParams,delieryData,rules } = toRefs(data)
|
||||
|
||||
/** 查询配送单据主列表 */
|
||||
function getList() {
|
||||
@@ -535,46 +536,45 @@ function changeQty(){
|
||||
}
|
||||
|
||||
}
|
||||
function calculateFun(vehicleTypeId){
|
||||
if(!delieryData.value.deliveryTon || !delieryData.value.goodsSize || !delieryData.value.totalKm){
|
||||
//根据重量、体积、公里数计算车型、费用
|
||||
function calculateFun(id) {
|
||||
if (
|
||||
!delieryData.value.deliveryTon ||
|
||||
!delieryData.value.goodsSize ||
|
||||
!delieryData.value.totalKm
|
||||
) {
|
||||
proxy.$modal.msgWarning("请输入公里数、重量、体积");
|
||||
return
|
||||
return;
|
||||
}
|
||||
let info = {
|
||||
weightTon:0,
|
||||
volumeM3:0,
|
||||
distanceKm:0,
|
||||
vehicleTypeId:vehicleTypeId
|
||||
weightTon: 0,
|
||||
volumeM3: 0,
|
||||
distanceKm: 0,
|
||||
};
|
||||
let hasVehicle = delieryData.value.vehicleTypeNameList.every(item => item.vehicleTypeId)
|
||||
if (hasVehicle) {
|
||||
info.vehicleTypeId = delieryData.value.vehicleTypeNameList.map(item => item.vehicleTypeId).join(',')
|
||||
}
|
||||
info.weightTon = delieryData.value.deliveryTon
|
||||
info.volumeM3 = delieryData.value.goodsSize
|
||||
info.distanceKm = delieryData.value.totalKm
|
||||
if(vehicleTypeId){
|
||||
info.vehicleTypeId = vehicleTypeId
|
||||
}
|
||||
calculate(info).then(response=>{
|
||||
info.weightTon = delieryData.value.deliveryTon;
|
||||
info.volumeM3 = delieryData.value.goodsSize;
|
||||
info.distanceKm = delieryData.value.totalKm;
|
||||
calculate(info).then((response) => {
|
||||
// 检查后端是否返回了错误信息
|
||||
if(response.data.errorMessage) {
|
||||
// 如果有错误信息,显示给用户,并清空相关字段
|
||||
proxy.$modal.msgError(response.data.errorMessage);
|
||||
if(!vehicleTypeId){
|
||||
delieryData.value.vehicleTypeId = null;
|
||||
if (response.data.warningMessage) {
|
||||
proxy.$modal.msgError(response.data.warningMessage);
|
||||
return;
|
||||
}
|
||||
delieryData.value.suggestFee = null;
|
||||
delieryData.value.vehicleTypeName = null;
|
||||
} else {
|
||||
// 没有错误信息,正常处理返回的车型信息
|
||||
if(!vehicleTypeId){
|
||||
delieryData.value.vehicleTypeId = response.data.vehicleTypeId;
|
||||
if (response.data.bestPlan.length > 0 && !id) {
|
||||
delieryData.value.vehicleTypeNameList = response.data.bestPlan;
|
||||
}
|
||||
carTypeList.value = response.data.candidates;
|
||||
delieryData.value.suggestFee = response.data.suggestFee;
|
||||
delieryData.value.vehicleTypeName = response.data.vehicleTypeName;
|
||||
}
|
||||
// console.log(response)
|
||||
})
|
||||
console.log(delieryData.value)
|
||||
});
|
||||
}
|
||||
//切换车型
|
||||
function changeCarType(id){
|
||||
function changeCarType(id, index){
|
||||
if(!delieryData.value.totalKm || !delieryData.value.deliveryTon || !delieryData.value.goodsSize){
|
||||
proxy.$modal.msgWarning("请输入公里数、重量、体积");
|
||||
return
|
||||
@@ -584,42 +584,24 @@ function changeCarType(id){
|
||||
|
||||
// 取消按钮
|
||||
function cancel() {
|
||||
delieryData.value.originName = null;
|
||||
delieryData.value.destName = null;
|
||||
delieryData.value.shipperName = null;
|
||||
delieryData.value.shipperPhone = null;
|
||||
delieryData.value.receiverName = null;
|
||||
delieryData.value.receiverPhone = null;
|
||||
delieryData.value.receiverOrgName = null;
|
||||
delieryData.value.deliveryDate = null;
|
||||
delieryData.value.totalKm = null;
|
||||
delieryData.value.vehicleTypeNameList = [{}];
|
||||
delieryData.value.suggestFee = null;
|
||||
goodsList.value = []
|
||||
proxy.$refs["form"].resetFields()
|
||||
openBill.value = false
|
||||
}
|
||||
|
||||
// 表单重置
|
||||
function reset() {
|
||||
form.value = {
|
||||
id: null,
|
||||
xmMs: null,
|
||||
xmNo: null,
|
||||
wlNo: null,
|
||||
wlMs: null,
|
||||
realQty: null,
|
||||
dw: null,
|
||||
sapNo: null,
|
||||
gysMc: null,
|
||||
remark: null,
|
||||
originName: null,
|
||||
originLng: null,
|
||||
originLat: null,
|
||||
destName: null,
|
||||
destLng: null,
|
||||
destLat: null,
|
||||
deliveryDate: null,
|
||||
vehiclePlate: null,
|
||||
shipperName: null,
|
||||
shipperPhone: null,
|
||||
receiverName: null,
|
||||
receiverPhone: null,
|
||||
receiverOrgName: null,
|
||||
deliveryTon: null,
|
||||
createBy: null,
|
||||
createTime: null,
|
||||
updateBy: null,
|
||||
updateTime: null,
|
||||
isDelete: null
|
||||
}
|
||||
proxy.resetForm("orderRef")
|
||||
}
|
||||
|
||||
@@ -673,18 +655,26 @@ function statusFun(status){
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
let hasVehicle = delieryData.value.vehicleTypeNameList.every(item => item.vehicleTypeId)
|
||||
if (!hasVehicle) {
|
||||
proxy.$modal.msgWarning('请选择配送车型')
|
||||
return
|
||||
}
|
||||
proxy.$refs["form"].validate(valid => {
|
||||
// console.log(delieryData.value)
|
||||
// return
|
||||
|
||||
if (valid) {
|
||||
let obj = JSON.parse(JSON.stringify(delieryData.value))
|
||||
obj.vehicleTypeName = obj.vehicleTypeNameList.map(item => item.vehicleTypeName).join(',')
|
||||
obj.vehicleTypeId = obj.vehicleTypeNameList.map(item => item.vehicleTypeId).join(',')
|
||||
if(goodsList.value.length==0){
|
||||
proxy.$modal.msgWarning("请添加货物信息");
|
||||
return
|
||||
}
|
||||
delieryData.value.items = goodsList.value
|
||||
obj.items = goodsList.value
|
||||
// console.log(delieryData.value)
|
||||
addDelivery(delieryData.value).then(response => {
|
||||
addDelivery(obj).then(response => {
|
||||
proxy.$modal.msgSuccess("操作成功")
|
||||
openBill.value = false
|
||||
getList()
|
||||
@@ -712,15 +702,14 @@ function handleExport() {
|
||||
}, `order_${new Date().getTime()}.xlsx`)
|
||||
}
|
||||
function handleAddBill(){
|
||||
delieryData.value ={}
|
||||
goodsList.value = []
|
||||
|
||||
|
||||
openBill.value = true
|
||||
//车型下拉数据
|
||||
listType({pageNum:1,pageSize:1000}).then(response => {
|
||||
carTypeList.value = response.rows
|
||||
// listType({pageNum:1,pageSize:1000}).then(response => {
|
||||
// carTypeList.value = response.rows
|
||||
|
||||
})
|
||||
// })
|
||||
//理货员下拉数据
|
||||
listUser().then(response=>{
|
||||
personList.value = response.rows
|
||||
|
||||
Reference in New Issue
Block a user