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/stock/stockView.js | 168 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 167 insertions(+), 1 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/stock/stockView.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/stock/stockView.js"
index c58c825..f786268 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/stock/stockView.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/stock/stockView.js"
@@ -1,4 +1,5 @@
-
+import { createVNode, render, h, reactive } from 'vue';
+import { ElDialog, ElForm, ElFormItem, ElSelect, ElOption, ElButton, ElMessage, ElLoading } from 'element-plus';
let extension = {
components: {
//鏌ヨ鐣岄潰鎵╁睍缁勪欢
@@ -156,6 +157,171 @@
}
}
})
+
+ let SelectTake = this.buttons.find(x => x.value == 'SelectStockTake');
+if (SelectTake) {
+ // 鏀逛负绠ご鍑芥暟纭繚this鎸囧悜Vue缁勪欢瀹炰緥
+ SelectTake.onClick = async () => {
+ // 鑾峰彇閫変腑鏁版嵁锛堜笌鍘熼�昏緫涓�鑷达紝纭繚鏄暟缁勬牸寮忥級
+ let stockViews = this.$refs.table.getSelected();
+
+ // 鏁版嵁鏍¢獙锛氳嚦灏戦�夋嫨涓�鏉℃暟鎹�
+ if (stockViews.length === 0) return ElMessage.error("璇烽�夋嫨闇�瑕佹搷浣滅殑鏁版嵁!");
+
+ // 绔欏彴閫夐」锛堝彲鏍规嵁瀹為檯涓氬姟璋冩暣閫夐」鍊硷級
+ const stationOptions = [
+ { label: "绔欏彴2", value: "2-1" },
+ { label: "绔欏彴3", value: "3-1" },
+ { label: "绔欏彴4", value: "4-1" },
+ ];
+
+ // 鍒涘缓寮圭獥鎸傝浇鑺傜偣
+ const mountNode = document.createElement("div");
+ document.body.appendChild(mountNode);
+
+ // 琛ㄥ崟鏁版嵁锛堢粦瀹氶�変腑鐨勭珯鍙帮級
+ const formData = reactive({
+ outStation: stationOptions[0].value, // 榛樿閫変腑绗竴涓珯鍙�
+ });
+
+ // 鍒涘缓寮圭獥VNode
+ const vnode = createVNode(
+ ElDialog,
+ {
+ title: "搴撳瓨鎿嶄綔 - 閫夋嫨鍑哄簱绔欏彴",
+ width: "500px",
+ modelValue: true,
+ appendToBody: true,
+ "onUpdate:modelValue": (isVisible) => {
+ if (!isVisible) {
+ render(null, mountNode);
+ document.body.removeChild(mountNode);
+ }
+ },
+ style: {
+ padding: "20px 0",
+ borderRadius: "8px",
+ },
+ },
+ {
+ default: () =>
+ h(
+ ElForm,
+ {
+ model: formData,
+ rules: {
+ outStation: [
+ { required: true, message: "璇烽�夋嫨鍑哄簱绔欏彴", trigger: "change" },
+ ],
+ },
+ ref: "stockTakeForm", // 琛ㄥ崟ref鏍囪瘑
+ labelWidth: "100px",
+ style: {
+ padding: "0 30px",
+ },
+ },
+ [
+ // 绔欏彴閫夋嫨涓嬫媺妗�
+ h(ElFormItem, {
+ label: "鍑哄簱绔欏彴",
+ prop: "outStation",
+ style: { marginBottom: "24px" },
+ }, [
+ h(ElSelect, {
+ placeholder: "璇烽�夋嫨鍑哄簱绔欏彴",
+ modelValue: formData.outStation,
+ "onUpdate:modelValue": (val) => {
+ formData.outStation = val;
+ },
+ style: {
+ width: "100%",
+ height: "40px",
+ borderRadius: "4px",
+ borderColor: "#dcdfe6",
+ },
+ }, stationOptions.map((station) =>
+ h(ElOption, { label: station.label, value: station.value })
+ )),
+ ]),
+ // 搴曢儴鎸夐挳鍖哄煙
+ h("div", {
+ style: {
+ textAlign: "right",
+ marginTop: "8px",
+ paddingRight: "4px",
+ },
+ }, [
+ // 鍙栨秷鎸夐挳
+ h(ElButton, {
+ type: "text",
+ onClick: () => {
+ render(null, mountNode);
+ document.body.removeChild(mountNode);
+ ElMessage.info("鍙栨秷搴撳瓨鎿嶄綔");
+ },
+ style: { marginRight: "8px", color: "#606266" },
+ }, "鍙栨秷"),
+ // 纭畾鎸夐挳
+ h(ElButton, {
+ type: "primary",
+ onClick: async () => {
+ // 纭繚琛ㄥ崟ref宸叉寕杞�
+ await this.$nextTick();
+ const formRef = vnode.component.refs.stockTakeForm;
+
+ if (!formRef) {
+ ElMessage.error("琛ㄥ崟鍒濆鍖栧け璐ワ紝璇烽噸璇�");
+ return;
+ }
+
+ // 琛ㄥ崟楠岃瘉
+ try {
+ await formRef.validate();
+ } catch (err) {
+ return;
+ }
+
+ const requestBody = stockViews;
+ const outStation = formData.outStation;
+
+ try {
+
+ const url = `api/Task/TakeOutbound?outStation=${encodeURIComponent(outStation)}`;
+
+ const x = await this.http.post(
+ url, // 甯︽煡璇㈠弬鏁扮殑URL
+ requestBody, // 璇锋眰浣擄細stockViews鏁扮粍
+ "鏁版嵁澶勭悊涓�"
+ );
+
+ if (!x.status) {
+ ElMessage.error(x.message || "搴撳瓨鎿嶄綔澶辫触");
+ return;
+ }
+
+ ElMessage.success("鎿嶄綔鎴愬姛");
+ this.refresh(); // 鍘熷埛鏂伴�昏緫淇濈暀
+ } catch (error) {
+ console.error("搴撳瓨鎺ュ彛璇锋眰澶辫触锛�", error);
+ ElMessage.error("璇锋眰澶辫触锛岃绋嶅悗閲嶈瘯");
+ } finally {
+ // 鏃犺鎴愬姛澶辫触锛屽叧闂脊绐�
+ render(null, mountNode);
+ document.body.removeChild(mountNode);
+ }
+ },
+ style: { borderRadius: "4px", padding: "8px 20px" },
+ }, "纭畾鎿嶄綔"),
+ ]),
+ ]),
+ }
+ );
+
+ // 缁戝畾app涓婁笅鏂囷紙纭繚寮圭獥鍐呯粍浠舵甯稿伐浣滐級
+ vnode.appContext = this.$.appContext;
+ render(vnode, mountNode);
+ };
+}
},
onInited() {
//妗嗘灦鍒濆鍖栭厤缃悗
--
Gitblit v1.9.3