Просмотр исходного кода

1、修复刷新清单和刷新配置错误问题
2、优化刷新清单和刷新配置

MY 22 часов назад
Родитель
Сommit
b5fc147661

+ 2 - 37
JLHHJSvr/Excutor/RefreshMattressInterfaceExcutor.cs

@@ -52,43 +52,8 @@ namespace JLHHJSvr.Excutor
 
                 var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
 
-                if (request.isPz != null && request.isPz == 0)
-                {
-                    var interfaceList = interfaceHelper.RefreshMattressInterfaceList(request.mattressid.Value, request.configcodetype);
-                    copy_list = interfaceList;
-                    //var copyDict = copy_list.Where(mx2 => mx2.erp_pzid > 0)
-                    //            .ToDictionary(mx2 => mx2.erp_pzid, mx2 => mx2);
-
-                    //foreach (var mx in interfaceList)
-                    //{
-                    //    if (mx.erp_pzid > 0 && copyDict.TryGetValue(mx.erp_pzid, out var mx2))
-                    //    {
-                    //        if (mx.bj_inputtype != 2 || (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1))
-                    //        {
-                    //            mx.bj_namemx = mx2.bj_namemx;
-                    //            mx.actual_size = mx2.actual_size;
-                    //            mx.sb_craft = mx2.sb_craft;
-                    //            mx.actual_size_sb = mx2.actual_size_sb;
-                    //            mx.ss_rate = mx2.ss_rate;
-                    //            mx.ls_rate = mx2.ls_rate;
-
-                    //            if (mx.bj_inputtype == 2 && mx2.bj_inputtype == 1)
-                    //            {
-                    //                mx.bj_inputtype = 1;
-                    //            }
-                    //        }
-                    //        else
-                    //        {
-                    //            mx.actual_size = mx2.actual_size;
-                    //            mx.sb_craft = mx2.sb_craft;
-                    //            mx.actual_size_sb = mx2.actual_size_sb;
-                    //            mx.ss_rate = mx2.ss_rate;
-                    //            mx.ls_rate = mx2.ls_rate;
-                    //        }
-                    //    }
-                    //}
-                }
-
+                interfaceHelper.ImportMattressInterfaceList(request.mattressid.Value, copy_list);
+                interfaceHelper.MattressInterfaceFindERPPz(request.mattressid.Value, copy_list, request.configcodetype);
                 rslt.mxList = copy_list;
             }
         }

+ 5 - 6
JLHHJSvr/Excutor/RefreshMattressInterfaceQdExcutor.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Data.SqlClient;
 using System.Linq;
@@ -42,6 +43,7 @@ namespace JLHHJSvr.Excutor
                 }
 
                 var copy_list = new List<u_mattress_interface_qd>();
+                var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
 
                 var selectStr = @"SELECT u_mattress_interface_qd.mattressid 
 	                            ,u_mattress_interface_qd.printid 
@@ -67,15 +69,12 @@ namespace JLHHJSvr.Excutor
                 var outputFields = "mattressid,printid,itemname,bj_pzname,bj_pzname_mx,bj_pzname_mx_mx,mtrlid,erp_mtrlid,useqty,dscrp,mtrlname,actual_useqty,qd_actual_size,qd_pfgroupqty,wrkgrpid,ss_rate,ls_rate,sh_rate,formulaid";
                 DbSqlHelper.SelectJoin(cmd, selectStr, "mattressid = @mattressid", new Dictionary<string, object>() { { "@mattressid", request.mattressid } }, "printid", outputFields, 0, 0, copy_list);
 
-                var interfaceHelper = HelperBase.GetHelper<InterfaceHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
-
-                if (request.isPz != null && request.isPz == 0)
+                if (request.isPz != 1)
                 {
-                    var qdList = interfaceHelper.RefreshMattressInterfaceQdList(request.mattressid.Value);
-                    copy_list = qdList;
+                    interfaceHelper.ImportMattressInterfaceQdList(request.mattressid.Value, copy_list);
                 }
 
