Преглед на файлове

1、软床报价,修复发生报错后,按钮一直处于loading状态
2、床垫报价,修复分享报价副规格依然按照主规格属性复制

MY преди 3 седмици
родител
ревизия
0818bc98b9

+ 49 - 22
JLHHJSvr/Helper/MattressHelper.cs

@@ -2813,7 +2813,30 @@ namespace JLHHJSvr.Helper
             {
                 // 已经审核的不进行再次保存/修改
                 if (child.flag == 1 || child.yw_flag == 1 || child.xd_flag == 1) continue;
-                InitMattressSubSpecs(parent, child);
+                if(child.copy_id > 0)
+                {
+                    child.mxList = GetMattressMxMtrl(child.copy_id.Value);
+                    foreach (var mx in child.mxList)
+                    {
+                        mx.mattressid = 0;
+                        mx.mattressmxid = 0;
+                    }
+
+                    child.extraList = GetMattressMxExtra(child.copy_id.Value, 1);
+                    foreach (var mx in child.extraList)
+                    {
+                        mx.mattressid = 0;
+                        mx.mattressmxid = 0;
+                    }
+
+                    child.extraCostList = GetMattressMxExtra(child.copy_id.Value, 2);
+                    foreach (var mx in child.extraCostList)
+                    {
+                        mx.mattressid = 0;
+                        mx.mattressmxid = 0;
+                    }
+                }
+                else InitMattressSubSpecs(parent, child);
 
                 MattressCalculateCost(child, child.mxList, child.extraList, child.extraCostList);
                 SaveMattressPro(child, ifErp, true);
@@ -2862,27 +2885,31 @@ namespace JLHHJSvr.Helper
             clone.extras_cost = child.extras_cost;
             clone.version = child.version;
             clone.DynamicFields = child.DynamicFields;
-            clone.mxList = parent.mxList?.Select(mx =>
-            {
-                var mxClone = ObjectHelper.DeepCopy(mx);
-                mxClone.mattressid = 0;
-                mxClone.mattressmxid = 0;
-                return mxClone;
-            }).ToList();
-            clone.extraList = parent.extraList?.Select(mx =>
-            {
-                var mxClone = ObjectHelper.DeepCopy(mx);
-                mxClone.mattressid = 0;
-                mxClone.mattressmxid = 0;
-                return mxClone;
-            }).ToList();
-            clone.extraCostList = parent.extraCostList?.Select(mx =>
-            {
-                var mxClone = ObjectHelper.DeepCopy(mx);
-                mxClone.mattressid = 0;
-                mxClone.mattressmxid = 0;
-                return mxClone;
-            }).ToList();
+            clone.copy_id = child.copy_id;
+            if(clone.copy_id > 0)
+            {
+                clone.mxList = parent.mxList?.Select(mx =>
+                {
+                    var mxClone = ObjectHelper.DeepCopy(mx);
+                    mxClone.mattressid = 0;
+                    mxClone.mattressmxid = 0;
+                    return mxClone;
+                }).ToList();
+                clone.extraList = parent.extraList?.Select(mx =>
+                {
+                    var mxClone = ObjectHelper.DeepCopy(mx);
+                    mxClone.mattressid = 0;
+                    mxClone.mattressmxid = 0;
+                    return mxClone;
+                }).ToList();
+                clone.extraCostList = parent.extraCostList?.Select(mx =>
+                {
+                    var mxClone = ObjectHelper.DeepCopy(mx);
+                    mxClone.mattressid = 0;
+                    mxClone.mattressmxid = 0;
+                    return mxClone;
+                }).ToList();
+            }
 
             // iferp
             clone.erp_mtrlcode = child.erp_mtrlcode;

+ 5 - 7
JLHWEB/src/views/quote/softbedQuote/detail.vue

@@ -166,6 +166,7 @@ const {
   SoftBedTemplateDialogRef,
   SoftBedTemplateDialogProps,
   partsConfig,
+  loadingStatus,
   detail_getData,
   toAddMx,
   toDelMx,
@@ -192,10 +193,6 @@ const initParams = ref({ billid: 0 as Number });
 
 const tabRemove: Function = inject("tabRemove") as Function;
 const { userInfo } = useUserStore();
-const loadingStatus = reactive({
-  save: false,
-  download: false
-});
 /**
  * @description 明细表格组件基础配置
  */
@@ -338,7 +335,7 @@ const orderDefaultAction = [
   buttonNew({
     label: t("common.saveText"),
     icon: "iconsave-01",
-    loading: () => loadingStatus.save,
+    loading: () => loadingStatus.value.save,
     limited: () => !orderStatus.value,
     disabledTextCallBack: data => {
       if (data.flag > 0) {
@@ -347,9 +344,7 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: () => {
-      loadingStatus.save = true;
       onSave(res => {
-        loadingStatus.save = false;
         if (res.softbed.softbed_id) {
           pageRefresh({
             name: "softbedQuoteDetail",
@@ -411,6 +406,7 @@ const orderDefaultAction = [
   buttonDefault({
     label: t("common.delText"),
     power: 155,
+    loading: () => loadingStatus.value.delete,
     limited: () => {
       return !!orderStatus.value;
     },
@@ -431,6 +427,7 @@ const orderDefaultAction = [
   buttonDefault({
     label: t("common.auditText"),
     power: 153,
+    loading: () => loadingStatus.value.audit,
     limited: () => {
       return !!orderStatus.value;
     },
@@ -453,6 +450,7 @@ const orderDefaultAction = [
   buttonDefault({
     label: t("common.withdrawAuditText"),
     power: 154,
+    loading: () => loadingStatus.value.caudit,
     limited: () => {
       return !!orderStatus.value;
     },

+ 69 - 15
JLHWEB/src/views/quote/softbedQuote/hooks/index.tsx

@@ -115,6 +115,16 @@ interface defaultState {
   softBedFormulaEnum: any[];
   deptEnum: any[];
   accessoryEnum: any[];
+  /**
+   * @description 按钮loading状态管理
+   */
+  loadingStatus: {
+    save: boolean;
+    audit: boolean;
+    caudit: boolean;
+    delete: boolean;
+    download: boolean;
+  };
 }
 
 /**
@@ -159,7 +169,14 @@ export const useHooks = (t?: any) => {
     ErpMtrlPriceDialogProps: {},
     softBedFormulaEnum: [],
     deptEnum: [],
-    accessoryEnum: []
+    accessoryEnum: [],
+    loadingStatus: {
+      save: false,
+      audit: false,
+      caudit: false,
+      delete: false,
+      download: false
+    }
   });
   // 表格配置项
   const columns: ColumnProps<any>[] = [
@@ -1579,6 +1596,9 @@ export const useHooks = (t?: any) => {
       type: state.orderStatus
     };
 
+    // 设置loading状态为true
+    state.loadingStatus.save = true;
+
     try {
       await SaveSoftBedQuote(params)
         .then((res: any) => {
@@ -1592,9 +1612,16 @@ export const useHooks = (t?: any) => {
         })
         .catch(error => {
           console.log("error !! :>> ", error);
+          ElMessage.error(t("sys.api.operationFailed"));
+        })
+        .finally(() => {
+          // 无论成功失败都要重置loading状态
+          state.loadingStatus.save = false;
         });
     } catch (error) {
       ElMessage.error(t("sys.api.operationFailed"));
+      // 异常情况下也要重置loading状态
+      state.loadingStatus.save = false;
     }
   };
 
@@ -1613,10 +1640,19 @@ export const useHooks = (t?: any) => {
       type: "warning"
     })
       .then(() => {
-        AuditSoftBedQuote({ list, type: 1 }).then(() => {
-          ElMessage.success(t("sys.api.operationSuccess"));
-          cb && cb();
-        });
+        state.loadingStatus.audit = true;
+        AuditSoftBedQuote({ list, type: 1 })
+          .then(() => {
+            ElMessage.success(t("sys.api.operationSuccess"));
+            cb && cb();
+          })
+          .catch(error => {
+            console.log("审核失败:", error);
+            ElMessage.error(t("sys.api.operationFailed"));
+          })
+          .finally(() => {
+            state.loadingStatus.audit = false;
+          });
       })
       .catch((e: TypeError) => {
         ElMessage({
@@ -1635,11 +1671,20 @@ export const useHooks = (t?: any) => {
       type: "warning"
     })
       .then(() => {
-        AuditSoftBedQuote({ list, type: 0 }).then(() => {
-          ElMessage.success(t("sys.api.operationSuccess"));
-          cb && cb();
-          state.VxeTableRef.refresh();
-        });
+        state.loadingStatus.caudit = true;
+        AuditSoftBedQuote({ list, type: 0 })
+          .then(() => {
+            ElMessage.success(t("sys.api.operationSuccess"));
+            cb && cb();
+            state.VxeTableRef.refresh();
+          })
+          .catch(error => {
+            console.log("撤审失败:", error);
+            ElMessage.error(t("sys.api.operationFailed"));
+          })
+          .finally(() => {
+            state.loadingStatus.caudit = false;
+          });
       })
       .catch((e: TypeError) => {
         ElMessage({
@@ -1658,11 +1703,20 @@ export const useHooks = (t?: any) => {
       type: "warning"
     })
       .then(() => {
-        DeleteSoftBedQuote({ list }).then(() => {
-          ElMessage.success(t("sys.api.operationSuccess"));
-          cb && cb();
-          state.VxeTableRef.refresh();
-        });
+        state.loadingStatus.delete = true;
+        DeleteSoftBedQuote({ list })
+          .then(() => {
+            ElMessage.success(t("sys.api.operationSuccess"));
+            cb && cb();
+            state.VxeTableRef.refresh();
+          })
+          .catch(error => {
+            console.log("删除失败:", error);
+            ElMessage.error(t("sys.api.operationFailed"));
+          })
+          .finally(() => {
+            state.loadingStatus.delete = false;
+          });
       })
       .catch((e: TypeError) => {
         ElMessage({

+ 4 - 1
JLHWEB/src/views/quote/softbedQuote/index.vue

@@ -43,7 +43,7 @@ import { usePageRouter } from "@/hooks/usePageRouter";
 const { t } = useI18n();
 const router = useRouter();
 const globalStore = useGlobalStore();
-const { columns, orderStatus, VxeTableRef, initParams, onAudit, onCAudit, onDelete, onShowFormula } = useHooks(t);
+const { columns, orderStatus, VxeTableRef, initParams, loadingStatus, onAudit, onCAudit, onDelete, onShowFormula } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 const { userInfo } = useUserStore();
 const { pageOpen } = usePageRouter();
@@ -161,6 +161,7 @@ const action: detailAction[] = [
   buttonDefault({
     label: t("common.delText"),
     power: 155,
+    loading: () => loadingStatus.value.delete,
     disabledTextCallBack: (data: any) => {
       if (!CheckPower(155)) {
         return "你没有【报价单-删除】的使用权限";
@@ -186,6 +187,7 @@ const action: detailAction[] = [
   buttonDefault({
     label: t("common.auditText"),
     power: 153,
+    loading: () => loadingStatus.value.audit,
     limited: () => {
       return !!orderStatus.value;
     },
@@ -208,6 +210,7 @@ const action: detailAction[] = [
   buttonDefault({
     label: t("common.withdrawAuditText"),
     power: 154,
+    loading: () => loadingStatus.value.caudit,
     limited: () => {
       return !!orderStatus.value;
     },