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/inbound/inboundOrder.js |  339 +++++++++-----------------------------------------------
 1 files changed, 55 insertions(+), 284 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
index 8c60161..9176f78 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/inbound/inboundOrder.js"
@@ -1,24 +1,13 @@
 //姝s鏂囦欢鏄敤鏉ヨ嚜瀹氫箟鎵╁睍涓氬姟浠g爜锛屽彲浠ユ墿灞曚竴浜涜嚜瀹氫箟椤甸潰鎴栬�呴噸鏂伴厤缃敓鎴愮殑浠g爜
 import gridHeader from "./extend/EmptyTrayInbound.vue";
 import gridBody from "./extend/Pallet.vue";
-import http from "@/api/http.js";
-import { h, createVNode, render, reactive, ref } from "vue";
-import {
-  ElDialog,
-  ElForm,
-  ElFormItem,
-  ElInput,
-  ElButton,
-  ElMessage,
-  ElSelect,
-  ElOption,
-} from "element-plus";
+import gridFooter from "./extend/UndoPalletGroup.vue";
 let extension = {
   components: {
     //鏌ヨ鐣岄潰鎵╁睍缁勪欢
     gridHeader: gridHeader,
     gridBody: gridBody,
-    gridFooter: "",
+    gridFooter: gridFooter,
     //鏂板缓銆佺紪杈戝脊鍑烘鎵╁睍缁勪欢
     modelHeader: "",
     modelBody: "",
@@ -27,243 +16,7 @@
   tableAction: "", //鎸囧畾鏌愬紶琛ㄧ殑鏉冮檺(杩欓噷濉啓琛ㄥ悕,榛樿涓嶇敤濉啓)
   buttons: {
     view: [
-      {
-        name: "鎾ら攢缁勭洏",
-        type: "primary",
-        value: "鎾ら攢缁勭洏",
-        onClick: function() {
-          console.log("鎾ら攢缁勭洏鎸夐挳琚偣鍑�");
-          const mountNode = document.createElement("div");
-          document.body.appendChild(mountNode);
-
-          // 鍝嶅簲寮忚〃鍗曟暟鎹細鎵樼洏鍙凤紙蹇呭~锛�
-          const formData = reactive({
-            palletCode: "", // 鎵樼洏鍙疯緭鍏ユ
-            barcode: "",
-          });
-
-          // 鎻愪氦琛ㄥ崟鐨勭粺涓�閫昏緫
-          const submitForm = async () => {
-            const formRef = vnode.component.refs.cancelPalletForm;
-            try {
-              // 鎵ц琛ㄥ崟鏍¢獙锛堟墭鐩樺彿蹇呭~锛�
-              await formRef.validate();
-            } catch (err) {
-              ElMessage.warning("璇疯緭鍏ユ湁鏁堢殑鎵樼洏鍙�");
-              return;
-            }
-
-            // 鍙戣捣鎾ら攢缁勭洏璇锋眰
-            try {
-              const response = await http.post(
-                "/api/InboundOrder/UndoPalletGroup?palletCode=" +
-                  formData.palletCode.trim() +
-                  "&barcode=" +
-                  formData.barcode.trim()
-              );
-              const { status, message, data } = response;
-              if (status) {
-                ElMessage.success(response.message);
-                this.refresh(); // 鎴愬姛鍚庡埛鏂板垪琛�
-                // 鍏抽棴瀵硅瘽妗�
-                render(null, mountNode);
-                document.body.removeChild(mountNode);
-              } else {
-                ElMessage.error(message || data?.message || "鎾ら攢缁勭洏澶辫触");
-                selectPalletCodeInput(); // 閫変腑杈撳叆妗嗘柟渚块噸鏂拌緭鍏�
-              }
-            } catch (error) {
-              console.error("鎾ら攢缁勭洏璇锋眰寮傚父锛�", error);
-              ElMessage.error("缃戠粶寮傚父鎴栨帴鍙i敊璇紝璇风◢鍚庨噸璇�");
-              selectPalletCodeInput();
-            }
-          };
-
-          // 閫変腑杈撳叆妗嗘枃鏈紙鏂逛究閲嶆柊杈撳叆锛�
-          const selectPalletCodeInput = () => {
-            setTimeout(() => {
-              const inputRef = vnode.component.refs.palletCodeInput;
-              if (inputRef) {
-                const targetInput =
-                  inputRef.$el?.querySelector("input") || inputRef;
-                targetInput?.focus();
-                targetInput?.select();
-              }
-            }, 100);
-          };
-
-          // 鍒涘缓瀵硅瘽妗哣Node
-          const vnode = createVNode(
-            ElDialog,
-            {
-              title: "鎾ら攢缁勭洏",
-              width: "400px",
-              modelValue: true,
-              appendToBody: true,
-              onOpened: () => {
-                // 瀵硅瘽妗嗘墦寮�鍚庤嚜鍔ㄨ仛鐒﹁緭鍏ユ
-                setTimeout(() => {
-                  const inputRef = vnode.component.refs.palletCodeInput;
-                  inputRef?.focus();
-                }, 100);
-              },
-              "onUpdate:modelValue": (isVisible) => {
-                if (!isVisible) {
-                  render(null, mountNode);
-                  document.body.removeChild(mountNode);
-                }
-              },
-            },
-            {
-              default: () =>
-                h(
-                  ElForm,
-                  {
-                    model: formData,
-                    rules: {
-                      palletCode: [
-                        {
-                          required: true,
-                          message: "璇疯緭鍏ユ墭鐩樺彿",
-                          trigger: ["blur", "enter"],
-                        },
-                        {
-                          min: 1,
-                          max: 50,
-                          message: "鎵樼洏鍙烽暱搴︿笉鑳借秴杩�50涓瓧绗�",
-                          trigger: ["blur", "input"],
-                        },
-                      ],
-                    },
-                    ref: "cancelPalletForm",
-                  },
-                  [
-                    // 鎵樼洏鍙疯緭鍏ラ」
-                    h(
-                      ElFormItem,
-                      { label: "鎵樼洏鏉$爜", prop: "palletCode", required: true },
-                      [
-                        h(ElInput, {
-                          type: "text",
-                          modelValue: formData.palletCode,
-                          "onUpdate:modelValue": (val) => {
-                            formData.palletCode = val;
-                          },
-                          ref: "palletCodeInput",
-                          placeholder: "鎵爜杈撳叆鎴栨墜鍔ㄨ緭鍏ユ墭鐩樺彿",
-                          maxLength: 50,
-                          // 鐩戝惉鍥炶溅浜嬩欢锛堟壂鐮佹灙榛樿浼氬彂閫佸洖杞︼級
-                          onKeydown: (e) => {
-                            if (e.key === "Enter") {
-                              e.preventDefault();
-                              submitForm();
-                            }
-                          },
-                        }),
-                      ]
-                    ),
-                    h(ElFormItem, { label: " 鍐呯鏍囩", prop: "barcode" }, [
-                      h(ElInput, {
-                        type: "text",
-                        modelValue: formData.barcode,
-                        "onUpdate:modelValue": (val) => {
-                          formData.barcode = val;
-                        },
-                        placeholder: "鍙�夛紝鎵爜杈撳叆鎴栨墜鍔ㄨ緭鍏ユ潯鐮�",
-                        maxLength: 50,
-                        onKeydown: (e) => {
-                          if (e.key === "Enter") {
-                            e.preventDefault();
-                            submitForm();
-                          }
-                        },
-                      }),
-                    ]),
-                    // 搴曢儴鎸夐挳鍖�
-                    h(
-                      "div",
-                      { style: { textAlign: "right", marginTop: "16px" } },
-                      [
-                        h(
-                          ElButton,
-                          {
-                            type: "text",
-                            onClick: () => {
-                              render(null, mountNode);
-                              document.body.removeChild(mountNode);
-                              ElMessage.info("鍙栨秷鎾ら攢缁勭洏");
-                            },
-                          },
-                          "鍙栨秷"
-                        ),
-                        h(
-                          ElButton,
-                          {
-                            type: "primary",
-                            onClick: submitForm.bind(this), // 缁戝畾this涓婁笅鏂�
-                          },
-                          "纭鎾ら攢"
-                        ),
-                      ]
-                    ),
-                  ]
-                ),
-            }
-          );
-
-          vnode.appContext = this.$.appContext;
-          render(vnode, mountNode);
-        },
-      },
-      // {
-      //   name: '鍒嗘壒鍏ュ簱',
-      //   type: 'primary',
-      //   value: '鍒嗘壒鍏ュ簱',
-      //   onClick: async function () {
-      //     console.log('鍒嗘壒鍏ュ簱鎸夐挳琚偣鍑伙紝寮�濮嬫牎楠�');
-      //     const selectedRows = this.$refs.table.getSelected();
-
-      //     // 鏍¢獙1锛氭槸鍚﹂�変腑琛岋紙鑷冲皯閫夋嫨涓�鏉★級
-      //     if (selectedRows.length === 0) {
-      //       console.log('鏍¢獙涓嶉�氳繃锛氭湭閫変腑浠讳綍鍗曟嵁');
-      //       ElMessage.warning('璇烽�夋嫨鑷冲皯涓�鏉″崟鎹�');
-      //       return;
-      //     }
-
-      //     // 鏀堕泦鎵�鏈夐�変腑鍗曟嵁鐨勭紪鍙凤紙杩囨护鏃犲崟鎹彿鐨勫紓甯歌锛�
-      //     const inboundOrderNos = selectedRows
-      //       .filter(row => row.inboundOrderNo)
-      //       .map(row => row.inboundOrderNo);
-
-      //     // 鏍¢獙2锛氭槸鍚︽湁鏈夋晥鍗曟嵁鍙�
-      //     if (inboundOrderNos.length === 0) {
-      //       console.log('鏍¢獙涓嶉�氳繃锛氶�変腑鍗曟嵁鏃犳湁鏁堢紪鍙�');
-      //       ElMessage.warning('閫変腑鐨勫崟鎹腑鏃犳湁鏁堢紪鍙凤紝璇烽噸鏂伴�夋嫨');
-      //       return;
-      //     }
-
-      //     try {
-      //       console.log('鍙戣捣鍒嗘壒鍏ュ簱璇锋眰锛屽弬鏁帮細', { inboundOrderNos });
-      //       const response = await http.post('/api/InboundOrder/BatchOrderFeedbackToMes', {
-      //         orderNos: inboundOrderNos,
-      //         inout: 1
-      //       });
-
-      //       const { status, message, data } = response;
-      //       if (status) {
-      //         console.log('鍒嗘壒鍏ュ簱鎴愬姛锛屽悗绔繑鍥烇細', data);
-      //         ElMessage.success(`鍒嗘壒鍏ュ簱鎴愬姛锛乣);
-      //         this.refresh(); // 鍏ュ簱鎴愬姛鍚庡埛鏂板垪琛紙澶嶇敤鍘熸湁閫昏緫锛�
-      //       } else {
-      //         console.log('鍒嗘壒鍏ュ簱澶辫触锛屽悗绔彁绀猴細', message);
-      //         ElMessage.error(message || data?.message || '鍒嗘壒鍏ュ簱澶辫触');
-      //       }
-      //     } catch (error) {
-      //       console.error('鍒嗘壒鍏ュ簱璇锋眰寮傚父锛�', error);
-      //       ElMessage.error('缃戠粶寮傚父鎴栨帴鍙i敊璇紝璇风◢鍚庨噸璇�');
-      //     }
-      //   }
-      // },
+      
     ],
     box: [],
     detail: [],
@@ -279,6 +32,14 @@
           this.$refs.gridHeader.open();
         };
       }
+      var UndoPalletGroupBtn = this.buttons.find(
+        (x) => x.value == "UndoPalletGroup"
+      );
+      if (UndoPalletGroupBtn != null) {
+        UndoPalletGroupBtn.onClick = () => {
+          this.$refs.gridFooter.open();
+        };
+      }
       var BatchInOrderFeedbackToMesBtn = this.buttons.find(
         (x) => x.value == "BatchInOrderFeedbackToMes"
       );
@@ -292,7 +53,7 @@
           if (rows.length > 1) {
             return this.$Message.error("璇烽�夋嫨涓�鏉℃暟鎹�");
           }
-          this.http.post(`api/Inbound/BatchInOrderFeedbackToMes?OrderNo=${rows[0].inboundOrderNo}`,{},"鏁版嵁澶勭悊涓�...")
+          this.http.post(`api/Inbound/BatchInOrderFeedbackToMes?id=${rows[0].id}`, {}, "鏁版嵁澶勭悊涓�...")
             .then((x) => {
               if (x.status) {
                 this.$Message.success(x.message);
@@ -308,34 +69,34 @@
         };
       }
 
-      // let BatchInOrderFeedbackToMesBtn = this.buttons.find((x) => x.value == "BatchInOrderFeedbackToMes");
-      // if (BatchInOrderFeedbackToMesBtn != null) {
-      //   BatchInOrderFeedbackToMesBtn.onClick = ()=> {
-      //     let selectedRows = this.$refs.table.getSelected();
-
-      //     // 鏍¢獙鏄惁鏈夐�変腑鏁版嵁
-      //     if (!selectedRows || selectedRows.length === 0) {
-      //       return this.$Message.warning("璇峰厛閫夋嫨闇�瑕佸鐞嗙殑鍗曟嵁");
-      //     }
-      //     if (selectedRows.length > 1) {
-      //       return this.$Message.warning("璇烽�夋嫨涓�鏉℃暟鎹�");
-      //     }
-      //     this.http.post(`api/Inbound/BatchInOrderFeedbackToMes?orderNo=${selectedRows[0].orderNo}`,{},"鏁版嵁澶勭悊涓�...")
-      //       .then((x) => {
-      //         if (x.status) {
-      //           this.$Message.success("鍒嗘壒鍑哄簱鍥炶皟瀹屾垚");
-      //           this.refresh();
-      //         } else {
-      //           return this.$Message.error("鍒嗘壒鍑哄簱鍥炶皟澶辫触");
-      //         }
-      //       })
-      //       .catch((error) => {
-      //         // 澧炲姞寮傚父鎹曡幏锛屽鐞嗙綉缁滈敊璇瓑鎯呭喌
-      //         //_this.$Message.error('璇锋眰澶辫触锛�' + (error.message || '鏈煡閿欒'));
-      //       });
-      //   };
-      // }
-
+      var CloseOrderBtn = this.buttons.find(
+        (x) => x.value == "CloseOrder"
+      );
+      if (CloseOrderBtn != null) {
+        CloseOrderBtn.onClick = () => {
+          var rows = this.$refs.table.getSelected();
+          // 鏍¢獙鏄惁鏈夐�変腑鏁版嵁
+          if (!rows || rows.length === 0) {
+            return this.$Message.error("璇峰厛閫夋嫨闇�瑕佸叧闂殑鍗曟嵁");
+          }
+          if (rows.length > 1) {
+            return this.$Message.error("璇烽�夋嫨涓�鏉″崟鎹�");
+          }
+          this.http.post(`api/InboundOrder/HandCloseOrder?orderIds=${rows[0].inboundOrderNo}`, {}, "鏁版嵁澶勭悊涓�...")
+            .then((x) => {
+              if (x.status) {
+                this.$Message.success(x.message);
+                this.refresh();
+              } else {
+                return this.$Message.error(x.message);
+              }
+            })
+            .catch((error) => {
+              // 澧炲姞寮傚父鎹曡幏锛屽鐞嗙綉缁滈敊璇瓑鎯呭喌
+              //_this.$Message.error('璇锋眰澶辫触锛�' + (error.message || '鏈煡閿欒'));
+            });
+        };
+      }
       var GroupPalletBtn = this.buttons.find((x) => x.value == "GroupPallet");
       if (GroupPalletBtn != null) {
         GroupPalletBtn.onClick = () => {
@@ -349,18 +110,28 @@
           column.formatter = (row) => {
             // 鏍¢獙details鏄惁瀛樺湪涓旀湁鏁版嵁
             if (row.details && row.details.length > 0) {
-              //鎸塵aterielCode鍒嗙粍缁熻orderQuantity鎬诲拰
+              // 鎸塵aterielCode鍒嗙粍锛屽悓鏃朵繚瀛樺搴旂殑materielName鍜岀粺璁rderQuantity鎬诲拰
               const materielSumMap = row.details.reduce((acc, item) => {
+                const materielName = item.materielName || "鏈煡鍚嶇О";
                 const materielCode = item.materielCode || "鏈煡鐗╂枡";
                 const quantity = Number(item.orderQuantity) || 0;
-                acc[materielCode] = (acc[materielCode] || 0) + quantity;
+
+                // 鏍稿績淇敼锛氫笉鍐嶅彧瀛樻暟閲忥紝鑰屾槸瀛樺寘鍚悕绉板拰鏁伴噺鐨勫璞�
+                if (!acc[materielCode]) {
+                  acc[materielCode] = {
+                    name: materielName, // 瀛樺偍鐗╂枡鍚嶇О
+                    total: 0 // 瀛樺偍鏁伴噺鎬诲拰
+                  };
+                }
+                acc[materielCode].total += quantity;
                 return acc;
               }, {});
 
-              //姣忎釜鐗╂枡椤圭敓鎴愮嫭绔媎iv锛岃法琛屾樉绀�
+              // 姣忎釜鐗╂枡椤圭敓鎴愮嫭绔媎iv锛屾樉绀虹紪鐮�+鍚嶇О+鏁伴噺
               const displayItems = Object.entries(materielSumMap).map(
-                ([code, total]) => {
-                  return `<div style="line-height: 1.5; white-space: normal;">${code}锛�${total}涓�</div>`;
+                ([code, data]) => {
+                  // 鏄剧ず鏍煎紡锛氱墿鏂欑紪鐮侊紙鐗╂枡鍚嶇О锛夛細鏁伴噺涓�
+                  return `<div style="line-height: 1.5; white-space: normal;">${code}锛�${data.name}锛夛細${data.total}涓�</div>`;
                 }
               );
               const displayContent = displayItems.join("");

--
Gitblit v1.9.3