Просмотр исходного кода

1、新增床垫报价副规格保存接口
2、修复床垫报价产品补充审核后能够取消业务下单问题
3、新增日志捕捉床垫清单清空问题

MY 1 месяц назад
Родитель
Сommit
d1e6320e0b

+ 38 - 0
JLHHJSvr/Com/SaveMattressSubSpecs.cs

@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.Com.Model;
+using LJLib.Net.SPI.Com;
+using Newtonsoft.Json.Linq;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 保存车辆信息
+    /// </summary>
+    public sealed class SaveMattressSubSpecsRequest : ILJRequest<SaveMattressSubSpecsResponse>
+    {
+        public override string GetApiName()
+        {
+            return "SaveMattressSubSpecs";
+        }
+        public string token { get; set; }
+        /// <summary>
+        /// 床垫信息:主表
+        /// </summary>
+        public u_mattress mattress { get; set; }
+        /// <summary>
+        /// 副规格列表
+        /// </summary>
+        public List<u_mattress> subspecsList { get; set; }
+    }
+
+    public sealed class SaveMattressSubSpecsResponse : LJResponse
+    {
+        public int mattressid { get; set; }
+        public string mattresscode { get; set; }
+        public string message { get; set; }
+        public List<string> mxmessage { get; set; }
+    }
+}

+ 1 - 1
JLHHJSvr/Excutor/SaveMattressAuditingExcutor.cs

@@ -43,7 +43,7 @@ namespace JLHHJSvr.Excutor
                         foreach (int itemid in request.mattressids)
                         {
                             var mattressInfo = new u_mattress() { mattressid = itemid };
-                            if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag, xd_flag, yw_flag, mattresscode, parentid") != 1)
+                            if (DbSqlHelper.SelectOne(cmd, mattressInfo, "flag, xd_flag, yw_flag, js1_flag,mattresscode, parentid") != 1)
                             {
                                 rslt.ErrMsg = "查找报价单据失败:" + itemid;
                                 return;

+ 69 - 0
JLHHJSvr/Excutor/SaveMattressSubSpecsExcutor.cs

@@ -0,0 +1,69 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using DirectService.Tools;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
+using JLHHJSvr.Tools;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+using LJLib.SQLEX;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class SaveMattressSubSpecsExcutor : ExcutorBase<SaveMattressSubSpecsRequest, SaveMattressSubSpecsResponse>
+    {
+        protected override void ExcuteInternal(SaveMattressSubSpecsRequest request, object state, SaveMattressSubSpecsResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+            if (request.mattress == null)
+            {
+                rslt.ErrMsg = "缺少主表信息";
+                return;
+            }
+
+            using (var con = GlobalVar.ConnectionString.NewSqlConnection())
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                var mattressHelper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
+                var _mattress = mattressHelper.GetMattress(request.mattress.mattressid);
+                _mattress.mxList = mattressHelper.GetMattressMxMtrl(request.mattress.mattressid);
+                _mattress.extraList = mattressHelper.GetMattressMxExtra(request.mattress.mattressid,1);
+                _mattress.extraCostList = mattressHelper.GetMattressMxExtra(request.mattress.mattressid, 2);
+                _mattress.subspecsList = request.subspecsList;
+
+                using (cmd.Transaction = con.BeginTransaction())
+                {
+                    try
+                    {
+                        mattressHelper.ProcessSubSpecs(_mattress, false);
+
+                        rslt.mattressid = _mattress.mattressid;
+                        rslt.mattresscode = _mattress.mattresscode;
+
+                        cmd.Transaction.Commit();
+                    }
+                    catch (Exception e)
+                    {
+                        rslt.ErrMsg = e.Message;
+                        Trace.Write(e);
+                        cmd.Transaction?.Rollback();
+                    }
+                }
+            }
+        }
+    }
+}