-                interfaceHelper.MattressInterfaceFindERPPrdPf(copy_list);
+                interfaceHelper.MattressInterfaceFindERPPrdPf(copy_list, null);
                 rslt.mxList = copy_list;
             }
         }

+ 8 - 6
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -1139,7 +1139,7 @@ namespace JLHHJSvr.Helper
             foreach (var mx in qdList)
             {
                 // 带出有设置 的erp_mtrlid
-                if (mx.erp_mtrlid == 0 && mx.mtrlid != null && mx.mtrlid > 0)
+                if ((mx.erp_mtrlid == null || mx.erp_mtrlid == 0) && mx.mtrlid != null && mx.mtrlid > 0)
                 {
                     var mtrldef = new u_mtrl_price() { mtrlid = mx.mtrlid };
                     if (DbSqlHelper.SelectOne(cmd, mtrldef, "erp_mtrlid") == 1)
@@ -1321,7 +1321,9 @@ namespace JLHHJSvr.Helper
                 {"小侧2",new int[] { 3, 43, 53, 63, 73, 83 } },
                 {"小侧3",new int[] { 3, 43, 53, 63, 73, 83 } },
                 {"V侧1_EMPTY",new int[] { 4, 44, 54, 64, 74, 84 } },
-                {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } }
+                {"V侧1",new int[] { 4, 44, 54, 64, 74, 84 } },
+                {"V侧2",new int[] { 4, 44, 54, 64, 74, 84 } },
+                {"V侧3",new int[] { 4, 44, 54, 64, 74, 84 } }
             };
             var chastrArrDict = new Dictionary<string, string[]>()
             {
@@ -1360,19 +1362,19 @@ namespace JLHHJSvr.Helper
                 {
                     if (mx.mtrlid > 0 && (item.Key.Equals(mx.chastr) || item.Key.Contains("_EMPTY")) && item.Value.Contains(mx.formulakind.Value))
                     {
-                        if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3)
+                        if (mx.formulakind == 0 || mx.formulakind == 1 || mx.formulakind == 2 || mx.formulakind == 3 || mx.formulakind == 4)
                         {
                             qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "布料", mx.mtrlid.Value, mx.useqty.Value, mx.formulaid.Value));
                         }
-                        if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43)
+                        if (mx.formulakind == 40 || mx.formulakind == 41 || mx.formulakind == 42 || mx.formulakind == 43 || mx.formulakind == 44)
                         {
                             qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "喷胶棉", mx.mtrlid.Value, mx.useqty.Value, mx.formulaid.Value));
                         }
-                        if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53)
+                        if (mx.formulakind == 50 || mx.formulakind == 51 || mx.formulakind == 52 || mx.formulakind == 53 || mx.formulakind == 54)
                         {
                             qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "裥面海绵", mx.mtrlid.Value, mx.useqty.Value, mx.formulaid.Value));
                         }
-                        if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63)
+                        if (mx.formulakind == 60 || mx.formulakind == 61 || mx.formulakind == 62 || mx.formulakind == 63 || mx.formulakind == 64)
                         {
                             qdList.Add(InserMattressInterfacePrdPf(chastrArrDict[item.Key][0], chastrArrDict[item.Key][1], "无纺布", mx.mtrlid.Value, mx.useqty.Value, mx.formulaid.Value));
                         }

+ 4 - 4
JLHWEB/src/views/erpapi/mattressInterface/detail.vue

@@ -778,7 +778,7 @@ const orderDefaultAction = [
         return !orderStatus.value || editType.value == 3;
       },
       clickFunc: item => {
-        RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 1, LjDetailRef.value?._mainData.erp_configcodetype);
+        RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 0, LjDetailRef.value?._mainData.erp_configcodetype);
       }
     }),
     buttonDefault({
@@ -804,7 +804,7 @@ const orderDefaultAction = [
         return "";
       },
       clickFunc: item => {
-        RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 0, LjDetailRef.value?._mainData.erp_configcodetype);
+        RefreshMattressInterfaceList(LjDetailRef.value?._mainData.mattressid, 2, LjDetailRef.value?._mainData.erp_configcodetype);
       }
     })
   ],
