From 1378fc4cd7abc24ed3a982e09437c2c8a74e9f2f Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期二, 27 一月 2026 19:06:32 +0800
Subject: [PATCH] 代码优化
---
项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/StockSelect.vue | 291 ++++++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 223 insertions(+), 68 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 f2e53d8..0fc8112 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"
@@ -1,5 +1,6 @@
<template>
<div>
+ <!-- 搴撳瓨鎸囧畾寮圭獥 -->
<vol-box
v-model="showDetialBox"
:lazy="true"
@@ -26,13 +27,6 @@
</span>
</el-col>
<el-col :span="8">
- <!-- <el-link
- type="primary"
- size="small"
- style="float: right; height: 20px"
- @click="getData(false)"
- >{{ kcname }}</el-link
- > -->
<el-link
type="primary"
size="small"
@@ -40,13 +34,6 @@
@click="getData"
>鍒锋柊</el-link
>
- <!-- <el-link
- type="primary"
- size="small"
- style="float: right; height: 20px; margin-right: 10px"
- @click="revokeAssign"
- >鎾ら攢鍒嗛厤</el-link
- > -->
</el-col>
</el-row>
</el-alert>
@@ -61,7 +48,6 @@
height="500px"
@selection-change="handleSelectionChange"
>
- >
<el-table-column type="selection" width="55"> </el-table-column>
<el-table-column
label="搴忓彿"
@@ -78,46 +64,106 @@
:width="item.width"
align="center"
>
- <template #default="scoped" v-if="item.type == 'icon'">
- <el-tooltip
- class="item"
- effect="dark"
- :content="item.title"
- placement="bottom"
- ><el-button
- type="text"
- @click="tableButtonClick(scoped.row, item)"
- ><i :class="item.icon" style="font-size: 22px"></i></el-button
- ></el-tooltip>
+ <template #default="scoped">
+ <div v-if="item.type == 'icon'">
+ <el-tooltip
+ class="item"
+ effect="dark"
+ :content="item.title"
+ placement="bottom"
+ ><el-button
+ type="text"
+ @click="tableButtonClick(scoped.row, item)"
+ ><i :class="item.icon" style="font-size: 22px"></i></el-button
+ ></el-tooltip>
+ </div>
+ <div v-else-if="item.type == 'tag'">
+ <el-tag size="small">
+ {{ getDictionary(scoped.row, item) }}
+ </el-tag>
+ </div>
+ <div v-else>
+ {{ scoped.row[item.prop] }}
+ </div>
</template>
</el-table-column>
</el-table>
</div>
<template #footer>
- <el-button type="primary" size="small" @click="outbound"
+ <el-button type="primary" size="small" @click="openStationDialog"
>鐩存帴鍑哄簱</el-button
>
-
<el-button type="danger" size="small" @click="showDetialBox = false"
>鍏抽棴</el-button
>
</template>
</vol-box>
+
+ <!-- 绔欏彴閫夋嫨寮圭獥 -->
+ <el-dialog
+ v-model="showStationDialog"
+ title="閫夋嫨鍑哄簱绔欏彴"
+ width="500px"
+ :close-on-click-modal="false"
+ >
+ <div class="station-dialog-content">
+ <el-form :model="stationForm" label-width="100px">
+ <el-form-item label="閫夋嫨绔欏彴锛�" required>
+ <el-select
+ v-model="stationForm.selectedPlatform"
+ placeholder="璇烽�夋嫨鍑哄簱绔欏彴"
+ style="width: 100%"
+ >
+ <el-option
+ v-for="item in stations"
+ :key="item.value"
+ :label="item.label"
+ :value="item.value"
+ ></el-option>
+ </el-select>
+ </el-form-item>
+ <el-form-item label="鍑哄簱鏁伴噺锛�">
+ <el-input
+ v-model="selectionSum"
+ readonly
+ style="width: 100%"
+ ></el-input>
+ </el-form-item>
+ <el-form-item label="鐗╂枡淇℃伅锛�">
+ <div style="font-size: 12px; color: #666; line-height: 1.5">
+ <div>鐗╂枡缂栧彿锛歿{ row.materielCode }}</div>
+ <div>鐗╂枡鍚嶇О锛歿{ row.materielName }}</div>
+ </div>
+ </el-form-item>
+ </el-form>
+ </div>
+ <template #footer>
+ <span class="dialog-footer">
+ <el-button @click="showStationDialog = false">鍙栨秷</el-button>
+ <el-button type="primary" @click="confirmOutbound">纭鍑哄簱</el-button>
+ </span>
+ </template>
+ </el-dialog>
</div>
</template>
+
<script>
import VolBox from "@/components/basic/VolBox.vue";
-import { fa } from "element-plus/es/locales.mjs";
+// 寮曞叆绔欏彴绠$悊宸ュ叿
+import { stationManager } from "@/../src/uitils/stationManager";
+
export default {
components: { VolBox },
data() {
return {
row: null,
kcname: "",
- mainOrderNo: '',
+ mainOrderNo: "",
pkcx: false,
showDetialBox: false,
+ showStationDialog: false, // 绔欏彴閫夋嫨寮圭獥鏄剧ず鎺у埗
tableData: [],
+ dictionaryList: null, // 鏂板锛氬瓧鍏告暟鎹�
tableColumns: [
{
prop: "materielCode",
@@ -165,10 +211,18 @@
type: "string",
},
{
+ prop: "stockStatus",
+ title: "搴撳瓨鏄庣粏鐘舵��",
+ type: "tag",
+ width: 90,
+ bindKey: "stockStatusEmun",
+ },
+ {
prop: "stockId",
title: "搴撳瓨涓婚敭",
type: "string",
- },{
+ },
+ {
prop: "orderDetailId",
title: "鍗曟嵁鏄庣粏涓婚敭",
type: "string",
@@ -178,15 +232,27 @@
selectionSum: 0,
selectionClass: "less-style",
originalQuantity: 0,
+
+ // 绔欏彴鐩稿叧鏁版嵁
+ stations: [
+ { label: "绔欏彴2", value: "2-1" },
+ { label: "绔欏彴3", value: "3-1" },
+ ],
+ stationForm: {
+ selectedPlatform: "", // 淇敼瀛楁鍚嶄互鍖归厤鍙傛暟
+ },
};
},
methods: {
open(row, orderNo) {
- this.row = row;
- this.mainOrderNo = orderNo; // 瀛樺偍涓诲崟鎹紪鍙�
- this.showDetialBox = true;
+ this.row = row;
+ this.mainOrderNo = orderNo;
+ this.showDetialBox = true;
this.originalQuantity = this.row.lockQuantity;
this.selectionSum = this.row.lockQuantity;
+
+ // 鍔犺浇瀛楀吀鏁版嵁
+ this.getDictionaryData();
this.getData();
if (this.selectionSum == this.row.orderQuantity) {
@@ -197,40 +263,118 @@
this.selectionClass = "more-style";
}
},
- lockStock() {
- this.http
- .post(
- "api/OutboundOrderDetail/LockOutboundStock?id=" + this.row.id,
- this.selection,
- "鏁版嵁澶勭悊涓�"
- )
- .then((x) => {
- if (!x.status) return this.$message.error(x.message);
- this.$message.success("鎿嶄綔鎴愬姛");
- this.showDetialBox = false;
- this.$emit("parentCall", ($vue) => {
- $vue.getData();
- });
- });
- },
- outbound() {
- if (this.selection.length <= 0) {
- return this.$message.error("璇峰嬀閫�");
+
+ // 鑾峰彇瀛楀吀鏁版嵁
+ getDictionaryData() {
+ if (this.dictionaryList) {
+ return;
}
- let url = this.pkcx
- ? "api/Task/GenerateOutboundTask?orderDetailId="
- : "api/Task/GenerateOutboundTask?orderDetailId=";
+ var param = [];
+ this.tableColumns.forEach((x) => {
+ if (x.type == "tag" && x.bindKey != "") {
+ param.push(x.bindKey);
+ }
+ });
this.http
- .post(url + this.row.id, this.selection, "鏁版嵁澶勭悊涓�")
+ .post("api/Sys_Dictionary/GetVueDictionary", param, "鏌ヨ涓�")
.then((x) => {
- if (!x.status) return this.$message.error(x.message);
- this.$message.success("鎿嶄綔鎴愬姛");
- this.showDetialBox = false;
- this.$emit("parentCall", ($vue) => {
- $vue.getData();
- });
+ if (x.length > 0) {
+ this.dictionaryList = x;
+ }
});
},
+
+ // 鑾峰彇瀛楀吀鍊�
+ getDictionary(row, column) {
+ if (this.dictionaryList) {
+ var item = this.dictionaryList.find((x) => x.dicNo == column.bindKey);
+ if (item) {
+ var dicItem = item.data.find((x) => x.key == row[column.prop]);
+ if (dicItem) {
+ return dicItem.value;
+ } 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) // 搴撳瓨鏄庣粏涓婚敭鏁扮粍
+ };
+
+ try {
+ const x = await this.http.post(
+ "api/Outbound/ProcessPickingOutbound",
+ requestParams,
+ "鏁版嵁澶勭悊涓�"
+ );
+
+ if (!x.status) {
+ return this.$message.error(x.message);
+ }
+
+ this.$message.success("鍑哄簱浠诲姟鍒涘缓鎴愬姛");
+ this.showStationDialog = false;
+ this.showDetialBox = false;
+ this.$emit("parentCall", ($vue) => {
+ $vue.getData();
+ });
+ } catch (error) {
+ this.$message.error(error.message || "鍑哄簱澶勭悊澶辫触");
+ }
+ },
+
+ // 鑾峰彇褰撳墠鎿嶄綔浜�
+ getCurrentOperator() {
+ // 鍙互浠庢湰鍦板瓨鍌ㄣ�乂uex鎴栧叏灞�鐘舵�佷腑鑾峰彇褰撳墠鐢ㄦ埛
+ try {
+ // 绀轰緥锛氫粠localStorage鑾峰彇鐢ㄦ埛淇℃伅
+ 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);
+ }
+
+ // 榛樿鎿嶄綔浜�
+ return "admin";
+ },
+
getData(a) {
if (!a) this.pkcx = !this.pkcx;
let url = this.pkcx
@@ -247,7 +391,7 @@
this.tableData = x;
});
},
-
+
handleSelectionChange(val) {
this.selection = val;
this.selectionSum =
@@ -264,6 +408,7 @@
this.selectionClass = "more-style";
}
},
+
toggleSelection(rows) {
if (rows) {
rows.forEach((row) => {
@@ -273,15 +418,18 @@
this.$refs.singleTable.clearSelection();
}
},
+
clearSelection() {
this.$refs.singleTable.clearSelection();
},
+
handleRowClick(row) {
this.$refs.singleTable.toggleRowSelection(row);
},
},
};
</script>
+
<style scoped>
.less-style {
color: black;
@@ -294,9 +442,18 @@
.more-style {
color: red;
}
-</style>
-<style>
+/* 绔欏彴閫夋嫨寮圭獥鏍峰紡 */
+.station-dialog-content {
+ padding: 10px 0;
+}
+
+.dialog-footer {
+ display: flex;
+ justify-content: flex-end;
+ gap: 10px;
+}
+
.text-button:hover {
background-color: #f0f9eb !important;
}
@@ -307,12 +464,10 @@
.box-table .el-table tbody tr:hover > td {
background-color: #d8e0d4 !important;
- /* color: #ffffff; */
}
.box-table .el-table tbody tr.current-row > td {
background-color: #f0f9eb !important;
- /* color: #ffffff; */
}
.el-table .success-row {
--
Gitblit v1.9.3