From ca3e4977395bc02c5d147dffdff7381333fdfbca Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期四, 09 四月 2026 14:39:37 +0800
Subject: [PATCH] 空箱跨区域移库
---
项目代码/WIDESEA_WMSClient/src/extension/check/extend/ReCheckGroupPallet.vue | 135 ++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 128 insertions(+), 7 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/extend/ReCheckGroupPallet.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/extend/ReCheckGroupPallet.vue"
index cea7cce..57655b5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/extend/ReCheckGroupPallet.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/check/extend/ReCheckGroupPallet.vue"
@@ -19,8 +19,8 @@
<div class="location-section compact">
<el-form :model="form" :rules="rules" ref="locationForm" class="compact-form">
<el-form-item label="浠撳簱鍖哄煙" prop="locationType" class="location-select compact-item">
- <el-select v-model="form.locationType" placeholder="璇峰厛閫夋嫨浠撳簱" clearable filterable
- @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium">
+ <el-select v-model="form.locationType" placeholder="鑷姩鑾峰彇浠撳簱鍖哄煙" clearable filterable
+ @change="handleLocationChange" style="width: 100%" :loading="locationLoading" size="medium" :disabled="true">
<el-option v-for="item in locationTypes" :key="item.locationType" :label="item.locationTypeDesc"
:value="item.locationType" />
</el-select>
@@ -74,7 +74,7 @@
class="custom-input" size="medium">
<template slot="append">
<el-button :loading="loading" @click="handleBarcodeSubmit" type="primary" icon="el-icon-search"
- :disabled="!form.locationType || !trayBarcode || !barcode || !from.warehouseType" size="medium">
+ :disabled="!form.locationType || !trayBarcode || !barcode || !form.warehouseType" size="medium">
{{ loading ? '鏌ヨ涓�...' : '鏌ヨ' }}
</el-button>
</template>
@@ -240,7 +240,11 @@
trigger: 'change'
}
]
- }
+ },
+
+ // 鏂板锛氶敭鐩樹簨浠剁洃鍚爣璁�
+ keyPressListenerAdded: false,
+ isDialogClosing: false
}
},
@@ -256,7 +260,29 @@
return location ? location.locationTypeDesc : ''
}
},
+
watch: {
+ // 鐩戝惉show鍙橀噺鍙樺寲
+ show(newVal) {
+ if (newVal === true) {
+ console.log('寮规鎵撳紑锛岄噸缃暟鎹�');
+ this.isDialogClosing = false;
+ this.resetData();
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.fetchUnpalletMaterialDetails();
+ this.addKeyPressListener(); // 娣诲姞閿洏浜嬩欢鐩戝惉
+ }, 300);
+ });
+ } else if (newVal === false && !this.isDialogClosing) {
+ console.log('寮规鍏抽棴锛岀Щ闄や簨浠剁洃鍚�');
+ this.isDialogClosing = true;
+ this.removeKeyPressListener(); // 绉婚櫎閿洏浜嬩欢鐩戝惉
+ this.resetData();
+ }
+ },
+
+
visible(newVal, oldVal) {
this.palletVisible = newVal;
@@ -289,14 +315,36 @@
}
}
},
+
mounted() {
- document.addEventListener('keypress', this.handleKeyPress);
+ // 涓嶅湪mounted鏃舵坊鍔犵洃鍚紝鍦ㄥ脊绐楁墦寮�鏃舵坊鍔�
},
+
beforeDestroy() {
- document.removeEventListener('keypress', this.handleKeyPress);
+ // 纭繚缁勪欢閿�姣佹椂绉婚櫎鐩戝惉
+ this.removeKeyPressListener();
this.clearAllTimers();
},
+
methods: {
+ // 娣诲姞閿洏浜嬩欢鐩戝惉
+ addKeyPressListener() {
+ if (!this.keyPressListenerAdded) {
+ document.addEventListener('keypress', this.handleKeyPress);
+ this.keyPressListenerAdded = true;
+ console.log('閿洏浜嬩欢鐩戝惉宸叉坊鍔�');
+ }
+ },
+
+ // 绉婚櫎閿洏浜嬩欢鐩戝惉
+ removeKeyPressListener() {
+ if (this.keyPressListenerAdded) {
+ document.removeEventListener('keypress', this.handleKeyPress);
+ this.keyPressListenerAdded = false;
+ console.log('閿洏浜嬩欢鐩戝惉宸茬Щ闄�');
+ }
+ },
+
open() {
this.show = true;
this.orderNo = "";
@@ -304,7 +352,15 @@
this.initLocationTypes();
this.initwarehouseTypes();
this.fetchUnpalletMaterialDetails();
+
+ // 寮圭獥鎵撳紑鏃舵坊鍔犻敭鐩樹簨浠剁洃鍚�
+ this.$nextTick(() => {
+ setTimeout(() => {
+ this.addKeyPressListener();
+ }, 100);
+ });
},
+
validateLocationType(rule, value, callback) {
if (!this.form.warehouseType) {
callback(new Error('璇峰厛閫夋嫨浠撳簱'));
@@ -338,6 +394,7 @@
}));
}
},
+
async initLocationTypes() {
try {
const { data } = await this.http.post("api/LocationInfo/GetLocationTypes")
@@ -346,6 +403,7 @@
this.$message.error('鑾峰彇鍖哄煙绫诲瀷澶辫触')
}
},
+
async initwarehouseTypes() {
try {
const { data } = await this.http.post("api/Warehouse/GetwarehouseTypes")
@@ -355,6 +413,33 @@
}
},
+ fetchLocationByWarehouse(warehouseCode) {
+ if (!warehouseCode) {
+ this.form.locationType = null;
+ return;
+ }
+ this.locationLoading = true;
+ http.post(`/api/InboundOrder/GetLocationType?code=${warehouseCode}`)
+ .then(({ data }) => {
+ if (data) {
+ this.form.locationType = data.locationType || data;
+ if (!this.locationTypes.find(item => item.locationType === this.form.locationType)) {
+ this.locationTypes.push({
+ locationType: this.form.locationType,
+ locationTypeDesc: this.form.locationType
+ });
+ }
+ }
+ })
+ .catch((err) => {
+ console.error("鑾峰彇浠撳簱鍖哄煙澶辫触:", err);
+ this.$message.error("鑾峰彇浠撳簱鍖哄煙澶辫触锛岃閲嶈瘯");
+ this.form.locationType = null;
+ })
+ .finally(() => {
+ this.locationLoading = false;
+ });
+ },
async fetchStockStatistics(orderNo) {
// 鍗曟嵁鍙蜂负绌烘椂涓嶆煡璇�
if (!orderNo) {
@@ -394,7 +479,8 @@
this.error = '';
resolve(true);
} else {
- if (!this.from.warehouseType) {
+ // 淇鎷煎啓閿欒锛歵his.from.warehouseType 搴旇鏄� this.form.warehouseType
+ if (!this.form.warehouseType) {
this.error = '璇峰厛閫夋嫨浠撳簱';
}
else if (this.form.locationType === null || this.form.locationType === undefined || this.form.locationType === '') {
@@ -407,6 +493,7 @@
});
});
},
+
// 鑱氱劍鍒版墭鐩樿緭鍏ユ
focusTrayInput() {
if (this.$refs.trayInput && this.$refs.trayInput.$el) {
@@ -432,8 +519,12 @@
}
}
},
+
// 閲嶇疆鎵�鏈夋暟鎹�
resetData() {
+ // 鍏堢Щ闄ら敭鐩樹簨浠剁洃鍚�
+ this.removeKeyPressListener();
+
this.trayBarcode = '';
this.barcode = '';
this.materials = [];
@@ -458,6 +549,9 @@
}
this.warehouseTypes = [];
this.locationTypes = [];
+ this.isDialogClosing = false;
+ this.keyPressListenerAdded = false;
+
// 娓呴櫎琛ㄥ崟楠岃瘉鐘舵��
this.$nextTick(() => {
if (this.$refs.locationForm) {
@@ -477,7 +571,10 @@
this.scanTimer = null;
}
},
+
handleDialogClose() {
+ // 鍏堢Щ闄ら敭鐩樹簨浠剁洃鍚�
+ this.removeKeyPressListener();
this.show = false;
this.resetData();
},
@@ -510,6 +607,7 @@
this.$emit('back-success', result);
this.palletVisible = false;
},
+
// 澶勭悊鎵樼洏杈撳叆
handleTrayInput() {
// 鏍囪涓烘墜鍔ㄨ緭鍏ユā寮�
@@ -715,6 +813,11 @@
// 澶勭悊鎵爜鏋緭鍏�
handleKeyPress(event) {
+ // 妫�鏌ュ脊绐楁槸鍚︽樉绀�
+ if (!this.show || this.isDialogClosing) {
+ return;
+ }
+
// 濡傛灉鏄墜鍔ㄨ緭鍏ユā寮忥紝涓嶅鐞嗘壂鐮佹灙閫昏緫
if (this.isManualInput) {
return;
@@ -776,6 +879,24 @@
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+ },
+
+ // 浠撳簱鍒囨崲浜嬩欢
+ handleWarehouseChange() {
+ this.form.locationType = null;
+ this.trayBarcode = '';
+ this.barcode = '';
+ this.materials = [];
+ this.error = '';
+ this.fetchLocationByWarehouse(this.form.warehouseType);
+ },
+
+ // 鍖哄煙鍒囨崲浜嬩欢
+ handleLocationChange() {
+ this.trayBarcode = '';
+ this.barcode = '';
+ this.materials = [];
+ this.error = '';
}
}
}
--
Gitblit v1.9.3