diff --git a/src/views/modules/recv/recv.vue b/src/views/modules/recv/recv.vue
index 71273f3..7918064 100644
--- a/src/views/modules/recv/recv.vue
+++ b/src/views/modules/recv/recv.vue
@@ -103,7 +103,17 @@
spellcheck="false" />
-
+
+
回退
保存
@@ -199,7 +209,9 @@ export default {
warehouseId:localStorage.getItem('selectedWarehouse'),
fullscreenLoading: false, // 控制全屏loading
loadingText: '加载中...', // 动态loading文本
- autoCalculate: true // 自动计算包装数开关
+ autoCalculate: true, // 自动计算包装数开关
+ locationHistoryList: [],
+ locationHistoryLimit: 20
};
},
computed: {
@@ -217,6 +229,11 @@ export default {
},
displayLineWdr() {
return `${this.recvItem.lineNo || ''}/${this.recvItem.releaseNo}`;
+ },
+ locationHistoryKey() {
+ // 按站点隔离,避免不同站点的库位混在同一份历史里。
+ const site = this.site || 'defaultSite';
+ return `recv_location_history_${site}`;
}
},
watch: {
@@ -471,6 +488,51 @@ export default {
}
});
},
+ loadLocationHistory() {
+ const rawHistory = localStorage.getItem(this.locationHistoryKey);
+ if (!rawHistory) {
+ this.locationHistoryList = [];
+ return;
+ }
+ try {
+ const parsedHistory = JSON.parse(rawHistory);
+ if (!Array.isArray(parsedHistory)) {
+ this.locationHistoryList = [];
+ return;
+ }
+ this.locationHistoryList = parsedHistory
+ .map(item => (item || '').toString().trim())
+ .filter((item, index, arr) => item && arr.indexOf(item) === index)
+ .slice(0, this.locationHistoryLimit);
+ } catch (error) {
+ console.warn('解析库位历史缓存失败:', error);
+ this.locationHistoryList = [];
+ }
+ },
+ querySearchLocation(queryString, cb) {
+ const normalizedKeyword = (queryString || '').trim().toLowerCase();
+ const historyOptions = this.locationHistoryList.map(location => ({ value: location }));
+ const result = normalizedKeyword
+ ? historyOptions.filter(item => item.value.toLowerCase().includes(normalizedKeyword))
+ : historyOptions;
+ cb(result);
+ },
+ handleLocationSelect(selectedItem) {
+ // 选中历史值后立即置顶,保证高频库位下次优先展示。
+ this.saveLocationHistory(selectedItem && selectedItem.value);
+ },
+ handleLocationBlur() {
+ // 失焦即缓存,覆盖“手输后直接切换焦点”的场景。
+ this.saveLocationHistory(this.recvItem.locationNo);
+ },
+ saveLocationHistory(locationNo) {
+ const normalizedLocation = (locationNo || '').trim();
+ if (!normalizedLocation) return;
+ const dedupedHistory = [normalizedLocation, ...this.locationHistoryList.filter(item => item !== normalizedLocation)]
+ .slice(0, this.locationHistoryLimit);
+ this.locationHistoryList = dedupedHistory;
+ localStorage.setItem(this.locationHistoryKey, JSON.stringify(dedupedHistory));
+ },
// 校验库位
async validateLocation() {
if (!this.recvItem.locationNo || !this.recvItem.receiveCaseDB) {
@@ -593,6 +655,8 @@ export default {
receivePo(receiveData).then(({ data }) => {
if (data.code === 0) {
this.$message.success("操作成功");
+ // 提交成功后再记一次,避免只填了默认库位、未失焦就保存时漏记。
+ this.saveLocationHistory(item.locationNo);
this.clearAllHandlingUnitCache();
let printLabelType;
if (item.partNo && item.partNo.startsWith("80")) {
@@ -653,6 +717,7 @@ export default {
},
},
mounted() {
+ this.loadLocationHistory();
this.$nextTick(() => this.$refs.scanCodeRef.focus());
},