From 2bdda9b2bedb8f084e364e92627f19e1938dceca Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期二, 21 四月 2026 11:05:57 +0800
Subject: [PATCH] 1
---
项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue | 311 ++++++++++++++++++++++-----------------------------
1 files changed, 133 insertions(+), 178 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
index 0fc8112..a8d5da4 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue"
@@ -18,12 +18,12 @@
<el-divider direction="vertical"></el-divider>
<span class="less-style">鐗╂枡缂栧彿锛� {{ row.materielCode }} </span>
<el-divider direction="vertical"></el-divider>
- <span class="less-style"
- >闇�姹傛暟閲忥細 {{ row.orderQuantity }}
+ <span class="less-style">
+ 闇�姹傛暟閲忥細 {{ requireQuantity }}
</span>
<el-divider direction="vertical"></el-divider>
- <span :class="selectionClass"
- >宸查�夋暟閲忥細 {{ selectionSum }}
+ <span :class="selectionClass">
+ 宸查�夋暟閲忥細 {{ selectionSum }}
</span>
</el-col>
<el-col :span="8">
@@ -47,6 +47,8 @@
@row-click="handleRowClick"
height="500px"
@selection-change="handleSelectionChange"
+ @select="selectRowChange"
+ @select-all="selectAllChange"
>
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column
@@ -149,7 +151,6 @@
<script>
import VolBox from "@/components/basic/VolBox.vue";
-// 寮曞叆绔欏彴绠$悊宸ュ叿
import { stationManager } from "@/../src/uitils/stationManager";
export default {
@@ -161,55 +162,18 @@
mainOrderNo: "",
pkcx: false,
showDetialBox: false,
- showStationDialog: false, // 绔欏彴閫夋嫨寮圭獥鏄剧ず鎺у埗
+ showStationDialog: false,
tableData: [],
- dictionaryList: null, // 鏂板锛氬瓧鍏告暟鎹�
+ dictionaryList: null,
tableColumns: [
- {
- prop: "materielCode",
- title: "鐗╂枡缂栧彿",
- type: "string",
- width: 150,
- },
- {
- prop: "materielName",
- title: "鐗╂枡鍚嶇О",
- type: "string",
- width: 150,
- },
- {
- prop: "palletCode",
- title: "鎵樼洏缂栧彿",
- type: "string",
- width: 150,
- },
- {
- prop: "barcode",
- title: "鏉$爜",
- type: "string",
- width: 150,
- },
- {
- prop: "locationCode",
- title: "璐т綅缂栧彿",
- type: "string",
- width: 180,
- },
- {
- prop: "useableQuantity",
- title: "鍙敤鏁伴噺",
- type: "string",
- },
- {
- prop: "supplyCode",
- title: "渚涘簲鍟�",
- type: "string",
- },
- {
- prop: "batchNo",
- title: "鎵规鍙�",
- type: "string",
- },
+ { prop: "materielCode", title: "鐗╂枡缂栧彿", type: "string", width: 150 },
+ { prop: "materielName", title: "鐗╂枡鍚嶇О", type: "string", width: 150 },
+ { prop: "palletCode", title: "鎵樼洏缂栧彿", type: "string", width: 150 },
+ { prop: "barcode", title: "鏉$爜", type: "string", width: 150 },
+ { prop: "locationCode", title: "璐т綅缂栧彿", type: "string", width: 180 },
+ { prop: "useableQuantity", title: "鍙敤鏁伴噺", type: "string" },
+ { prop: "supplyCode", title: "渚涘簲鍟�", type: "string" },
+ { prop: "batchNo", title: "鎵规鍙�", type: "string" },
{
prop: "stockStatus",
title: "搴撳瓨鏄庣粏鐘舵��",
@@ -217,54 +181,48 @@
width: 90,
bindKey: "stockStatusEmun",
},
- {
- prop: "stockId",
- title: "搴撳瓨涓婚敭",
- type: "string",
- },
- {
- prop: "orderDetailId",
- title: "鍗曟嵁鏄庣粏涓婚敭",
- type: "string",
- },
+ { prop: "stockId", title: "搴撳瓨涓婚敭", type: "string" },
+ { prop: "orderDetailId", title: "鍗曟嵁鏄庣粏涓婚敭", type: "string" },
],
selection: [],
selectionSum: 0,
selectionClass: "less-style",
originalQuantity: 0,
-
- // 绔欏彴鐩稿叧鏁版嵁
+
stations: [
{ label: "绔欏彴2", value: "2-1" },
{ label: "绔欏彴3", value: "3-1" },
],
stationForm: {
- selectedPlatform: "", // 淇敼瀛楁鍚嶄互鍖归厤鍙傛暟
+ selectedPlatform: "",
},
+ isProcessingSelect: false,
};
+ },
+ computed: {
+ requireQuantity() {
+ if (!this.row) return 0;
+ return this.row.orderQuantity - this.row.lockQuantity - (this.row.moveQty || 0);
+ },
+ isFull() {
+ return this.selectionSum >= this.requireQuantity && this.requireQuantity > 0;
+ }
},
methods: {
open(row, orderNo) {
this.row = row;
this.mainOrderNo = orderNo;
this.showDetialBox = true;
- this.originalQuantity = this.row.lockQuantity;
- this.selectionSum = this.row.lockQuantity;
-
- // 鍔犺浇瀛楀吀鏁版嵁
+
+ this.originalQuantity = 0;
+ this.selectionSum = 0;
+ this.selection = [];
+
this.getDictionaryData();
this.getData();
-
- if (this.selectionSum == this.row.orderQuantity) {
- this.selectionClass = "equle-style";
- } else if (this.selectionSum < this.row.orderQuantity) {
- this.selectionClass = "less-style";
- } else {
- this.selectionClass = "more-style";
- }
+ this.updateSelectionStyle();
},
- // 鑾峰彇瀛楀吀鏁版嵁
getDictionaryData() {
if (this.dictionaryList) {
return;
@@ -284,7 +242,6 @@
});
},
- // 鑾峰彇瀛楀吀鍊�
getDictionary(row, column) {
if (this.dictionaryList) {
var item = this.dictionaryList.find((x) => x.dicNo == column.bindKey);
@@ -295,40 +252,32 @@
} else {
return row[column.prop];
}
- } else {
- return row[column.prop];
}
}
return row[column.prop];
},
- // 鎵撳紑绔欏彴閫夋嫨寮圭獥
openStationDialog() {
if (this.selection.length <= 0) {
return this.$message.error("璇峰厛鍕鹃�夎鍑哄簱鐨勫簱瀛�");
}
-
- // 浠庣紦瀛樹腑鑾峰彇榛樿绔欏彴
const cachedStation = stationManager.getStation();
this.stationForm.selectedPlatform = cachedStation || "";
-
this.showStationDialog = true;
},
- // 纭鍑哄簱
async confirmOutbound() {
if (!this.stationForm.selectedPlatform) {
return this.$message.error("璇烽�夋嫨鍑哄簱绔欏彴");
}
- // 鍑嗗璇锋眰鍙傛暟
const requestParams = {
- detailIds: [this.row.id], // 鍑哄簱鍗曠殑鏄庣粏ID
- outboundTargetLocation: this.stationForm.selectedPlatform, // 閫夋嫨鐨勭珯鍙�
- outboundQuantity: this.selectionSum, // 宸查�夋暟閲�
- operator: this.getCurrentOperator(), // 鑾峰彇褰撳墠鎿嶄綔浜�
- orderNo: this.mainOrderNo, // 鍗曟嵁缂栧彿
- stockDetailIds: this.selection.map(item => item.stockId) // 搴撳瓨鏄庣粏涓婚敭鏁扮粍
+ detailIds: [this.row.id],
+ outboundTargetLocation: this.stationForm.selectedPlatform,
+ outboundQuantity: this.selectionSum,
+ operator: this.getCurrentOperator(),
+ orderNo: this.mainOrderNo,
+ stockDetailIds: this.selection.map((item) => item.stockId),
};
try {
@@ -337,11 +286,9 @@
requestParams,
"鏁版嵁澶勭悊涓�"
);
-
if (!x.status) {
return this.$message.error(x.message);
}
-
this.$message.success("鍑哄簱浠诲姟鍒涘缓鎴愬姛");
this.showStationDialog = false;
this.showDetialBox = false;
@@ -353,25 +300,18 @@
}
},
- // 鑾峰彇褰撳墠鎿嶄綔浜�
getCurrentOperator() {
- // 鍙互浠庢湰鍦板瓨鍌ㄣ�乂uex鎴栧叏灞�鐘舵�佷腑鑾峰彇褰撳墠鐢ㄦ埛
try {
- // 绀轰緥锛氫粠localStorage鑾峰彇鐢ㄦ埛淇℃伅
- const userInfo = JSON.parse(localStorage.getItem('userInfo') || '{}');
+ const userInfo = JSON.parse(localStorage.getItem("userInfo") || "{}");
if (userInfo.userName) {
return userInfo.userName;
}
-
- // 绀轰緥锛氫粠Vuex鑾峰彇鐢ㄦ埛淇℃伅
if (this.$store && this.$store.state.user) {
return this.$store.state.user.userName;
}
} catch (error) {
- console.error('鑾峰彇鎿嶄綔浜轰俊鎭け璐�:', error);
+ console.error("鑾峰彇鎿嶄綔浜轰俊鎭け璐�:", error);
}
-
- // 榛樿鎿嶄綔浜�
return "admin";
},
@@ -389,96 +329,111 @@
)
.then((x) => {
this.tableData = x;
+ this.clearSelection();
});
},
- handleSelectionChange(val) {
- this.selection = val;
- this.selectionSum =
- val.reduce(
- (accumulator, currentValue) =>
- accumulator + currentValue["useableQuantity"],
- 0
- ) + this.originalQuantity;
- if (this.selectionSum == this.row.orderQuantity) {
- this.selectionClass = "equle-style";
- } else if (this.selectionSum < this.row.orderQuantity) {
- this.selectionClass = "less-style";
- } else {
- this.selectionClass = "more-style";
+ // 鐐瑰嚮琛屽嬀閫� - 鏈�缁堜慨澶嶇増
+ handleRowClick(row) {
+ // 鍒ゆ柇褰撳墠琛屾槸鍚﹀凡閫変腑
+ const isSelected = this.selection.some(s => s.stockId === row.stockId);
+
+ // 宸查�変腑 鈫� 鍏佽鍙栨秷鍕鹃��
+ if (isSelected) {
+ this.$refs.singleTable.toggleRowSelection(row);
+ return;
+ }
+
+ // 鏈�変腑 + 宸叉弧 鈫� 绂佹鏂板锛屾姤閿�
+ if (this.isFull) {
+ this.$message.error(`宸茶揪鍒伴渶姹傛暟閲� ${this.requireQuantity}锛屾棤娉曞啀鍕鹃�夊簱瀛橈紒`);
+ return;
+ }
+
+ // 姝e父鍕鹃��
+ this.$refs.singleTable.toggleRowSelection(row);
+ },
+
+ // 鍕鹃�夋閫夋嫨 - 鏈�缁堜慨澶嶇増
+ selectRowChange(selection, row) {
+ if (this.isProcessingSelect) return;
+
+ const isAdding = selection.some(x => x.stockId === row.stockId);
+
+ // 鏂板鍕鹃�� + 宸叉弧 鈫� 鎷︽埅
+ if (isAdding && this.isFull) {
+ this.isProcessingSelect = true;
+ this.$message.error(`宸茶揪鍒伴渶姹傛暟閲� ${this.requireQuantity}锛屾棤娉曞啀鍕鹃�夛紒`);
+ this.$nextTick(() => {
+ this.$refs.singleTable.toggleRowSelection(row, false);
+ this.isProcessingSelect = false;
+ });
}
},
- toggleSelection(rows) {
- if (rows) {
- rows.forEach((row) => {
- this.$refs.singleTable.toggleRowSelection(row);
- });
- } else {
+ // 鍏ㄩ�� - 鏈�缁堜慨澶嶇増
+ selectAllChange(selection) {
+ if (this.isProcessingSelect) return;
+
+ const allTotal = this.tableData.reduce((sum, item) => sum + (item.useableQuantity || 0), 0);
+ const need = this.requireQuantity;
+
+ if (allTotal > need && selection.length > 0) {
+ this.isProcessingSelect = true;
+ this.$message.error(`鍏ㄩ�夋暟閲忚秴鍑洪渶姹傦紝宸叉竻绌洪�夋嫨锛乣);
+
this.$refs.singleTable.clearSelection();
+ this.selection = [];
+ this.selectionSum = 0;
+ this.updateSelectionStyle();
+
+ this.$nextTick(() => {
+ this.isProcessingSelect = false;
+ });
+ }
+ },
+
+ // 閫夋嫨璁$畻
+ handleSelectionChange(val) {
+ if (this.isProcessingSelect) return;
+
+ let total = val.reduce((s, i) => s + (i.useableQuantity || 0), 0);
+ const need = this.requireQuantity;
+
+ this.selectionSum = total >= need ? need : total;
+ this.selection = val;
+ this.updateSelectionStyle();
+ },
+
+ updateSelectionStyle() {
+ if (this.isFull) {
+ this.selectionClass = "equle-style";
+ } else {
+ this.selectionClass = "less-style";
}
},
clearSelection() {
this.$refs.singleTable.clearSelection();
- },
-
- handleRowClick(row) {
- this.$refs.singleTable.toggleRowSelection(row);
+ this.selection = [];
+ this.selectionSum = 0;
+ this.updateSelectionStyle();
},
},
};
</script>
<style scoped>
-.less-style {
- color: black;
-}
-
-.equle-style {
- color: green;
-}
-
-.more-style {
- color: red;
-}
-
-/* 绔欏彴閫夋嫨寮圭獥鏍峰紡 */
-.station-dialog-content {
- padding: 10px 0;
-}
-
-.dialog-footer {
- display: flex;
- justify-content: flex-end;
- gap: 10px;
-}
-
-.text-button:hover {
- background-color: #f0f9eb !important;
-}
-
-.el-table .warning-row {
- background: oldlace;
-}
-
-.box-table .el-table tbody tr:hover > td {
- background-color: #d8e0d4 !important;
-}
-
-.box-table .el-table tbody tr.current-row > td {
- background-color: #f0f9eb !important;
-}
-
-.el-table .success-row {
- background: #f0f9eb;
-}
-
-.box-table .el-table {
- border: 1px solid #ebeef5;
-}
-
-.box-head .el-alert__content {
- width: 100%;
-}
+.less-style { color: black; }
+.equle-style { color: green; }
+.more-style { color: red; }
+.station-dialog-content { padding: 10px 0; }
+.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; }
+.text-button:hover { background-color: #f0f9eb !important; }
+.el-table .warning-row { background: oldlace; }
+.box-table .el-table tbody tr:hover > td { background-color: #d8e0d4 !important; }
+.box-table .el-table tbody tr.current-row > td { background-color: #f0f9eb !important; }
+.el-table .success-row { background: #f0f9eb; }
+.box-table .el-table { border: 1px solid #ebeef5; }
+.box-head .el-alert__content { width: 100%; }
</style>
\ No newline at end of file
--
Gitblit v1.9.3