Procházet zdrojové kódy

JLHWEB:1、床垫报价,修改床垫类型时,自动导入特殊工艺费用相关费用;2、床垫报价,修改拼侧时自动导入拼侧费用;3、床垫清单支持批量设置;4、修复床垫报价相关报错

JohnnyChan před 2 dny
rodič
revize
de5e106417

+ 4 - 2
JLHWEB/src/components/LjHeaderMenu/index.vue

@@ -30,6 +30,7 @@ interface LjHeaderMenuProps {
    * @description ButtonGroup组件:data
    */
   data?: any;
+  groupCls?: string;
 }
 
 const { assemblySize } = useGlobalStore();
@@ -37,7 +38,8 @@ const { CheckPower, funcFilterPower, funcRightActionPower } = useAuthButtons(t);
 
 const orderBtnGroup = ref([]);
 const props = withDefaults(defineProps<LjHeaderMenuProps>(), {
-  action: () => []
+  action: () => [],
+  groupCls: ""
 });
 
 onMounted(() => {
@@ -135,7 +137,7 @@ const RenderHeaderDefault = (rProp: any) => {
   return (
     <>
       <div class={["flx w-full flx-justify-between", "lj-header-menu"]} style={{ height: _height }}>
-        <div class="flx-start flx-1" id="detail-button-group">
+        <div id="detail-button-group" class={`flx-1 ${props.groupCls ? props.groupCls : "flx-start"}`}>
           {props.action.length > 0 && (
             <ButtonGroup
               update={props.update}

+ 21 - 4
JLHWEB/src/components/LjVxeTable/index.vue

@@ -837,7 +837,15 @@ const propsEvents = computed(() => {
     checkboxRangeStart: (data: any) => emit("checkboxRangeStart", data),
     checkboxRangeChange: (data: any) => emit("checkboxRangeChange", data),
     checkboxRangeEnd: (data: any) => emit("checkboxRangeEnd", data),
-    cellClick: (data: any) => emit("cellClick", data),
+    cellClick: (data: any) => {
+      const { row, rowIndex, column, columnIndex } = data;
+      // currentEditCell.value.row = row;
+      currentEditCell.value.rowIndex = rowIndex;
+      // currentEditCell.value.column = column;
+      currentEditCell.value.field = column.field;
+      console.log("editConfig cellClick :>> ", row, currentEditCell.value);
+      emit("cellClick", data);
+    },
     cellDblclick: (data: any) => emit("cellDblclick", data),
     cellMenu: (data: any) => emit("cellMenu", data),
     cellMouseenter: (data: any) => emit("cellMouseenter", data),
@@ -2750,14 +2758,22 @@ onClickOutside(tableRef, event => {
   ];
   const isExcluded = excludeElements.filter(Boolean).some(el => el.contains(event.target));
 
-  console.log("onClickOutside excludeElements :>> ", excludeElements);
-  console.log("onClickOutside isExcluded :>> ", isExcluded, !isExcluded && ifEdit);
+  // console.log("onClickOutside excludeElements :>> ", excludeElements);
+  // console.log("onClickOutside isExcluded :>> ", isExcluded, !isExcluded && ifEdit);
 
   if (!isExcluded && ifEdit) {
     tableRef.value.clearEdit();
   }
 });
 
+/**
+ * @description 当前编辑的单元格
+ */
+const currentEditCell = ref<any>({
+  field: 0,
+  rowIndex: 0
+});
+
 // 暴露给父组件的参数和方法(外部需要什么,都可以从这里暴露出去)
 defineExpose({
   element: tableRef,
@@ -2781,7 +2797,8 @@ defineExpose({
   // isSelected,
   // selectedList,
   // selectedListIds
-  initLayoutColumns
+  initLayoutColumns,
+  currentEditCell
 });
 </script>
 

+ 46 - 2
JLHWEB/src/utils/index.ts

@@ -879,8 +879,8 @@ export const floatSub = (arg1: any, arg2: any) => {
 };
 export const floatMul = (arg1: any, arg2: any) => {
   let m = 0,
-    s1 = arg1.toString(),
-    s2 = arg2.toString();
+    s1 = (arg1 ?? 0).toString(),
+    s2 = (arg2 ?? 0).toString();
   try {
     m += s1.split(".")[1].length;
   } catch (e) {}
@@ -1316,3 +1316,47 @@ export const autoMergeCells = ($table: any, fields: string[]) => {
   });
   return result;
 };
+
+export const text2Formula = (str: any) => {
+  let rt = [];
+
+  if (str.includes("以上") || str.includes("以下")) {
+    // 匹配 "上下拼接X及以上Y以下"
+    let rangeMatch = str.match(/(\d+)及以下/);
+    if (rangeMatch) {
+      const value = parseInt(rangeMatch[1], 10);
+      rt.push(`value <= ${value}`);
+    } else {
+      rangeMatch = str.match(/(\d+)以下/);
+      if (rangeMatch) {
+        const value = parseInt(rangeMatch[1], 10);
+        rt.push(`value < ${value}`);
+      }
+    }
+
+    rangeMatch = str.match(/(\d+)及以上/);
+    if (rangeMatch) {
+      const value = parseInt(rangeMatch[1], 10);
+      rt.push(`value >= ${value}`);
+    } else {
+      rangeMatch = str.match(/(\d+)以上/);
+      if (rangeMatch) {
+        const value = parseInt(rangeMatch[1], 10);
+        rt.push(`value > ${value}`);
+      }
+    }
+  } else {
+    // 匹配 "上下拼接X"
+    const exactMatch = str.match(/(\d+)/);
+    if (exactMatch) {
+      const value = parseInt(exactMatch[1], 10);
+      rt.push(`value == ${value}`);
+    }
+  }
+
+  if (rt.length > 0) {
+    return rt.join(" && ");
+  }
+
+  throw new Error(`无法解析规则: ${str}`);
+};

+ 12 - 0
JLHWEB/src/views/baseinfo/extra/hooks/index.tsx

@@ -80,6 +80,18 @@ export const useHooks = (t?: any) => {
         editable: ALLOW_EDIT_STATE
       }
     },
+    {
+      field: "qty",
+      title: "数量",
+      basicinfo: {
+        el: "input",
+        props: {
+          type: "number"
+        },
+        span: 4,
+        editable: ALLOW_EDIT_STATE
+      }
+    },
     {
       field: "dscrp",
       title: "备注",

+ 42 - 2
JLHWEB/src/views/erpapi/mattressInterface/detail.vue

@@ -27,6 +27,11 @@
       >
       </LjVxeTable>
     </template>
+    <template #tabNavRight v-if="orderStatus">
+      <div class="flx-center flx-end flx-1">
+        <LjHeaderMenu group-cls="flx-end" :action="qdAction"></LjHeaderMenu>
+      </div>
+    </template>
     <template #mattressQD>
       <el-row class="h-full" :gutter="10">
         <el-col :span="6">
@@ -70,7 +75,7 @@
 </template>
 
 <script setup lang="tsx" name="mattressInterfaceDetail">
-import { ref, watch, reactive, inject, onMounted, computed } from "vue";
+import { ref, watch, reactive, inject, onMounted, computed, nextTick } from "vue";
 import { DwnameEnum } from "@/enums/dwnameEnum";
 import LjDetail from "@/components/LjDetail/index.vue";
 import { DetailProp } from "@/components/LjDetail/interface";
@@ -142,7 +147,8 @@ const {
   toUpdateL1Planprice,
   YWAudit,
   JSAudit,
-  JS2Audit
+  JS2Audit,
+  resetMergeCellsQd
 } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 
@@ -181,6 +187,40 @@ const loadingStatus = reactive({
   save: false
 });
 
+const qdAction = [
+  buttonDefault({
+    label: "批量设置",
+    clickFunc: () => {
+      let _cur = QdTableRef.value.currentEditCell;
+      console.log("qdAction _cur :>> ", _cur);
+      console.log("qdAction ![d) :>> ", !["wrkgrpid", "wrkgrpid2", "useqty"].includes(_cur.field));
+
+      if (!["wrkgrpid", "wrkgrpid2", "useqty"].includes(_cur.field)) {
+        return ElMessage.warning("此列暂不支持批量设置(仅支持实际用量、工组)");
+      }
+      // return mattressQDList.value.length == 0;
+      // nextTick(() => {
+      const $table = QdTableRef.value.element;
+
+      const { visibleData } = $table.getTableData();
+
+      console.log("qdAction _cur :>> ", _cur);
+
+      if (visibleData) {
+        let _val = visibleData[_cur.rowIndex][_cur.field];
+        visibleData.map((o, idx) => {
+          if (o.useqty > 0 && idx > _cur.rowIndex) {
+            o[_cur.field] = _val;
+          }
+        });
+
+        $table.reloadData(visibleData);
+        resetMergeCellsQd();
+      }
+    }
+  })
+];
+
 const orderDefaultAction = [
   buttonDefault({
     label: t("common.cancelText"),

+ 6 - 5
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -1413,10 +1413,10 @@ export const useHooks = (t?: any) => {
     editConfig: {
       trigger: "click",
       mode: "cell",
-      enabled: false,
-      afterEditMethod: ({ row, rowIndex, column, columnIndex }) => {
-        console.log("afterEditMethod :>> ", row);
-      }
+      enabled: false
+      // afterEditMethod: ({ row, rowIndex, column, columnIndex }) => {
+      //   console.log("afterEditMethod :>> ", row);
+      // }
     },
     showOverflow: false,
     // exportConfig: {
@@ -1941,6 +1941,7 @@ export const useHooks = (t?: any) => {
     toUpdateL1Planprice,
     YWAudit,
     JSAudit,
-    JS2Audit
+    JS2Audit,
+    resetMergeCellsQd
   };
 };

+ 139 - 59
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -638,33 +638,23 @@
         ref="specialProcessesMxRef"
         row-key="key"
         table-cls=""
-        :data="specialProcessesMxData"
+        :request-api="getData_specialProcesses"
         :data-callback="dataCallbackMx"
         :init-param="initParams"
         :columns="columnsMx_processes"
         :table-props="tableProps_mx"
         :tool-button="[]"
-        :request-auto="false"
         :auto-load-layout="false"
         collapseButtons
         :footer-sum-attrs="['price']"
       >
         <template #tableHeader v-if="orderStatus">
-          <el-button type="primary">
-            {{ t("common.addText") }}
-          </el-button>
-          <!-- <el-space wrap>
-            <el-dropdown placement="bottom-start" @command="wf_add_w_butao">
-              <template #dropdown>
-                <el-dropdown-menu>
-                  <el-dropdown-item v-for="item in topCottonAddList" :key="item.value" :command="item">{{
-                    item.label
-                  }}</el-dropdown-item>
-                </el-dropdown-menu>
-              </template>
-            </el-dropdown>
-            <el-button type="danger" @click="wf_del_w_butao">{{ t("common.delText") }}</el-button>
-          </el-space> -->
+          <el-space wrap>
+            <el-button type="primary" @click="funcAddMtrlMx({}, null, 'specialProcessesMxRef', -1)">
+              {{ t("common.addText") }}
+            </el-button>
+            <!-- <el-button type="danger" @click="funcDelMtrlMx()">{{ t("common.delText") }}</el-button> -->
+          </el-space>
         </template>
       </LjVxeTable>
     </template>
@@ -679,33 +669,23 @@
         ref="additionalCostsMxRef"
         row-key="key"
         table-cls=""
-        :data="additionalCostsMxData"
+        :request-api="getData_additionalCosts"
         :data-callback="dataCallbackMx"
         :init-param="initParams"
-        :columns="columnsMx_processes"
+        :columns="columnsMx_additional"
         :table-props="tableProps_mx"
         :tool-button="[]"
-        :request-auto="false"
         :auto-load-layout="false"
         collapseButtons
         :footer-sum-attrs="['price']"
       >
         <template #tableHeader v-if="orderStatus">
-          <!-- <el-space wrap>
-            <el-dropdown placement="bottom-start" @command="wf_add_w_butao">
-              <el-button type="primary">
-                {{ t("common.addText") }}<el-icon class="el-icon--right"><ArrowDown /></el-icon>
-              </el-button>
-              <template #dropdown>
-                <el-dropdown-menu>
-                  <el-dropdown-item v-for="item in topCottonAddList" :key="item.value" :command="item">{{
-                    item.label
-                  }}</el-dropdown-item>
-                </el-dropdown-menu>
-              </template>
-            </el-dropdown>
-            <el-button type="danger" @click="wf_del_w_butao">{{ t("common.delText") }}</el-button>
-          </el-space> -->
+          <el-space wrap>
+            <el-button type="primary" @click="funcAddMtrlMx({}, null, 'additionalCostsMxRef', -1)">
+              {{ t("common.addText") }}
+            </el-button>
+            <!-- <el-button type="danger" @click="wf_del_w_butao">{{ t("common.delText") }}</el-button> -->
+          </el-space>
         </template>
       </LjVxeTable>
     </template>
@@ -803,7 +783,7 @@ import BednetDialog from "@/views/system/selector/bednet/index.vue";
 import LjDrawerQuoteList from "./components/QuoteListNew.vue";
 import mittBus from "@/utils/mittBus";
 import { MittEnum } from "@/enums/mittEnum";
-import { getCurrentRecords, floatAdd, floatMul } from "@/utils/index";
+import { getCurrentRecords, floatAdd, floatMul, text2Formula } from "@/utils/index";
 import { useUserStore } from "@/stores/modules/user";
 import AllFormula from "./components/AllFormula.vue";
 import LjDrawer from "@/components/LjDrawer/index.vue";
@@ -856,6 +836,7 @@ const {
   columnsMxPackag,
   columnsMxInnerClothLayer,
   columnsMx_processes,
+  columnsMx_additional,
   LjDetailRef,
   MtrldefDialogRef,
   MtrldefDialogProps,
@@ -914,6 +895,8 @@ const {
   additionalCostsMxRef,
   specialProcessesMxData,
   additionalCostsMxData,
+  specialProcessesMxInitData,
+  additionalCostsMxInitData,
   specialProcessesEnum,
   additionalCostsEnum,
   isShowOriginFormulaMattress,
@@ -938,7 +921,8 @@ const {
   funcAddMtrlMx,
   resetMergeCellsInner,
   resetMergeCellsTopCotton,
-  wf_rtr_cwdc
+  wf_rtr_cwdc,
+  resetSpecialProcesses
 } = useHooks(t);
 const { toExcelQuote } = useHooksCpQuote();
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
@@ -1639,7 +1623,7 @@ const save = async () => {
       fabricMxTabList.value.map(t => {
         if (t.ref) {
           console.log("t.ref?.value :>> ", t.ref, dynamicRef(t.ref));
-          if (dynamicRef(t.ref)) {
+          if (dynamicRef(t.ref) && !["specialProcessesMxRef", "additionalCostsMxRef"].includes(t.ref)) {
             let $table = dynamicRef(t.ref)?.element;
             $table.clearEdit();
             let { visibleData } = $table.getTableData();
@@ -1720,17 +1704,20 @@ const save = async () => {
     let $table_processes = specialProcessesMxRef.value.element;
     if ($table_processes) {
       $table_processes.clearEdit();
+      console.log("$table_processes.getTableData() :>> ", $table_processes.getTableData());
       extraProcesses = $table_processes.getTableData().visibleData;
-      extraProcesses = extraProcesses.filter(itm => Number(itm.extraid) <= 0);
+      extraProcesses = extraProcesses.filter(itm => Number(itm.extraid) > 0);
     }
 
+    console.log("save++++extraProcesses :>> ", extraProcesses);
+
     // 其他额外费用
     let extraCosts = [];
     let $table_costs = additionalCostsMxRef.value.element;
     if ($table_costs) {
       $table_costs.clearEdit();
       extraCosts = $table_costs.getTableData().visibleData;
-      extraCosts = extraCosts.filter(itm => Number(itm.extraid) <= 0);
+      extraCosts = extraCosts.filter(itm => Number(itm.extraid) > 0);
     }
 
     loadingStatus.save = true;
@@ -2072,7 +2059,7 @@ const orderDefaultAction = [
     disabledTextCallBack: () => {
       return userInfo.usermode == 1 ? "业务员模式不可以查看!" : "";
     },
-    clickFunc: item => gotoShowFormula()
+    clickFunc: item => gotoShowFormula({ type: LjDetailRef.value._mainData.dannum_type })
   }),
   buttonDefault({
     label: t("common.viewHistoricalQuotes"),
@@ -2251,11 +2238,11 @@ const funcAfterMound = async () => {
     if (resDw2) {
       diancengAreaEnum.value = resDw2?.diancengarea;
 
-      specialProcessesMxData.value = resDw2?.extraProcessesMx;
-      additionalCostsMxData.value = resDw2?.extraCostsMx;
+      specialProcessesMxData.value = resDw2?.extraEnum.filter(t => t.typeid == 1);
+      additionalCostsMxData.value = resDw2?.extraEnum.filter(t => t.typeid == 2);
 
-      specialProcessesEnum.value = resDw2?.extraEnum.filter(t => t.typeid == 1);
-      additionalCostsEnum.value = resDw2?.extraEnum.filter(t => t.typeid == 2);
+      specialProcessesEnum.value = resDw2?.extraTypeEnum.filter(t => t.typeid == 1);
+      additionalCostsEnum.value = resDw2?.extraTypeEnum.filter(t => t.typeid == 2);
     }
 
     console.log("funcAfterMound oriMxData.value :>> ", oriMxData.value);
@@ -2272,42 +2259,52 @@ const funcAfterMound = async () => {
   }
 };
 
-const handleSelFabricMxNewMtrlGroup = (target: string, item: any) => {
+const handleSelFabricMxNewMtrlGroup = async (target: string, item: any) => {
   console.log("handleSelFabricMxNewMtrlGroup target :>> ", target, item, fabricMxTab10.value);
   if (target == "tabpage_10") {
-    let hasSame = fabricMxTab10.value.findIndex(t => t.sortcode == item.label);
+    // 裥大恻
+    const $table = fabricMxTab10Ref.value.element;
+    const { visibleData } = $table.getTableData();
+    let hasSame = visibleData.findIndex(t => t.sortcode == item.label);
     if (hasSame > -1) {
       ElMessage.error(item.label + "已存在");
       return false;
     }
 
-    const $table = fabricMxTab10Ref.value.element;
     if ($table) {
       let _arr = [];
-      fabricMxTab10.value.map(t => {
-        if (t.sortcode == "普通大侧") {
-          _arr.push(t);
-        }
-      });
-      $table.remove(_arr);
+      if (item.label == "普通大侧") {
+        $table.remove();
+      } else {
+        visibleData.map(t => {
+          if (t.sortcode == "普通大侧") {
+            _arr.push(t);
+          }
+        });
+        $table.remove(_arr);
+      }
     }
 
     let _params = {
       arg_array_formulakind: [2, 42, 52, 62, 72, 82],
       arg_array_formulatype: [0, 1, 2, 3]
     };
-    funcAddMxSide(_params, item, fabricMxTab10Ref.value);
+    await funcAddMxSide(_params, item, fabricMxTab10Ref.value);
+
+    autoLoadExtraData(fabricMxTab10Ref.value, specialProcessesMxRef.value);
   } else if (target == "tabpage_11") {
-    let hasSame = fabricMxTab11.value.findIndex(t => t.sortcode == item.label);
+    // 裥小恻
+    const $table = fabricMxTab11Ref.value.element;
+    const { visibleData } = $table.getTableData();
+    let hasSame = visibleData.findIndex(t => t.sortcode == item.label);
     if (hasSame > -1) {
       ElMessage.error(item.label + "已存在");
       return false;
     }
 
-    const $table = fabricMxTab11Ref.value.element;
     if ($table) {
       let _arr = [];
-      fabricMxTab11.value.map(t => {
+      visibleData.map(t => {
         if (t.sortcode == "小侧1") {
           _arr.push(t);
         }
@@ -2319,10 +2316,91 @@ const handleSelFabricMxNewMtrlGroup = (target: string, item: any) => {
       arg_array_formulakind: [3, 83, 43, 53, 63, 73],
       arg_array_formulatype: [0, 1, 2, 3]
     };
-    funcAddMxSide(_params, item, fabricMxTab11Ref.value);
+    await funcAddMxSide(_params, item, fabricMxTab11Ref.value);
+  }
+};
+
+/**
+ * @description 判断目前选择的拼接数据量,自动导入修改特殊工艺费用
+ */
+const autoLoadExtraData = (tableRef?: any, targetRef?: any) => {
+  //计算拼侧数量
+
+  const $table = tableRef.element;
+  const { visibleData } = $table.getTableData();
+  const $tableTarget = targetRef.element;
+  const { visibleData: tgVisibleData } = $tableTarget.getTableData();
+
+  let arr = [];
+  // 收集拼侧,并去重
+  visibleData.map(t => arr.push(t.sortcode));
+  arr = Array.from(new Set(arr));
+
+  //
+  let _remove = [];
+  tgVisibleData.map(t => {
+    if (t.extraid == 1) {
+      _remove.push(t);
+    }
+  });
+  $tableTarget.remove(_remove);
+  if (!arr.includes("普通大侧")) {
+    let result = [];
+    result = result.concat(computedExtraSizeNum(specialProcessesMxData.value, arr, "上下"));
+    result = result.concat(computedExtraSizeNum(specialProcessesMxData.value, arr, "左右"));
+
+    console.log("autoLoadExtraData result :>> ", result);
+
+    if (result.length) {
+      let _arr = [];
+      let _mattressId = LjDetailRef.value._mainData.mattressid;
+      result.map(o => {
+        let _itm = {
+          mattressid: _mattressId,
+          mattressmxid: 0,
+          extraid: o.extraid,
+          // extratypename: "",
+          extraname: o.extramxname,
+          price: o.price,
+          qty: o.qty,
+          dscrp: o.dscrp,
+          inputtype: o.inputtype,
+          typeid: o.typeid
+        };
+        _arr.push(_itm);
+      });
+      $tableTarget.insertAt(_arr, -1);
+    }
   }
 };
 
+/**
+ * @description 计算拼侧数量
+ */
+const computedExtraSizeNum = (enumarr: any, arr: any, key: string) => {
+  console.log("computedExtraSizeNum specialProcessesEnum.value :>> ", enumarr);
+  let extraArr = enumarr.filter(item => item.typeid == 1 && item.extraid == 1 && item.extramxname.includes(key));
+
+  let arrNum = arr.filter(item => item.includes(key)).length;
+
+  let result = [];
+  extraArr.forEach(o => {
+    // 判断名称中出现的数量
+    try {
+      const checker = new Function("value", `return ${text2Formula(o.extramxname)};`);
+
+      if (checker(arrNum)) {
+        result.push(o);
+      }
+    } catch (error) {
+      console.log("error :>> ", error);
+      ElMessage.error(`${t("sys.api.operationFailed")}特殊工艺名称: ${error}`);
+    }
+  });
+
+  return result;
+};
+
 const handleDelFabricMxNewMtrlGroup = (target: string) => {
   let sameMx = [];
   let $table = null;
@@ -2361,6 +2439,8 @@ const handleDelFabricMxNewMtrlGroup = (target: string) => {
           $table.remove(_arr);
 
           fabricMxTab10.value = visibleData.filter((t, idx) => !_idx.includes(idx));
+
+          autoLoadExtraData(fabricMxTab10Ref.value, specialProcessesMxRef.value);
         } else if (target == "tabpage_11") {
           let _arr = [];
           let _idx = [];

+ 349 - 37
JLHWEB/src/views/quote/mattressQuote/hooks/index.tsx

@@ -129,6 +129,8 @@ interface defaultState {
   additionalCostsMxRef: any;
   specialProcessesMxData: any;
   additionalCostsMxData: any;
+  specialProcessesMxInitData: any;
+  additionalCostsMxInitData: any;
   specialProcessesEnum: any;
   additionalCostsEnum: any;
   isShowOriginFormulaMattress: boolean;
@@ -232,6 +234,16 @@ export const useHooks = (t?: any) => {
         label: "顶布裥棉",
         name: "topCottonMx",
         ref: "topCottonMxRef"
+      },
+      {
+        label: "特殊工艺费用",
+        name: "specialProcesses",
+        ref: "specialProcessesMxRef"
+      },
+      {
+        label: "其他额外费用",
+        name: "additionalCosts",
+        ref: "additionalCostsMxRef"
       }
     ],
     otherMxTabList: [
@@ -385,6 +397,8 @@ export const useHooks = (t?: any) => {
     additionalCostsMxRef: null,
     specialProcessesMxData: [],
     additionalCostsMxData: [],
+    specialProcessesMxInitData: [],
+    additionalCostsMxInitData: [],
     specialProcessesEnum: [],
     additionalCostsEnum: [],
     isShowOriginFormulaMattress: false
@@ -1764,7 +1778,7 @@ export const useHooks = (t?: any) => {
   /**
    * @description 明细,新增
    */
-  const funcAddMtrlMx = async (data: any, cb?: Function, refName?: string, firstRow?: boolean) => {
+  const funcAddMtrlMx = async (data: any, cb?: Function, refName?: string, firstRow?: any) => {
     console.log("state.LjDetail. :>> ", state.LjDetailRef);
     console.log("funcAddMtrlMx data :>> ", data);
     let { row, $rowIndex, visibleData } = data;
@@ -1782,23 +1796,39 @@ export const useHooks = (t?: any) => {
 
     const $table = state[tgRefName].element;
     if ($table) {
-      const records = {
-        addmx: "+",
-        delmx: "-",
-        formulatype: row.formulatype,
-        if_mtrl: row.if_mtrl,
-        formulaid: row.formulaid,
-        sortcode: row.sortcode,
-        formulakind: row.formulakind,
-        formula: row.formula,
-        thickness: 0,
-        mtrlid: 0,
-        chastr: row.chastr,
-        xu: Number(row.xu) + 0.01
-      };
+      let records = {};
+      if (["specialProcessesMxRef", "additionalCostsMxRef"].includes(tgRefName)) {
+        records = {
+          addmx: "+",
+          delmx: "-",
+          mattressid: state.LjDetailRef._mainData.mattressid,
+          mattressmxid: 0,
+          extraid: row?.extraid ?? 0,
+          extraname: "",
+          price: "",
+          qty: 1,
+          dscrp: ""
+        };
+      } else {
+        records = {
+          addmx: "+",
+          delmx: "-",
+          formulatype: row.formulatype,
+          if_mtrl: row.if_mtrl,
+          formulaid: row.formulaid,
+          sortcode: row.sortcode,
+          formulakind: row.formulakind,
+          formula: row.formula,
+          thickness: 0,
+          mtrlid: 0,
+          chastr: row.chastr,
+          xu: Number(row.xu) + 0.01
+        };
+      }
 
       // null 从第一行插入, row: 从当前行下一行插入
-      let _rowIdx = firstRow ? null : row;
+      let _rowIdx = firstRow == -1 ? -1 : firstRow ? null : row;
+      console.log("funcAddMtrlMx _rowIdx :>> ", firstRow, firstRow == -1, _rowIdx);
 
       const { row: newRow } = await $table.insertNextAt(records, _rowIdx);
       await $table.setEditCell(newRow, "mtrlname");
@@ -2022,6 +2052,15 @@ export const useHooks = (t?: any) => {
       newMxData = res.mattressMx;
       _mainData.biandai_qty = res?.biandai_qty;
       state.diancengAreaEnum = res?.diancengarea;
+
+      state.specialProcessesMxData = res?.extraEnum.filter(t => t.typeid == 1);
+      state.additionalCostsMxData = res?.extraEnum.filter(t => t.typeid == 2);
+
+      state.specialProcessesEnum = res?.extraTypeEnum.filter(t => t.typeid == 1);
+      state.additionalCostsEnum = res?.extraTypeEnum.filter(t => t.typeid == 2);
+
+      state.specialProcessesMxInitData = res?.extraProcessesMx;
+      state.additionalCostsMxInitData = res?.extraCostsMx;
     }
 
     state.oriMxData.list = newMxData;
@@ -2029,8 +2068,61 @@ export const useHooks = (t?: any) => {
     getMattressType();
 
     funcChaifenTab();
+
+    await initExtraData();
   };
 
+  const initExtraData = async () => {
+    console.log("initExtraData state.specialProcessesMxInitData :>> ", state.specialProcessesMxInitData);
+    console.log("initExtraData state.additionalCostsMxInitData :>> ", state.additionalCostsMxInitData);
+    const $tableSpecial = state.specialProcessesMxRef.element;
+    const $tableAdditional = state.additionalCostsMxRef.element;
+
+    if ($tableSpecial) {
+      $tableSpecial.remove();
+      let _arr = [];
+      let _mattressId = state.LjDetailRef._mainData.mattressid;
+      state.specialProcessesMxInitData.map(o => {
+        let _itm = {
+          addmx: "+",
+          delmx: "-",
+          mattressid: _mattressId,
+          mattressmxid: 0,
+          extraid: o.extraid,
+          extraname: o.extraname,
+          price: o.price,
+          qty: o.qty,
+          dscrp: o.dscrp,
+          inputtype: o.inputtype,
+          typeid: o.typeid
+        };
+        _arr.push(_itm);
+      });
+      await $tableSpecial.insertAt(_arr, -1);
+    }
+    if ($tableAdditional) {
+      $tableAdditional.remove();
+      let _arr = [];
+      let _mattressId = state.LjDetailRef._mainData.mattressid;
+      state.additionalCostsMxInitData.map(o => {
+        let _itm = {
+          addmx: "+",
+          delmx: "-",
+          mattressid: _mattressId,
+          mattressmxid: 0,
+          extraid: o.extraid,
+          extraname: o.extraname,
+          price: o.price,
+          qty: o.qty,
+          dscrp: o.dscrp,
+          inputtype: o.inputtype,
+          typeid: o.typeid
+        };
+        _arr.push(_itm);
+      });
+      await $tableAdditional.insertAt(_arr, -1);
+    }
+  };
   /**
    * @description 变更床垫分类时,重载明细数据 dw_1 itemchange
    * @author w_mattress_add dw_1 itemchange
@@ -4555,15 +4647,10 @@ export const useHooks = (t?: any) => {
       field: "addmx",
       width: 80,
       render: (scope: any) => {
-        let _if_mtrl = Number(scope.row.if_mtrl);
-        if (_if_mtrl > 1) {
-          if (state.orderStatus) {
-            return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
-          } else {
-            return <>+</>;
-          }
+        if (state.orderStatus) {
+          return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
         } else {
-          return <></>;
+          return <>+</>;
         }
       }
     },
@@ -4599,38 +4686,201 @@ export const useHooks = (t?: any) => {
     },
     {
       title: "项目类型",
-      field: "extratypename",
-      editRender: {
-        name: "select"
+      field: "extraid",
+      // editRender: {
+      //   name: "select"
+      // }
+      editRender: {},
+      editColRender: (scope: any) => {
+        console.log("extratypename state.specialProcessesEnum :>> ", state.specialProcessesEnum);
+        return (
+          <el-select v-model={scope.row.extraid} disabled={scope.row.extraid == 1}>
+            {{
+              default: () => {
+                let rs = [];
+                if (state.specialProcessesEnum.length) {
+                  state.specialProcessesEnum.map((t: any) => {
+                    rs.push(<el-option label={t.typename} value={t.extraid} disabled={t.extraid == 1} />);
+                  });
+                }
+                return rs;
+              }
+            }}
+          </el-select>
+        );
+      },
+      render: scope => {
+        let item = state.specialProcessesEnum.find(t => t.extraid == scope.row.extraid);
+        if (item) {
+          return item.typename;
+        } else {
+          return "";
+        }
       }
     },
     {
       title: "项目名称",
       field: "extraname",
-      editRender: {
-        name: "$input"
+      editRender: {},
+      editColRender: (scope: any) => {
+        let _disabled = scope.row.inputtype == 2;
+        return (
+          <el-autocomplete
+            v-model={scope.row.extraname}
+            disabled={_disabled}
+            value-key="extramxname"
+            fetch-suggestions={(queryString: string, callback: any) =>
+              querySearch_processes(queryString, callback, scope, state.specialProcessesMxData)
+            }
+            onSelect={itm => additionalOnSelect(itm, scope)}
+            clearable
+          />
+        );
       }
     },
     {
       title: "金额",
       field: "price",
-      editRender: {
-        name: "$input",
-        props: {
-          type: "number"
-        }
+      datatype: "number",
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row, status } = scope;
+        return <el-input v-model={scope.row.price} type="number" disabled={row.inputtype == 2}></el-input>;
       }
     },
     {
       title: "数量",
       field: "qty",
+      datatype: "number",
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row, status } = scope;
+        return <el-input v-model={scope.row.qty} type="number" disabled={row.inputtype == 2}></el-input>;
+      }
+    },
+    {
+      title: "备注",
+      field: "dscrp",
       editRender: {
-        name: "$input",
-        props: {
-          type: "number"
+        name: "$input"
+      }
+    }
+  ];
+  const columnsMx_additional: any = [
+    { type: "checkbox", width: 50, fixed: "left" },
+    {
+      title: "+",
+      field: "addmx",
+      width: 80,
+      render: (scope: any) => {
+        if (state.orderStatus) {
+          return <ElButton type="primary" plain circle icon={Plus} onClick={() => funcAddMtrlMx(scope)}></ElButton>;
+        } else {
+          return <>+</>;
+        }
+      }
+    },
+    {
+      title: "-",
+      field: "delmx",
+      width: 80,
+      render: (scope: any) => {
+        if (state.orderStatus) {
+          return (
+            <>
+              <ElPopconfirm
+                width="220"
+                icon={InfoFilled}
+                title={t("business.tips.mattress.delMx")}
+                confirm-button-text={t("common.delText")}
+                confirm-button-type="danger"
+                onConfirm={() => funcDelMtrlMx(scope)}
+              >
+                {{
+                  reference: () => {
+                    return <ElButton type="danger" plain circle icon={Minus} />;
+                  }
+                }}
+              </ElPopconfirm>
+            </>
+          );
+          // return <ElButton type="danger" plain circle icon={Minus} onClick={() => funcDelMtrlMx(scope)}></ElButton>;
+        } else {
+          return <>-</>;
+        }
+      }
+    },
+    {
+      title: "项目类型",
+      field: "extraid",
+      editRender: {},
+      editColRender: (scope: any) => {
+        return (
+          <el-select v-model={scope.row.extraid}>
+            {{
+              default: () => {
+                let rs = [];
+                if (state.additionalCostsEnum.length) {
+                  state.additionalCostsEnum.map((t: any) => {
+                    rs.push(<el-option label={t.typename} value={t.extraid} />);
+                  });
+                }
+                return rs;
+              }
+            }}
+          </el-select>
+        );
+      },
+      render: scope => {
+        let item = state.additionalCostsEnum.find(t => t.extraid == scope.row.extraid);
+        if (item) {
+          return item.typename;
+        } else {
+          return "";
         }
       }
     },
+    {
+      title: "项目名称",
+      field: "extraname",
+      editRender: {},
+      editColRender: (scope: any) => {
+        console.log("editColRender 1111 scope :>> ", scope);
+        let _disabled = scope.row.inputtype == 2;
+        return (
+          <el-autocomplete
+            v-model={scope.row.extraname}
+            disabled={_disabled}
+            value-key="extramxname"
+            fetch-suggestions={(queryString: string, callback: any) =>
+              querySearch_additional(queryString, callback, scope, state.additionalCostsMxData)
+            }
+            onSelect={itm => additionalOnSelect(itm, scope)}
+            clearable
+          />
+        );
+      }
+    },
+    {
+      title: "金额",
+      field: "price",
+      datatype: "number",
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row, status } = scope;
+        return <el-input v-model={scope.row.price} type="number" disabled={row.inputtype == 2}></el-input>;
+      }
+    },
+    {
+      title: "数量",
+      field: "qty",
+      datatype: "number",
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row, status } = scope;
+        return <el-input v-model={scope.row.qty} type="number" disabled={row.inputtype == 2}></el-input>;
+      }
+    },
     {
       title: "备注",
       field: "dscrp",
@@ -4640,6 +4890,52 @@ export const useHooks = (t?: any) => {
     }
   ];
 
+  const additionalOnSelect = (item: Record<string, any>, scope: any) => {
+    const { row } = scope;
+    // console.log("additionalOnSelect: >>", item);
+    // const $tableAdditional = state.additionalCostsMxRef.element;
+
+    // if ($tableAdditional) {
+    //   const { visibleData } = $tableAdditional.getTableData();
+
+    //   const row = visibleData[$rowIndex];
+    //   console.log("additionalOnSelect: row >>", row);
+    // row.extramxname = item.extramxname;
+    row.extramxid = item.extramxid;
+    row.inputtype = item.inputtype;
+    row.extraid = item.extraid;
+    row.extraname = item.extramxname;
+    row.typeid = item.typeid;
+    row.price = item.price;
+    row.qty = item.qty;
+    row.dscrp = item.dscrp;
+
+    //   $tableAdditional.reloadData(visibleData);
+    // }
+  };
+
+  const querySearch_processes = (queryString: string, cb: any, data, list) => {
+    const { row } = data;
+    const results = queryString
+      ? list.filter(o => {
+          return o.extramxname.indexOf(queryString) > -1 && o.extraid == row.extraid;
+        })
+      : list.filter(o => o.extraid == row.extraid);
+
+    cb(results);
+  };
+
+  const querySearch_additional = (queryString: string, cb: any, data, list) => {
+    const { row } = data;
+    const results = queryString
+      ? list.filter(o => {
+          return o.extramxname.indexOf(queryString) > -1 && o.extraid == row.extraid;
+        })
+      : list.filter(o => o.extraid == row.extraid);
+
+    cb(results);
+  };
+
   const columnsMx_subSpecs: any = [
     { type: "checkbox", width: 50, fixed: "left" },
     {
@@ -4802,6 +5098,20 @@ export const useHooks = (t?: any) => {
     }, 200);
   };
 
+  const resetSpecialProcesses = (type: string) => {
+    console.log("resetSpecialProcesses type:>> ", type);
+    console.log("resetSpecialProcesses additionalCostsMxInitData:>> ", state.additionalCostsMxInitData);
+    console.log("resetSpecialProcesses specialProcessesMxInitData:>> ", state.specialProcessesMxInitData);
+    // setTimeout(() => {
+    //   const $table = state.innerClothLayerMxRef.element;
+    //   if ($table) {
+    //     let mergeCells = autoMergeCells($table, ["chastr"]);
+    //     console.log("resetMergeCellsInner autoMergeCells  :>> ", mergeCells);
+    //     $table.setMergeCells(mergeCells);
+    //   }
+    // }, 200);
+  };
+
   const hanleDelMxInner = (type: number) => {
     const $table = state.innerClothLayerMxRef.element;
     if ($table) {
@@ -5040,6 +5350,7 @@ export const useHooks = (t?: any) => {
     // fieldParams,
     columnsMx_subSpecs,
     columnsMx_processes,
+    columnsMx_additional,
     funcAddMxSide,
     funcChaifenTab,
     getData_mx,
@@ -5060,6 +5371,7 @@ export const useHooks = (t?: any) => {
     wf_rtr_bednet,
     funcAddMtrlMx,
     resetMergeCellsInner,
+    resetSpecialProcesses,
     resetMergeCellsTopCotton,
     wf_rtr_cwdc
   };