Browse Source

更新床网保存逻辑代码

MY 5 months ago
parent
commit
de678a69c1

+ 24 - 0
JLHHJSvr/DataStore/_Mapper_bednettypeid_mattresstypeid.xml

@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<select>
+  <selectstr>
+SELECT u_factory_profitrate.bednet_or_mattress 
+	,u_factory_profitrate.bednettypeid_mattresstypeid 
+	,u_factory_profitrate.profitrate
+FROM u_factory_profitrate
+  </selectstr>
+  <where>
+	<when>
+		u_factory_profitrate.bednet_or_mattress = @bednet_or_mattress
+	</when>
+	<when notnull="@arg_deptid">
+		u_factory_profitrate.deptid = @deptid
+	</when>
+	<when notnull="@bednettypeid_mattresstypeid">
+		u_factory_profitrate.bednettypeid_mattresstypeid = @bednettypeid_mattresstypeid
+	</when>
+  </where>
+  <orderstr>
+  </orderstr>
+  <displayfields>
+  </displayfields>
+</select>

+ 37 - 0
JLHHJSvr/DataStore/web_bednet_var_define_cw.xml

@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<select>
+  <selectstr>
+SELECT u_bednet_varmx.varid AS varid
+	,varkind
+	,varcode
+	,varname
+	,varclass
+	,vartype
+	,varunit
+	,u_bednet_varmx.varvalue AS varvalue
+	,dscrp
+	,createtime
+	,createby
+FROM u_bednet_var
+INNER JOIN u_bednet_varmx ON u_bednet_varmx.varid = u_bednet_var.varid
+WHERE (
+		varkind = @varkind
+		OR @varkind = - 1
+		)
+	AND (u_bednet_varmx.pricelistid = @pricelistid)
+	AND (
+		(
+			u_bednet_var.varclass = 1
+			AND (
+				u_bednet_varmx.bednettypeid = @bednettypeid
+				OR @bednettypeid = 0
+				)
+			)
+		OR (u_bednet_var.varclass = 0)
+		)
+  </selectstr>
+  <where>
+  </where>
+  <displayfields>
+  </displayfields>
+</select>

File diff suppressed because it is too large
+ 1685 - 7
JLHHJSvr/Excutor/SaveBedNetExcutor.cs


+ 39 - 121
JLHWEB/src/views/quote/bednetQuote/detail.vue

@@ -94,7 +94,7 @@ import LjVxeTable from "@/components/LjVxeTable/index.vue";
 // import { cloneDeep } from "lodash-es";
 import { useRoute, useRouter } from "vue-router";
 import { CommonDynamicSelect, GetFormulaCompute } from "@/api/modules/common";
-// import { SaveMattress, SaveMattressAuditing, DelMattress } from "@/api/modules/quote";
+import { SaveBedNet } from "@/api/modules/quote";
 // import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
 import { TYPE, useToast, POSITION } from "vue-toastification";
 import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
