瀏覽代碼

单证底部增加相关产品信息展示,且产品一样的合并

cz 1 年之前
父節點
當前提交
3179a88ebd
共有 1 個文件被更改,包括 47 次插入0 次删除
  1. 47 0
      src/views/salesMange/shipmentMange/document/index.vue

+ 47 - 0
src/views/salesMange/shipmentMange/document/index.vue

@@ -2648,6 +2648,27 @@ const clickToView = (item) => {
   proxy
     .get("/documents/generateInvoiceAPackPdf", { id: rowData.value.id })
     .then((res) => {
+      let arr = [];
+      for (let i = 0; i < res.data.documentsProducts.length; i++) {
+        const ele = res.data.documentsProducts[i];
+        let index = -1;
+        if (i === 0) {
+          arr.push(ele);
+        } else {
+          const isHaveProduct = arr.some((x, i) => {
+            if (x.productId === ele.productId) {
+              index = i;
+              return true;
+            }
+          });
+          if (isHaveProduct && index >= 0) {
+            arr[index].quantity += ele.quantity;
+          } else {
+            arr.push(ele);
+          }
+        }
+      }
+      res.data.documentsProducts = arr;
       printDetails.value = res.data;
     });
 };
@@ -2694,6 +2715,32 @@ const clickPrint = (status) => {
       .then((res) => {
         if (res.data.content) {
           res.data.content = JSON.parse(res.data.content);
+          if (
+            res.data.content.products &&
+            res.data.content.products.length > 0
+          ) {
+            let arr = [];
+            for (let i = 0; i < res.data.content.products.length; i++) {
+              const ele = res.data.content.products[i];
+              let index = -1;
+              if (i === 0) {
+                arr.push(ele);
+              } else {
+                const isHaveProduct = arr.some((x, i) => {
+                  if (x.productId === ele.productId) {
+                    index = i;
+                    return true;
+                  }
+                });
+                if (isHaveProduct && index >= 0) {
+                  arr[index].quantity += ele.quantity;
+                } else {
+                  arr.push(ele);
+                }
+              }
+            }
+            res.data.content.products = arr;
+          }
         }
         printCustomsDeclaration.value = res.data;
       });