فهرست منبع

JLHWeb:优化表格计算合并行

JohnnyChan 4 ماه پیش
والد
کامیت
65c16a56ca

+ 17 - 1
JLHWEB/src/components/LjVxeTable/index.vue

@@ -519,6 +519,9 @@ const props = withDefaults(defineProps<LjVxetableProps>(), {
   miniSearchbar: true,
   footerSumAttrs: () => [],
   searchBtnSizeExtent: () => ["xs", "sm", "md"],
+  multiSelect: undefined,
+  editable: false,
+  autoSelectFirstAfterRefresh: false,
   ifLoadQueryHabit: true
 });
 
@@ -1857,15 +1860,28 @@ onMounted(async () => {
 
   initLayoutColumns();
 
-  props.requestAuto &&
+  if (props.requestAuto) {
     getTableList().then(() => {
       emit("onMountedData", tableData.value);
       console.log("onMounted tableColumns.value :>> ", tableColumns.value);
 
       nextTick(() => {
         props.toolButton.indexOf("guide") > -1 && checkIfNeedGuide();
+
+        props.afterMound && props.afterMound(tableData.value);
+        if (props.autoSelectFirstAfterRefresh && tableData.value.length) {
+          nextTick(() => {
+            tableRef.value?.setCurrentRow(tableData.value[0]);
+            if (props.tableEvents && "current-change" in props.tableEvents) {
+              props.tableEvents["current-change"]({ newValue: tableData.value[0] });
+            }
+          });
+        }
       });
     });
+  } else {
+    props.afterMound && props.afterMound(tableData.value);
+  }
 
   /**
    * @description 获取打印机选项状态

+ 18 - 0
JLHWEB/src/components/LjVxeTable/interface/index.ts

@@ -481,6 +481,24 @@ export interface LjVxetableProps extends aboutVxetableApiProps {
    * @description 搜索栏按钮需要缩小尺寸的屏幕尺寸,eg: ["xs", "sm"]
    */
   searchBtnSizeExtent?: string[];
+
+  /**
+   * @description 绑定多选的列名
+   */
+  multiSelect?: string;
+  /**
+   * @description 表格是否可编辑
+   */
+  editable?: boolean;
+  /**
+   * @description 列表刷新后,自动选中第一行
+   */
+  autoSelectFirstAfterRefresh?: boolean;
+  /**
+   * @argument function
+   * @description 组件加载后,执行函数
+   */
+  afterMound?: (params: any) => void;
 }
 
 export type LjVxeTableInstance = Omit<InstanceType<typeof LjVxeTable>, keyof ComponentPublicInstance | keyof LjVxetableProps>;

+ 5 - 1
JLHWEB/src/utils/index.ts

@@ -1260,12 +1260,16 @@ export const isFilterPrice = data => {
 
 /**
  * @description 计算vxetable的合并单元格
+ * @param $table 表对象
  * @param data 数据
  * @param fields 计算合并的字段明
  * @returns 需要合并的单元格数组
  */
-export const autoMergeCells = (columns: any, data: any, fields: string[]) => {
+export const autoMergeCells = ($table: any, fields: string[]) => {
   let result = [];
+  let columns = $table.getColumns();
+  let { visibleData: data } = $table.getTableData();
+  console.log("mergeCells data :>> ", columns, data);
   data.map((item: any, rowIndex: number) => {
     for (const key in item) {
       if (fields.includes(key)) {

+ 6 - 10
JLHWEB/src/views/erpapi/mattressInterface/detail.vue

@@ -13,7 +13,6 @@
   >
     <template #mattressYW>
       <LjVxeTable
-        v-if="mattressYWList.length > 0"
         ref="VxeTableMxRef"
         row-key="key"
         table-cls=""
@@ -31,14 +30,13 @@
       <el-row class="h-full" :gutter="10">
         <el-col :span="6">
           <LjVxeTable
-            v-if="mattressYWList.length > 0"
             ref="YwTableRef"
             row-key="key"
             table-cls="h-full"
             :data="mattressYWList"
             :columns="columns_yw_qd"
             :dwname="DwnameEnum.mattressInterfaceYw"
-            :table-props="tableProps_mx_yw"
+            :table-props="tableProps_mx"
             :tool-button="[]"
             :auto-load-layout="false"
             collapseButtons
@@ -47,14 +45,13 @@
         </el-col>
         <el-col :span="18">
           <LjVxeTable
-            v-if="mattressQDList.length > 0"
             ref="QdTableRef"
             row-key="key"
             table-cls="h-full"
             :data="mattressQDList"
             :columns="columns_qd"
             :dwname="DwnameEnum.mattressInterfaceQd"
-            :table-props="tableProps_mx_qd"
+            :table-props="tableProps_mx"
             :tool-button="[]"
             :auto-load-layout="false"
             collapseButtons
@@ -112,6 +109,7 @@ const { t } = useI18n();
 const route = useRoute();
 const router = useRouter();
 const {
+  VxeTableMxRef,
   YwTableRef,
   QdTableRef,
   orderStatus,
@@ -129,8 +127,6 @@ const {
   MtrldefErpDialogRef,
   MtrldefErpDialogProps,
   tableProps_mx,
-  tableProps_mx_qd,
-  tableProps_mx_yw,
   workgrpEnum,
   RetriveMattressInterface,
   RefreshMattressInterfaceList,
@@ -320,8 +316,8 @@ const funcAfterMound = async () => {
   } else {
     // 新增/编辑
     tableProps_mx.value.editConfig.enabled = true;
-    tableProps_mx_yw.value.editConfig.enabled = true;
-    tableProps_mx_qd.value.editConfig.enabled = true;
+    // tableProps_mx_yw.value.editConfig.enabled = true;
+    // tableProps_mx_qd.value.editConfig.enabled = true;
   }
 
   console.log("onMounted detail sale start LjDetailRef.value.mainData :>> ", LjDetailRef.value);
@@ -359,7 +355,7 @@ onMounted(async () => {
     editType.value = Number(route.query?.type);
     console.log("detail onMounted initParams.value :>> ", initParams.value);
     console.log("领用工组领用工组领用工组领用工组 columns_qd.value :>> ", columns_qd.value);
-    RetriveMattressInterface(initParams.value.mattressid.valueOf());
+    await RetriveMattressInterface(initParams.value.mattressid.valueOf());
   }
 });
 </script>

+ 25 - 68
JLHWEB/src/views/erpapi/mattressInterface/hooks/index.tsx

@@ -47,6 +47,7 @@ interface defaultState {
   MtrldefErpDialogRef: any;
   MtrldefErpDialogProps: any;
   workgrpEnum: any;
+  VxeTableMxRef: any;
   YwTableRef: any;
   QdTableRef: any;
 }
@@ -60,6 +61,7 @@ export const useHooks = (t?: any) => {
     initParams: {},
     orderStatus: "",
     VxeTableRef: null,
+    VxeTableMxRef: null,
     YwTableRef: null,
     QdTableRef: null,
     LjDetailRef: null,
@@ -1310,75 +1312,30 @@ export const useHooks = (t?: any) => {
       selected: true
     }
   });
-  const tableProps_mx_yw = ref<any>({
-    height: "auto",
-    align: "left",
-    // height: "",
-    minHeight: "300px",
-    editConfig: { trigger: "click", mode: "cell", enabled: false },
-    // exportConfig: {
-    //   filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
-    // }
-    keyboardConfig: {
-      isEdit: true,
-      isArrow: true,
-      isEnter: true,
-      isTab: true,
-      isDel: true,
-      isBack: true,
-      isEsc: true,
-      editMethod({ $table, row, column }) {
-        // 先清空原先的值
-        row[column.field] = "";
-        // 再激活编辑状态并输入新值
-        $table.setEditCell(row, column);
-      }
-    },
-    mouseConfig: {
-      selected: true
-    }
-  });
-  const tableProps_mx_qd = ref<any>({
-    height: "auto",
-    align: "left",
-    // height: "",
-    minHeight: "300px",
-    editConfig: { trigger: "click", mode: "cell", enabled: false },
-    // exportConfig: {
-    //   filename: t("menu.saleTaskCrmDetail") + formatToDate(new Date(), "YYYY-MM-DDHH:mm:ss")
-    // }
-    keyboardConfig: {
-      isEdit: true,
-      isArrow: true,
-      isEnter: true,
-      isTab: true,
-      isDel: true,
-      isBack: true,
-      isEsc: true,
-      editMethod({ $table, row, column }) {
-        // 先清空原先的值
-        row[column.field] = "";
-        // 再激活编辑状态并输入新值
-        $table.setEditCell(row, column);
-      }
-    },
-    mouseConfig: {
-      selected: true
-    }
-  });
-
-  const resetMergeCells = (data: any) => {
-    tableProps_mx.value.mergeCells = autoMergeCells(columns_yw, data, ["itemname"]);
 
+  const resetMergeCells = () => {
     nextTick(() => {
-      state.YwTableRef.refresh();
+      const $table = state.YwTableRef.element;
+      const $table2 = state.VxeTableMxRef.element;
+      if ($table) {
+        let mergeCells = autoMergeCells($table, ["itemname"]);
+        $table.setMergeCells(mergeCells);
+      }
+      if ($table2) {
+        let mergeCells = autoMergeCells($table2, ["itemname"]);
+        $table2.setMergeCells(mergeCells);
+        // });
+      }
     });
   };
-  const resetMergeCellsQd = (data: any) => {
-    tableProps_mx_qd.value.mergeCells = autoMergeCells(columns_qd.value, data, ["itemname", "bj_pzname", "bj_pzname_mx_mx"]);
-
+  const resetMergeCellsQd = () => {
     nextTick(() => {
-      state.QdTableRef.refresh();
+      const $table = state.QdTableRef.element;
+      if ($table) {
+        let mergeCells = autoMergeCells($table, ["itemname", "bj_pzname", "bj_pzname_mx_mx"]);
+        console.log("autoMergeCells mergeCells :>> ", mergeCells);
+        $table.setMergeCells(mergeCells);
+      }
     });
   };
 
@@ -1392,8 +1349,8 @@ export const useHooks = (t?: any) => {
     state.mattressYWList = res.interfaceList;
     state.mattressQDList = res.qdList;
 
-    resetMergeCells(res.interfaceList);
-    resetMergeCellsQd(res.qdList);
+    resetMergeCells();
+    resetMergeCellsQd();
   };
   /**
    * 获取产品配置,产品清单
@@ -1402,6 +1359,8 @@ export const useHooks = (t?: any) => {
   const RefreshMattressInterfaceList = async (mattressid: number, isPz: number) => {
     let res = await RefreshMattressInterface({ mattressid, isPz });
     state.mattressYWList = res.mxList;
+
+    resetMergeCells();
   };
   /**
    * 获取产品配置,产品清单
@@ -1735,8 +1694,6 @@ export const useHooks = (t?: any) => {
     columns_yw_qd,
     columns_qd,
     tableProps_mx,
-    tableProps_mx_yw,
-    tableProps_mx_qd,
     RetriveMattressInterface,
     RefreshMattressInterfaceList,
     RefreshMattressInterfaceQdList,

+ 53 - 5
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -524,9 +524,16 @@
     </template>
 
     <template #innerClothLayerMx__tabtitle="scope">
-      <el-badge :value="innerClothLayerNum" :type="innerClothLayerNum > 0 ? 'danger' : 'info'" :show-zero="false">
-        {{ scope.props.label }}
-      </el-badge>
+      <template v-if="innerClothLayerNum_error">
+        <el-badge :value="innerClothLayerNum_error + '异常'" type="danger">
+          {{ scope.props.label }}
+        </el-badge>
+      </template>
+      <template v-else>
+        <el-badge :value="innerClothLayerNum" type="primary" :show-zero="false">
+          {{ scope.props.label }}
+        </el-badge>
+      </template>
     </template>
     <template #innerClothLayerMx>
       <LjVxeTable
@@ -543,6 +550,7 @@
         :auto-load-layout="false"
         collapseButtons
         :footer-sum-attrs="['costamt']"
+        :after-mound="resetMergeCellsInner"
       >
         <template #tableHeader v-if="orderStatus">
           <el-space wrap>
@@ -581,6 +589,7 @@
         :auto-load-layout="false"
         collapseButtons
         :footer-sum-attrs="['costamt']"
+        :after-mound="resetMergeCellsTopCotton"
       >
         <template #tableHeader v-if="orderStatus">
           <el-space wrap>
@@ -603,7 +612,12 @@
     </template>
 
     <template #subSpecs__tabtitle="scope">
-      <el-badge :value="subSpecsNum" type="primary" :show-zero="false">
+      <template v-if="LjDetailRef._mainData.parentid > 0">
+        <el-badge value="副" type="primary" :show-zero="false">
+          {{ scope.props.label }}
+        </el-badge>
+      </template>
+      <el-badge v-else :value="subSpecsNum" type="primary" :show-zero="false">
         {{ scope.props.label }}
       </el-badge>
     </template>
@@ -618,6 +632,7 @@
         :columns="columnsMx_subSpecs"
         :dwname="DwnameEnum.mattressQuoteSubspecs"
         :table-props="tableProps_mx"
+        :table-events="tableEvents"
         :tool-button="[]"
         :auto-load-layout="false"
         collapseButtons
@@ -793,7 +808,9 @@ const {
   wf_del_w_butao,
   w_mattress_add_itemname_choose,
   wf_rtr_bednet,
-  funcAddMtrlMx
+  funcAddMtrlMx,
+  resetMergeCellsInner,
+  resetMergeCellsTopCotton
 } = useHooks(t);
 const { toExcelQuote } = useHooksCpQuote();
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
@@ -1097,6 +1114,14 @@ const innerClothLayerNum = computed(() => {
   }
   return arr.length;
 });
+const innerClothLayerNum_error = computed(() => {
+  let arr = [];
+  const $table = innerClothLayerMxRef.value?.element;
+  if ($table) {
+    arr = $table.getTableData().visibleData.filter(t => Number(t.if_success));
+  }
+  return arr.length;
+});
 
 const getData_innerClothLayer = (params: any) => {
   console.log("getData params :>> ", params);
@@ -2281,6 +2306,7 @@ const toAddMx_subSpecs = async () => {
   if ($table) {
     let records = {
       mattressid: 0,
+      mattresscode: "",
       mattress_width: "",
       mattress_length: "",
       mattress_height: ""
@@ -2316,6 +2342,28 @@ const gotoMainMattress = () => {
     router.push(`/mattressQuote/detail?id=${LjDetailRef.value._mainData.parentid}`);
   }
 };
+
+const handleDBlClickTable = ({ row, rowIndex, $rowIndex, column, columnIndex, $columnIndex, $event }: any) => {
+  if (orderStatus.value) return false;
+  if (globalStore.detailBlank) {
+    // 打开新的窗口
+    const routeUrl = router.resolve({
+      path: `/mattressQuote/detail`,
+      query: {
+        id: row.mattressid,
+        code: row.mattresscode
+      }
+    });
+    window.open(routeUrl.href, "_blank");
+  } else {
+    router.push(`/mattressQuote/detail?id=${row.mattressid}&code=${row.mattresscode}`);
+  }
+};
+
+// 返回绑定的事件
+const tableEvents = {
+  "cell-dblclick": handleDBlClickTable
+};
 </script>
 
 <style lang="scss">

+ 64 - 4
JLHWEB/src/views/quote/mattressQuote/hooks/index.tsx

@@ -12,7 +12,7 @@ import { ElButton, ElMessage, ElPopconfirm, ElMessageBox, ElNotification, ElTag
 import { Minus, Plus, InfoFilled } from "@element-plus/icons-vue";
 import { DwnameEnum } from "@/enums/dwnameEnum";
 import { isArray } from "@/utils/is";
-import { calculateFormula, formulaPartsFormula, floatAdd, floatMul, formatFixedNumber } from "@/utils/index";
+import { calculateFormula, formulaPartsFormula, floatAdd, floatMul, formatFixedNumber, autoMergeCells } from "@/utils/index";
 import { cloneDeep, defaultsDeep } from "lodash-es";
 import { TYPE, useToast, POSITION } from "vue-toastification";
 import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
@@ -4336,6 +4336,26 @@ export const useHooks = (t?: any) => {
     }
   ];
   const columnsMxInnerClothLayer: ColumnProps<any>[] = [
+    {
+      title: "计算成功?",
+      field: "if_success",
+      datatype: "checkbox",
+      limited: () => {
+        const { userInfo } = useUserStore();
+        return userInfo.usermode != 0;
+      },
+      render: (scope: any) => {
+        if (Number(scope.row.if_success)) {
+          return (
+            <>
+              <ElTag type="danger">异常</ElTag>
+            </>
+          );
+        } else {
+          return <></>;
+        }
+      }
+    },
     {
       title: "位置",
       field: "chastr"
@@ -4523,6 +4543,18 @@ export const useHooks = (t?: any) => {
     };
     let res = await CommonDynamicSelect(_params);
 
+    let idxStr = "";
+    const $table = state.innerClothLayerMxRef.element;
+    if ($table) {
+      const { visibleData } = $table.getTableData();
+      if (visibleData.length) {
+        let lastMx = visibleData[visibleData.length - 1];
+        idxStr = Number(lastMx.chastr.match(/\d+$/)?.[0] ?? 0) + 1 + "";
+      } else {
+        idxStr = "";
+      }
+    }
+
     if (res?.datatable?.length) {
       const $table = state.innerClothLayerMxRef.element;
 
@@ -4540,7 +4572,7 @@ export const useHooks = (t?: any) => {
         _data.sortcode = item.sortcode;
         _data.formulakind = item.formulakind;
         _data.formula = item.formula;
-        _data.chastr = "内布套";
+        _data.chastr = "内布套" + idxStr;
         _data.useformula = item.useformula;
         _data.gydscrp = item.gydscrp;
         _data.pid = index + 1;
@@ -4554,8 +4586,22 @@ export const useHooks = (t?: any) => {
       // };
 
       // $table.insertAt(tree, -1);
-      $table.insertAt(_rows, -1);
+      await $table.insertAt(_rows, -1);
+
+      ElMessage.success("导入成功");
     }
+    resetMergeCellsInner();
+  };
+
+  const resetMergeCellsInner = () => {
+    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) => {
@@ -4656,6 +4702,18 @@ export const useHooks = (t?: any) => {
         $table.insertAt(_rows, -1);
       }
     }
+    resetMergeCellsTopCotton();
+  };
+
+  const resetMergeCellsTopCotton = () => {
+    setTimeout(() => {
+      const $table = state.topCottonMxRef.element;
+      if ($table) {
+        let mergeCells = autoMergeCells($table, ["chastr"]);
+        console.log("resetMergeCellsInner autoMergeCells  :>> ", mergeCells);
+        $table.setMergeCells(mergeCells);
+      }
+    }, 1);
   };
 
   /**
@@ -4719,6 +4777,8 @@ export const useHooks = (t?: any) => {
     wf_del_w_butao,
     w_mattress_add_itemname_choose,
     wf_rtr_bednet,
-    funcAddMtrlMx
+    funcAddMtrlMx,
+    resetMergeCellsInner,
+    resetMergeCellsTopCotton
   };
 };