Parcourir la source

1、优化床垫清单刷新配置,刷新清单逻辑

MY il y a 6 jours
Parent
commit
f03e7462f8
1 fichiers modifiés avec 42 ajouts et 9 suppressions
  1. 42 9
      JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

+ 42 - 9
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -1918,6 +1918,8 @@ export const useHooks = (t?: any) => {
     const copyMap = new Map();
     let matchQty = 0;
 
+    // bj_namemx字段不修改
+    const PRESERVE_PROPS = ["bj_namemx"];
     const COMMON_PRESERVED_PROPS = ["bj_inputtype", "erp_pzname", "erp_pzcode", "bj_pzname", "bj_namemx", "itemname"];
     const SPECIAL_PRESERVED_PROPS = ["actual_size", "sb_craft", "actual_size_sb", "ss_rate", "ls_rate"];
     const FULL_PRESERVED_PROPS = [...COMMON_PRESERVED_PROPS, ...SPECIAL_PRESERVED_PROPS];
@@ -1932,16 +1934,30 @@ export const useHooks = (t?: any) => {
         const key = `${mx.erp_pzid}`;
         if (copyMap.has(key)) {
           matchQty++;
-          const mx2 = copyMap.get(key);
-          if (mx2.bj_inputtype === 2) {
-            SPECIAL_PRESERVED_PROPS.forEach(prop => {
-              mx[prop] = mx2[prop];
-            });
+          const oldMx = copyMap.get(key);
+          if (oldMx.bj_inputtype === 2) {
+            const tempMx = {};
+            for (const key in oldMx) {
+              if (!PRESERVE_PROPS.includes(key)) {
+                tempMx[key] = oldMx[key];
+              }
+            }
+
+            for (const key in tempMx) {
+              mx[key] = tempMx[key];
+            }
           } else {
-            FULL_PRESERVED_PROPS.forEach(prop => {
-              mx[prop] = mx2[prop];
-            });
+            mx = oldMx;
           }
+          // if (mx2.bj_inputtype === 2) {
+          //   SPECIAL_PRESERVED_PROPS.forEach(prop => {
+          //     mx[prop] = mx2[prop];
+          //   });
+          // } else {
+          //   FULL_PRESERVED_PROPS.forEach(prop => {
+          //     mx[prop] = mx2[prop];
+          //   });
+          // }
           mx.haschange = 1;
         } else {
           mx.haschange = 0;
@@ -2061,9 +2077,26 @@ export const useHooks = (t?: any) => {
         const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
         if (copyMap.has(key)) {
           matchQty++;
+
+          const oldMx = copyMap.get(key);
+          const tempMx = {};
           PRESERVE_PROPS.forEach(prop => {
-            mx[prop] = copyMap.get(key)[prop];
+            tempMx[prop] = oldMx[prop];
           });
+
+          for (const key in oldMx) {
+            // 筛选条件:obj1[key]不为空且obj2[key]为空
+            if (oldMx[key] !== "" && (mx[key] === "" || !(key in mx))) {
+              tempMx[key] = oldMx[key];
+            }
+          }
+
+          for (const key in tempMx) {
+            mx[key] = tempMx[key];
+          }
+          // PRESERVE_PROPS.forEach(prop => {
+          //   mx[prop] = copyMap.get(key)[prop];
+          // });
         }
         return mx;
       });