@@ -815,7 +815,7 @@ const orderDefaultAction = [
         return !orderStatus.value;
       },
       clickFunc: item => {
-        RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 1);
+        RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 0);
       }
     }),
     buttonDefault({
@@ -835,7 +835,7 @@ const orderDefaultAction = [
         return !orderStatus.value;
       },
       clickFunc: item => {
-        RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 0);
+        RefreshMattressInterfaceQdList(LjDetailRef.value?._mainData.mattressid, 2);
       }
     })
   ],

+ 103 - 59
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -1856,53 +1856,75 @@ export const useHooks = (t?: any) => {
     resetMergeCellsQd();
   };
   /**
-   * 获取产品配置,产品清单
+   * 刷新产品配置
    * @param mattressid 床垫ID
+   * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
    */
   const RefreshMattressInterfaceList = async (mattressid: number, isPz: number, configcodetype: number = 0) => {
     let res = await RefreshMattressInterface({ mattressid, isPz: isPz, configcodetype });
-    // state.mattressYWList = res.mxList;
 
-    // 获取先有配置信息
     const $table = state.YwTableRef?.element;
-    if ($table) {
-      let { visibleData } = $table.getTableData();
-      const copyMap = new Map();
-
-      res.mxList.forEach((mx: any) => {
+    let { visibleData } = $table.getTableData();
+    const copyMap = new Map();
+
+    //  inputtype 0 - 选择 1 - 录入 2 - 带出
+    if (isPz === 0) {
+      // 刷新配置 FEAT: 只刷新带出类型的配置,只刷新明细名称列,如果有新增的,需要补齐。
+      visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
+
+      const PRESERVE_PROPS = [
+        "bj_inputtype",
+        "erp_pzname",
+        "erp_pzcode",
+        "bj_pzname",
+        "itemname",
+        "actual_size",
+        "sb_craft",
+        "actual_size_sb",
+        "ss_rate",
+        "ls_rate"
+      ];
+      state.mattressYWList = res.mxList.map(mx => {
         const key = `${mx.erp_pzid}`;
-        if (!copyMap.has(key)) copyMap.set(key, mx);
+        if (copyMap.has(key)) {
+          PRESERVE_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
+          });
+        }
+        return mx;
       });
+    } else if (isPz === 1) {
+      // 复制配置 FEAT:只复制录入和选择类型的配置,生产信息不覆盖
+      const NEED_PROPS = ["bj_inputtype", "bj_namemx"];
+      res.mxList.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
 
-      visibleData.forEach((mx: any) => {
+      visibleData.forEach(mx => {
         const key = `${mx.erp_pzid}`;
-        if (mx.erp_pzid > 0 && copyMap.has(key)) {
-          const mx2 = copyMap.get(key);
-
-          if (mx.bj_inputtype !== 2 || (mx.bj_inputtype === 2 && mx2.bj_inputtype === 1)) {
-            mx.bj_namemx = mx2.bj_namemx;
-            mx.actual_size = mx2.actual_size;
-            mx.sb_craft = mx2.sb_craft;
-            mx.actual_size_sb = mx2.actual_size_sb;
-            mx.ss_rate = mx2.ss_rate;
-            mx.ls_rate = mx2.ls_rate;
-
-            if (mx.bj_inputtype === 2 && mx2.bj_inputtype === 1) {
-              mx.bj_inputtype = 1;
-            }
-          } else {
-            mx.actual_size = mx2.actual_size;
-            mx.sb_craft = mx2.sb_craft;
-            mx.actual_size_sb = mx2.actual_size_sb;
-            mx.ss_rate = mx2.ss_rate;
-            mx.ls_rate = mx2.ls_rate;
-          }
+        if (copyMap.has(key) && (mx.bj_inputtype === 1 || mx.bj_inputtype === 0)) {
+          NEED_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
+          });
         }
       });
 
-      $table.reloadData(visibleData);
+      state.mattressQDList = visibleData.map((mx: any) => mx);
+    } else {
+      const PRESERVE_PROPS = ["actual_size", "sb_craft", "actual_size_sb", "ss_rate", "ls_rate"];
+
+      visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
+
+      state.mattressYWList = res.mxList.map(mx => {
+        const key = `${mx.erp_pzid}`;
+        if (copyMap.has(key)) {
+          PRESERVE_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
+          });
+        }
+        return mx;
+      });
     }
 
+    // $table.reloadData(visibleData);
     resetMergeCells();
 
     ElNotification({
@@ -1911,8 +1933,9 @@ export const useHooks = (t?: any) => {
     });
   };
   /**
-   * 获取产品配置,产品清单
+   * 刷新产品清单
    * @param mattressid 床垫ID
+   * @param isPz 类型 0 - 刷新 1 - 复制 2 - 重新生成
    */
   const RefreshMattressInterfaceQdList = async (mattressid: number, isPz: number, isCheck?: number) => {
     isCheck = isCheck ?? 1;
@@ -1940,46 +1963,67 @@ export const useHooks = (t?: any) => {
       }
     });
 
