Bladeren bron

JLHWEB: 1、优化框架标签页缓存与刷新机制;
2、优化床垫清单,刷新、复制操作的提示逻辑
3、优化床网报价,多区弹簧填写机制

JohnnyChan 3 dagen geleden
bovenliggende
commit
739add6ed5

+ 40 - 6
JLHWEB/src/layouts/components/Tabs/index.vue

@@ -94,43 +94,77 @@ watch(
       close: !route.meta.isAffix
     };
     console.log("tabStore :>> ", tabStore, route);
+    console.log("tabsParams :>> ", tabsParams, route);
     let isReplace = false;
+    // console.log(
+    //   'tabsParams.path.indexOf("/edit?") > -1 , :>> ',
+    //   tabsParams.path.indexOf("/edit?") > -1,
+    //   tabsParams.path.indexOf("/edit/") > -1
+    // );
+    // console.log(
+    //   'tabsParams.path.indexOf("/detail?") > -1 , :>> ',
+    //   tabsParams.path.indexOf("/detail?") > -1,
+    //   tabsParams.path.indexOf("/detail/") > -1
+    // );
     if (tabsParams.path.indexOf("/edit?") > -1 || tabsParams.path.indexOf("/edit/") > -1) {
       let key = "/edit?";
       let name = "";
       let _path = tabsParams.path.replace(key, "/detail?");
       // 使用路由参数的地址,忽略查询参数后,查找相同地址
       let _path2 = tabsParams.path.replace("/edit/", "/detail/");
+      let hasPath1 = route.fullPath.indexOf("/edit?") > -1;
       let hasPath2 = route.fullPath.indexOf("/edit/") > -1;
       let tabsMenuList = tabStore.tabsMenuList;
       for (let i = 0; i < tabsMenuList.length; i++) {
-        if (tabsMenuList[i].path == _path || (hasPath2 && tabsMenuList[i].path.split("?")[0] == _path2.split("?")[0])) {
+        if (
+          (hasPath1 && tabsMenuList[i].path == _path) ||
+          (hasPath2 && tabsMenuList[i].path.split("?")[0] == _path2.split("?")[0])
+        ) {
           name = tabsMenuList[i].name;
           tabsMenuList[i] = tabsParams;
           isReplace = true;
           break;
         }
       }
-      console.log("keilll name :>> ", name);
+      console.log("keilll name edit:>> ", name);
       tabStore.setTabs(tabsMenuList);
-      // name && keepAliveStore.removeKeepAliveName(route);
-      route.meta.isKeepAlive && keepAliveStore.updateKeepAliveName(route);
+      name && keepAliveStore.updateKeepAliveName(route);
+      // route.meta.isKeepAlive && keepAliveStore.updateKeepAliveName(route);
     } else if (tabsParams.path.indexOf("/detail?") > -1 || tabsParams.path.indexOf("/detail/") > -1) {
       let key = "/detail?";
+      let name = "";
       let _path = tabsParams.path.replace(key, "/edit?");
       // 使用路由参数的地址,忽略查询参数后,查找相同地址
       let _path2 = tabsParams.path.replace("/detail/", "/edit/");
+      let hasPath1 = route.fullPath.indexOf("/detail?") > -1;
       let hasPath2 = route.fullPath.indexOf("/detail/") > -1;
       let tabsMenuList = tabStore.tabsMenuList;
       for (let i = 0; i < tabsMenuList.length; i++) {
-        if (tabsMenuList[i].path == _path || (hasPath2 && tabsMenuList[i].path.split("?")[0] == _path2.split("?")[0])) {
+        if (
+          (hasPath1 && tabsMenuList[i].path == _path) ||
+          (hasPath2 && tabsMenuList[i].path.split("?")[0] == _path2.split("?")[0])
+        ) {
+          // console.log(
+          //   " (hasPath2 && tabsMenuList[i].path.split('?)[0] == _path2.split('?')[0])",
+          //   tabsMenuList[i].path,
+          //   _path,
+          //   tabsMenuList[i].path == _path,
+          //   hasPath2,
+          //   tabsMenuList[i].path.split("?")[0],
+          //   _path2.split("?")[0],
+          //   tabsMenuList[i].path.split("?")[0] == _path2.split("?")[0],
+          //   tabsMenuList[i]
+          // );
+          name = tabsMenuList[i].name;
           tabsMenuList[i] = tabsParams;
           isReplace = true;
           break;
         }
       }
       tabStore.setTabs(tabsMenuList);
-      route.meta.isKeepAlive && keepAliveStore.updateKeepAliveName(route);
+      console.log("keilll name detail:>> ", name);
+      name && keepAliveStore.updateKeepAliveName(route);
+      // route.meta.isKeepAlive && keepAliveStore.addKeepAliveName(route);
       console.log("add keepAliveStore.keepAliveName :>> ", keepAliveStore.keepAliveName);
     }
     !isReplace && tabStore.addTabs(tabsParams);

+ 12 - 13
JLHWEB/src/views/erpapi/mattressInterface/detail.vue

@@ -155,6 +155,7 @@ const {
   workgrpEnum,
   workgrpEnum2,
   configureTypeEnum,
+  loadingStatus,
   RetriveMattressInterface,
   RefreshMattressInterfaceList,
   RefreshMattressInterfaceQdList,
@@ -211,10 +212,6 @@ const detailProps = reactive<DetailProp>({
 });
 
 const tabRemove: Function = inject("tabRemove") as Function;
-const loadingStatus = reactive({
-  save: false,
-  synchsL1: false
-});
 
 const cellClassNameFn = (data: any, editable) => {
   let { column, row } = data;
@@ -659,7 +656,7 @@ const orderDefaultAction = [
   }),
   buttonDefault({
     label: t("common.saveText"),
-    loading: () => loadingStatus.save,
+    loading: () => loadingStatus.value.save,
     limited: () => !orderStatus.value,
     clickFunc: async item => {
       try {
@@ -695,7 +692,7 @@ const orderDefaultAction = [
           cancelButtonText: "否",
           type: "warning"
         }).then(async () => {
-          loadingStatus.save = true;
+          loadingStatus.value.save = true;
           try {
             let _qdList = mattressQDList.value;
             let _ywList = mattressYWList.value;
@@ -743,14 +740,14 @@ const orderDefaultAction = [
                   replace: true
                 });
                 // LjDetailRef.value.refresh();
-                loadingStatus.save = false;
+                loadingStatus.value.save = false;
               })
               .catch(error => {
                 console.log("error !! :>> ", error);
-                loadingStatus.save = false;
+                loadingStatus.value.save = false;
               });
           } catch (error) {
-            loadingStatus.save = false;
+            loadingStatus.value.save = false;
             ElMessage.error(t("sys.api.operationFailed"));
           }
         });
@@ -1075,6 +1072,7 @@ const orderDefaultAction = [
   buttonDefault({
     label: "生成/更新物料",
     power: 88,
+    loading: () => loadingStatus.value.mtrldef,
     limited: () => {
       return !!orderStatus.value;
     },
@@ -1086,6 +1084,7 @@ const orderDefaultAction = [
     buttonDefault({
       label: "生成金蝶清单",
       power: 90,
+      loading: () => loadingStatus.value.prdpf,
       disabledTextCallBack: (data: any) => {
         console.log("生成金蝶清单 disabledTextCallBack data", data);
         if (data.js2_flag == 0) {
@@ -1124,10 +1123,10 @@ const orderDefaultAction = [
     // limited: () => {
     //   return !orderStatus.value;
     // },
-    loading: () => loadingStatus.synchsL1,
+    loading: () => loadingStatus.value.synchsL1,
     clickFunc: async () => {
       try {
-        loadingStatus.synchsL1 = true;
+        loadingStatus.value.synchsL1 = true;
         let res = await UpdateL1Basicinfo();
         if (res) {
           ElNotification({
@@ -1137,9 +1136,9 @@ const orderDefaultAction = [
             type: "warning"
           });
         }
-        loadingStatus.synchsL1 = false;
+        loadingStatus.value.synchsL1 = false;
       } catch (error) {
-        loadingStatus.synchsL1 = false;
+        loadingStatus.value.synchsL1 = false;
         console.error(error);
       }
     }

+ 91 - 39
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -58,6 +58,7 @@ interface defaultState {
   QdTableRef: any;
   CodeMxDialogProps: any;
   CodeMxDialogRef: any;
+  loadingStatus: any;
 }
 
 /**
@@ -85,7 +86,13 @@ export const useHooks = (t?: any) => {
     workgrpEnum2: [],
     configureTypeEnum: [],
     CodeMxDialogProps: null,
-    CodeMxDialogRef: null
+    CodeMxDialogRef: null,
+    loadingStatus: {
+      save: false,
+      synchsL1: false,
+      mtrldef: false,
+      prdpf: false
+    }
   });
 
   const QdAddRowList = [
@@ -207,13 +214,19 @@ export const useHooks = (t?: any) => {
         type: "warning"
       })
         .then(() => {
-          CreatPrdPf({ list }).then(() => {
-            ElNotification({
-              title: "金蝶清单",
-              message: "生成成功!",
-              type: "success"
+          state.loadingStatus.prdpf = true;
+          CreatPrdPf({ list })
+            .then(() => {
+              ElNotification({
+                title: "金蝶清单",
+                message: "生成成功!",
+                type: "success"
+              });
+              state.loadingStatus.prdpf = false;
+            })
+            .catch(error => {
+              state.loadingStatus.prdpf = false;
             });
-          });
         })
         .catch((e: TypeError) => {
           console.log("e :>> ", e);
@@ -249,19 +262,26 @@ export const useHooks = (t?: any) => {
       type: "warning"
     })
       .then(() => {
-        CreatMtrlPf({ list }).then(res => {
-          console.log("toCreateMtrl, res :>> ", res);
-          if (state.LjDetailRef) {
-            state.LjDetailRef._mainData.erp_mtrlid = res.mattress.erp_mtrlid;
-            state.LjDetailRef._mainData.creatmtrl_flag = res.mattress.creatmtrl_flag;
-            state.LjDetailRef._mainData.erp_mtrlcode = res.mattress.erp_mtrlcode;
-          }
-          ElNotification({
-            title: "物料",
-            message: "生成/更新成功!",
-            type: "success"
+        state.loadingStatus.mtrldef = true;
+        CreatMtrlPf({ list })
+          .then(res => {
+            console.log("toCreateMtrl, res :>> ", res);
+            if (state.LjDetailRef) {
+              state.LjDetailRef._mainData.erp_mtrlid = res.mattress.erp_mtrlid;
+              state.LjDetailRef._mainData.creatmtrl_flag = res.mattress.creatmtrl_flag;
+              state.LjDetailRef._mainData.erp_mtrlcode = res.mattress.erp_mtrlcode;
+            }
+            ElNotification({
+              title: "物料",
+              message: "生成/更新成功!",
+              type: "success"
+            });
+
+            state.loadingStatus.mtrldef = false;
+          })
+          .catch(error => {
+            state.loadingStatus.mtrldef = false;
           });
-        });
       })
       .catch((e: TypeError) => {
         ElMessage({
@@ -1867,6 +1887,8 @@ export const useHooks = (t?: any) => {
     const $table = state.YwTableRef?.element;
     let { visibleData } = $table.getTableData();
     const copyMap = new Map();
+    let showData: any = [];
+    let matchQty = 0;
 
     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"];
@@ -1878,9 +1900,10 @@ export const useHooks = (t?: any) => {
         copyMap.set(`${mx.erp_pzid}`, mx);
       });
 
-      state.mattressYWList = res.mxList.map(mx => {
+      showData = res.mxList.map(mx => {
         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 => {
@@ -1899,22 +1922,25 @@ export const useHooks = (t?: any) => {
       const NEED_PROPS = ["bj_inputtype", "bj_namemx"];
       res.mxList.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
 
-      visibleData.forEach(mx => {
+      showData = visibleData.map(mx => {
         const key = `${mx.erp_pzid}`;
         if (copyMap.has(key) && (mx.bj_inputtype === 1 || mx.bj_inputtype === 0)) {
+          matchQty++;
           NEED_PROPS.forEach(prop => {
             mx[prop] = copyMap.get(key)[prop];
           });
         }
+        return mx;
       });
 
-      state.mattressQDList = visibleData.map((mx: any) => mx);
+      // state.mattressYWList = visibleData.map((mx: any) => mx);
     } else {
       // 重新生成:  FEAT: 删除所有已经填写的【录入】和【选择)项目,根据核价资料,重新生成所有的【带出】资料
       visibleData.forEach(mx => copyMap.set(`${mx.erp_pzid}`, mx));
-      state.mattressYWList = res.mxList.map(mx => {
+      showData = res.mxList.map(mx => {
         const key = `${mx.erp_pzid}`;
         if (copyMap.has(key)) {
+          matchQty++;
           SPECIAL_PRESERVED_PROPS.forEach(prop => {
             mx[prop] = copyMap.get(key)[prop];
           });
@@ -1923,13 +1949,22 @@ export const useHooks = (t?: any) => {
       });
     }
 
-    // $table.reloadData(visibleData);
-    resetMergeCells();
+    if (res.mxList.length > 0) {
+      await $table.reloadData(showData);
+      resetMergeCells();
 
-    ElNotification({
-      title: "刷新成功",
-      type: "success"
-    });
+      ElNotification({
+        title: "刷新成功",
+        message: `成功匹配${matchQty}条数据`,
+        type: "success"
+      });
+    } else {
+      ElNotification({
+        title: "刷新失败",
+        message: "暂无配置数据(mattressid: " + mattressid + ")",
+        type: "warning"
+      });
+    }
   };
   /**
    * 刷新产品清单
@@ -1941,6 +1976,9 @@ export const useHooks = (t?: any) => {
 
     let res = await RefreshMattressInterfaceQd({ mattressid, isPz, isCheck });
 
+    let showData: any = [];
+    let matchQty = 0;
+
     const interfaceMap = {};
     state.mattressYWList.forEach(mb => {
       interfaceMap[mb.bj_pzname] = mb;
@@ -1972,9 +2010,10 @@ export const useHooks = (t?: any) => {
       // 刷新清单
       visibleData.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
 
-      state.mattressQDList = res.mxList.map(mx => {
+      showData = res.mxList.map(mx => {
         const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
         if (copyMap.has(key)) {
+          matchQty++;
           PRESERVE_PROPS.forEach(prop => {
             mx[prop] = copyMap.get(key)[prop];
           });
@@ -1988,6 +2027,7 @@ export const useHooks = (t?: any) => {
         "erp_mtrlcode",
         "erp_mtrlname",
         "erp_mtrlmode",
+        "erp_mtrlengname",
         "erp_unit",
         "useqty",
         "actual_useqty",
@@ -1997,23 +2037,26 @@ export const useHooks = (t?: any) => {
       ];
       res.mxList.forEach(mx => copyMap.set(`${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`, mx));
 
-      visibleData.forEach(mx => {
+      showData = visibleData.map(mx => {
         const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
         if (copyMap.has(key)) {
+          matchQty++;
           NEED_PROPS.forEach(prop => {
             mx[prop] = copyMap.get(key)[prop];
           });
         }
+        return mx;
       });
 
-      state.mattressQDList = visibleData.map((mx: any) => mx);
+      // 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 => {
+      showData = res.mxList.map(mx => {
         const key = `${mx.itemname}|${mx.bj_pzname}|${mx.bj_pzname_mx}`;
         if (copyMap.has(key)) {
+          matchQty++;
           PRESERVE_PROPS.forEach(prop => {
             mx[prop] = copyMap.get(key)[prop];
           });
@@ -2022,13 +2065,22 @@ export const useHooks = (t?: any) => {
       });
     }
 
-    // $table.reloadData(visibleData);
-    resetMergeCellsQd();
+    if (res.mxList.length > 0) {
+      await $table.reloadData(showData);
+      resetMergeCellsQd();
 
-    ElNotification({
-      title: "刷新成功",
-      type: "success"
-    });
+      ElNotification({
+        title: "刷新成功",
+        message: `成功匹配${matchQty}条数据`,
+        type: "success"
+      });
+    } else {
+      ElNotification({
+        title: "刷新失败",
+        message: "暂无清单数据(mattressid: " + mattressid + ")",
+        type: "warning"
+      });
+    }
   };
 
   /**

+ 77 - 2
JLHWEB/src/views/quote/bednetQuote/hooks/index.tsx

@@ -179,12 +179,14 @@ export const useHooks = (t?: any, props?: any) => {
   /**
    * @description 填充海绵
    */
-  const rModelSetSpring = (data: any, item: any) => {
+  const rModelSetSpring = async (data: any, item: any) => {
     if (item) {
       data.row.springid = item.springid;
       data.row.springname = item.springname;
     }
 
+    const $table = state.vxeTableMxRef.element;
+    let { visibleData } = $table.getTableData();
     if (data.rowIndex == 0) {
       data.visibleData.forEach((o, i) => {
         if (i % 2 == 0 && i > 0) {
@@ -192,6 +194,8 @@ export const useHooks = (t?: any, props?: any) => {
           o.springname = item.springname;
         }
       });
+      setMxSpringQtyWidthAndLength(visibleData[0]);
+      await $table.reloadData(visibleData);
     } else if (data.rowIndex == 1) {
       data.visibleData.forEach((o, i) => {
         if (i % 2 == 1 && i > 1) {
@@ -199,6 +203,8 @@ export const useHooks = (t?: any, props?: any) => {
           o.springname = item.springname;
         }
       });
+      setMxSpringQtyWidthAndLength(visibleData[0]);
+      await $table.reloadData(visibleData);
     }
   };
 
@@ -896,6 +902,18 @@ export const useHooks = (t?: any, props?: any) => {
       field: "mattress_height",
       basicinfo: {
         el: "input",
+        props: {
+          onChange: async val => {
+            const $table = state.vxeTableMxRef.element;
+            let { visibleData } = $table.getTableData();
+            if (visibleData.length > 0) {
+              visibleData[0].bednet_height = val;
+            }
+            console.log("mattress_height val :>> ", val, visibleData);
+            setMxSpringQtyWidthAndLength(visibleData[0]);
+            await $table.reloadData(visibleData);
+          }
+        },
         editable: ALLOW_EDIT_STATE,
         rules: [{ validator: numCheck, trigger: "blur" }]
       }
@@ -1710,6 +1728,30 @@ export const useHooks = (t?: any, props?: any) => {
               }
               console.log("$table :>> ", $table, arr);
               await $table.insertAt(arr, -1);
+
+              const $tableMx = state.vxeTableMxRef.element;
+              let { visibleData } = $tableMx.getTableData();
+              let { visibleData: springVisibleData } = $table.getTableData();
+              let firstItem = springVisibleData.find((o, i) => i == 0);
+              let secondItem = springVisibleData.find((o, i) => i == 1);
+              if (firstItem) {
+                springVisibleData.forEach((o, i) => {
+                  if (i % 2 == 0 && i > 0) {
+                    o.springid = firstItem.springid;
+                    o.springname = firstItem.springname;
+                  }
+                });
+              }
+              if (secondItem) {
+                springVisibleData.forEach((o, i) => {
+                  if (i % 2 == 1 && i > 1) {
+                    o.springid = secondItem.springid;
+                    o.springname = secondItem.springname;
+                  }
+                });
+              }
+
+              setMxSpringQtyWidthAndLength(visibleData[0]);
             } else if (springData.length > num) {
               let arrs = springData.filter((item, index) => index + 1 > num);
               await $table.remove(arrs);
@@ -1890,7 +1932,10 @@ export const useHooks = (t?: any, props?: any) => {
             <el-input
               v-model={row.bednet_height}
               onBlur={() => handleBlur(row.bednet_height, row, "bednet_height")}
-              onChange={() => setMxSpringQtyWidthAndLength(row)}
+              onChange={val => {
+                state.LjDetailRef._mainData.mattress_height = val;
+                setMxSpringQtyWidthAndLength(row);
+              }}
               style="width: unset"
             />
           </>
@@ -2155,6 +2200,7 @@ export const useHooks = (t?: any, props?: any) => {
             <el-input
               v-model={row.spring_qty_width}
               onBlur={() => handleBlur(row.spring_qty_width, row, "spring_qty_width")}
+              onChange={val => handleChangeSpringWidth(val, scope)}
               style="width: unset"
             />
           </>
@@ -2171,6 +2217,7 @@ export const useHooks = (t?: any, props?: any) => {
             <el-input
               v-model={row.spring_qty_length}
               onBlur={() => handleBlur(row.spring_qty_length, row, "spring_qty_length")}
+              onChange={val => handleChangeSpringLength(val, scope)}
               style="width: unset"
             />
           </>
@@ -2179,6 +2226,34 @@ export const useHooks = (t?: any, props?: any) => {
     }
   ]);
 
+  const handleChangeSpringWidth = (val: any, scope: any) => {
+    const { row, data, $table } = scope;
+
+    data.forEach(item => {
+      item.spring_qty_width = val;
+    });
+
+    // $table.reloadData(data);
+
+    const $tableMx = state.vxeTableMxRef.element;
+    let { visibleData } = $tableMx.getTableData();
+    visibleData[0].spring_qty_width = val;
+    $tableMx.reloadData(visibleData);
+  };
+
+  const handleChangeSpringLength = (val: any, scope: any) => {
+    const { row, data } = scope;
+
+    let sumLength = data.reduce((pre, cur) => {
+      return pre + Number(cur.spring_qty_length);
+    }, 0);
+
+    const $table = state.vxeTableMxRef.element;
+    let { visibleData } = $table.getTableData();
+    visibleData[0].spring_qty_length = sumLength;
+    $table.reloadData(visibleData);
+  };
+
   const columnsBednet = ref<ColumnProps<any>[]>([{}]);
 
   /**

+ 7 - 0
JLHWEB/src/views/quote/bednetQuote/index.vue

@@ -228,6 +228,13 @@ const action: detailAction[] = [
       if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
         _deptid = vxeTableRef.value.searchParam.arg_deptid;
       }
+      if (_deptid == 0) {
+        let enumMap = vxeTableRef.value.enumMap;
+        let enumdata = enumMap.get("deptid");
+        if (enumdata && enumdata.length > 0) {
+          _deptid = enumdata[0].value;
+        }
+      }
       router.push(`/bednetQuote/new?id=0&deptid=${_deptid}`);
     }
   }),