@@ -137,7 +137,8 @@ const {
   getDataMxAdd,
   getDataMxSpring,
   dataCallback,
-  dataCallbackMx
+  dataCallbackMx,
+  wf_cmp_cb
 } = useHooks();
 
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
@@ -241,127 +242,44 @@ const orderDefaultAction: detailAction[] = [
       // console.log("save------------ :>> ", loadingStatus.save);
       // console.log("save cushionsMxData :>> ", cushionsMxData.value);
 
-      // try {
-      //   await LjDetailRef.value.toValidateForm();
-
-      //   wf_cmp_cb();
-      //   loadingStatus.save = true;
-
-      //   let mattress = LjDetailRef.value._mainData;
-      //   console.log("save cushionsMxData :>> ", LjDetailRef.value._mainData, mattress?.if_d_chai, Number(mattress.if_d_chai));
-      //   mattress.mattressid = Number(mattress.mattressid ?? 0);
-      //   mattress.if_moneyrate = Number(mattress.if_moneyrate ?? 0);
-      //   mattress.if_bcp_type = Number(mattress.if_bcp_type ?? 0);
-      //   mattress.if_d_chai = Number(mattress.if_d_chai ?? 0);
-      //   mattress.if_m_chai = Number(mattress.if_m_chai ?? 0);
-      //   mattress.if_m_wbutao_way = Number(mattress.if_m_wbutao_way ?? 0);
-      //   mattress.if_moneyrate = Number(mattress.if_moneyrate ?? 0);
-      //   mattress.if_moneyrate = Number(mattress.if_moneyrate ?? 0);
-      //   mattress.if_n_butao = Number(mattress.if_n_butao ?? 0);
-      //   mattress.if_w_butao = Number(mattress.if_w_butao ?? 0);
-      //   mattress.if_z_chai = Number(mattress.if_z_chai ?? 0);
-      //   mattress.if_zhedie_type = Number(mattress.if_zhedie_type ?? 0);
-      //   mattress.packqty = Number(mattress.packqty ?? 0);
-      //   mattress.woodpallettype = mattress?.woodpallettype ?? "0";
-      //   mattress.total_hr_cost = mattress?.total_hr_cost ?? "0";
-      //   mattress.total_material_cost = mattress?.total_material_cost ?? "0";
-      //   mattress.total_hr_cost = mattress?.total_hr_cost ?? 0;
-      //   mattress.total_material_cost = mattress?.total_material_cost ?? 0;
-      //   mattress.total_fees_cost = mattress?.total_fees_cost ?? 0;
-      //   mattress.total_cost = mattress?.total_cost ?? 0;
-      //   mattress.commissionrate = mattress?.commissionrate ?? 0;
-      //   mattress.fob = mattress?.fob ?? 0;
-      //   mattress.profitrate = mattress?.profitrate ?? 0;
-      //   mattress.nottax_factory_cost = mattress?.nottax_factory_cost ?? 0;
-      //   mattress.nottax_dept_cost = mattress?.nottax_dept_cost ?? 0;
-      //   mattress.foreign_cost = mattress?.foreign_cost ?? 0;
-      //   mattress.diameter = mattress?.diameter ?? 0;
-      //   mattress.area = mattress?.area ?? 0;
-      //   mattress.cabinet_type = mattress?.cabinet_type ?? 0;
-      //   mattress.hrcost = mattress?.hrcost ?? 0;
-      //   mattress.biandaicost = mattress?.biandaicost ?? 0;
-      //   mattress.flag = mattress?.flag ?? 0;
-      //   mattress.dept_profitrate_rangli = mattress?.dept_profitrate_rangli ?? 0;
-      //   mattress.profitrate_point = mattress?.profitrate_point ?? 0;
-      //   mattress.chaizhuang_point = mattress?.chaizhuang_point ?? 0;
-      //   mattress.haimian_point = mattress?.haimian_point ?? 0;
-      //   mattress.qr_auditingdate = mattress?.qr_auditingdate ?? 0;
-      //   mattress.zhizao_amt = mattress?.zhizao_amt ?? 0;
-      //   mattress.foreign_cost_bz = mattress?.foreign_cost_bz ?? 0;
-      //   mattress.cubage = mattress?.cubage ?? 0;
-
-      //   let mattressMx = [];
-      //   fabricMxTabList.value.map(t => {
-      //     if (t.ref) {
-      //       console.log("t.ref?.value :>> ", t.ref, dynamicRef(t.ref));
-      //       if (dynamicRef(t.ref)) {
-      //         let { fullData } = dynamicRef(t.ref)?.element.getTableData();
-      //         console.log("fullData :>> ", fullData);
-      //         fullData = fullData.map((itm, idx) => {
-      //           itm.xu = idx + 1;
-      //           return itm;
-      //         });
-      //         mattressMx = mattressMx.concat(fullData);
-      //       }
-      //     }
-      //   });
+      try {
+        await LjDetailRef.value.toValidateForm();
 
-      //   mattressMx = mattressMx.map(t => {
-      //     t.formulaid = t.formulaid ?? 0;
-      //     t.formula = t.formula ?? "";
-      //     t.if_success = t.if_success ?? 0;
-      //     t.replace_formula = t.replace_formula ?? "";
-      //     t.priceunit = t.priceunit ?? "";
-      //     t.shrinkage = t.shrinkage ?? 0;
-      //     t.mtrlid = t.mtrlid ?? 0;
-      //     t.price = t.price ?? 0;
-      //     t.gram_weight = t.gram_weight ?? 0;
-      //     t.cloth_width = t.cloth_width ?? 0;
-      //     t.if_inputqty = t.if_inputqty ?? 0;
-      //     t.qty = t.qty ?? 0;
-      //     t.costamt = t.costamt ?? 0;
-      //     t.if_areaprice = t.if_areaprice ?? 0;
-      //     t.thickness = t.thickness ?? 0;
-      //     t.chastr = t.chastr ?? "";
-      //     t.useqty = t.useqty ?? 0;
-      //     t.useformula = t.useformula ?? "";
-      //     t.replace_useformula = t.replace_useformula ?? "";
-      //     t.gydscrp = t.gydscrp ?? "";
-      //     t.xu = t.xu ?? 0;
-      //     return t;
-      //   });
+        wf_cmp_cb();
 
-      //   let _param_mf = {
-      //     mattress,
-      //     mattressMx
-      //   };
-      //   try {
-      //     console.log("综合 _param_mf :>> ", _param_mf);
-      //     // await SaveMattress(_param_mf)
-      //     //   .then(res => {
-      //     //     ElNotification({
-      //     //       title: "温馨提示",
-      //     //       message: t("sys.api.sueccessToSave"),
-      //     //       type: "success"
-      //     //     });
-      //     //     if (res.mattressid) {
-      //     //       router.replace(`/mattressQuote/detail?id=${res.mattressid}`);
-      //     //     } else {
-      //     //       router.replace("/mattressQuote");
-      //     //     }
-      //     //     loadingStatus.save = false;
-      //     //   })
-      //     //   .catch(error => {
-      //     //     console.log("error !! :>> ", error);
-      //     //     loadingStatus.save = false;
-      //     //   });
-      //   } catch (error) {
-      //     ElMessage.error(t("sys.api.operationFailed"));
-      //   }
-      // } catch (e) {
-      //   loadingStatus.save = false;
-      //   console.log("buttonNew eee :>> ", e, loadingStatus.save);
-      // }
+        let bednet = LjDetailRef.value._mainData;
+
+        let bednetMx = vxeTableMxRef.value?.element.getTableData();
+
+        let spring = vxeTableMxSpringRef.value?.element.getTableData();
+
+        let _param_mf = {
+          bednet,
+          bednetMx,
+          spring
+        };
+        try {
+          console.log("综合 _param_mf :>> ", _param_mf);
+          await SaveBedNet(_param_mf)
+            .then(res => {
+              ElNotification({
+                title: "温馨提示",
+                message: t("sys.api.sueccessToSave"),
+                type: "success"
+              });
+              if (res.bednet.billid) {
+                router.replace(`/mattressQuote/detail?id=${res.bednet.billid}`);
+              } else {
+                router.replace("/mattressQuote");
+              }
+            })
+            .catch(error => {
+              console.log("error !! :>> ", error);
+            });
+        } catch (error) {
+          ElMessage.error(t("sys.api.operationFailed"));
+        }
+      } catch (e) {}
     }
   }),
   buttonDefault({

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

@@ -36,6 +36,7 @@ interface defaultState {
   SpringDialogProps: any;
   currentArea: any;
   AreaList: any;
+  bednetVarList: any;
 }
 
 /**
@@ -131,7 +132,8 @@ export const useHooks = (t?: any) => {
     SpringDialogRef: null,
     SpringDialogProps: {},
     currentArea: null,
-    AreaList: []
+    AreaList: [],
+    bednetVarList: []
   });
   state.orderStatus = inject("orderStatus", "");
 
@@ -1824,6 +1826,842 @@ export const useHooks = (t?: any) => {
 
   const columnsBednet = ref<ColumnProps<any>[]>([{}]);
 
+  /**
+   * @description 计算价格
+   */
+  const wf_cmp_cb = async () => {
+    const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
+
+    wf_clear();
+
+    wf_set_if_doublespring();
+
+    if (!wf_check_rule()) return;
+
+    if (!wf_check_required()) return;
+  };
+
+  /**
+   * @description 清除运算结果
+   */
+  const wf_clear = () => {
+    const { _mainData } = state.LjDetailRef;
+
+    _mainData.spring_mtrl_cost = 0;
+    _mainData.spring_hr_cost = 0;
+    _mainData.total_mtrl_cost = 0;
+    _mainData.total_hr_cost = 0;
+    _mainData.total_fees_cost = 0;
+    _mainData.total_cost = 0;
+    _mainData.nottax_factory_cost = 0;
+    _mainData.nottax_dept_cost = 0;
+    _mainData.dept_cost = 0;
+    _mainData.foreign_cost = 0;
+    _mainData.taxes = 0;
+    _mainData.snake_wire_mtrl_cost = 0;
+    _mainData.pocket_around_spring_cost = 0;
+    _mainData.pocket_around_fabrics_cost = 0;
+    _mainData.hard_around_mtrl_cost = 0;
+    _mainData.hard_around_hr_cost = 0;
+    _mainData.glue_price = 0;
+    _mainData.felt_price = 0;
+    _mainData.felt_mtrl_cost = 0;
+    _mainData.felt_hr_cost = 0;
+    _mainData.glue_mtrl_cost = 0;
+    _mainData.fabrics1_mtrl_cost = 0;
+    _mainData.fabrics2_mtrl_cost = 0;
+    _mainData.side_iron_mtrl_cost = 0;
+    _mainData.side_iron_hr_cost = 0;
+    _mainData.side_iron_price = 0;
+    _mainData.side_iron_lossrate = 0;
+    _mainData.cnail_price = 0;
+    _mainData.cnail_mtrl_cost = 0;
+    _mainData.cnail_hr_cost = 0;
+    _mainData.sponge_mtrl_cost = 0;
+    _mainData.sponge_hr_cost = 0;
+    _mainData.edge_mtrl_cost = 0;
+    _mainData.edge_hr_cost = 0;
+    _mainData.fork_mtrl_cost = 0;
+    _mainData.fork_hr_cost = 0;
+    _mainData.rsorwa_mtrl_cost = 0;
+    _mainData.rsorwa_hr_cost = 0;
+    _mainData.sponge_drilling_hr_cost = 0;
+    _mainData.sponge_price = 0;
+    _mainData.edge_price = 0;
+    _mainData.fork_price = 0;
+    _mainData.rsorwa_price = 0;
+    _mainData.felt_mtrl_x_cost = 0;
+    _mainData.packet_mtrl_cost = 0;
+    _mainData.packet_hr_cost = 0;
+    _mainData.sum_weight = 0;
+    _mainData.spring_weight_qty = 0;
+    _mainData.side_iron_weight_qty = 0;
+    _mainData.hard_around_weight_qty = 0;
+    _mainData.fabrics1_weight_qty = 0;
+    _mainData.fabrics2_weight_qty = 0;
+    _mainData.felt_weight_qty = 0;
+    _mainData.cnail_weight_qty = 0;
+    _mainData.sponge_weight_qty = 0;
+    _mainData.sponge_weight_tc_qty = 0;
+    _mainData.fork_weight_qty = 0;
+    _mainData.edge_weight_qty = 0;
+  };
+
+  const wf_set_if_doublespring = () => {
+    const { _mainData, enumMap } = state.LjDetailRef;
+
+    const deptEnum = enumMap.get("deptid");
+    const bednettypeEnum = enumMap.get("bednettypeid");
+
+    let deptItem = deptEnum.find((item: any) => Number(item.value) == _mainData.deptid);
+    let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
+
+    if (typeItem.indexOf("圆网") > -1 && deptItem.indexOf("外贸") === -1 && deptItem.indexOf("国外") === -1) {
+      _mainData.if_doublespring = 1;
+    }
+  };
+
+  const wf_check_rule = (): boolean => {
+    let { fullData: mxlist } = state.vxeTableMxRef.element.getTableData();
+    let { fullData: springlist } = state.vxeTableMxSpringRef.element.getTableData();
+
+    for (let mx of mxlist) {
+      //1.如果没有四周加硬   左边 弹簧个数排列宽   等于   右边每行  弹簧个数排列宽      , 左边 弹簧个数排列长  等于  右边每行合计  弹簧个数排列长
+      if (Number(mx.if_hard_around) === 0) {
+        // 左边 弹簧个数排列宽   等于   右边每行  弹簧个数排列宽
+        let sum_length = 0;
+        for (let spring of springlist) {
+          sum_length += parseFloat(spring.spring_qty_length);
+
+          if (Number(mx.spring_qty_width) != Number(spring.spring_qty_width)) {
+            ElMessage({
+              type: "info",
+              message: `多区袋装明细列表,第${spring.pid}行,弹簧个数排列宽填写错误!`
+            });
+            return false;
+          }
+        }
+
+        if (parseFloat(mx.spring_qty_length) != sum_length) {
+          ElMessage({
+            type: "info",
+            message: `床网明细列表 弹簧个数排列长${parseFloat(
+              mx.spring_qty_length
+            )}不等于 多区袋装明细列表 弹簧个数排列长合计${sum_length}!`
+          });
+          return false;
+        }
+      } else if (Number(mx.if_hard_around) === 1) {
+        // 左边 弹簧个数排列宽   小于   右边每行  弹簧个数排列宽
+        let sum_length = 0;
+        for (let spring of springlist) {
+          sum_length += parseFloat(spring.spring_qty_length);
+
+          if (Number(mx.spring_qty_width) < Number(spring.spring_qty_width)) {
+            ElMessage({
+              type: "info",
+              message: `多区袋装明细列表,第${spring.pid}行,弹簧个数排列宽填写错误!`
+            });
+            return false;
+          }
+        }
+
+        //左边 弹簧个数排列长  小于  右边每行合计  弹簧个数排列长
+        if (parseFloat(mx.spring_qty_length) < sum_length) {
+          ElMessage({
+            type: "info",
+            message: `床网明细列表 弹簧个数排列长${parseFloat(
+              mx.spring_qty_length
+            )}小于 多区袋装明细列表 弹簧个数排列长合计${sum_length}!`
+          });
+          return false;
+        }
+      }
+    }
+
+    return true;
+  };
+
+  const wf_check_required = async (): Promise<boolean> => {
+    const { _mainData, enumMap } = state.LjDetailRef;
+    let { fullData: mxlist } = state.vxeTableMxRef.element.getTableData();
+
+    //检查有没有填写床网高
+    for (let mx of mxlist) {
+      if (mx.bednet_height + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `请填写床网高!`
+        });
+        return false;
+      } else {
+        _mainData.mattress_height = parseFloat(mx.bednet_height);
+      }
+    }
+
+    // 检查有没有 填写 填充海绵高
+    if (_mainData.sponge_tc_mtrlid + 0 > 0) {
+      if (_mainData.sponge_tc_thickness + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `请填写填充海绵厚度!`
+        });
+        return false;
+      }
+
+      if (_mainData.sponge_tc_height + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `请填写填充海绵厚度!`
+        });
+        return false;
+      }
+
+      if ((_mainData.sponge_tc_thickness + 0 > 0 || _mainData.sponge_tc_height + 0 > 0) && _mainData.sponge_tc_mtrlid + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `请选择填充海绵物料!`
+        });
+        return false;
+      }
+    }
+
+    // 如果 没有填写 海绵高和封边高  自动等于 床网高
+    if (_mainData.sponge_mtrlid > 0 && _mainData.sponge_height + 0 <= 0) _mainData.sponge_height = _mainData.mattress_height;
+    if (_mainData.edge_mtrlid > 0 && _mainData.edge_height + 0 <= 0) _mainData.edge_height = _mainData.mattress_height;
+
+    _mainData.commission = _mainData.commission ?? 1;
+    _mainData.taxrate = _mainData.taxrate ?? 1;
+    _mainData.other_rate = _mainData.other_rate ?? 1;
+    _mainData.moneyrate = _mainData.moneyrate ?? 1;
+
+    if (_mainData.commission < 1) {
+      ElMessage({
+        type: "info",
+        message: `佣金点数不能小于1!`
+      });
+      return false;
+    }
+
+    if (_mainData.taxrate < 1) {
+      ElMessage({
+        type: "info",
+        message: `税率不能小于1!`
+      });
+      return false;
+    }
+
+    if (_mainData.other_rate < 1) {
+      ElMessage({
+        type: "info",
+        message: `额外点数不能小于1!`
+      });
+      return false;
+    }
+
+    if (_mainData.packtype && _mainData.packtype.length > 0) {
+      _mainData.packtype = _mainData.packtype.trim();
+
+      if (_mainData.packtype != "不压不卷" && _mainData.packqty + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `请填写包装数量!`
+        });
+        return false;
+      }
+
+      if (_mainData.packtype != "不压不卷" && _mainData.packtype != "裸包装" && _mainData.transport_type + "" == "") {
+        ElMessage({
+          type: "info",
+          message: `请选择运输方式!`
+        });
+        return false;
+      }
+
+      if (_mainData.packtype == "卷包" && _mainData.packmtrl + "" == "") {
+        ElMessage({
+          type: "info",
+          message: `请选择包装材料!`
+        });
+        return false;
+      }
+    }
+
+    await wf_factory_profitrate();
+
+    if (_mainData.dept_profitrate + 0 == 0) {
+      ElMessage({
+        type: "info",
+        message: `部门利润率不能为0!`
+      });
+      return false;
+    }
+
+    if (_mainData.bednettypeid + 0 == 0) {
+      ElMessage({
+        type: "info",
+        message: `请选择床网类别!`
+      });
+      return false;
+    }
+
+    if (_mainData.sponge_mtrlid + 0 > 0 && _mainData.sponge_thickness + 0 == 0) {
+      ElMessage({
+        type: "info",
+        message: `请填写海绵厚度!`
+      });
+      return false;
+    }
+
+    if (_mainData.sponge_mtrlid + 0 == 0 && _mainData.sponge_thickness + 0 > 0) {
+      ElMessage({
+        type: "info",
+        message: `请选择海绵物料!`
+      });
+      return false;
+    }
+
+    const bednettypeEnum = enumMap.get("bednettypeid");
+    let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
+
+    for (let mx of mxlist) {
+      if (mx.bednet_height + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `第${mx.pid}行,请填写床网高!`
+        });
+        return false;
+      }
+      if (mx.spring_qty_width + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `第${mx.pid}行,请填写弹簧排列个数-宽!`
+        });
+        return false;
+      }
+      if (mx.spring_qty_length + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `第${mx.pid}行,请填写弹簧排列个数-长!`
+        });
+        return false;
+      }
+
+      if (typeItem.indexOf("袋装网") > -1 && mx.fabrics1_mtrlid + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `第${mx.pid}行,请选择入袋无纺布!`
+        });
+        return false;
+      }
+
+      if (mx.if_side_iron > 0 && mx.side_iron_qty + 0 == 0) {
+        ElMessage({
+          type: "info",
+          message: `第${mx.pid}行,请填写边铁条数!`
+        });
+        return false;
+      }
+    }
+
+    return true;
+  };
+
+  const wf_replace_expression = (arg_str: string, mx: any) => {
+    const { _mainData, enumMap } = state.LjDetailRef;
+
+    // 替换中文符号
+    arg_str = arg_str.replace(/(/g, " ( ").replace(/)/g, " ) ");
+    arg_str = arg_str.replace(/,/g, " , ");
+
+    const bednettypeEnum = enumMap.get("bednettypeid");
+
+    let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
+
+    // 四周加硬逻辑
+    if (mx.if_hard_around + 0 === 1) {
+      let ls_temp_str = 0;
+      if (typeItem.indexOf("袋装") > -1) {
+        ls_temp_str = (mx.hard_around_row + 0) * 2;
+      } else {
+        ls_temp_str = mx.hard_around_row + 0;
+      }
+
+      let ls_temp_str_all = ` ( 【弹簧排列个数-宽】 - ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧计算个数(宽)】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧排列个数-长】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧计算个数(长)】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", ls_temp_str_all);
+    }
+
+    // 四周口袋逻辑
+    if (mx.if_pocket_around + 0 === 1) {
+      let ls_temp_str = 0;
+      if (typeItem.indexOf("袋装") > -1) {
+        ls_temp_str = (mx.pocket_around_row + 0) * 2;
+      } else {
+        ls_temp_str = mx.pocket_around_row + 0;
+      }
+
+      let ls_temp_str_all = ` ( 【弹簧排列个数-宽】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧计算个数(宽)】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧排列个数-长】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", ls_temp_str_all);
+
+      ls_temp_str_all = ` ( 【弹簧计算个数(长)】  -   ${ls_temp_str} ) `;
+      arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", ls_temp_str_all);
+    }
+
+    return arg_str;
+  };
+
+  const wf_cmp_spring_mtrl_cost_dw2 = (arg_str: string, mx: any) => {
+    const { _mainData, enumMap } = state.LjDetailRef;
+    // 替换中文符号
+    arg_str = arg_str.replace(/(/g, " ( ").replace(/)/g, " ) ");
+    arg_str = arg_str.replace(/,/g, " , ");
+
+    const bednettypeEnum = enumMap.get("bednettypeid");
+
+    let typeItem = bednettypeEnum.find((item: any) => Number(item.value) == _mainData.bednettypeid);
+
+    arg_str = replaceArgStr(arg_str, "【床垫宽】", _mainData.mattress_width);
+    arg_str = replaceArgStr(arg_str, "【床垫长】", _mainData.mattress_length);
+    arg_str = replaceArgStr(arg_str, "【床垫高】", _mainData.mattress_height);
+    arg_str = replaceArgStr(arg_str, "【双簧】", _mainData.if_doublespring);
+    arg_str = replaceArgStr(arg_str, "【床网类别】", typeItem.typename);
+
+    for (let item of state.bednetVarList) {
+      if (item.varvalue + 0 <= 0) continue;
+      arg_str = replaceArgStr(arg_str, `【${item.varname}】`, item.varvalue + 0);
+    }
+
+    arg_str = replaceArgStr(arg_str, "【弹簧排列个数-宽】", mx.spring_qty_width);
+    arg_str = replaceArgStr(arg_str, "【弹簧排列个数-长】", mx.spring_qty_length);
+    arg_str = replaceArgStr(arg_str, "【弹簧计算个数(宽)】", mx.spring_qty_width);
+    arg_str = replaceArgStr(arg_str, "【弹簧计算个数(长)】", mx.spring_qty_length);
+    arg_str = replaceArgStr(arg_str, "【边铁条数】", mx.side_iron_qty);
+    arg_str = replaceArgStr(arg_str, "【条数】", mx.side_iron_qty);
+  };
+
+  // 替换字符串
+  const replaceArgStr = (arg_str: string, findStr: string, replaceStr: any) => {
+    return arg_str.replace(findStr, replaceStr);
+  };
+
+  /**
+   * @description 获取部门利润率
+   */
+  const wf_factory_profitrate = async () => {
+    const { _mainData, enumMap } = state.LjDetailRef;
+
+    console.log("wf_factory_profitrate enumMap :>> ", enumMap);
+
+    let deptEnum = enumMap.get("deptid");
+    console.log("deptEnum :>> ", deptEnum);
+    if (deptEnum) {
+      let depItem = deptEnum.find((item: any) => item.value == _mainData.deptid);
+      console.log("depItem :>> ", depItem);
+      if (depItem) {
+        _mainData.dept_profitrate = parseFloat(depItem.profitrate);
+      }
+    }
+
+    let _params = {
+      dsname: "web_factory_profitratelist",
+      queryparams: {
+        arg_deptid: _mainData.deptid,
+        arg_bednettypeid_mattresstypeid: _mainData.mattresstypeid,
+        kind: 0
+      }
+    };
+    let res = await CommonDynamicSelect(_params);
+    if (res?.datatable?.length > 0) {
+      _mainData.profitrate = parseFloat(res?.datatable[0].profitrate);
+    }
+  };
+
+  const wf_bednet_var = async (varkind: Number, pricelistid: Number, bednettypeid: Number) => {
+    let _params = {
+      dsname: "web_bednet_var_define_cw",
+      queryparams: {
+        varkind,
+        pricelistid,
+        bednettypeid
+      }
+    };
+    let res = await CommonDynamicSelect(_params);
+    if (res?.datatable?.length > 0) {
+      state.bednetVarList = res?.datatable;
+    }
+  };
+
+  /**
+   * @description 主表计算公式
+   */
+  const summaryData = ref<any>([
+    {
+      label: "弹簧材料总成本",
+      field: "spring_mtrl_cost",
+      formula:
+        "if([折叠款] = 1, ([总材料成本]*[大小单]+[款式费用]+[边带费用]+[额外费用]+[制造费用]) * 2, [总材料成本]*[大小单]+[款式费用]+[边带费用]+[额外费用]+[制造费用])"
+    },
+    {
+      label: "弹簧人工总成本",
+      field: "spring_hr_cost",
+      formula: "[总成本] * ([工厂利润率] + [利润率点数] + [布套点数] + [拆装点数] + [海绵点数]) * [管理费点]"
+    },
+    {
+      label: "蛇线材料成本",
+      field: "snake_wire_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1)) * [额外点数] + [fob]"
+    },
+    {
+      label: "四周口袋弹簧成本",
+      field: "pocket_around_spring_cost",
+      formula: "([部门售价] * ([税率] - 1)) + [佣金] * 0.05"
+    },
+    {
+      label: "四周口袋无纺布成本",
+      field: "pocket_around_fabrics_cost",
+      formula: "([部门售价] + [佣金] * 0.06) * [税率] * if([fob] = 0, 1, [折扣率])"
+    },
+    {
+      label: "四周加硬材料成本",
+      field: "hard_around_mtrl_cost",
+      formula: "if([汇率] <> 0, [部门含税价] / [汇率], 0)"
+    },
+    {
+      label: "四周加硬人力成本",
+      field: "hard_around_hr_cost",
+      formula: "if(([dept_profitrate] + [dept_profitrate_rangli] / 100) <> 0, [dijia_cost] ,0 )"
+    },
+    {
+      label: "入袋无纺布材料成本",
+      field: "fabrics1_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "胶水材料成本",
+      field: "glue_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "底面无纺布材料成本",
+      field: "fabrics2_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "边铁人力成本",
+      field: "side_iron_hr_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "边铁材料成本",
+      field: "side_iron_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "C钉/夹码材料成本",
+      field: "cnail_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "C钉/夹码人力成本",
+      field: "cnail_hr_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "海绵包边材料成本",
+      field: "sponge_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "海绵包边人力成本",
+      field: "sponge_hr_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "填充海绵成本",
+      field: "sponge_mtrl_tc_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "封边材料成本",
+      field: "edge_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "封边人力成本",
+      field: "edge_hr_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "弹叉材料成本",
+      field: "fork_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "弹叉人力成本",
+      field: "fork_hr_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "胶条/包角材料成本",
+      field: "rsorwa_mtrl_cost",
+      formula: "[dijia_cost] / (1 - ([佣金点数] - 1 )) - [dijia_cost]"
+    },
+    {
+      label: "胶条/包角人力成本",
+      field: "rsorwa_hr_cost",
+      formula: ""
+    },
+    {
+      label: "海绵打孔人力成本",
+      field: "sponge_drilling_hr_cost",
+      formula: ""
+    },
+    {
+      label: "上垫层物料成本",
+      field: "felt_mtrl_cost",
+      formula: ""
+    },
+    {
+      label: "下垫层物料成本",
+      field: "felt_mtrl_x_cost",
+      formula: ""
+    },
+    {
+      label: "上垫层人力成本",
+      field: "felt_hr_cost",
+      formula: ""
+    },
+    {
+      label: "下垫层人力成本",
+      field: "felt_hr_x_cost",
+      formula: ""
+    },
+    {
+      label: "包装材料成本",
+      field: "packet_mtrl_cost",
+      formula: ""
+    },
+    {
+      label: "包装人工成本",
+      field: "packet_hr_cost",
+      formula: ""
+    },
+    {
+      label: "总材料成本",
+      field: "total_mtrl_cost",
+      formula: ""
+    },
+    {
+      label: "总人力成本",
+      field: "total_hr_cost",
+      formula: ""
+    },
+    {
+      label: "总成本",
+      field: "total_cost",
+      formula: ""
+    },
+    {
+      label: "钢丝重量",
+      field: "spring_weight_qty",
+      formula: ""
+    },
+    {
+      label: "边铁重量",
+      field: "side_iron_weight_qty",
+      formula: ""
+    },
+    {
+      label: "四周加硬重量",
+      field: "hard_around_weight_qty",
+      formula: ""
+    },
+    {
+      label: "入袋无纺布重量",
+      field: "fabrics1_weight_qty",
+      formula: ""
+    },
+    {
+      label: "面底无纺布重量",
+      field: "fabrics2_weight_qty",
+      formula: ""
+    },
+    // {
+    //   label: "上垫层重量",
+    //   field: "felt_mtrl_cost",
+    //   formula: ""
+    // },
+    {
+      label: "下垫层重量",
+      field: "felt_weight_qty",
+      formula: ""
+    },
+    {
+      label: "C钉/夹码重量",
+      field: "cnail_weight_qty",
+      formula: ""
+    },
+    {
+      label: "海绵包边重量",
+      field: "sponge_weight_qty",
+      formula: ""
+    },
+    {
+      label: "填充海绵重量",
+      field: "sponge_weight_tc_qty",
+      formula: ""
+    },
+    {
+      label: "封边材料重量",
+      field: "edge_weight_qty",
+      formula: ""
+    },
+    {
+      label: "弹叉材料重量",
+      field: "fork_weight_qty",
+      formula: ""
+    },
+    {
+      label: "重量汇总",
+      field: "sum_weight",
+      formula: ""
+    },
+    {
+      label: "FOB",
+      field: "fob",
+      formula: "[fob]"
+    }
+  ]);
+
+  /**
+   * @description 主表公式字段照表
+   */
+  const fieldParams = ref<any>([
+    {
+      label: "总成本",
+      field: "total_cost"
+    },
+    {
+      label: "不含税出厂价",
+      field: "nottax_factory_cost"
+    },
+    {
+      label: "部门售价",
+      field: "nottax_dept_cost"
+    },
+    {
+      label: "税金",
+      field: "taxes"
+    },
+    {
+      label: "部门含税价",
+      field: "dept_cost"
+    },
+    {
+      label: "外币价",
+      field: "foreign_cost"
+    },
+    {
+      label: "总材料成本",
+      field: "total_material_cost"
+    },
+    {
+      label: "大小单",
+      field: "dannum_rate"
+    },
+    {
+      label: "款式费用",
+      field: "hrcost"
+    },
+    {
+      label: "边带费用",
+      field: "biandaicost"
+    },
+    {
+      label: "额外费用",
+      field: "extras_cost"
+    },
+    {
+      label: "制造费用",
+      field: "zhizao_amt"
+    },
+    {
+      label: "折叠款",
+      field: "if_zhedie_type"
+    },
+    {
+      label: "管理费点",
+      field: "guanli_rate"
+    },
+    {
+      label: "工厂利润率",
+      field: "profitrate"
+    },
+    {
+      label: "利润率点数",
+      field: "profitrate_point"
+    },
+    {
+      label: "布套点数",
+      field: "butao_point"
+    },
+    {
+      label: "拆装点数",
+      field: "chaizhuang_point"
+    },
+    {
+      label: "海绵点数",
+      field: "haimian_point"
+    },
+    {
+      label: "部门利润率",
+      field: "dept_profitrate"
+    },
+    {
+      label: "部门让利点",
+      field: "dept_profitrate_rangli"
+    },
+    {
+      label: "额外点数",
+      field: "other_rate"
+    },
+    {
+      label: "佣金点数",
+      field: "commission"
+    },
+    {
+      label: "税率",
+      field: "taxrate"
+    },
+    {
+      label: "折扣率",
+      field: "discount"
+    },
+    {
+      label: "汇率",
+      field: "moneyrate"
+    },
+    {
+      label: "底价",
+      field: "dijia_cost"
+    }
+  ]);
+
   return {
     ...toRefs(state),
     columns,
@@ -1836,6 +2674,7 @@ export const useHooks = (t?: any) => {
     getDataMxSpring,
     getDataMxAdd,
     dataCallback,
-    dataCallbackMx
+    dataCallbackMx,
+    wf_cmp_cb
   };
 };