From bbccf269fe937573a6fa0101b3c5e39c9e8d186c Mon Sep 17 00:00:00 2001 From: xzg <4727863@qq.com> Date: Sun, 7 Apr 2024 16:16:23 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=95=86=E9=85=8D=E5=8F=B8?= =?UTF-8?q?=E6=9C=BA=E9=80=89=E6=8B=A9=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../turndelivery/deliveryDiscuss.vue | 107 ++++++++++++++---- 1 file changed, 87 insertions(+), 20 deletions(-) diff --git a/src/views/distribution/turndelivery/deliveryDiscuss.vue b/src/views/distribution/turndelivery/deliveryDiscuss.vue index a761beae..66665ec9 100644 --- a/src/views/distribution/turndelivery/deliveryDiscuss.vue +++ b/src/views/distribution/turndelivery/deliveryDiscuss.vue @@ -28,17 +28,21 @@ remote :loading='sjloading' loading-text='正在加载中' + > @@ -1026,9 +1030,14 @@ Info(); //页面初始化获取车辆和司机信息 // arr1 传入需要匹配的 // arr2进行匹配的 function CurrentVehicle(arr1, arr2) { + console.log(arr1,'arr1====>'); + console.log(arr2,'arr2====>'); + const matchedArray = []; arr1.forEach(id => { const matchedItem = arr2.find(item => item.id === id); + console.log(matchedItem,'matchedItem'); + if (matchedItem) { matchedArray.push(matchedItem); } @@ -2587,22 +2596,44 @@ const Outsourcing = val => { }; // 选择司机触发 -const SJchangeSelect = val => { - if (!val.length) { - DataSubmit.value.masterDriverName = null; //清空司机信息 - StockInfo.value.VehicleInformation[1].options = vehicle.value; //初始化车辆 - return; - } + const SJchangeSelect = async (val) => { + console.log(val,'司机接受的参数Val'); if (val.length) { - let SJname = null; //用来少选第一选择的司机名称 - SJname = CurrentVehicle(val, StockInfo.value.DriverInformation[1].options); - + let SJname = null; //用来筛选第一选择的司机名称 + console.log(StockInfo.value.DriverInformation[1].options,'StockInfo.value.DriverInformation[1].options首次'); + SJname = await CurrentVehicle(val, StockInfo.value.DriverInformation[1].options);//司机信息 + console.log(SJname,'SJname'); + if(!SJname.length){ + ElMessage({ + message: '选择司机不属于当前仓库,或者没有维护关系,请重新选择司机', + type: 'warning', + }) + DataSubmit.value.masterDriverName='';//清空主司机 + return + } + if(SJname.length){ + if(SJname[0].vehicleVOList){ + if(SJname[0].vehicleVOList.length===1 && !StockInfo.value.Cl.length){ + //带出来的车辆如果只有1辆并且车辆没有选择值,就直接进行带出赋值 + StockInfo.value.Cl.push(SJname[0].vehicleVOList[0].id);//输入框赋值 + DataSubmit.value.masterVehicleNub = SJname[0].vehicleVOList[0].vehicleNub; //主车牌赋值 + CLchangeSelect([SJname[0].vehicleVOList[0].id]) + }else{ + // 如果存在多辆车展开输入框自己选择 + clSelect.value[0].visible = true; // 展开车辆下拉框 + } + } + } + + + console.log(StockInfo.value.Cl,'StockInfo.value.Cl') DataSubmit.value.masterDriverName = SJname[0].name; let data = []; //存储函数筛选后的司机车辆信息 let dataInfo = []; //临时存储的司机车辆信息 let SjData = []; //临时存放司机信息 // CurrentVehicle()方法 传入ID可以匹配出数组里面对应的数据 data = CurrentVehicle(val, StockInfo.value.DriverInformation[1].options); + console.log(data,'筛选出来的司机') if (data) { data.forEach(item => { SjData.push({ @@ -2628,29 +2659,41 @@ const SJchangeSelect = val => { //VehicleInformation[0] 存储的是当下司机名下所有车辆信息 StockInfo.value.VehicleInformation[0].options = dataInfo; } + }else{ + DataSubmit.value.masterDriverName = null; //清空司机信息 + StockInfo.value.VehicleInformation[1].options = vehicle.value; //初始化车辆 + StockInfo.value.VehicleInformation[0].options = []; //清空当前车辆 } + StockInfo.value.VehicleInformation[1].options= removeDuplicatesById(StockInfo.value.VehicleInformation[1].options) }; // 选择车辆触发 -const CLchangeSelect = val => { - if (!val.length) { - StockInfo.value.DriverInformation[1].options = driver.value; //初始化司机信息 - DataSubmit.value.masterVehicleNub = null; //清空司机牌照 - return; - } - // 接收一个车辆ID 用于查询车辆车牌 +const CLchangeSelect = async val => { + + + if (val.length) { + // 接收一个车辆ID 用于查询车辆车牌 let data = []; let dataInfo = []; //临时存储的当前车辆的所有司机信息 let ClData = []; //临时存放车辆信息 let ClName = null; //用来筛选第一选择的车牌信息 - if (val.length) { - ClName = CurrentVehicle(val, StockInfo.value.VehicleInformation[1].options); + ClName = await CurrentVehicle(val, StockInfo.value.VehicleInformation[1].options); + if(await !ClName.length){ + ElMessage({ + message: '查询失败请重试', + type: 'warning', + }) + DataSubmit.value.masterVehicleNub='';//清空主车辆 + return + } + sjSelect.value[0].visible = true; // 展开司机下拉框 + DataSubmit.value.masterVehicleNub = ClName[0].vehicleNub; //处理好的车牌 data = CurrentVehicle(val, StockInfo.value.VehicleInformation[1].options); console.log(data, '返回的值==='); - // 处理从车辆 信息 获取车辆的ID和车牌号 if (data) { + console.log(data,'data===>'); data.forEach(item => { ClData.push({ vehicleId: item.id, //车辆ID @@ -2667,17 +2710,38 @@ const CLchangeSelect = val => { data.forEach(item => { // 防止有些车辆下面没有绑定司机 if (item.driverArteryEntityList) { - item.driverArteryEntityList.forEach(item => { + if(item.driverArteryEntityList.length){ + item.driverArteryEntityList.forEach(item => { dataInfo.push(item); console.log(item, 'itemInfo解析'); }); + } + } }); dataInfo = removeDuplicatesById(dataInfo); //对当前选择的车辆司机去重 console.log(dataInfo, 'dataInfo信息'); StockInfo.value.DriverInformation[0].options = dataInfo; // 把去重后的值赋值给当前车辆下面的司机 + console.log(StockInfo.value.DriverInformation,'司机触发查看'); + + +// 判断打带出来的司机是否属于本仓库,如不属于不可选中! + StockInfo.value.DriverInformation[0].options.forEach(item => { + // 检查该对象的 id 是否存在于 全部数组中 + const exists = StockInfo.value.DriverInformation[1].options.some(btcItem => btcItem.id === item.id); + // 如果不存在于则给该对象添加 display 属性并设置为 true + if (!exists) { + item.display = true; + } + }); } + }else{ + StockInfo.value.DriverInformation[1].options = driver.value; //初始化司机信息 + StockInfo.value.DriverInformation[0].options=[];//清空当前司机 + console.log( StockInfo.value.DriverInformation,' StockInfo.value.DriverInformation'); + DataSubmit.value.masterVehicleNub = null; //清空司机牌照 } + StockInfo.value.DriverInformation[1].options= removeDuplicatesById(StockInfo.value.DriverInformation[1].options);//去重 }; // 合并司机和车辆信息 @@ -2740,6 +2804,9 @@ const merge = (val, kindS) => { } // 判读司机配置是否选择完整 if (DriverTemporaryStorage.value.length != VehicleTemporaryStorage.value.length) { + console.log(DriverTemporaryStorage.value,'DriverTemporaryStorage.value'); + console.log(VehicleTemporaryStorage.value,'VehicleTemporaryStorage.value'); + ElMessage({ message: '司机配置未选择完整!', type: 'warning',