+ 1 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -264,6 +264,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("SaveErpMtrlPriceList", typeof(SaveErpMtrlPriceListRequest), new SaveErpMtrlPriceListExcutor()); // 保存物料价格
                 excutorManager.AddMap("GetErpMtrlPriceList", typeof(GetErpMtrlPriceListRequest), new GetErpMtrlPriceListExcutor()); // 获取ERP物料资料定义
                 excutorManager.AddMap("GetChangeSoftBedMxList", typeof(GetChangeSoftBedMxListRequest), new GetChangeSoftBedMxListExcutor()); // 获取软床报价换料后明细
+                excutorManager.AddMap("SaveMattressSubSpecs", typeof(SaveMattressSubSpecsRequest), new SaveMattressSubSpecsExcutor()); // 获取软床报价换料后明细
             }
             catch (Exception ex)
             {

+ 4 - 3
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -6,6 +6,7 @@ using JLHHJSvr.LJException;
 using JLHHJSvr.Tools;
 using LJLib.DAL.SQL;
 using Microsoft.SqlServer.Server;
+using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using NPOI.SS.Formula.Functions;
 using System;
@@ -39,12 +40,12 @@ namespace JLHHJSvr.Helper
             }
 
             DbSqlHelper.Update(cmd, mattress, "erp_mtrlname,erp_mtrltypeid,erp_mtrlmode,erp_mtrltype,erp_mtrlunit,erp_mtrlengname,erp_configcodetype,old_mtrlname");
-            //
-            var caller = new StackTrace().GetFrame(1).GetMethod();
-            Trace.Write($"Called By {caller.DeclaringType?.Name}.{caller.Name},INFOS:erp_mtrlid = {mattress.erp_mtrlid},erp_mtrlcod = {mattress.erp_mtrlcode},mattressid = {mattress.mattressid}");
             // 保存接口数据
             var mattressHelper = GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = context.tokendata });
             mattressHelper.SaveMattressInterface(mattress.mattressid, mxlist, qdlist);
+            // 
+            var caller = new StackTrace().GetFrame(1).GetMethod();
+            Trace.Write($"CALLED BY {caller.DeclaringType?.Name}.{caller.Name},MAIN_INFOS:{JsonConvert.SerializeObject(mattress)},MXLIST_INFOS:{JsonConvert.SerializeObject(mxlist)},QDLIST_INFOS:{JsonConvert.SerializeObject(qdlist)}");
         }
 
         public void AutoSetMtrlName(u_mattress mattress, List<u_mattress_interface> mxlist)

+ 28 - 3
JLHHJSvr/Helper/MattressHelper.cs

