From b1df61fb5b2c9437af19dafbeeec362e0b06170f Mon Sep 17 00:00:00 2001 From: zhangdi <1104545947@qq.com> Date: Mon, 30 Mar 2026 15:51:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E6=96=99=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/logistics.js | 51 +++++--- pages/logistics/delivery.vue | 220 +++++++++++++++++++++++++--------- pages/logistics/packaging.vue | 196 ++++++++++++++++++++++++------ 3 files changed, 354 insertions(+), 113 deletions(-) diff --git a/api/logistics.js b/api/logistics.js index 9fb9f7b..46f1ad1 100644 --- a/api/logistics.js +++ b/api/logistics.js @@ -14,7 +14,7 @@ const boxBinding = (data) => { return http.request({ url: '/blade-desk/order-bind/box-binding', method: 'POST', - data:data + data: data }) } @@ -23,7 +23,7 @@ const boxBindingTesk = (data) => { return http.request({ url: '/blade-desk/order/box-binding', method: 'POST', - data:data + data: data }) } @@ -116,18 +116,39 @@ const stationUpdate = (data) => { }) } + +// 物料箱一键解绑 +const boxUnbind = (data) => { + return http.request({ + url: '/blade-desk/order-bind/box-unbind', + method: 'POST', + data:data + }) +} + +// 叫料--起点区域站点 +const getStationRegion = (params) => { + return http.request({ + url: '/blade-desk/order/stationRegion-list', + method: 'GET', + params + }) +} + export default { - getWeighing, - getOrderBindPage, - boxBinding, - boxBindingTesk, - getWorkCenter, - receiveOrder, - boxbarcodeDetails, - queryCardNo, - getQuantityLocation, - getStationName, - getStationNameBoxbarcode, - getStationList, - stationUpdate + getWeighing, + getOrderBindPage, + boxBinding, + boxBindingTesk, + getWorkCenter, + receiveOrder, + boxbarcodeDetails, + queryCardNo, + getQuantityLocation, + getStationName, + getStationNameBoxbarcode, + getStationList, + stationUpdate, + boxUnbind, + getStationRegion } \ No newline at end of file diff --git a/pages/logistics/delivery.vue b/pages/logistics/delivery.vue index 7ca467d..e0d34f2 100644 --- a/pages/logistics/delivery.vue +++ b/pages/logistics/delivery.vue @@ -2,6 +2,11 @@ + + @@ -64,6 +74,12 @@ label-width="100px" v-if="scanMode === 'bind'" > + + + + + + 暂无数据 + @@ -151,33 +184,6 @@ 配送 - - - - 箱 {{ boxData.boxBarcode }} 明细 - - - - - - {{ order.partCode }} - {{ order.actualWeighing }}g - - {{ order.partName }} - - - - - - - - @@ -221,15 +227,7 @@ export default { startStationIndex: 0, // 起点站点选中索引 }; }, - computed: { - endCenterIndex() { - if (!this.endCenter) return 0; - - const index = this.workCenters.find((c) => c.name === this.endCenter); - console.log(9999, this.endCenter, index.id); - return index.id; - }, - }, + computed: {}, mounted() { this.getWorkCenterList(); }, @@ -238,11 +236,13 @@ export default { handleStartAreaChange(e) { const index = e.detail.value; this.startArea = this.startAreas[index].name; - this.startAreaIndex = this.startAreas[index].id; + this.startAreaIndex = index; + // 清空起点站点 this.startStation = ""; this.startStationIndex = 0; - // 获取对应站点列表 + + // 获取对应站点列表(从 stationCodeList 读取) this.getStartStationsList(this.startAreas[index].id); }, @@ -250,17 +250,37 @@ export default { handleStartStationChange(e) { const index = e.detail.value; this.startStation = this.startStations[index].name; - this.startStationIndex = this.startStations[index].id; + this.startStationIndex = index; }, // 获取起点区域列表 getStartAreasList() { - this.$u.api.getStartAreas().then((res) => { - this.startAreas = res.data.map((area) => ({ - id: area.id, - name: area.areaName, - })); + uni.showLoading({ + title: "加载中...", + mask: true, }); + + this.$u.api + .getStationRegion() + .then((res) => { + uni.hideLoading(); + + console.log("起点区域列表:", res.data); + + this.startAreas = res.data.map((area) => ({ + id: area.stationRegion, + name: area.stationRegion, + stationCodeList: area.stationCodeList || [], + })); + }) + .catch((err) => { + uni.hideLoading(); + console.error("获取区域列表失败:", err); + uni.showToast({ + title: "加载区域列表失败", + icon: "none", + }); + }); }, // 获取起点站点列表(根据区域 ID) @@ -269,27 +289,78 @@ export default { this.startStations = []; return; } - this.$u.api.getStartStations({ areaId }).then((res) => { - this.startStations = res.data.map((station) => ({ - id: station.id, - name: station.stationName, + + // 从 startAreas 中找到对应区域,获取 stationCodeList + const area = this.startAreas.find((item) => item.id === areaId); + + if (area && area.stationCodeList && area.stationCodeList.length > 0) { + // 将 stationCodeList 转换为 picker 需要的格式 + this.startStations = area.stationCodeList.map((code, index) => ({ + id: code, + name: code, })); + // 默认选中第一个站点 if (this.startStations.length > 0) { this.startStation = this.startStations[0].name; - this.startStationIndex = this.startStations[0].id; + this.startStationIndex = 0; } - }); + } else { + this.startStations = []; + this.startStation = ""; + this.startStationIndex = 0; + } }, // 作业中心选择变化 handleEndChange(e) { const index = e.detail.value; - this.endCenter = this.workCenters[index].name; - this.endCenterIndex = index; - // 清空终点区域,并获取对应区域列表 + const selectedWorkCenter = this.workCenters[index]; + + this.endCenter = selectedWorkCenter.name; + this.endCenterIndex = selectedWorkCenter.id; + + // 清空终点区域 this.endArea = ""; this.endAreaIndex = 0; - this.getEndAreaList(this.workCenters[index].id); + + console.log("选中的作业中心:", selectedWorkCenter); + console.log("stationRegionList:", selectedWorkCenter.stationRegionList); + + // 从作业中心获取 stationRegionList 作为区域列表 + if ( + selectedWorkCenter.stationRegionList && + selectedWorkCenter.stationRegionList.length > 0 + ) { + // 判断 stationRegionList 是对象数组还是字符串数组 + const firstItem = selectedWorkCenter.stationRegionList[0]; + + if (typeof firstItem === "object") { + // 对象数组 + this.endAreas = selectedWorkCenter.stationRegionList.map( + (region) => ({ + id: region.id, + name: region.regionName || region.name || region.areaName, + }) + ); + } else { + // 字符串数组 + this.endAreas = selectedWorkCenter.stationRegionList.map( + (region, idx) => ({ + id: idx, + name: region, + }) + ); + } + + // 默认选中第一个区域 + if (this.endAreas.length > 0) { + this.endArea = this.endAreas[0].name; + this.endAreaIndex = this.endAreas[0].id; + } + } else { + this.endAreas = []; + console.log("stationRegionList 为空或不存在"); + } }, // 终点区域选择变化 @@ -355,6 +426,10 @@ export default { if (mode === "unbind") { this.getStartAreasList(); } + uni.showToast({ + title: `已切换到${mode === "bind" ? "送料" : "叫料"}模式`, + icon: "none", + }); }, // 获取订单明细 detailsFn() { @@ -411,11 +486,6 @@ export default { }); }, - handleEndChange(e) { - const index = e.detail.value; - this.endCenter = this.workCenters[index].name; - }, - // 获取作业中心列表 getWorkCenterList() { this.$u.api.getWorkCenter().then((res) => { @@ -423,6 +493,7 @@ export default { this.workCenters = res.data.map((c) => ({ id: c.id, name: c.wcName, + stationRegionList: c.stationRegionList, })); }); }, @@ -880,6 +951,37 @@ export default { opacity: 0.5; background-color: #f1f5f9; } +.uni-input-border { + margin-bottom: 20rpx; +} +.required-label { + display: flex; + align-items: center; +} + +.required-mark { + color: #ff0000; + font-size: 28rpx; + font-weight: bold; + margin-right: 4rpx; +} +/* 空数据提示样式 */ +.empty-tip-picker { + width: 100%; + padding: 16rpx; + background-color: #f8fafc; + border: 2rpx solid #e2e8f0; + border-radius: 4rpx; + margin-bottom: 20rpx; +} + +.empty-text { + color: #94a3b8; + font-size: 28rpx; + text-align: center; + display: block; +} + .uni-input-border { margin-bottom: 20rpx; } diff --git a/pages/logistics/packaging.vue b/pages/logistics/packaging.vue index 32a4a18..aa0705c 100644 --- a/pages/logistics/packaging.vue +++ b/pages/logistics/packaging.vue @@ -56,7 +56,9 @@ 配送终点 - {{ totalCount }} + {{ boxInfo.wcName }}-{{ boxInfo.stationRegion }} - + {{ order.woOrder }}订单号 {{ order.cardNo }} {{ order.partCode }} - {{ order.actualWeighing }} g + {{ + order.actualWeighing >= 0 ? order.actualWeighing + "g" : 0 + "g" + }} + @@ -165,7 +176,9 @@ export default { return 0; } return this.boxInfo.yieldOrderList.reduce((sum, o) => { - return sum + (Number(o.actualWeighing) || 0); + const weight = Number(o.actualWeighing) || 0; + // 只计算大于等于 0 的重量 + return weight >= 0 ? sum + weight : sum; }, 0); }, }, @@ -209,6 +222,21 @@ export default { handleModeChange(mode) { this.scanMode = mode; this.hasData = false; + // 清空页面数据 + this.boxInfo = { + yieldOrderList: [], + }; + this.boxCode = ""; + this.cardCode = ""; + this.activeBox = null; + this.orders = []; + this.boxInputFocus = true; + this.cardInputFocus = false; + + uni.showToast({ + title: `已切换到${mode === "bind" ? "绑定" : "解绑"}模式`, + icon: "none", + }); }, handleDeleteOrder(order, index) { uni.showModal({ @@ -250,7 +278,6 @@ export default { handleCardConfirm() { const code = this.cardCode; - // if (!code) return; if (this.cardCode) { if (!this.activeBox) { uni.showToast({ @@ -263,46 +290,125 @@ export default { }); return; } - if ( - this.boxInfo.yieldOrderList.some((o) => o.cardNo === this.cardCode) - ) { - uni.showToast({ - title: `订单 ${this.cardCode} 已在该箱中!`, - icon: "none", - }); - this.cardCode = ""; - this.cardInputFocus = false; - this.$nextTick(() => { - this.cardInputFocus = true; - }); - return; - } + uni.showLoading({ title: "查询中...", mask: true, }); + this.$u.api .queryCardNo({ cardNo: this.cardCode }) .then((res) => { - this.boxInfo.yieldOrderList.push(res.data); uni.hideLoading(); - // 计算当前总重量 - const currentWeight = this.boxInfo.yieldOrderList.reduce( - (sum, o) => { - return sum + (Number(o.actualWeighing) || 0); - }, - 0 - ); - if (currentWeight > 50000) { - uni.showToast({ - title: `请注意箱子已超重!!!!!`, - icon: "warring", - }); - } else { - uni.showToast({ - title: `流程卡 ${code} 装箱成功`, - icon: "success", - }); + + // 根据扫描模式执行不同逻辑 + if (this.scanMode === "bind") { + // === 绑定模式 === + // 检查是否已在箱中 + if ( + this.boxInfo.yieldOrderList.some( + (o) => o.cardNo === this.cardCode + ) + ) { + uni.showToast({ + title: `订单 ${this.cardCode} 已在该箱中!`, + icon: "none", + }); + this.cardCode = ""; + this.cardInputFocus = false; + this.$nextTick(() => { + this.cardInputFocus = true; + }); + return; + } + + // 先将新数据添加到列表 + this.boxInfo.yieldOrderList.push(res.data); + + // 计算当前总重量(只计算>=0 的重量) + const currentWeight = this.boxInfo.yieldOrderList.reduce( + (sum, o) => { + const weight = Number(o.actualWeighing) || 0; + return weight >= 0 ? sum + weight : sum; + }, + 0 + ); + + if (currentWeight > 50000) { + uni.showToast({ + title: `请注意箱子已超重!!!!!`, + icon: "warring", + }); + // 超重时移除刚添加的数据 + this.boxInfo.yieldOrderList.pop(); + } else { + // 自动调用绑定接口 + this.$u.api + .boxBinding({ + boxBarcode: this.activeBox, + orderIdList: this.boxInfo.yieldOrderList.map( + (o) => o.cardNo + ), + }) + .then((bindRes) => { + uni.showToast({ + title: `流程卡 ${code} 装箱绑定成功`, + icon: "success", + }); + // 刷新箱内明细 + this.refreshBoxInfo(); + }) + .catch((bindErr) => { + uni.showToast({ + title: bindErr || "绑定失败", + icon: "error", + }); + // 绑定失败时移除刚添加的数据 + this.boxInfo.yieldOrderList.pop(); + }); + } + } else if (this.scanMode === "unbind") { + // === 解绑模式 === + // 检查是否在箱中 + const orderIndex = this.boxInfo.yieldOrderList.findIndex( + (o) => o.cardNo === this.cardCode + ); + + if (orderIndex === -1) { + uni.showToast({ + title: `订单 ${this.cardCode} 不在该箱中!`, + icon: "none", + }); + this.cardCode = ""; + this.cardInputFocus = false; + this.$nextTick(() => { + this.cardInputFocus = true; + }); + return; + } + + // 调用解绑接口(单个解绑) + this.$u.api + .boxUnbind({ + boxBarcode: this.activeBox, + orderIdList: [this.cardCode], + }) + .then((unbindRes) => { + uni.showToast({ + title: `流程卡 ${code} 解绑成功`, + icon: "success", + }); + // 从列表中移除 + this.boxInfo.yieldOrderList.splice(orderIndex, 1); + // 刷新箱内明细 + this.refreshBoxInfo(); + }) + .catch((unbindErr) => { + uni.showToast({ + title: unbindErr || "解绑失败", + icon: "error", + }); + }); } this.cardCode = ""; @@ -312,6 +418,7 @@ export default { }); }) .catch((err) => { + uni.hideLoading(); uni.showToast({ title: err, icon: "error", @@ -324,6 +431,17 @@ export default { }); } }, + // 刷新箱内明细 + refreshBoxInfo() { + this.$u.api + .boxbarcodeDetails({ boxBarcode: this.activeBox }) + .then((res) => { + this.boxInfo = res.data; + if (this.boxInfo.yieldOrderList == null) { + this.boxInfo.yieldOrderList = []; + } + }); + }, handleResetBox() { this.activeBox = null;