-    // 获取先有清单信息
     const $table = state.QdTableRef?.element;
-    if ($table) {
-      let { visibleData } = $table.getTableData();
-      const copyMap = new Map();
+    let { visibleData } = $table.getTableData();
+    const copyMap = new Map();
+    // qd_actual_size字段不修改
+    const PRESERVE_PROPS = ["qd_actual_size"];
 
-      res.mxList.forEach(mx => {
-        const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
+    if (isPz === 0) {
+      // 刷新清单
+      visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
 
-        if (!copyMap.has(key)) copyMap.set(key, mx);
+      state.mattressQDList = res.mxList.map(mx => {
+        const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
+        if (copyMap.has(key)) {
+          PRESERVE_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
+          });
+        }
+        return mx;
       });
+    } else if (isPz === 1) {
+      // 复制清单
+      const NEED_PROPS = [
+        "erp_mtrlid",
+        "erp_mtrlcode",
+        "erp_mtrlname",
+        "erp_mtrlmode",
+        "erp_unit",
+        "useqty",
+        "actual_useqty",
+        "wrkgrpid",
+        "qd_pfgroupqty",
+        "dscrp"
+      ];
+      res.mxList.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
 
       visibleData.forEach(mx => {
-        // 创建复合键(使用模板字符串生成唯一标识)
         const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
-
-        // 从Map中查找对应值(替代TryGetValue)
         if (copyMap.has(key)) {
-          const mx2 = copyMap.get(key);
-
-          Object.assign(mx, {
-            erp_mtrlid: mx2.erp_mtrlid,
-            erp_mtrlcode: mx2.erp_mtrlcode,
-            erp_mtrlname: mx2.erp_mtrlname,
-            erp_mtrlmode: mx2.erp_mtrlmode,
-            erp_unit: mx2.erp_unit,
-            useqty: mx2.useqty,
-            actual_useqty: mx2.actual_useqty,
-            wrkgrpid: mx2.wrkgrpid,
-            qd_actual_size: mx2.qd_actual_size,
-            qd_pfgroupqty: mx2.qd_pfgroupqty,
-            dscrp: mx2.dscrp
+          NEED_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
           });
         }
       });
 
-      $table.reloadData(visibleData);
+      state.mattressQDList = visibleData.map((mx: any) => mx);
+    } else {
+      // 重新刷新清单
+      visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
+
+      state.mattressQDList = res.mxList.map(mx => {
+        const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
+        if (copyMap.has(key)) {
+          PRESERVE_PROPS.forEach(prop => {
+            mx[prop] = copyMap.get(key)[prop];
+          });
+        }
+        return mx;
+      });
     }
-    // state.mattressQDList = res.mxList;
 
+    // $table.reloadData(visibleData);
     resetMergeCellsQd();
 
     ElNotification({