@@ -1900,7 +1900,7 @@ namespace JLHHJSvr.Helper
         public List<u_mattress> GetMattressSubspecs(int mattressid,string fields = null)
         {
             var list = new List<u_mattress>();
-            fields = fields ?? "mattressid,mattresscode,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode,parentid,erp_mtrlid,erp_mtrlcode,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode";
+            fields = fields ?? "mattressid,mattresscode,mattress_width,mattress_length,mattress_height,mattressname,mattressrelcode,parentid,erp_mtrlid,erp_mtrlcode,erp_configcodetype, erp_mtrlengname, erp_mtrlmode, erp_mtrlname, erp_mtrltype, erp_mtrltypeid, erp_mtrlunit, erp_piccode,xd_flag";
             var whereList = new List<string>();
             whereList.Add(@"u_mattress.parentid = @mattressid OR  parentid = (
                 SELECT parentid FROM u_mattress WHERE mattressid = @mattressid and parentid > 0
@@ -3031,13 +3031,13 @@ namespace JLHHJSvr.Helper
         /// </summary>
         /// <param name="mattress"></param>
         /// <param name="ifErp"></param>
-        private void ProcessSubSpecs(u_mattress mattress, bool ifErp)
+        public void ProcessSubSpecs(u_mattress mattress, bool ifErp)
         {
             if (mattress.subspecsList == null) return;
 
             var existing = GetMattressSubspecs(mattress.mattressid, "mattressid") ?? new List<u_mattress>();
 
-            var oldIdSet = new HashSet<int>(existing.Select(x => x.mattressid));
+            var oldIdSet = new HashSet<int>(existing.Where(t => t.xd_flag != null && t.xd_flag == 0).Select(x => x.mattressid));
             var newIdSet = new HashSet<int>(mattress.subspecsList.Where(x => x.mattressid != 0).Select(x => x.mattressid));
             var toUpdate = mattress.subspecsList.Where(x => oldIdSet.Contains(x.mattressid)).ToList();
             var toInsert = mattress.subspecsList.Where(x => x.mattressid == 0).ToList();
@@ -3090,6 +3090,24 @@ namespace JLHHJSvr.Helper
             clone.mattresscode = child.mattresscode;
             clone.mattressrelcode = child.mattressrelcode;
             clone.mattressname = child.mattressname;
+            clone.xd_flag = 0;
+            clone.xd_auditingdate = null;
+            clone.xd_auditingrep = string.Empty;
+            clone.flag = 0;
+            clone.auditingdate = null;
+            clone.auditingrep = string.Empty;
+            clone.js1_flag = 0;
+            clone.js1_auditingdate = null;
+            clone.js1_auditingrep = string.Empty;
+            clone.yw_flag = 0;
+            clone.yw_auditingdate = null;
+            clone.yw_auditingrep = string.Empty;
+            clone.js2_flag = 0;
+            clone.js2_auditingdate = null;
+            clone.js2_auditingrep = string.Empty;
+            clone.qr_flag = 0;
+            clone.qr_auditingdate = null;
+            clone.qr_auditingrep = string.Empty;
             clone.subspecsList = child.subspecsList;
             clone.mattress_width = child.mattress_width;
             clone.mattress_length = child.mattress_length;
@@ -3139,6 +3157,13 @@ namespace JLHHJSvr.Helper
         /// <param name="isDelMain"></param>
         public void DeleteMattress(int mattressid, bool isDelMain = false)
         {
+            //
+            if (mattressid <= 0) throw new LJCommonException("ID错误,删除床垫报价失败!");
+            var mattress = GetMattress(mattressid, "mattresscode,flag,js1_flag,xd_flag");
+            if (mattress.xd_flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已下单,无法删除!");
+            if (mattress.js1_flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已产品审核,无法删除!");
+            if (mattress.flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已财务审核,无法删除!");
+
             // 删除所有明细
             cmd.CommandText = @"DELETE u_mattress_mx_mtrl WHERE mattressid = @mattressid";
             cmd.Parameters.Clear();

+ 2 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -150,6 +150,7 @@
     <Compile Include="Com\SaveErpMtrlPriceList.cs" />
     <Compile Include="Com\SaveMattressExtraType.cs" />
     <Compile Include="Com\SaveMattressExtra.cs" />
+    <Compile Include="Com\SaveMattressSubSpecs.cs" />
     <Compile Include="Com\SaveSoftBedFormula.cs" />
     <Compile Include="Com\SaveSoftBedQuote.cs" />
     <Compile Include="Com\UnLockUser.cs" />
@@ -362,6 +363,7 @@
     <Compile Include="Excutor\SaveErpMtrlPriceListExcutor.cs" />
     <Compile Include="Excutor\SaveMattressExtraTypeExcutor.cs" />
     <Compile Include="Excutor\SaveMattressExtraExcutor.cs" />
+    <Compile Include="Excutor\SaveMattressSubSpecsExcutor.cs" />
     <Compile Include="Excutor\SaveSoftBedFormulaExcutor.cs" />
     <Compile Include="Excutor\SaveSoftBedQuoteExcutor.cs" />
     <Compile Include="Excutor\UnLockUserExcutor.cs" />

+ 7 - 0
JLHWEB/src/api/modules/quote.ts

@@ -9,6 +9,13 @@ export const SaveMattress = (params: Mattress.ReqSaveMattress) => {
   return http.post<Mattress.ResSaveMattress>(PORT1 + `/SaveMattress`, params);
 };
 
+/**
+ * @name 床垫报价副规格保存
+ */
+export const SaveMattressSubSpecs = (params: Mattress.ReqSaveMattress) => {
+  return http.post<Mattress.ResSaveMattress>(PORT1 + `/SaveMattressSubSpecs`, params);
+};
+
 /**
  * @name 床垫报价:业务下单/取消/审核
  */

+ 164 - 6
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -747,7 +747,9 @@
               <el-button type="primary" @click="toAddMx_subSpecs">{{ t("common.addText") }}</el-button>
               <el-button type="danger" @click="toDelMx_subSpecs">{{ t("common.delText") }}</el-button>
               <el-divider direction="vertical" />
-              <el-button type="success" @click="toSave_subSpecs">{{ t("common.saveText") }}</el-button>
+              <el-button type="success" @click="toSave_subSpecs" :loading="loadingStatus.save">{{
+                t("common.saveText")
+              }}</el-button>
               <el-button type="default" @click="toCancel_subSpecs">{{ t("common.cancelText") }}</el-button>
             </template>
           </el-space>
@@ -799,7 +801,14 @@ import LjVxeTable from "@/components/LjVxeTable/index.vue";
 import { cloneDeep } from "lodash-es";
 import { useRoute, useRouter } from "vue-router";
 import { CommonDynamicSelect, GetFormulaCompute } from "@/api/modules/common";
-import { SaveMattress, SaveMattressAuditing, DelMattress, GetMattressImportDW2, GetMattressSubspecs } from "@/api/modules/quote";
+import {
+  SaveMattress,
+  SaveMattressAuditing,
+  DelMattress,
+  GetMattressImportDW2,
+  GetMattressSubspecs,
+  SaveMattressSubSpecs
+} from "@/api/modules/quote";
 // import ToastFormula from "@/components/ToastWidget/Formula/index.vue";
 import { TYPE, useToast, POSITION } from "vue-toastification";
 import { ElMessage, ElMessageBox, ElNotification } from "element-plus";
@@ -1926,6 +1935,158 @@ const save = async () => {
   }
 };
 
+const save_subSpecs = async () => {
+  try {
+    let mattress = LjDetailRef.value._mainData;
+    mattress.mattressid = Number(mattress.mattressid ?? 0);
+
+    let mattressMx = [];
+    try {
+      fabricMxTabList.value.map(t => {
+        if (t.ref) {
+          console.log("t.ref?.value :>> ", t.ref, dynamicRef(t.ref));
+          if (dynamicRef(t.ref) && !["specialProcessesMxRef", "additionalCostsMxRef"].includes(t.ref)) {
+            let $table = dynamicRef(t.ref)?.element;
+            $table.clearEdit();
+            let { visibleData } = $table.getTableData();
+            console.log("visibleData t.ref?.value :>> ", t.ref, visibleData);
+            visibleData = visibleData.map((itm, idx) => {
+              // 检查明细输入是否正确
+              let _disabled = !(
+                (itm.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 12, 13, 14, 32, 33].includes(itm.formulakind)) ||
+                itm.formulakind == 202 ||
+                itm.formulakind == 7
+              );
+              console.log("_disabled :>> ", _disabled);
+              if (t.ref == "cushionsMxRef") {
+                _disabled = !(
+                  (itm.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 14, 32, 33].includes(itm.formulakind)) ||
+                  itm.formulakind == 7 ||
+                  itm.formulakind == 999
+                );
+              } else if (t.ref == "innerClothLayerMxRef") {
+                _disabled = !(
+                  (itm.if_inputqty == 0 && [50, 51, 52, 53, 54, 104, 114, 11, 14, 32, 33].includes(itm.formulakind)) ||
+                  itm.formulakind == 202 ||
+                  itm.formulakind == 203
+                );
+              }
+              console.log(
+                "itm.mtrlid > 0 && !_disabled && Number(itm.thickness) <= 0 :>> ",
+                _disabled,
+                itm.mtrlid > 0 && !_disabled && Number(itm.thickness) <= 0
+              );
+              if (itm.mtrlid > 0 && !_disabled && Number(itm.thickness) <= 0) {
+                throw new Error(t.label + "相关厚度输入有误,请检查");
+              }
+
+              itm.xu = idx + 1;
+              itm.mattress_width = Number(itm?.mattress_width ?? 0);
+              itm.mattress_length = Number(itm?.mattress_length ?? 0);
+              return itm;
+            });
+
+            mattressMx = mattressMx.concat(visibleData);
+          }
+        }
+      });
+    } catch (error) {
+      ElMessage.error(error.message);
+      return false;
+    }
+
+    // 主副规格
+    let subspecs = [];
+    let $table_subspecs = subSpecsRef.value?.element;
+    if ($table_subspecs) {
+      $table_subspecs.clearEdit();
+      subspecs = $table_subspecs.getTableData().visibleData;
+
+      try {
+        // 忽略长宽高没填的明细行
+        subspecs = subspecs.filter(
+          itm => Number(itm.mattress_width) > 0 || Number(itm.mattress_length) > 0 || Number(itm.mattress_height) > 0
+        );
+
+        let ifHas99 = mattressMx.filter(itm => itm.formulakind == 99 && itm.mtrlid > 0);
+        if (ifHas99.length > 0) {
+          subspecs.map(itm => {
+            if (Number(itm.mattress_width) <= 0 || Number(itm.mattress_length) <= 0 || Number(itm.mattress_height) <= 0) {
+              throw new Error("主副规格相关尺寸输入有误(不能为空),请输入正数");
+            }
+            for (const key in itm) {
+              if (key.indexOf("spring_qty_") > -1) {
+                if (Number(itm[key]) <= 0) {
+                  throw new Error("主副规格相关弹簧排列数不能为空,请检查");
+                }
+              }
+            }
+          });
+        }
+
+        const prefixes = [
+          "spring_qty_width",
+          "spring_qty_length",
+          "bednet_iffork",
+          "bednet_fork_qty",
+          "cushions_subspecs",
+          "accessories_subspecs"
+        ];
+        subspecs = subspecs.map(itm => {
+          itm.mattress_width = Number(itm.mattress_width ?? 0);
+          itm.mattress_length = Number(itm.mattress_length ?? 0);
+          itm.mattress_height = Number(mattress.mattress_height ?? 0);
+          itm.DynamicFields = Object.keys(itm)
+            .filter(key => prefixes.some(prefix => key.startsWith(prefix)))
+            .reduce((obj, key) => {
+              obj[key] = itm[key];
+              return obj;
+            }, {});
+          return itm;
+        });
+      } catch (error) {
+        ElMessage.error(error.message);
+        return false;
+      }
+    }
+
+    loadingStatus.save = true;
+    let _param_mf = {
+      mattress,
+      subspecsList: subspecs
+    };
+    try {
+      await SaveMattressSubSpecs(_param_mf)
+        .then(res => {
+          ElNotification({
+            title: "温馨提示",
+            message: t("sys.api.sueccessToSave"),
+            type: "success"
+          });
+          if (res.mattressid) {
+            // router.replace(`/mattressQuote/detail?id=${res.mattressid}&code=${res.mattresscode}`);
+            nextTick(() => {
+              getData_subSpecs().then(res => {
+                const { list } = dataCallbackSubspecs(res);
+                subSpecsData.value = list;
+              });
+            });
+          } else {
+            router.replace("/mattressQuote");
+          }
+          loadingStatus.save = false;
+        })
+        .catch(error => {
+          loadingStatus.save = false;
+        });
+    } catch (error) {
+      ElMessage.error(t("sys.api.operationFailed"));
+    }
+  } catch (e) {
+    loadingStatus.save = false;
+  }
+};
+
 const orderDefaultAction = [
   buttonDefault({
     label: t("common.cancelText"),
@@ -2075,9 +2236,6 @@ const orderDefaultAction = [
   buttonDefault({
     label: t("common.businessOrderCancel"),
     power: 95,
-    limited: () => {
-      return !!orderStatus.value;
-    },
     disabledTextCallBack: (data: any) => {
       if (!CheckPower(95)) {
         return `你没有【报价单-${t("common.businessOrderCancel")}】的使用权限`;
@@ -3113,7 +3271,7 @@ const toCancel_subSpecs = () => {
 };
 
 const toSave_subSpecs = async () => {
-  await save();
+  await save_subSpecs();
 
   editSubSpecs.value = false;
 };