|
@@ -6,11 +6,11 @@ import { CommonDynamicSelect } from "@/api/modules/common";
|
|
|
import { useUserStore } from "@/stores/modules/user";
|
|
|
import MtrldefSelect from "@/views/system/selector/mtrldef/select.vue";
|
|
|
import { handleRowAccordingToProp } from "@/utils";
|
|
|
-import { ElButton, ElMessage, ElPopconfirm } from "element-plus";
|
|
|
+import { ElButton, ElMessage, ElPopconfirm, ElMessageBox } from "element-plus";
|
|
|
import { Minus, Plus, InfoFilled } from "@element-plus/icons-vue";
|
|
|
import { DwnameEnum } from "@/enums/dwnameEnum";
|
|
|
import { isArray } from "@/utils/is";
|
|
|
-import { calculateFormula } from "@/utils/index";
|
|
|
+import { calculateFormula, formulaPartsFormula, floatAdd, floatMul, formatFixedNumber } from "@/utils/index";
|
|
|
import { cloneDeep, defaultsDeep } from "lodash-es";
|
|
|
import { TYPE, useToast, POSITION } from "vue-toastification";
|
|
|
import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
|
|
@@ -103,10 +103,7 @@ interface defaultState {
|
|
|
cabinetTypeOptions: any;
|
|
|
diancengAreaEnum: any;
|
|
|
}
|
|
|
-/**
|
|
|
- * @description 表格多选数据操作
|
|
|
- * @param {String} rowKey 当表格可以多选时,所指定的 id
|
|
|
- * */
|
|
|
+
|
|
|
export const useHooks = (t?: any) => {
|
|
|
const state = reactive<defaultState>({
|
|
|
orderStatus: "",
|
|
@@ -521,6 +518,23 @@ export const useHooks = (t?: any) => {
|
|
|
};
|
|
|
|
|
|
const dataCallback = (data: any) => {
|
|
|
+ console.log("dataCallback data :>> ", data);
|
|
|
+ if (data.datatable.length > 0) {
|
|
|
+ data.datatable = data.datatable.map((item: any) => {
|
|
|
+ item.dannum_rate = Number(item.dannum_rate);
|
|
|
+ return item;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ list: data.datatable,
|
|
|
+ tableinfo: data.tableinfo,
|
|
|
+ total: data.totalcnt,
|
|
|
+ pageNum: data.pageindex,
|
|
|
+ pageSize: data.pagesize
|
|
|
+ };
|
|
|
+ };
|
|
|
+
|
|
|
+ const dataCallbackMx = (data: any) => {
|
|
|
console.log("dataCallback data :>> ", data);
|
|
|
return {
|
|
|
list: data.datatable,
|
|
@@ -535,7 +549,7 @@ export const useHooks = (t?: any) => {
|
|
|
let newParams = {
|
|
|
dsname: "_Mapper_deptid",
|
|
|
queryparams: {
|
|
|
- arg_deptid: data.deptid
|
|
|
+ deptid: data.deptid
|
|
|
}
|
|
|
};
|
|
|
let res = await CommonDynamicSelect(newParams);
|
|
@@ -695,19 +709,19 @@ export const useHooks = (t?: any) => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // const wf_mtrl_find = async (params: any) => {
|
|
|
- // let _params: any = {
|
|
|
- // dsname: "web_mtrl_choose",
|
|
|
- // queryparams: params
|
|
|
- // }
|
|
|
- // let res = await CommonDynamicSelect(_params);
|
|
|
+ const wf_mtrl_find = async (params: any) => {
|
|
|
+ let _params: any = {
|
|
|
+ dsname: "web_mtrl_choose",
|
|
|
+ queryparams: params
|
|
|
+ };
|
|
|
+ let res = await CommonDynamicSelect(_params);
|
|
|
|
|
|
- // if (res?.datatable?.length) {
|
|
|
- // return res?.datatable
|
|
|
- // } else {
|
|
|
- // return [];
|
|
|
- // }
|
|
|
- // };
|
|
|
+ if (res?.datatable?.length) {
|
|
|
+ return res?.datatable;
|
|
|
+ } else {
|
|
|
+ return [];
|
|
|
+ }
|
|
|
+ };
|
|
|
|
|
|
/**
|
|
|
* @description 垫层配置 和 垫层可选项
|
|
@@ -1518,6 +1532,669 @@ export const useHooks = (t?: any) => {
|
|
|
|
|
|
// }
|
|
|
|
|
|
+ /**
|
|
|
+ * @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 = Number(depItem.profitrate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let _params = {
|
|
|
+ dsname: "web_factory_profitratelist",
|
|
|
+ queryparams: {
|
|
|
+ arg_deptid: _mainData.deptid,
|
|
|
+ arg_bednettypeid_mattresstypeid: _mainData.mattresstypeid,
|
|
|
+ kind: 1
|
|
|
+ }
|
|
|
+ };
|
|
|
+ let res = await CommonDynamicSelect(_params);
|
|
|
+ if (res?.datatable?.length > 0) {
|
|
|
+ _mainData.profitrate = res?.datatable[0].profitrate;
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 获取部门汇率 和 折扣率
|
|
|
+ */
|
|
|
+ const wf_get_moneyrate_discount = () => {
|
|
|
+ const { _mainData, enumMap } = state.LjDetailRef;
|
|
|
+
|
|
|
+ let deptEnum = enumMap.get("deptid");
|
|
|
+ console.log("deptEnum :>> ", deptEnum);
|
|
|
+ if (deptEnum) {
|
|
|
+ let depItem = deptEnum.find((item: any) => item.value == _mainData.deptid);
|
|
|
+ console.log("wf_get_moneyrate_discount depItem :>> ", depItem);
|
|
|
+ if (depItem) {
|
|
|
+ let _moneyrate = !depItem.moneyrate || Number(depItem.moneyrate) == 0 ? 1 : depItem.moneyrate;
|
|
|
+ console.log("_mainData.if_moneyrate == 0 :>> ", _mainData.if_moneyrate == "0");
|
|
|
+ if (_mainData.if_moneyrate == "0" || !_mainData.if_moneyrate) {
|
|
|
+ _mainData.moneyrate = 1;
|
|
|
+ } else {
|
|
|
+ _mainData.moneyrate = _moneyrate;
|
|
|
+ }
|
|
|
+
|
|
|
+ _mainData.discount = depItem.discount;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @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[t.ref].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 计算价格
|
|
|
+ */
|
|
|
+ const wf_cmp_cb = async () => {
|
|
|
+ const { _mainData, enumMap, baseformRef } = state.LjDetailRef;
|
|
|
+
|
|
|
+ //清除运算结果
|
|
|
+ wf_clear();
|
|
|
+
|
|
|
+ await wf_factory_profitrate();
|
|
|
+
|
|
|
+ wf_get_moneyrate_discount();
|
|
|
+
|
|
|
+ wf_cmp_update_mtrl();
|
|
|
+
|
|
|
+ wf_check_dianceng_ifright();
|
|
|
+
|
|
|
+ if (!wf_cmp_bednet()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 佣金
|
|
|
+ if (_mainData?.commission == 0 || !_mainData.commission) {
|
|
|
+ _mainData.commission = 1;
|
|
|
+ }
|
|
|
+ if (_mainData?.taxrate == 0 || !_mainData.taxrate) {
|
|
|
+ _mainData.taxrate = 1;
|
|
|
+ }
|
|
|
+ if (_mainData?.other_rate == 0 || !_mainData.other_rate) {
|
|
|
+ _mainData.other_rate = 1;
|
|
|
+ }
|
|
|
+ if (_mainData?.moneyrate == 0 || !_mainData.moneyrate) {
|
|
|
+ _mainData.moneyrate = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (_mainData?.commission < 1) {
|
|
|
+ ElMessage.error("佣金点数不能小于1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_mainData?.taxrate < 1) {
|
|
|
+ ElMessage.error("税率不能小于1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_mainData?.other_rate < 1) {
|
|
|
+ ElMessage.error("额外点数不能小于1");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (_mainData?.dept_profitrate == 0) {
|
|
|
+ ElMessage.error("部门利润率不能为0!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ let _data = {
|
|
|
+ ls_mattress_width: _mainData.mattress_width,
|
|
|
+ ls_mattress_length: _mainData.mattress_length,
|
|
|
+ ls_mattress_height: _mainData.mattress_height,
|
|
|
+ ls_packqty: _mainData.packqty,
|
|
|
+ ls_diameter: _mainData.diameter,
|
|
|
+ ls_woodpallettype: _mainData.woodpallettype,
|
|
|
+ ls_if_m_wbutao_way: _mainData.if_m_wbutao_way ?? "0",
|
|
|
+ ls_if_db_wbutao_way: _mainData.if_db_wbutao_wa ?? "0",
|
|
|
+ ls_s_cover_qty: _mainData.s_cover_qty ?? "0",
|
|
|
+ ls_z_cover_qty: _mainData.z_cover_qty ?? "0",
|
|
|
+ ls_x_cover_qty: _mainData.x_cover_qty ?? "0",
|
|
|
+ ls_s_m_cover_qty: _mainData.s_m_cover_qty ?? "0",
|
|
|
+ ls_z_m_cover_qty: _mainData.z_m_cover_qty ?? "0",
|
|
|
+ ls_x_m_cover_qty: _mainData.x_m_cover_qty ?? "0",
|
|
|
+ ls_if_m_chai: _mainData.if_m_chai ?? "0",
|
|
|
+ ls_if_z_chai: _mainData.if_z_chai ?? "0",
|
|
|
+ ls_if_d_chai: _mainData.if_d_chai ?? "0"
|
|
|
+ };
|
|
|
+
|
|
|
+ state.fabricMxTabList.map(t => {
|
|
|
+ if (t.ref && state[t.ref]) {
|
|
|
+ let { fullData } = state[t.ref].element.getTableData();
|
|
|
+ fullData.map(item => {
|
|
|
+ if ((!item.mtrlid || Number(item.mtrlid) == 0) && Number(item.formulakind) != 31) {
|
|
|
+ let ls_Expression = item.formula;
|
|
|
+ let ls_Use_Expression = item.useformula;
|
|
|
+
|
|
|
+ let _mxData = {
|
|
|
+ ls_price: item.price,
|
|
|
+ ls_gram_weight: item.gram_weight,
|
|
|
+ ls_cloth_width: item.cloth_width,
|
|
|
+ ls_if_inputqty: item.if_inputqty,
|
|
|
+ ls_qty: item.qty,
|
|
|
+ ls_thickness: item.thickness,
|
|
|
+ ls_shrinkage: Number(item.shrinkage) == 0 ? "1" : item.shrinkage,
|
|
|
+ ls_if_areaprice: item.if_areaprice,
|
|
|
+ ls_mtrlname: item.mtrlname ?? "null"
|
|
|
+ };
|
|
|
+
|
|
|
+ ls_Expression = wf_replace_height_big_side(ls_Expression, item.chastr);
|
|
|
+ ls_Use_Expression = wf_replace_height_big_side(ls_Use_Expression, item.chastr);
|
|
|
+
|
|
|
+ ls_Expression = wf_replace_height_small_side(ls_Expression, item.chastr);
|
|
|
+ ls_Use_Expression = wf_replace_height_small_side(ls_Use_Expression, item.chastr);
|
|
|
+
|
|
|
+ ls_Expression = wf_replace_height_v_side(ls_Expression, item.chastr);
|
|
|
+ ls_Use_Expression = wf_replace_height_v_side(ls_Use_Expression, item.chastr);
|
|
|
+
|
|
|
+ // 替换布料幅宽start
|
|
|
+ let ls_bl_cloth_width = "";
|
|
|
+ let _formulakind = Number(item.formulakind);
|
|
|
+ // 大侧
|
|
|
+ if (t.name == "tabpage_10" && t.type.includes(_formulakind)) {
|
|
|
+ ls_bl_cloth_width = wf_replace_cloth_width(item, fullData, 2);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //小侧
|
|
|
+ if (t.name == "tabpage_11" && t.type.includes(_formulakind)) {
|
|
|
+ ls_bl_cloth_width = wf_replace_cloth_width(item, fullData, 3);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //V侧
|
|
|
+ if (t.name == "tabpage_12" && t.type.includes(_formulakind)) {
|
|
|
+ ls_bl_cloth_width = wf_replace_cloth_width(item, fullData, 4);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //面裥绵
|
|
|
+ if (t.name == "tabpage_8" && t.type.includes(_formulakind)) {
|
|
|
+ ls_bl_cloth_width = wf_replace_cloth_width(item, fullData, 0);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //底裥绵
|
|
|
+ if (t.name == "tabpage_9" && t.type.includes(_formulakind)) {
|
|
|
+ ls_bl_cloth_width = wf_replace_cloth_width(item, fullData, 1);
|
|
|
+
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //替换布料幅宽end
|
|
|
+
|
|
|
+ //替换布套高star
|
|
|
+ let ls_bl_bt_height = "";
|
|
|
+ // 内布套
|
|
|
+ let tabpage_14 = state.otherMxTabList.find(t => t.name == "tabpage_14");
|
|
|
+ if (tabpage_14.type.includes(_formulakind)) {
|
|
|
+ ls_bl_bt_height = "";
|
|
|
+
|
|
|
+ let { fullData: mlData } = state[t.ref].element.getTableData();
|
|
|
+ fullData.find(itm => {
|
|
|
+ if (itm.formulakind == 101) {
|
|
|
+ ls_bl_bt_height = formatFixedNumber({ val: itm.thickness }, 4);
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (Number(ls_bl_cloth_width) > 0) {
|
|
|
+ ls_Expression = ls_Expression.replaceAll("【布套高】", ls_bl_bt_height);
|
|
|
+ ls_Use_Expression = ls_Use_Expression.replaceAll("【布套高】", ls_bl_bt_height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 外布套
|
|
|
+ let tabpage_15 = state.otherMxTabList.find(t => t.name == "tabpage_15");
|
|
|
+ if (tabpage_15.type.includes(_formulakind)) {
|
|
|
+ ls_bl_bt_height = "";
|
|
|
+
|
|
|
+ let { fullData: mlData } = state[t.ref].element.getTableData();
|
|
|
+ fullData.find(itm => {
|
|
|
+ if (itm.formulakind == 101) {
|
|
|
+ ls_bl_bt_height = formatFixedNumber({ val: itm.thickness }, 4);
|
|
|
+ return t;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (Number(ls_bl_cloth_width) > 0) {
|
|
|
+ ls_Expression = ls_Expression.replaceAll("【布套高】", ls_bl_bt_height);
|
|
|
+ ls_Use_Expression = ls_Use_Expression.replaceAll("【布套高】", ls_bl_bt_height);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //替换布套高end
|
|
|
+
|
|
|
+ //计算裥绵收缩率
|
|
|
+ if ([50, 0, 40, 60, 70, 80].includes(_formulakind)) {
|
|
|
+ //...
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log("fullData item :>> ", item, item.formula);
|
|
|
+ console.log("fullData item useformula :>> ", item.useformula);
|
|
|
+ summaryMxData.value = summaryMxData.value.map(itm => {
|
|
|
+ if (itm.field == "costamt") {
|
|
|
+ itm.formula = ls_Expression;
|
|
|
+ } else if (itm.field == "useqty") {
|
|
|
+ itm.formula = ls_Use_Expression;
|
|
|
+ }
|
|
|
+ return itm;
|
|
|
+ });
|
|
|
+
|
|
|
+ let result = formulaPartsFormula(summaryMxData.value, fieldMxParams.value, { ..._data, ..._mxData });
|
|
|
+ console.log(
|
|
|
+ "fabricMxTabList formula result :>> ",
|
|
|
+ summaryMxData.value,
|
|
|
+ fieldMxParams.value,
|
|
|
+ { ..._data, ..._mxData },
|
|
|
+ result
|
|
|
+ );
|
|
|
+ }
|
|
|
+ // 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 ?? ""
|
|
|
+ // });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ };
|
|
|
+
|
|
|
/**
|
|
|
* @description 展示计算公式
|
|
|
* @param timeout
|
|
@@ -1529,11 +2206,15 @@ export const useHooks = (t?: any) => {
|
|
|
|
|
|
let result = await calculateFormula(summaryData.value, fieldParams.value, _mainData);
|
|
|
if (result.length) {
|
|
|
- let _data = cloneDeep(_mainData);
|
|
|
+ // let _data = cloneDeep(_mainData);
|
|
|
+ // result.map((t, i) => {
|
|
|
+ // _data[t.field] = t.value;
|
|
|
+ // });
|
|
|
result.map((t, i) => {
|
|
|
- _data[t.field] = t.value;
|
|
|
+ _mainData[t.field] = t.value;
|
|
|
});
|
|
|
- console.log("_data :>> ", _data, result);
|
|
|
+
|
|
|
+ console.log("_data :>> ", _mainData, result);
|
|
|
// toast.clear();
|
|
|
toast(
|
|
|
{
|
|
@@ -1541,7 +2222,7 @@ export const useHooks = (t?: any) => {
|
|
|
props: {
|
|
|
t: t,
|
|
|
formulas: summaryData.value,
|
|
|
- data: _data,
|
|
|
+ data: _mainData,
|
|
|
fields: fieldParams.value,
|
|
|
showFormula: state.showFormula
|
|
|
},
|
|
@@ -1638,7 +2319,7 @@ export const useHooks = (t?: any) => {
|
|
|
basicinfo: {
|
|
|
el: "select",
|
|
|
editable: ALLOW_EDIT_STATE,
|
|
|
- rules: [{ required: true }],
|
|
|
+ rules: [{ required: true, message: "请先选择部门", trigger: "change" }],
|
|
|
props: {
|
|
|
filterable: true,
|
|
|
clearable: false
|
|
@@ -1661,7 +2342,7 @@ export const useHooks = (t?: any) => {
|
|
|
basicinfo: {
|
|
|
el: "select",
|
|
|
editable: ALLOW_EDIT_STATE,
|
|
|
- rules: [{ required: true }],
|
|
|
+ rules: [{ required: true, message: "请先选择床垫类别", trigger: "change" }],
|
|
|
props: {
|
|
|
clearable: false,
|
|
|
filterable: true,
|
|
@@ -2397,6 +3078,9 @@ export const useHooks = (t?: any) => {
|
|
|
}
|
|
|
];
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 主表计算公式
|
|
|
+ */
|
|
|
const summaryData = ref<any>([
|
|
|
{
|
|
|
label: "总成本",
|
|
@@ -2454,6 +3138,9 @@ export const useHooks = (t?: any) => {
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 主表公式字段照表
|
|
|
+ */
|
|
|
const fieldParams = ref<any>([
|
|
|
{
|
|
|
label: "总成本",
|
|
@@ -2565,6 +3252,141 @@ export const useHooks = (t?: any) => {
|
|
|
}
|
|
|
]);
|
|
|
|
|
|
+ /**
|
|
|
+ * @description 明细公式字段照表
|
|
|
+ */
|
|
|
+ const fieldMxParams = ref<any>([
|
|
|
+ {
|
|
|
+ label: "名称前2位",
|
|
|
+ field: "ls_temp_left_2"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "规格宽",
|
|
|
+ field: "ls_mattress_width"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "规格长",
|
|
|
+ field: "ls_mattress_length"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "规格高",
|
|
|
+ field: "ls_mattress_height"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "压包数量",
|
|
|
+ field: "ls_packqty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "卷包直径",
|
|
|
+ field: "ls_diameter"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "顶布裥棉外布套做法",
|
|
|
+ field: "ls_if_db_wbutao_way"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "面料外布套做法",
|
|
|
+ field: "ls_if_m_wbutao_way"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "内布套上覆",
|
|
|
+ field: "ls_s_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "内布套侧覆",
|
|
|
+ field: "ls_z_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "内布套下覆",
|
|
|
+ field: "ls_x_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "面料上覆",
|
|
|
+ field: "ls_s_m_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "面料侧覆",
|
|
|
+ field: "ls_z_m_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "面料下覆",
|
|
|
+ field: "ls_x_m_cover_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "面拆",
|
|
|
+ field: "ls_if_m_chai"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "中拆",
|
|
|
+ field: "ls_if_z_chai"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "底拆",
|
|
|
+ field: "ls_if_d_chai"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "物料单价",
|
|
|
+ field: "ls_price"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "物料克重",
|
|
|
+ field: "ls_gram_weight"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "幅宽",
|
|
|
+ field: "ls_cloth_width"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "数量",
|
|
|
+ field: "ls_qty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "物料厚度",
|
|
|
+ field: "ls_if_inputqty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "固定厚度",
|
|
|
+ field: "ls_if_inputqty"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "厚度",
|
|
|
+ field: "ls_thickness"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "按面积单价",
|
|
|
+ field: "ls_if_areaprice"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "物料名称",
|
|
|
+ field: "ls_mtrlname"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "木托方式",
|
|
|
+ field: "ls_woodpallettype",
|
|
|
+ enum: [
|
|
|
+ { label: " '普通木托' ", value: "0" },
|
|
|
+ { label: " '夹板木托' ", value: "1" },
|
|
|
+ { label: " '铁管木托' ", value: "2" }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description 明细表计算公式
|
|
|
+ */
|
|
|
+ const summaryMxData = ref<any>([
|
|
|
+ {
|
|
|
+ label: "计算成本金额",
|
|
|
+ field: "costamt",
|
|
|
+ formula: ""
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: "计算清单用量",
|
|
|
+ field: "useqty",
|
|
|
+ formula: ""
|
|
|
+ }
|
|
|
+ ]);
|
|
|
+
|
|
|
const funcMergeColumn = (columns: any, target: any) => {
|
|
|
return columns.map(t => {
|
|
|
let itm = target.find(item => t.field === item.field);
|
|
@@ -2699,11 +3521,13 @@ export const useHooks = (t?: any) => {
|
|
|
funcChaifenTab,
|
|
|
getData_mx,
|
|
|
dataCallback,
|
|
|
+ dataCallbackMx,
|
|
|
getMattressType,
|
|
|
gotoSummy,
|
|
|
gotoHisprice,
|
|
|
getFormulakindEnum,
|
|
|
funcPacktypeChange,
|
|
|
- dynamicRef
|
|
|
+ dynamicRef,
|
|
|
+ wf_cmp_cb
|
|
|
};
|
|
|
};
|