Bläddra i källkod

JLHWEB:补充提交

JohnnyChan 3 månader sedan
förälder
incheckning
7ccad3e037

+ 7 - 6
JLHWEB/src/components/LjDetail/components/BaseForm.vue

@@ -2185,13 +2185,14 @@ const saveDefaultClick = () => {
   confirmBtnLoading.value = true;
 
   let diff = saveLayoutFunc();
-  emit("saveDefault", groupFlatColumns.value, diff, () => {
+  emit("saveDefault", groupFlatColumns.value, diff, (ifsuccess: boolean) => {
     confirmBtnLoading.value = false;
-    ElNotification({
-      title: t("sys.api.operationSuccess"),
-      message: t("sys.layout.successToLayout"),
-      type: "success"
-    });
+    ifsuccess &&
+      ElNotification({
+        title: t("sys.api.operationSuccess"),
+        message: t("sys.layout.successToLayout"),
+        type: "success"
+      });
   });
 };
 

+ 68 - 10
JLHWEB/src/components/LjDetail/index.vue

@@ -37,8 +37,7 @@ import { ColumnProps, dwnameSaveLayoutAttr } from "@/components/LjVxeTable/inter
 import { useLayoutStore } from "@/stores/modules/layout";
 import { useRoute } from "vue-router";
 import { useAuthButtons } from "@/hooks/useAuthButtons";
-import { ElNotification } from "element-plus";
-import { ElMessage } from "element-plus";
+import { ElMessage, ElNotification, ElMessageBox } from "element-plus";
 import { useTable } from "@/hooks/useTable";
 import { useDwLayout } from "@/hooks/useDwLayout";
 import {
@@ -58,6 +57,7 @@ import { usePrint } from "@/hooks/usePrint";
 import variables from "@/styles/js.module.scss";
 import PrintEditor from "@/components/PrintEditor/index.vue";
 import PrintTemplateSelector from "@/components/Selector/PrintTemplate/index.vue";
+import { CommonDynamicSelect } from "@/api/modules/common";
 
 const { t } = useI18n();
 /** 默认使用通用接口,并只读第一条数据作为主表数据 */
@@ -247,6 +247,34 @@ const loadDwLayout = (data: any) => {
   initLayoutColumns();
 };
 
+/**
+ * @description 默认接口
+ * @param params
+ */
+const defaultRequest = (params: any) => {
+  if (!props.requestAuto) return undefined;
+  console.log("defaultRequest props, params :>> ", props, props.dsname, params);
+  let newParams: any = {};
+  params.pageNum && (newParams.pageindex = params.pageNum);
+  params.pageSize && (newParams.pagesize = params.pageSize);
+  params.orderstr && (newParams.orderstr = params.orderstr);
+  delete params.pageNum;
+  delete params.pageSize;
+  delete params.orderstr;
+  newParams.queryParams = JSON.parse(JSON.stringify(params));
+
+  newParams.dsname = props.dsname ?? dwnameBasic.value;
+  return CommonDynamicSelect(newParams, dwnameBasic.value);
+};
+const defaultDataCallback = (data: any) => {
+  return {
+    list: data.datatable,
+    tableinfo: data.tableinfo,
+    total: data.totalcnt,
+    pageNum: data.pageindex,
+    pageSize: data.pagesize
+  };
+};
 // 表格操作 Hooks
 const {
   tableData,
@@ -262,10 +290,10 @@ const {
   // handleCurrentChange,
   // handlePageChange
 } = useTable(
-  props.requestApi,
+  props.requestApi || defaultRequest,
   props.initParam,
   props.pagination,
-  props.dataCallback,
+  props.dataCallback || defaultDataCallback,
   props.requestError,
   props.dwname,
   undefined,
@@ -555,6 +583,12 @@ const setEnumMap = async (col: ColumnProps) => {
 const dwnameLayout = computed(() => {
   return props.dwname + "__layout-detail";
 });
+/**
+ * @description 基础信息布局
+ */
+const dwnameBasic = computed(() => {
+  return props.dwname + "-detail";
+});
 // /**
 //  * @description 当前基础信息的布展示列field集合
 //  */
@@ -946,19 +980,43 @@ const saveBasicSettingFunc = async (columns: any, formParams: any, callback: any
 /**
  * @description 基础设置: 保存系统默认模版
  */
-const saveDefaultLayout = async (columns: any, formParams: any, callback?: any) => {
+const saveDefaultLayout = async (columns: any, formParams: any, cb?: any) => {
   if (!props.dwname) {
     ElMessage.error("LjVextable组件未设置储存的模版名称,无法保存");
     return false;
   }
 
-  let layout = await saveColumnsFunc(columns, formParams, true, -1);
+  // let layout = await saveColumnsFunc(columns, formParams, true, -1);
 
-  console.log("saveDefaultLayout layout :>> ", layout);
+  // console.log("saveDefaultLayout layout :>> ", layout);
 
-  await layoutStore.saveDwLayout_online(-1, props.dwname, layout);
+  // await layoutStore.saveDwLayout_online(-1, props.dwname, layout);
 
-  callback && callback();
+  // callback && callback();
+
+  ElMessageBox.confirm("是否确认设置为默认布局?", "操作提示", {
+    distinguishCancelAndClose: true,
+    confirmButtonText: "仅设置默认布局",
+    cancelButtonText: t("sys.layout.settingsAndDelete")
+  })
+    .then(async () => {
+      let layout = await saveColumnsFunc(columns, formParams, true, -1);
+
+      props.dwname && (await layoutStore.saveDwLayout_online(-1, dwnameBasic.value, layout, 0, 1));
+
+      cb && cb(true);
+    })
+    .catch(async (action: any) => {
+      if (action === "cancel") {
+        let layout = await saveColumnsFunc(columns, formParams, true, -1);
+
+        props.dwname && (await layoutStore.saveDwLayout_online(-1, dwnameBasic.value, layout, 1, 1));
+
+        cb && cb(true);
+      } else {
+        cb && cb(false);
+      }
+    });
 };
 
 const initLayoutColFunc = (data: any) => {
@@ -1005,7 +1063,7 @@ const initLayoutColFunc = (data: any) => {
  */
 const resetBasicSettingFunc = async (callback: any) => {
   // 获取原始数据列
-  let oriColumns = await getOriColumns(true, true, -1, enumMap.value, props.columns);
+  let oriColumns = await getOriColumns(true, true, -1, enumMap.value, enumMap.value);
   console.log("resetBasicSettingFunc enumMap :>> ", enumMap.value);
   console.log("resetBasicSettingFunc oriColumns -1:>> ", oriColumns);
   oriColumns = initLayoutColFunc(oriColumns);

+ 12 - 8
JLHWEB/src/components/LjVxeTable/components/ColSetting.vue

@@ -342,7 +342,7 @@
       <div class="flx-justify-between" style="flex: auto">
         <div class="flx-shrink flx-center">
           <el-button
-            v-if="userInfo.usercode?.trim().toLocaleLowerCase() == 'super'"
+            v-if="userInfo.empid == 0"
             id="settingBtnSetDefault"
             class="enter-x"
             type="primary"
@@ -355,10 +355,12 @@
             </template>
             {{ $t("sys.layout.settings") }}
           </el-button>
-          <el-divider direction="vertical" v-if="userInfo.usercode?.trim().toLocaleLowerCase() == 'super'" />
+          <el-divider direction="vertical" v-if="userInfo.empid == 0" />
           <el-button id="settingBtnReset" class="enter-x" :icon="Refresh" :loading="resetBtnLoading" @click="resetClick">{{
             $t("common.resetText")
           }}</el-button>
+          <el-divider direction="vertical" />
+          {{ props.dwname }}
           <!-- <el-button text bg @click="resetClick" :loading="resetBtnLoading">{{ $t("common.resetText") }}</el-button> -->
           <!-- <div class="flx-center">
             <el-divider direction="vertical" />
@@ -499,6 +501,7 @@ interface ProTableProps {
   // updateColumns: Function;
   // search: (params: any) => void; // 搜索方法
   // reset: (params: any) => void; // 重置方法
+  dwname?: string;
 }
 
 interface BaseMseSettingColumns {
@@ -812,13 +815,14 @@ const saveDefaultClick = () => {
   saveDfBtnLoading.value = true;
 
   let { layout, scroll } = saveLayoutFunc();
-  emit("saveDefault", layout, { scrollY: scroll }, () => {
+  emit("saveDefault", layout, { scrollY: scroll }, (ifsuccess: boolean) => {
     saveDfBtnLoading.value = false;
-    ElNotification({
-      title: t("sys.api.operationSuccess"),
-      message: t("sys.layout.successToLayout"),
-      type: "success"
-    });
+    ifsuccess &&
+      ElNotification({
+        title: t("sys.api.operationSuccess"),
+        message: t("sys.layout.successToLayout"),
+        type: "success"
+      });
   });
 };
 

+ 26 - 18
JLHWEB/src/components/LjVxeTable/index.vue

@@ -304,6 +304,7 @@
   <ColSetting
     v-if="toolButton.length && toolButton.indexOf('setting') > -1"
     ref="baseMsgSettingRef"
+    :dwname="props.dwname"
     :data="colSetting"
     :title="props.title"
     :enum-map="baseEnumMap"
@@ -457,7 +458,7 @@ import { useLayoutStore } from "@/stores/modules/layout";
 import { useI18n } from "vue-i18n";
 import { useUserStore } from "@/stores/modules/user";
 import { useGlobalStore } from "@/stores/modules/global";
-import { ElMessage, ElNotification } from "element-plus";
+import { ElMessage, ElNotification, ElMessageBox } from "element-plus";
 import LoadingCom from "../Loading/index.vue";
 import { TABLE_LAYOUT_ATTR, TABLE_LAYOUT_ATTR_DEFINE, PRINT_KEY_ATTR, TABLE_TYPE_FILTER, ALLOW_EDIT_STATE } from "@/config/index";
 import { useHiprinterStore } from "@/stores/modules/hiprinter";
@@ -2190,23 +2191,30 @@ const saveDefaultLayout = async (column: any, param: any, cb: any) => {
     ElMessage.error("LjVextable组件未设置储存的模版名称,无法保存");
     return false;
   }
-  let { saveCol }: any = await saveColumnsFunc(column, param, true, -1);
-  // const $table = tableRef.value;
-  // 保存布局
-  console.log("settingConfirm saveCol :>> ", saveCol);
-  await layoutStore.saveDwLayout_online(-1, props.dwname, saveCol);
-
-  cb && cb();
-  // settingConfirm(tableColumns.value, {}, false).then(() => {
-  //   let orderstr = defaultSort.value.map((item: any) => `${item.field} ${item.order}`).join(", ");
-  //   console.log("after settingConfirm orderstr :>> ", orderstr);
-  //   searchInitParam.value.orderstr = orderstr;
-
-  //   // 当页码大于1时,才重新加载数据
-  //   if (fullData.length >= pageable.value.pageSize) {
-  //     getTableList();
-  //   }
-  // });
+  ElMessageBox.confirm("是否确认设置为默认布局?", "操作提示", {
+    distinguishCancelAndClose: true,
+    confirmButtonText: "仅设置默认布局",
+    cancelButtonText: t("sys.layout.settingsAndDelete")
+  })
+    .then(async () => {
+      let { saveCol }: any = await saveColumnsFunc(column, param, true, -1);
+      // 保存布局
+      console.log("settingConfirm saveCol :>> ", saveCol);
+      await layoutStore.saveDwLayout_online(-1, props.dwname ?? "", saveCol, 0, 1);
+
+      cb && cb(true);
+    })
+    .catch(async (action: any) => {
+      if (action === "cancel") {
+        let { saveCol }: any = await saveColumnsFunc(column, param, true, -1);
+        // 保存布局
+        console.log("settingConfirm saveCol :>> ", saveCol);
+        await layoutStore.saveDwLayout_online(-1, props.dwname ?? "", saveCol, 1, 1);
+        cb && cb(true);
+      } else {
+        cb && cb(false);
+      }
+    });
 };
 
 /**

+ 13 - 4
JLHWEB/src/components/LjVxeTable/interface/index.ts

@@ -314,6 +314,10 @@ export type aboutVxetableApiProps = {
    * @argument string 布局窗口名称
    */
   dwname?: string;
+  /**
+   * @argument string 通用接口名称
+   */
+  dsname?: string;
   /**
    * @argument string[] 布局读取/保存时,赋值的属性名称; 支持单属名称、属性路径: ["search", "search.order"]
    */
@@ -335,10 +339,6 @@ export type aboutVxetableApiProps = {
    */
   printDataCallback?: (data: any) => any;
   importApi?: (params: any) => Promise<any>;
-  /**
-   * @description 表格/详情页,是否可编辑
-   */
-  editable?: boolean;
 };
 
 /**
@@ -497,6 +497,10 @@ export interface LjVxetableProps extends aboutVxetableApiProps {
    * @description 列表是否显示搜索栏
    */
   ifSearch?: boolean;
+  /**
+   * @description 表格/详情页,是否可编辑
+   */
+  editable?: boolean;
   /**
    * @description 列表刷新后,自动选中第一行
    */
@@ -509,6 +513,11 @@ export interface LjVxetableProps extends aboutVxetableApiProps {
    * @description 当前行是否禁止点击
    */
   lockRow?: boolean | ((params: any) => boolean);
+  tableHeight?: string;
+  /**
+   * @description 获取表格数据后,自动合并单元格的列名
+   */
+  mergeCellsColumns?: string[];
 }
 
 export type LjVxeTableInstance = Omit<InstanceType<typeof LjVxeTable>, keyof ComponentPublicInstance | keyof LjVxetableProps>;

+ 1 - 1
JLHWEB/src/enums/httpEnum.ts

@@ -5,7 +5,7 @@ export enum ResultEnum {
   SUCCESS = 200,
   ERROR = 500,
   OVERDUE = 401,
-  TIMEOUT = 30000,
+  TIMEOUT = 60000,
   TYPE = "success"
 }
 

+ 10 - 4
JLHWEB/src/hooks/useDwLayout.tsx

@@ -4,9 +4,9 @@ import { computed, reactive, toRefs } from "vue";
 // import { useAuthStore } from "@/stores/modules/auth";
 import { useLayoutStore } from "@/stores/modules/layout";
 import { ColumnProps } from "@/components/LjVxeTable/interface";
-import { isFunction, isObject } from "@/utils/is";
+import { isFunction, isObject, isString } from "@/utils/is";
 import { cloneDeep, pick, has, get, set, defaultsDeep } from "lodash-es";
-import { streamlineFunc } from "@/utils";
+import { streamlineFunc, parseFormatType } from "@/utils";
 import { defineColumnStyle } from "@/config/columnStyle";
 import tableJson from "@/languages/modules/zh-cn/table.json";
 import { TABLE_TYPE_FILTER } from "@/config/index";
@@ -408,8 +408,14 @@ export const useDwLayout = (
           item.editRender = { name: "$input", props: { type: "date" } };
         } else if (item.datatype == "datetime") {
           item.editRender = { name: "$input", props: { type: "datetime" } };
-        } else if (item.datatype == "number" || item.datatype == "integer") {
+        } else if (item.datatype == "integer") {
           item.editRender = { name: "$input", props: { type: "number" } };
+        } else if (item.datatype == "number") {
+          const { digits } = parseFormatType(item.format);
+          item.editRender = {
+            name: "$input",
+            props: { type: "float", controls: false, digits }
+          };
         } else if (item.datatype == "input") {
           item.editRender = { name: "$input", props: {} };
         }
@@ -513,7 +519,7 @@ export const useDwLayout = (
     console.log("keepBasicinfo, online, empid :>> ", keepBasicinfo, online, empid);
     let layout: any;
     if (online) {
-      layout = await layoutStore.getDwLayout_online(empid!, dwname, 0);
+      layout = await layoutStore.getDwLayout_online(empid!, dwname, 1);
     } else {
       // 获取缓存中最新的表格布局
       layout = await layoutStore.getDwLayout(dwname);

+ 1 - 1
JLHWEB/src/hooks/useTable.ts

@@ -19,7 +19,7 @@ interface PageChange {
  * @param {Boolean} loadLayoutCallBack 加载布局数据, 返回的数据进行处理的方法 (非必传)
  * */
 export const useTable = (
-  api?: (params: any) => Promise<any>,
+  api?: (params: any) => Promise<any> | undefined,
   initParam: object = {},
   isPageable: boolean = true,
   dataCallBack?: (data: any) => any,

+ 12 - 8
JLHWEB/src/stores/modules/layout.ts

@@ -140,11 +140,11 @@ export const useLayoutStore = defineStore({
         layoutList.push(layout);
         this.setLayoutList(layoutList);
 
-        autoUpload &&
-          ElMessage({
-            message: t("sys.api.operationSuccess"),
-            type: "success"
-          });
+        // autoUpload &&
+        //   ElMessage({
+        //     message: t("sys.api.operationSuccess"),
+        //     type: "success"
+        //   });
       } catch (error) {
         ElMessage.error("设置布局失败:" + dwname);
       }
@@ -152,17 +152,21 @@ export const useLayoutStore = defineStore({
     /**
      * @description 获取窗口布局
      * @param {string} dwname 布局名称
-     * @param {boolean} autoDownload 是否自动获取布局信息
+     * @param {boolean} value 布局信息
+     * @param {number} ifdelother 是否删除其他用户的布局信息
+     * @param {number} iffilesave 是否保存到文件
      * @return {Object} fx_user_dwlayout
      */
-    async saveDwLayout_online(empid: number, dwname: string, value: any) {
+    async saveDwLayout_online(empid: number, dwname: string, value: any, ifdelother: number = 0, iffilesave: number = 0) {
       try {
         let layout = {
           empid: empid,
           dwname: import.meta.env.VITE_GLOB_PRODUCT_CODE,
           itemname: dwname,
           itemvalue: JSON.stringify(value),
-          ifcompress: 0
+          ifcompress: 0,
+          iffilesave: iffilesave,
+          ifdelother: ifdelother
         };
         await SetDwLyoutApi(layout);
       } catch (error) {

+ 9 - 0
JLHWEB/src/utils/index.ts

@@ -381,6 +381,15 @@ export function handleRowAccordingToProp(row: { [key: string]: any }, prop: stri
   return row;
 }
 
+// 工具函数:解析 formatType
+export function parseFormatType(formatType: string) {
+  const match = formatType.match(/^([a-zA-Z]+)(\d*)$/);
+  return {
+    fnName: match?.[1] || formatType,
+    digits: match?.[2] ? parseInt(match[2], 10) : 2
+  };
+}
+
 /**
  * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop
  * @param {String} prop 当前 prop

+ 37 - 19
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -3,8 +3,6 @@
     name="rpMustPayCrmDetail"
     ref="LjDetailRef"
     v-bind="detailProps"
-    :request-api="getData"
-    :data-callback="dataCallback"
     :init-param="initParams"
     v-model:order-status="orderStatus"
     :action="orderDefaultAction"
@@ -1467,6 +1465,7 @@ const dataCallbackSubspecs = (data: any) => {
   let cols = [];
   let list = data.mattresses.map((item: any, index: any) => {
     let _item = {
+      ...item,
       mattress_width: item.mattress_width,
       mattress_length: item.mattress_length,
       mattress_height: item.mattress_height,
@@ -1475,6 +1474,8 @@ const dataCallbackSubspecs = (data: any) => {
       mattressname: item.mattressname,
       mattressrelcode: item.mattressrelcode
     };
+    delete _item.spring_qty_width;
+    delete _item.spring_qty_length;
     let bednetMxs = data.bednetMxs.filter((t: any) => t.mattressid == item.mattressid);
     console.log("dataCallbackSubspecs bednetMxs :>> ", bednetMxs);
     if (bednetMxs.length > 0) {
@@ -1563,6 +1564,7 @@ const getData_additionalCosts = (params: any) => {
 
 const detailProps = reactive<DetailProp>({
   dwname: DwnameEnum.mattressQuote,
+  dsname: "web_mattress",
   columns: columns,
   // headerstatus: ["status", "ifamt_ok"],
   basicDefault: {},
@@ -1647,19 +1649,19 @@ const detailProps = reactive<DetailProp>({
   ]
 });
 
-const getData = (params: any) => {
-  console.log("getData params :>> ", params);
-  let newParams: any = {};
-  params.pageNum && (newParams.pageindex = params.pageNum);
-  params.pageSize && (newParams.pagesize = params.pageSize);
-  delete params.pageNum;
-  delete params.pageSize;
-  newParams.queryParams = params;
-  console.log("params :>> ", params);
-  newParams.dsname = "web_mattress";
-  return CommonDynamicSelect(newParams, DwnameEnum.mattressQuote);
-  // return [];
-};
+// const getData = (params: any) => {
+//   console.log("getData params :>> ", params);
+//   let newParams: any = {};
+//   params.pageNum && (newParams.pageindex = params.pageNum);
+//   params.pageSize && (newParams.pagesize = params.pageSize);
+//   delete params.pageNum;
+//   delete params.pageSize;
+//   newParams.queryParams = params;
+//   console.log("params :>> ", params);
+//   newParams.dsname = "web_mattress";
+//   return CommonDynamicSelect(newParams, DwnameEnum.mattressQuote);
+//   // return [];
+// };
 
 const currentType = ref(1);
 const gotoShowFormula = (type: any) => {
@@ -1763,6 +1765,7 @@ const save = async () => {
       $table_subspecs.clearEdit();
       subspecs = $table_subspecs.getTableData().visibleData;
 
+      console.log("主副规格 subspecs :>> ", subspecs);
       try {
         // 忽略长宽高没填的明细行
         subspecs = subspecs.filter(
@@ -2324,7 +2327,7 @@ onMounted(() => {
  * @description 页面数据加载完成
  */
 const funcAfterMound = async (data: any) => {
-  console.log("onMounted detail sale start!!!! :>> ", orderStatus.value, orderStatus.value != "new");
+  console.log("onMounted detail sale start!!!! :>> ", orderStatus.value, orderStatus.value != "new", data);
   if (route.fullPath.indexOf("/copy?") > -1) {
     LjDetailRef.value._mainData.mattresscode = "";
   }
@@ -2882,8 +2885,11 @@ const autoBednetSave = async (res: any, oldBednetid: number) => {
         price: _res.total_cost,
         qty: 1
       };
-
-      await $table.insertAt(_row, -1);
+      if (visibleData.length == 1 && visibleData[0].mtrlid == 0) {
+        await $table.reloadData([_row]);
+      } else {
+        await $table.insertAt(_row, -1);
+      }
 
       wf_rtr_cwdc(_row, _res, "add");
     }
@@ -2955,7 +2961,19 @@ const toAddMx_subSpecs = async () => {
 const toDelMx_subSpecs = () => {
   const { $table, curRecords } = getCurrentRecords(subSpecsRef.value);
   if ($table) {
-    $table.remove(curRecords);
+    if (curRecords.length) {
+      try {
+        curRecords.forEach((record: any) => {
+          if (record.erp_mtrlid > 0) {
+            throw new Error(`该规格(${record.mattress_width}*${record.mattress_length})已生成ERP物料,不能删除`);
+          }
+        });
+        $table.remove(curRecords);
+      } catch (error) {
+        ElMessage.error(error.message);
+        return false;
+      }
+    }
   }
 };