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

JLHWEB: 1、床垫报价列表页,点击新建,当没有选择部门,默认赋值权限内的第一个部门;
2、床垫报价-优化明细厚度赋值规则

JohnnyChan 3 дней назад
Родитель
Сommit
0cde2afba5

+ 6 - 376
JLHWEB/src/views/quote/mattressQuote/hooks/index.tsx

@@ -1357,7 +1357,9 @@ export const useHooks = (t?: any) => {
       data.mtrlname = item.mtrlname;
       data.priceunit = item.priceunit;
       data.shrinkage = item.price; // 收缩率
-      data.thickness = Number(item.thickness);
+      if (item.if_inputqty == 1 || Number(data.thickness) == 0) {
+        data.thickness = Number(item.thickness);
+      }
       data.price_formula = item.price_formula;
 
       let _qty = 1;
@@ -1439,7 +1441,9 @@ export const useHooks = (t?: any) => {
       data.mtrlname = item.mtrlname;
       data.priceunit = item.priceunit;
       data.shrinkage = item.price; // 收缩率
-      Number(item?.thickness) > 0 && (data.thickness = item.thickness);
+      if (item.if_inputqty == 1 || Number(data.thickness) == 0) {
+        data.thickness = Number(item.thickness);
+      }
       item?.price_formula != "" && (data.price_formula = item.price_formula);
 
       let _qty = 1;
@@ -2255,380 +2259,6 @@ export const useHooks = (t?: any) => {
     }
   };
 
-  /**
-   * @description 清除运算结果
-   */
-  const wf_clear = () => {
-    const { _mainData } = state.LjDetailRef;
-
-    _mainData.total_fees_cost = 0;
-    _mainData.total_cost = 0;
-    _mainData.nottax_factory_cost = 0;
-    _mainData.nottax_dept_cost = 0;
-    _mainData.taxes = 0;
-    _mainData.dept_cost = 0;
-    _mainData.foreign_cost = 0;
-    _mainData.hrcost = 0;
-    _mainData.biandaicost = 0;
-    _mainData.fob = 0;
-    _mainData.profitrate_point = 0;
-    _mainData.butao_point = 0;
-    _mainData.chaizhuang_point = 0;
-    _mainData.haimian_point = 0;
-
-    state.fabricMxTabList.map(t => {
-      if (t.ref && state[t.ref]) {
-        console.log("t.ref?.value :>> ", t.ref, state[t.ref]);
-        // console.log("state[t.ref].tableData :>> ", state[t.ref].tableData);
-        // state[t.ref].tableData.map(item => {
-        //   item.costamt = 0;
-        //   item.replace_formula = "";
-        //   item.if_success = 1;
-        //   item.thickness = 1;
-        // });
-        let { fullData } = state[t.ref].element.getTableData();
-        state[t.ref].element.setRow(fullData, {
-          costamt: 0,
-          replace_formula: "",
-          if_success: 0
-        });
-        // console.log("fullData :>> ", fullData);
-        // fullData = fullData.map((itm, idx) => {
-        //   itm.xu = idx + 1;
-        //   return itm
-        // });
-      }
-    });
-  };
-
-  /**
-   * @description 更新物料最新 单价等信息
-   */
-  const wf_cmp_update_mtrl = async () => {
-    const { _mainData, enumMap } = state.LjDetailRef;
-    let computeList = [
-      "tabpage_8",
-      "tabpage_9",
-      "tabpage_10",
-      "tabpage_11",
-      "tabpage_12",
-      "tabpage_13",
-      "cushionsMx",
-      "accessoriesMx",
-      "packagMx"
-    ];
-
-    let arg_array_formulakind = [];
-    state.fabricMxTabList.map(t => {
-      if (!computeList.includes(t.name)) {
-        return;
-      }
-
-      if (t.ref && state[t.ref]) {
-        let { fullData } = state[t.ref].element.getTableData();
-        fullData.map(itm => {
-          arg_array_formulakind.push(itm.formulakind);
-        });
-      }
-    });
-
-    // 数组去重
-    arg_array_formulakind = Array.from(new Set(arg_array_formulakind));
-
-    let _param = {
-      dsname: "web_mattress_formulalist",
-      queryparams: {
-        arg_array_formulakind: arg_array_formulakind
-      }
-    };
-    let res = await CommonDynamicSelect(_param);
-    if (res?.datatable?.length) {
-      state.fabricMxTabList.map(t => {
-        if (!computeList.includes(t.name)) {
-          return;
-        }
-
-        if (t.ref && state[t.ref]) {
-          let { fullData } = state[t.ref].element.getTableData();
-
-          fullData.map(item => {
-            let tFormula = res?.datatable.find(itm => itm.formulakind == item.formulakind);
-
-            state[t.ref].element.setRow(item, {
-              formula: tFormula.formula ?? "err",
-              useformula: tFormula.useformula ?? "",
-              gydscrp: tFormula.gydscrp ?? ""
-            });
-          });
-        }
-      });
-    }
-
-    //______________________________________________________
-    state.fabricMxTabList.map(t => {
-      if (!computeList.includes(t.name)) {
-        return;
-      }
-
-      if (t.ref && state[t.ref]) {
-        let { fullData } = state[t.ref].element.getTableData();
-
-        fullData.map(async item => {
-          if (item?.mtrlid && Number(item.mtrlid) > 0) {
-            let res_mtrls = await wf_mtrl_find({ arg_mtrlid: item.mtrlid, arg_pricelistid: item.pricelistid });
-
-            if (res_mtrls.length > 0) {
-              let res_mtrl = res_mtrls[0];
-              let _data: any = {
-                mtrlname: res_mtrl.mtrlname,
-                price: res_mtrl.pricelistprice,
-                gram_weight: res_mtrl.gram_weight,
-                cloth_width: res_mtrl.cloth_width,
-                if_inputqty: res_mtrl.if_inputqty,
-                priceunit: res_mtrl.priceunit,
-                shrinkage: res_mtrl.shrinkage,
-                if_areaprice: res_mtrl.if_areaprice
-              };
-              if (Number(res_mtrl.if_inputqty) == 1) {
-                _data.thickness = res_mtrl.thickness;
-              }
-              if (!res_mtrl.formula) {
-                _data.formula = res_mtrl.formula;
-              }
-              if (!res_mtrl.qty_formula) {
-                _data.useformula = res_mtrl.qty_formula;
-              }
-              state[t.ref].element.setRow(item, _data);
-            }
-          }
-        });
-      }
-    });
-  };
-
-  /**
-   * @description 检查垫层  是否填写正确 并 更新 u_mattress_mx_mtrl_formulaid
-   */
-  const wf_check_dianceng_ifright = async () => {
-    let arg_array_formulakind = [];
-    let { fullData: dcData } = state.cushionsMxRef.element.getTableData();
-    dcData.map(itm => {
-      arg_array_formulakind.push(Number(itm.formulakind));
-    });
-
-    // 数组去重
-    arg_array_formulakind = Array.from(new Set(arg_array_formulakind));
-
-    let _param = {
-      dsname: "web_mattress_formulalist",
-      queryparams: {
-        arg_array_formulakind: arg_array_formulakind
-      }
-    };
-    let res = await CommonDynamicSelect(_param);
-    if (res?.datatable?.length) {
-      let { fullData } = state.cushionsMxRef.element.getTableData();
-
-      fullData.map(item => {
-        let tFormula = res?.datatable.find(itm => itm.formulakind == item.formulakind);
-        state.cushionsMxRef.element.setRow(item, {
-          formulaid: tFormula.formulaid
-        });
-      });
-    }
-
-    //检查是否 含有床网
-    let lb_flag = arg_array_formulakind.includes(999);
-
-    let lb_re_cmp = false; //批重算
-    if (!lb_flag && !lb_re_cmp) {
-      // ElMessageBox.confirm("垫层没有包含床网_,是否继续?", "询问", {
-      //   confirmButtonText: '是',
-      //   cancelButtonText: "否",
-      //   type: "warning"
-      // })
-      //   .then(() => {
-
-      //     return
-      //   })
-      //   .catch((e: TypeError) => {
-      //     console.log("e :>> ", e);
-      ElMessage({
-        type: "info",
-        message: "垫层没有包含床网_!"
-      });
-      //   });
-    }
-  };
-
-  // /**
-  //  * @description 重算床网价格
-  //  */
-  // const wf_cmp_bednet = () => {
-  //   // bednetMxRef
-
-  //   return true;
-  // };
-
-  /**
-   * @description 公式替换:替换大侧高度
-   */
-  const wf_replace_height_big_side = (arg_str: string, arg_chastr: string) => {
-    if (arg_str.indexOf("【大侧高度】") <= 0) return arg_str;
-    // let ls_str = arg_str;
-    const { _mainData, enumMap } = state.LjDetailRef;
-
-    let ls_seachstr = "大侧";
-
-    let lde_sum = 0;
-    state.cushionsMxRef.element.getTableData().fullData.map(itm => {
-      if (itm.chastr.indexOf(ls_seachstr) > 0 && Number(itm.qty) > 0 && Number(itm.thickness) > 0) {
-        lde_sum = floatAdd(lde_sum, floatMul(itm.qty, itm.thickness));
-      }
-    });
-
-    let ls_temp = formatFixedNumber({ val: lde_sum }, 4);
-
-    let ls_formula_big_side = "";
-    let mtEnum = enumMap.get("mattresstypeid");
-    let _mattresstypeid = _mainData?.mattresstypeid ?? 0;
-    console.log("deptEnum :>> ", mtEnum);
-    if (mtEnum) {
-      let mtItem = mtEnum.find((item: any) => Number(item.value) == _mattresstypeid);
-      console.log("wf_replace_height_big_side mtItem :>> ", mtItem);
-      ls_formula_big_side = mtItem?.formula_big_side ?? "";
-    }
-
-    if (ls_formula_big_side) {
-      arg_str = arg_str.replaceAll("【大侧高度】", ` ( ${ls_formula_big_side} ) `);
-    }
-
-    if (lde_sum) {
-      arg_str = arg_str.replaceAll("【垫层】", ls_temp);
-      arg_str = arg_str.replaceAll("【大侧高度】", ls_temp);
-    }
-
-    arg_str = arg_str.replaceAll("【位置】", `'${ls_seachstr}'`);
-
-    return arg_str;
-  };
-  /**
-   * @description 公式替换:小侧高度
-   */
-  const wf_replace_height_small_side = (arg_str: string, arg_chastr: string) => {
-    if (arg_str.indexOf("【小侧高度】") <= 0) return arg_str;
-    // let ls_str = arg_str;
-    const { _mainData, enumMap } = state.LjDetailRef;
-
-    let ls_seachstr = !arg_chastr || arg_chastr == "" ? "小侧1" : arg_chastr;
-
-    let lde_sum = 0;
-    state.cushionsMxRef.element.getTableData().fullData.map(itm => {
-      if (itm.chastr.indexOf(ls_seachstr) > 0 && Number(itm.qty) > 0 && Number(itm.thickness) > 0) {
-        lde_sum = floatAdd(lde_sum, floatMul(itm.qty, itm.thickness));
-      }
-    });
-
-    let ls_temp = formatFixedNumber({ val: lde_sum }, 4);
-
-    let ls_formula_big_side = "";
-    let mtEnum = enumMap.get("mattresstypeid");
-    let _mattresstypeid = _mainData?.mattresstypeid ?? 0;
-    console.log("deptEnum :>> ", mtEnum);
-    if (mtEnum) {
-      let mtItem = mtEnum.find((item: any) => Number(item.value) == _mattresstypeid);
-      console.log("wf_replace_height_big_side mtItem :>> ", mtItem);
-      ls_formula_big_side = mtItem?.formula_big_side ?? "";
-    }
-
-    if (ls_formula_big_side) {
-      arg_str = arg_str.replaceAll("【小侧高度】", ` ( ${ls_formula_big_side} ) `);
-    }
-
-    if (lde_sum) {
-      arg_str = arg_str.replaceAll("【垫层】", ls_temp);
-    }
-
-    arg_str = arg_str.replaceAll("【位置】", `'${ls_seachstr}'`);
-    arg_str = arg_str.replaceAll("【小侧高度】", ls_temp);
-
-    return arg_str;
-  };
-
-  /**
-   * @description 公式替换:V侧高度
-   */
-  const wf_replace_height_v_side = (arg_str: string, arg_chastr: string) => {
-    if (arg_str.indexOf("【V侧高度】") <= 0) return arg_str;
-    // let ls_str = arg_str;
-    const { _mainData, enumMap } = state.LjDetailRef;
-
-    let ls_seachstr = !arg_chastr || arg_chastr == "" ? "小侧1" : arg_chastr;
-
-    let lde_sum = 0;
-    state.cushionsMxRef.element.getTableData().fullData.map(itm => {
-      if (itm.chastr.indexOf(ls_seachstr) > 0 && Number(itm.qty) > 0 && Number(itm.thickness) > 0) {
-        lde_sum = floatAdd(lde_sum, floatMul(itm.qty, itm.thickness));
-      }
-    });
-
-    let ls_temp = formatFixedNumber({ val: lde_sum }, 4);
-
-    let ls_formula_big_side = "";
-    let mtEnum = enumMap.get("mattresstypeid");
-    let _mattresstypeid = _mainData?.mattresstypeid ?? 0;
-    console.log("deptEnum :>> ", mtEnum);
-    if (mtEnum) {
-      let mtItem = mtEnum.find((item: any) => Number(item.value) == _mattresstypeid);
-      console.log("wf_replace_height_big_side mtItem :>> ", mtItem);
-      ls_formula_big_side = mtItem?.formula_big_side ?? "";
-    }
-
-    if (ls_formula_big_side) {
-      arg_str = arg_str.replaceAll("【V侧高度】", ` ( ${ls_formula_big_side} ) `);
-    }
-
-    if (lde_sum) {
-      arg_str = arg_str.replaceAll("【垫层】", ls_temp);
-    }
-
-    arg_str = arg_str.replaceAll("【位置】", `'${ls_seachstr}'`);
-
-    ls_temp = formatFixedNumber({ val: 18 }, 4);
-    arg_str = arg_str.replaceAll("【V侧高度】", ls_temp);
-
-    return arg_str;
-  };
-
-  /**
-   * @description 替换布料幅宽star
-   * @returns string
-   */
-  const wf_replace_cloth_width = (item: any, fullData: any, formulakind: any) => {
-    let ls_bl_cloth_width = "";
-
-    // let { fullData: mlData } = state[t.ref].element.getTableData();
-    fullData.find(itm => {
-      if (!item?.chastr) {
-        if (Number(itm.formulakind) == formulakind) {
-          ls_bl_cloth_width = formatFixedNumber({ val: itm.cloth_width }, 4);
-          return true;
-        }
-      } else {
-        if (Number(itm.formulakind) == formulakind && itm.chastr == item?.chastr) {
-          ls_bl_cloth_width = formatFixedNumber({ val: itm.cloth_width }, 4);
-          return true;
-        }
-      }
-    });
-
-    // if (Number(ls_bl_cloth_width) > 0) {
-    //   ls_Expression = ls_Expression.replaceAll('【布料幅宽】', ls_bl_cloth_width);
-    //   ls_Use_Expression = ls_Use_Expression.replaceAll('【布料幅宽】', ls_bl_cloth_width);
-    // }
-    return ls_bl_cloth_width;
-  };
-
   /**
    * @description 计算价格
    */

+ 20 - 10
JLHWEB/src/views/quote/mattressQuote/index.vue

@@ -266,6 +266,13 @@ const action: detailAction[] = [
       if (Object.keys(vxeTableRef.value.searchParam).includes("arg_deptid")) {
         _deptid = vxeTableRef.value.searchParam.arg_deptid ?? 0;
       }
+      if (_deptid == 0) {
+        let enumMap = vxeTableRef.value.enumMap;
+        let enumdata = enumMap.get("deptid");
+        if (enumdata && enumdata.length > 0) {
+          _deptid = enumdata[0].value;
+        }
+      }
       router.push(`/mattressQuote/new?id=0&deptid=${_deptid}`);
     }
   }),
@@ -525,16 +532,19 @@ const action: detailAction[] = [
 
 const openDeptChoosen = async curRecords => {
   try {
-    let newParams = {
-      dsname: "_Mapper_deptid",
-      queryparams: {}
-    };
-    let res = await CommonDynamicSelect(newParams);
-    if (res.datatable) {
-      deptEnum.value = res.datatable?.map((item: any) => {
-        return { label: item.deptname, value: item.deptid };
-      });
-    }
+    // let newParams = {
+    //   dsname: "_Mapper_deptid",
+    //   queryparams: {}
+    // };
+    // let res = await CommonDynamicSelect(newParams);
+    // if (res.datatable) {
+    //   deptEnum.value = res.datatable?.map((item: any) => {
+    //     return { label: item.deptname, value: item.deptid };
+    //   });
+    // }
+    let enumMap = vxeTableRef.value.enumMap;
+    deptEnum.value = enumMap.get("deptid");
+    console.log("openDeptChoosen deptEnum.value :>> ", deptEnum.value);
 
     if (deptEnum.value.length > 0) {
       formParam.value.deptid = curRecords[0].deptid;