浏览代码

1、新增单据上锁功能(界面待开发)

MY 2 月之前
父节点
当前提交
0c730be768

+ 4 - 11
JLHHJSvr/Com/Model/u_lock_table.cs

@@ -46,22 +46,15 @@ namespace JLHHJSvr.Com.Model
         /// 结果枚举
         /// </summary>
         public LockCheckResultCode Code { get; set; }
-        /// <summary>
-        /// 成功
-        /// </summary>
-        public bool Success => Code == LockCheckResultCode.Success;
-        /// <summary>
-        /// 失败
-        /// </summary>
-        public bool Locked => Code == LockCheckResultCode.Locked;
     }
 
     public enum LockCheckResultCode
     {
         Success = 0,       // 可以继续操作
-        Locked = 1,        // 被别人锁住
-        Expired = 2,       // 锁过期
-        NotFound = 3,      // 没有找到单据
+        LockedBySelf = 1,   // 被自己锁住(允许操作)
+        LockedByOther = 2,  // 被别人锁住(禁止操作)
+        Expired = 3,       // 锁过期
+        NotFound = 4,      // 没有找到单据
         Error = 99         // 其他未知错误
     }
 }

+ 7 - 1
JLHHJSvr/Excutor/CheckTableIsLockExcutor.cs

@@ -37,7 +37,13 @@ namespace JLHHJSvr.Excutor
 
                 try
                 {
-                    LockHelper.CheckLockAll(cmd, request.keyword, request.billid,tokendata.username);
+                    var lockItem = LockHelper.CheckLockAll(cmd, request.keyword, request.billid,tokendata.username);
+
+                    if (lockItem.Code == LockCheckResultCode.LockedByOther) throw new LJCommonException(lockItem.log_msg);
+                    if(lockItem.Code == LockCheckResultCode.Success)
+                    {
+                        LockHelper.LockBill(cmd,request.keyword,request.billid,tokendata.username);
+                    }
                 }catch(Exception ex)
                 {
                     rslt.ErrMsg = ex.Message;

+ 2 - 1
JLHHJSvr/Excutor/CreatMtrldefExcutor.cs

@@ -7,6 +7,7 @@ using JLHHJSvr.BLL;
 using JLHHJSvr.Com;
 using JLHHJSvr.Com.Model;
 using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
 using LJLib.DAL.SQL;
 using LJLib.Net.SPI.Server;
 using LJLib.SQLEX;
@@ -90,7 +91,7 @@ namespace JLHHJSvr.Excutor
                     {
                         foreach (var mattress in toUpdate.Where(m => m.erp_mtrlid > 0))
                         {
-                            LockHelper.CheckLockAll(cmd, MattressHelper.BillKeyWord, mattress.mattressid,tokendata.username);
+                            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattress.mattressid, tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
                             mattress.creatmtrl_flag = 1;
 
                             DbSqlHelper.Update(cmd, mattress, "erp_mtrlid, creatmtrl_flag, erp_mtrlcode");

+ 2 - 1
JLHHJSvr/Excutor/CreatPrdPfExcutor.cs

@@ -7,6 +7,7 @@ using JLHHJSvr.BLL;
 using JLHHJSvr.Com;
 using JLHHJSvr.Com.Model;
 using JLHHJSvr.Helper;
+using JLHHJSvr.LJException;
 using LJLib.DAL.SQL;
 using LJLib.Net.SPI.Server;
 using LJLib.SQLEX;
@@ -39,7 +40,7 @@ namespace JLHHJSvr.Excutor
 
                 foreach (var mattressid in request.list)
                 {
-                    LockHelper.CheckLockAll(cmd, InterfaceHelper.BillKeyWord, mattressid,tokendata.username);
+                    if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
                     var mattress = new u_mattress();
                     if (DbSqlHelper.SelectOne(cmd, "u_mattress", "mattressid = @mattressid", new Dictionary<string, object>() { { "mattressid", mattressid } }, mattress, "erp_mtrlid,erp_mtrlcode, erp_mtrlname, erp_mtrlmode, erp_mtrltypeid, erp_mtrltype, erp_mtrlunit, erp_mtrlengname,nottax_factory_cost,dept_profitrate,dept_profitrate_rangli,commission,taxes,fob,extras_cost,mattresstypeid,erp_configcodetype") != 1)

+ 1 - 1
JLHHJSvr/Excutor/ReCalculateERPCostExcutor.cs

@@ -82,7 +82,7 @@ namespace JLHHJSvr.Excutor
                                 mattress_temp.mxList = mxList;
                                 mattress_temp.extraList = mxExtra1List;
                                 mattress_temp.extraCostList = mxExtra2List;
-                                helper.SaveMattressPro(mattress_temp);
+                                helper.SaveMattressPro(mattress_temp,false,true);
 
                                 if (mattress_temp.erp_mtrlid > 0)
                                 {

+ 1 - 1
JLHHJSvr/Excutor/ReCalculateNoAuditExcutor.cs

@@ -78,7 +78,7 @@ namespace JLHHJSvr.Excutor
                             mattress_temp.mxList = mxList;
                             mattress_temp.extraList = mxExtra1List;
                             mattress_temp.extraCostList = mxExtra2List;
-                            helper.SaveMattressPro(mattress_temp);
+                            helper.SaveMattressPro(mattress_temp,false,true);
                         }
                         cmd.Transaction.Commit();
                     }

+ 3 - 3
JLHHJSvr/Helper/BedNetHelper.cs

@@ -2490,7 +2490,7 @@ namespace JLHHJSvr.Helper
             if (bednet.bednetid > 0)
             {
                 // 检查锁
-                LockHelper.CheckLockAll(cmd, BillKeyWord, bednet.bednetid.Value, context.tokendata.username);
+                if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, bednet.bednetid.Value, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
                 // 检测版本控制
                 CheckBillVersion<u_bednet>(cmd, bednet.bednetid.Value, bednet.version);
             }
@@ -3087,7 +3087,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有审核权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, bednetid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, bednetid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var bednet = GetBedNet(bednetid, "flag,bednetcode,version");
 
@@ -3113,7 +3113,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有审核权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, bednetid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, bednetid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var bednet = GetBedNet(bednetid, "flag,bednetcode,version");
             if (bednet.flag == 0)

+ 1 - 1
JLHHJSvr/Helper/InterfaceHelper.cs

@@ -30,7 +30,7 @@ namespace JLHHJSvr.Helper
             }
 
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattress.mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattress.mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
             // 检测版本
             CheckBillVersion<u_mattress>(cmd, mattress.mattressid, mattress.version);
             // 

+ 54 - 33
JLHHJSvr/Helper/LockHelper.cs

@@ -11,6 +11,7 @@ using System.Text;
 using System.Threading.Tasks;
 using System.ComponentModel;
 using NPOI.SS.Formula;
+using System.Web.Configuration;
 
 namespace JLHHJSvr.Helper
 {
@@ -57,53 +58,53 @@ namespace JLHHJSvr.Helper
         /// <param name="billid"></param>
         public static void UnLockBill(SqlCommand cmd, string keyword, int billid, string opemp, byte is_admin)
         {
-            //try
-            //{
-            //    cmd.CommandText = "sp_unlock_record";
-            //    cmd.CommandType = CommandType.StoredProcedure;
-            //    cmd.Parameters.Clear();
-            //    cmd.Parameters.AddWithValue("@keyword", keyword);
-            //    cmd.Parameters.AddWithValue("@billid", billid);
-            //    cmd.Parameters.AddWithValue("@opemp", opemp);
-            //    cmd.Parameters.AddWithValue("@is_admin", is_admin);
-            //    using (var reader = cmd.ExecuteReader())
-            //    {
-            //        if (reader.Read())
-            //        {
-            //            var arg_rslt = Convert.ToInt32(reader["arg_rslt"]);
-            //            var arg_msg = Convert.ToString(reader["arg_msg"]);
+            try
+            {
+                cmd.CommandText = "sp_unlock_record";
+                cmd.CommandType = CommandType.StoredProcedure;
+                cmd.Parameters.Clear();
+                cmd.Parameters.AddWithValue("@keyword", keyword);
+                cmd.Parameters.AddWithValue("@billid", billid);
+                cmd.Parameters.AddWithValue("@opemp", opemp);
+                cmd.Parameters.AddWithValue("@is_admin", is_admin);
+                using (var reader = cmd.ExecuteReader())
+                {
+                    if (reader.Read())
+                    {
+                        var arg_rslt = Convert.ToInt32(reader["arg_rslt"]);
+                        var arg_msg = Convert.ToString(reader["arg_msg"]);
 
-            //            if (arg_rslt != 1) throw new LJCommonException(arg_msg);
-            //        }
-            //    }
-            //}
-            //finally
-            //{
-            //    cmd.CommandType = CommandType.Text;
-            //    cmd.CommandText = string.Empty;
-            //}
+                        if (arg_rslt != 1) throw new LJCommonException(arg_msg);
+                    }
+                }
+            }
+            finally
+            {
+                cmd.CommandType = CommandType.Text;
+                cmd.CommandText = string.Empty;
+            }
         }
         /// <summary>
         /// 生成锁提示信息
         /// </summary>
         private static string GetLockMessage(SqlCommand cmd, string keyword, int billid, string opEmp)
         {
-            if ("u_mattress".Equals(keyword))
+            if (BillNames.MattressQuote.Equals(keyword))
             {
                 var mattress = GetHelper<MattressHelper>(cmd).GetMattress(billid, "mattresscode");
                 return $"床垫报价【{mattress.mattresscode}】被用户【{opEmp}】编辑中。";
             }
-            if ("u_mattress_interface".Equals(keyword))
+            if (BillNames.MattressInterface.Equals(keyword))
             {
                 var mattress = GetHelper<MattressHelper>(cmd).GetMattress(billid, "mattresscode");
                 return $"床垫清单【{mattress.mattresscode}】被用户【{opEmp}】编辑中。";
             }
-            if ("u_bednet".Equals(keyword))
+            if (BillNames.BedNetQuote.Equals(keyword))
             {
                 var bednet = GetHelper<BedNetHelper>(cmd).GetBedNet(billid, "bednetcode");
                 return $"床网报价【{bednet.bednetcode}】被用户【{opEmp}】编辑中。";
             }
-            if ("u_softbed".Equals(keyword))
+            if (BillNames.SoftBedQuote.Equals(keyword))
             {
                 var softbed = GetHelper<SoftBedHelper>(cmd).GetSoftBed(billid, "softbed_code");
                 return $"软床报价【{softbed.softbed_code}】正在被用户【{opEmp}】编辑中。";
@@ -120,6 +121,26 @@ namespace JLHHJSvr.Helper
             return GetLockBill(cmd, keyword, billid, opemp, visited);
         }
         /// <summary>
+        /// 检查单据是否上锁
+        /// </summary>
+        /// <param name="cmd"></param>
+        /// <param name="keyword"></param>
+        /// <param name="billid"></param>
+        /// <param name="opemp"></param>
+        /// <param name="arg_msg"></param>
+        /// <returns></returns>
+        public static bool CheckIsLock(SqlCommand cmd, string keyword, int billid, string opemp,out string arg_msg)
+        {
+            arg_msg = string.Empty;
+            var item = CheckLockAll(cmd, keyword, billid, opemp);
+            if (item.Code == LockCheckResultCode.LockedByOther)
+            {
+                arg_msg = item.log_msg;
+                return true;
+            }
+            return !(item.Code == LockCheckResultCode.Success || item.Code == LockCheckResultCode.LockedBySelf);
+        }
+        /// <summary>
         /// DFS方式检查单据及依赖链上的锁
         /// </summary>
         private static u_lock_table GetLockBill(SqlCommand cmd, string keyword, int billid, string opemp, Dictionary<string, int> visited)
@@ -134,13 +155,13 @@ namespace JLHHJSvr.Helper
 
             //
             var mainLock = new u_lock_table { keyword = keyword, billid = billid };
-            DbSqlHelper.SelectOne(cmd,"u_lock_table","keyword = @keyword AND billid = @billid AND is_locked = 1 AND opemp <> @opemp",
-                new Dictionary<string, object> { { "@keyword", keyword }, { "@billid", billid }, { "@opemp", opemp } },
+            DbSqlHelper.SelectOne(cmd,"u_lock_table","keyword = @keyword AND billid = @billid AND is_locked = 1",
+                new Dictionary<string, object> { { "@keyword", keyword }, { "@billid", billid } },
                 mainLock, "keyword,billid,opemp,is_locked,lock_time,expire_time");
 
-            if (mainLock.Code == LockCheckResultCode.Locked)
+            if (mainLock.is_locked == 1)
             {
-                mainLock.Code = LockCheckResultCode.Locked;
+                mainLock.Code = mainLock.opemp.Equals(opemp) ? LockCheckResultCode.LockedBySelf : LockCheckResultCode.LockedByOther;
                 mainLock.log_msg = GetLockMessage(cmd, keyword, billid, mainLock.opemp);
                 return mainLock;
             }
@@ -151,7 +172,7 @@ namespace JLHHJSvr.Helper
             foreach (var dep in dependencies)
             {
                 var depResult = GetLockBill(cmd, dep.keyword, dep.billid, opemp, visited);
-                if (depResult.Code == LockCheckResultCode.Locked) return depResult;
+                if (depResult.Code == LockCheckResultCode.LockedBySelf || depResult.Code == LockCheckResultCode.LockedByOther) return depResult;
             }
 
             mainLock.Code = LockCheckResultCode.Success;

+ 22 - 18
JLHHJSvr/Helper/MattressHelper.cs

@@ -2082,7 +2082,7 @@ namespace JLHHJSvr.Helper
                 _mattress.extraList = mattressMxExtra1List;
                 _mattress.extraCostList = mattressMxExtra2List;
                 _mattress.subspecsList = mattressSubspecs;
-                SaveMattressPro(_mattress,true);
+                SaveMattressPro(_mattress,true,true);
                 CopyMattressInterface(mattress.mattressid, _mattress.mattressid);
 
                 foreach (var sub in _mattress.subspecsList)
@@ -2272,7 +2272,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有审核权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg); 
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "flag,mattresscode,version");
@@ -2304,7 +2304,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有取消审核权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "flag,mattresscode,version");
@@ -2335,7 +2335,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有业务下单权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "flag,xd_flag,yw_flag,mattresscode,version");
@@ -2370,7 +2370,7 @@ namespace JLHHJSvr.Helper
                 throw new LJCommonException("你没有取消业务下单权限");
             }
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "js1_flag,js2_flag,xd_flag,yw_flag,mattresscode,version");
@@ -2405,7 +2405,7 @@ namespace JLHHJSvr.Helper
         public void MattressYWAudit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "yw_flag,version");
@@ -2430,7 +2430,7 @@ namespace JLHHJSvr.Helper
         public void MattressYWCancelAudit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "yw_flag,js1_flag");
@@ -2460,7 +2460,7 @@ namespace JLHHJSvr.Helper
         public void MattressJSAudit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "yw_flag,js1_flag,version");
@@ -2491,7 +2491,7 @@ namespace JLHHJSvr.Helper
         public void MattressJSCancelAudit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "yw_flag,js1_flag,creatmtrl_flag");
@@ -2521,7 +2521,7 @@ namespace JLHHJSvr.Helper
         public void MattressJS2Audit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "js2_flag,version");
@@ -2546,7 +2546,7 @@ namespace JLHHJSvr.Helper
         public void MattressJS2CancelAudit(int mattressid)
         {
             // 检查锁
-            LockHelper.CheckLockAll(cmd, BillKeyWord, mattressid, context.tokendata.username);
+            if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
 
             var mattress = new u_mattress() { mattressid = mattressid };
             DbSqlHelper.SelectOne(cmd, mattress, "js2_flag,version");
@@ -2572,7 +2572,11 @@ namespace JLHHJSvr.Helper
         /// </summary>
         /// <param name="mattress"></param>
         /// <param name="ifErp"></param>
-        public void SaveMattressPro(u_mattress mattress,bool ifErp = false)
+        public void SaveMattressPro(u_mattress mattress)
+        {
+            SaveMattressPro(mattress, false, false);
+        }
+        public void SaveMattressPro(u_mattress mattress, bool ifErp = false, bool ignoreLock = false)
         {
             SaveMattressCheck(mattress);
 
@@ -2713,7 +2717,7 @@ namespace JLHHJSvr.Helper
             // 处理子规格
             ProcessSubSpecs(mattress, ifErp);
             // 解锁
-            LockHelper.UnLockBill(cmd, BillKeyWord, mattress.mattressid, context.tokendata.username, 0);
+            if(!ignoreLock) LockHelper.UnLockBill(cmd, BillKeyWord, mattress.mattressid, context.tokendata.username, 0);
         }
         /// <summary>
         /// 初始化子规格
@@ -2861,7 +2865,7 @@ namespace JLHHJSvr.Helper
                 InitMattressSubSpecs(mattress, child);
 
                 MattressCalculateCost(child, child.mxList, child.extraList, child.extraCostList);
-                SaveMattressPro(child, ifErp);
+                SaveMattressPro(child, ifErp,true);
             }
 
             mattress.subspecsList = subspecsList;
@@ -2954,9 +2958,9 @@ namespace JLHHJSvr.Helper
             if (mattressid <= 0) throw new LJCommonException("ID错误,删除床垫报价失败!");
             var mattress = GetMattress(mattressid, "mattresscode,flag,js1_flag,xd_flag,parentid");
             if (mattress.parentid > 0 && (mattress.js1_flag == 1 || mattress.flag == 1)) return;
-            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}]已财务审核,无法删除!");
+            if (isDelMain && mattress.xd_flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已下单,无法删除!");
+            if (isDelMain && mattress.js1_flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已产品审核,无法删除!");
+            if (isDelMain && mattress.flag == 1) throw new LJCommonException($"床垫报价[{mattress.mattresscode}]已财务审核,无法删除!");
 
             // 删除所有明细
             cmd.CommandText = @"DELETE u_mattress_mx_mtrl WHERE mattressid = @mattressid";
@@ -2998,7 +3002,7 @@ namespace JLHHJSvr.Helper
             if (mattress.mattressid > 0 && mattress.parentid == 0)
             {
                 // 检查锁
-                LockHelper.CheckLockAll(cmd, BillKeyWord, mattress.mattressid, context.tokendata.username);
+                if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, mattress.mattressid, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
                 // 检测版本控制
                 CheckBillVersion<u_mattress>(cmd, mattress.mattressid, mattress.version);
             }

+ 1 - 1
JLHHJSvr/Helper/SoftBedHelper.cs

@@ -357,7 +357,7 @@ namespace JLHHJSvr.Helper
 			if(softbed.softbed_id > 0)
             {
                 // 检查锁
-                LockHelper.CheckLockAll(cmd, BillKeyWord, softbed.softbed_id, context.tokendata.username);
+				if (LockHelper.CheckIsLock(cmd, MattressHelper.BillKeyWord, softbed.softbed_id, context.tokendata.username, out string arg_msg)) throw new LJCommonException(arg_msg);
                 // 检测版本控制
                 CheckBillVersion<u_softbed>(cmd, softbed.softbed_id, softbed.version);
                 //var _softbed = GetSoftBed(softbed.softbed_id, "softbed_id,softbed_code,version,update_emp");

+ 7 - 0
JLHWEB/src/api/interface/index.ts

@@ -1058,6 +1058,13 @@ export namespace GenericApi {
      */
     workgroupList: any[];
   }
+  export interface ReqLockBill {
+    lockList: any[];
+  }
+  export interface ReqCheckLock {
+    keyword: string;
+    billid: number;
+  }
 }
 
 export namespace FileApi {

+ 24 - 0
JLHWEB/src/api/modules/common.ts

@@ -129,3 +129,27 @@ export const DelMtrlPf = (params?: Mattress.ReqMultiMattressBcp) => {
 export const GetERPMtrlPriceList = (params?: GenericApi.ReqGetERPMtrldefList) => {
   return http.post<GenericApi.ResGetERPMtrldefList>(PORT1 + `/GetErpMtrlPriceList`, params);
 };
+/**
+ * @description 加锁单据
+ * @param params
+ * @returns
+ */
+export const LockBill = (params?: GenericApi.ReqLockBill) => {
+  return http.post(PORT1 + `/LockTable`, params);
+};
+/**
+ * @description 解锁单据
+ * @param params
+ * @returns
+ */
+export const UnLockBill = (params?: GenericApi.ReqLockBill) => {
+  return http.post(PORT1 + `/UnLockTable`, params);
+};
+/**
+ * @description 检查锁
+ * @param params
+ * @returns
+ */
+export const CheckLock = (params?: GenericApi.ReqCheckLock) => {
+  return http.post(PORT1 + `/CheckTableIsLock`, params);
+};

+ 248 - 0
JLHWEB/src/hooks/usePageRouter.ts

@@ -0,0 +1,248 @@
+import { inject, onMounted, onUnmounted } from "vue";
+import { useRoute, useRouter } from "vue-router";
+import { CheckLock } from "@/api/modules/common";
+
+/**
+ * @description 路由器跳转封装
+ * */
+export const usePageRouter = () => {
+  const route = useRoute();
+  const router = useRouter();
+  const tabRemove: Function = inject("tabRemove") as Function;
+
+  /**
+   * @description 页面打开, 兼容:如果有pageid参数就postMessage给K3,由K3打开
+   *   showType
+   *       ModalInCurrentForm: 只在当前单据中模态显示,可以操作其它单据(这情况可以内部实现,不需要post给K3)
+   *       MainNewTabPage: 主界面新页签(默认)
+   * @param path 路由地址
+   * @param title K3显示的标题
+   */
+  const pageOpen = (path: string, title?: string) => {
+    let pageid = window.location.href.split("pageid=")[1];
+    if (pageid) {
+      // let poststr = JSON.stringify({
+      //   pageid: pageid,
+      //   putdata: {
+      //     url: path,
+      //     title: getRouteTitle(path, title),
+      //     showType: "MainNewTabPage"
+      //   }
+      // });
+      // let _window = window as any;
+      // if (_window?.chrome?.webview) {
+      //   // 客户端
+      //   console.log("_window.chrome.webview.postMessage ", poststr, ";_window ", _window);
+      //   _window.chrome.webview.postMessage(poststr);
+      // } else if (window.top) {
+      //   // 浏览器
+      //   console.log("window.top.postMessage ", poststr, ";window ", window);
+      //   window.top.postMessage(poststr, "*");
+      // } else if (window.parent) {
+      //   // 一般不使用
+      //   console.log("window.parent.postMessage ", poststr, ";window ", window);
+      //   window.parent.postMessage(poststr, "*");
+      // } else {
+      //   // 一般不使用
+      //   console.log("window.postMessage ", poststr, ";window ", window);
+      //   window.postMessage(poststr, "*");
+      // }
+    } else {
+      router.push(path);
+    }
+  };
+
+  const pageCheckOpen = async (path: string, keyword: string, billid: number) => {
+    await CheckLock({ keyword, billid });
+
+    // let pageid = window.location.href.split("pageid=")[1];
+    // if (pageid) {
+    // let poststr = JSON.stringify({
+    //   pageid: pageid,
+    //   putdata: {
+    //     url: path,
+    //     title: getRouteTitle(path, title),
+    //     showType: "MainNewTabPage"
+    //   }
+    // });
+
+    // let _window = window as any;
+    // if (_window?.chrome?.webview) {`
+    //   // 客户端
+    //   console.log("_window.chrome.webview.postMessage ", poststr, ";_window ", _window);
+    //   _window.chrome.webview.postMessage(poststr);
+    // } else if (window.top) {
+    //   // 浏览器
+    //   console.log("window.top.postMessage ", poststr, ";window ", window);
+    //   window.top.postMessage(poststr, "*");
+    // } else if (window.parent) {
+    //   // 一般不使用
+    //   console.log("window.parent.postMessage ", poststr, ";window ", window);
+    //   window.parent.postMessage(poststr, "*");
+    // } else {
+    //   // 一般不使用
+    //   console.log("window.postMessage ", poststr, ";window ", window);
+    //   window.postMessage(poststr, "*");
+    // }
+    // } else {
+    router.push(path);
+    // }
+  };
+
+  const pageCheckRefresh = async (path: string, keyword: string, billid: number) => {
+    await CheckLock({ keyword, billid });
+
+    // let pageid = window.location.href.split("pageid=")[1];
+    // if (pageid) {
+    // let poststr = JSON.stringify({
+    //   pageid: pageid,
+    //   putdata: {
+    //     url: path,
+    //     title: getRouteTitle(path, title),
+    //     showType: "MainNewTabPage"
+    //   }
+    // });
+
+    // let _window = window as any;
+    // if (_window?.chrome?.webview) {`
+    //   // 客户端
+    //   console.log("_window.chrome.webview.postMessage ", poststr, ";_window ", _window);
+    //   _window.chrome.webview.postMessage(poststr);
+    // } else if (window.top) {
+    //   // 浏览器
+    //   console.log("window.top.postMessage ", poststr, ";window ", window);
+    //   window.top.postMessage(poststr, "*");
+    // } else if (window.parent) {
+    //   // 一般不使用
+    //   console.log("window.parent.postMessage ", poststr, ";window ", window);
+    //   window.parent.postMessage(poststr, "*");
+    // } else {
+    //   // 一般不使用
+    //   console.log("window.postMessage ", poststr, ";window ", window);
+    //   window.postMessage(poststr, "*");
+    // }
+    // } else {
+    router.replace(path);
+    // }
+  };
+
+  /**
+   * @description 页面关闭, 兼容:如果有pageid参数就postMessage给K3,由K3关闭
+   * */
+  const pageClose = () => {
+    let pageid = window.location.href.split("pageid=")[1];
+    if (pageid) {
+      // let poststr = JSON.stringify({
+      //   pageid: pageid,
+      //   putdata: {
+      //     url: "close"
+      //   }
+      // });
+      // let _window = window as any;
+      // if (_window?.chrome?.webview) {
+      //   _window.chrome.webview.postMessage(poststr);
+      // } else {
+      //   window.top?.postMessage(poststr, "*");
+      // }
+    } else {
+      tabRemove(route.fullPath);
+    }
+  };
+
+  /**
+   * @description 页面刷新, 兼容:如果有pageid参数就postMessage给K3,由K3刷新
+   *   showType
+   *       InCurrentForm: 在当前单据中刷新
+   *       MainNewTabPage: 主界面新页签(默认)
+   * @param path 路由地址
+   * @param title K3显示的标题
+   */
+  const pageRefresh = (path: string, title?: string) => {
+    let pageid = window.location.href.split("pageid=")[1];
+    if (pageid) {
+      // let poststr = JSON.stringify({
+      //   pageid: pageid,
+      //   putdata: {
+      //     url: path,
+      //     title: getRouteTitle(path, title),
+      //     showType: "InCurrentForm"
+      //   }
+      // });
+      // let _window = window as any;
+      // if (_window?.chrome?.webview) {
+      //   _window.chrome.webview.postMessage(poststr);
+      // } else {
+      //   window.top?.postMessage(poststr, "*");
+      // }
+    } else {
+      router.replace(path);
+    }
+  };
+
+  /**
+   * @description 获取路由标题
+   * @param path 路由地址
+   * @param title 标题
+   */
+  const getRouteTitle = (path: string, title?: string) => {
+    if (title) return title;
+    const basePath = path.split("?")[0];
+    try {
+      const resolved = router.resolve(basePath);
+      if (resolved.matched.length === 0) return "";
+
+      // 获取最深层级的路由记录(支持嵌套路由)
+      const matchedRoute = resolved.matched[resolved.matched.length - 1];
+      return matchedRoute.meta?.title || "";
+    } catch (e) {
+      console.error("路由解析失败:", e);
+      return "";
+    }
+  };
+
+  /**
+   * @description 自动监听message事件
+   * */
+  const useAutoMessageHandler = (handler: (e: MessageEvent) => void) => {
+    onMounted(() => {
+      addMessageHandler(handler);
+    });
+
+    onUnmounted(() => {
+      removeMessageHandler(handler);
+    });
+  };
+
+  /**
+   * @description 手动监听message事件
+   * */
+  const addMessageHandler = (handler: (e: MessageEvent) => void) => {
+    let _window = window as any;
+    if (_window?.chrome?.webview) {
+      _window.chrome.webview.addEventListener("message", handler);
+    } else {
+      window.addEventListener("message", handler);
+    }
+  };
+
+  /**
+   * @description 手动移除message事件
+   * */
+  const removeMessageHandler = (handler: (e: MessageEvent) => void) => {
+    let _window = window as any;
+    if (_window?.chrome?.webview) {
+      _window.chrome.webview.removeEventListener("message", handler);
+    } else {
+      window.removeEventListener("message", handler);
+    }
+  };
+
+  return {
+    pageOpen,
+    pageClose,
+    pageRefresh,
+    pageCheckOpen,
+    pageCheckRefresh,
+    useAutoMessageHandler
+  };
+};

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

@@ -109,6 +109,8 @@ import dialog from "@/utils/dialog";
 import InsterMxDialog from "./components/insterMx.vue";
 import InsterPzDialog from "./components/insterPz.vue";
 import { SaveMattressAuditing } from "@/api/modules/quote";
+import { usePageRouter } from "@/hooks/usePageRouter";
+import { CheckLock } from "@/api/modules/common";
 
 interface detailProp {
   /**
@@ -179,6 +181,7 @@ const {
   CodeMxDialogRef
 } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+const { pageCheckRefresh } = usePageRouter();
 
 const initParams = ref({ mattressid: 0 as Number });
 
@@ -1275,10 +1278,11 @@ const orderDefaultAction = [
   })
 ];
 
-const routeToEdit = (type: any) => {
+const routeToEdit = async (type: any) => {
   console.log("routeToEdit mainData :>> ", mainData, route.fullPath);
-
   const _cur = mainData.value[0];
+
+  await CheckLock({ keyword: "MattressInterface", billid: _cur.mattressid });
   // router.replace(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
 
   router.push({

+ 3 - 1
JLHWEB/src/views/erpapi/mattressInterface/index.vue

@@ -44,6 +44,7 @@ import { detailAction } from "@/components/LjDetail/interface";
 import mittBus from "@/utils/mittBus";
 import { MittEnum } from "@/enums/mittEnum";
 import { getCurrentRecords } from "@/utils/index";
+import { CheckLock } from "@/api/modules/common";
 
 const { t } = useI18n();
 const router = useRouter();
@@ -317,7 +318,7 @@ const dataCallback = (data: any) => {
   };
 };
 
-const routeToEdit = type => {
+const routeToEdit = async type => {
   const { $table, curRecords } = getCurrentRecords(vxeTableRef.value);
 
   if (!curRecords.length) {
@@ -326,6 +327,7 @@ const routeToEdit = type => {
   }
 
   const _cur = curRecords[curRecords.length - 1];
+  await CheckLock({ keyword: "MattressInterface", billid: _cur.mattressid });
   // router.push(`/erpapi/mattressInterface/${type}/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}&type=${type}`);
 
   try {

+ 9 - 2
JLHWEB/src/views/quote/bednetQuote/detail.vue

@@ -111,6 +111,7 @@ import { useUserStore } from "@/stores/modules/user";
 // import { getBedNetAreaList } from "@/api/modules/basicinfo";
 import AllFormula from "./components/AllFormula.vue";
 import Statistic from "./components/Statistic.vue";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 interface DetailProps {
   deptid?: number | string;
@@ -192,6 +193,7 @@ const {
 } = useHooks(t, props);
 
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+const { pageCheckRefresh } = usePageRouter();
 // const toast = useToast();
 
 // const orderStatus = ref("");
@@ -507,8 +509,13 @@ const orderDefaultAction: detailAction[] = [
       return "";
     },
     clickFunc: item => {
-      tabRemove(route.fullPath);
-      router.replace(`/bednetQuote/edit?id=${LjDetailRef.value._mainData.bednetid}`);
+      // tabRemove(route.fullPath);
+      pageCheckRefresh(
+        `/bednetQuote/edit?id=${LjDetailRef.value._mainData.bednetid}`,
+        "BedNetQuote",
+        LjDetailRef.value._mainData.bednetid
+      );
+      // router.replace(`/bednetQuote/edit?id=${LjDetailRef.value._mainData.bednetid}`);
     }
   }),
   buttonDefault({

+ 5 - 1
JLHWEB/src/views/quote/bednetQuote/index.vue

@@ -101,6 +101,7 @@ import mittBus from "@/utils/mittBus";
 import { MittEnum } from "@/enums/mittEnum";
 import { getCurrentRecords } from "@/utils/index";
 import LjFoldLayout from "@/components/LjFoldLayout/index.vue";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 const { t } = useI18n();
 const router = useRouter();
@@ -119,6 +120,7 @@ const {
   dataCallback
 } = useHooks();
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+const { pageCheckRefresh, pageCheckOpen } = usePageRouter();
 
 const dialogVisible = ref(false);
 // const vxeTableRef = ref();
@@ -260,7 +262,9 @@ const action: detailAction[] = [
         ElMessage.warning("单据已审核,不能修改");
         return;
       }
-      router.push(`/bednetQuote/edit?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
+
+      pageCheckOpen(`/bednetQuote/edit?id=${_cur.bednetid}&code=${_cur.bednetcode}`, "BedNetQuote", _cur.bednetid);
+      // router.push(`/bednetQuote/edit?id=${_cur.bednetid}&code=${_cur.bednetcode}`);
       // }
     }
   }),

+ 9 - 2
JLHWEB/src/views/quote/mattressQuote/detail.vue

@@ -828,6 +828,7 @@ import BednetDetail from "@/views/quote/bednetQuote/detail.vue";
 import Statistic from "./components/Statistic.vue";
 import variables from "@/styles/js.module.scss";
 import { useGlobalStore } from "@/stores/modules/global";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 // interface detailProp {
 //   // /**
@@ -855,6 +856,7 @@ const router = useRouter();
 const globalStore = useGlobalStore();
 // const { isShowOriginFormulaMattress } = storeToRefs(globalStore);
 const ifcopy = ref(false);
+const { pageCheckRefresh } = usePageRouter();
 
 const showOriginFormulaMattress = (value: any) => {
   globalStore.setGlobalState("isShowOriginFormulaMattress", Boolean(value));
@@ -2147,9 +2149,14 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: item => {
-      router.replace(
-        `/mattressQuote/edit?id=${LjDetailRef.value._mainData.mattressid}&code=${LjDetailRef.value._mainData.mattresscode}`
+      pageCheckRefresh(
+        `/mattressQuote/edit?id=${LjDetailRef.value._mainData.mattressid}&code=${LjDetailRef.value._mainData.mattresscode}`,
+        "MattressQuote",
+        LjDetailRef.value._mainData.mattressid
       );
+      // router.replace(
+      //   `/mattressQuote/edit?id=${LjDetailRef.value._mainData.mattressid}&code=${LjDetailRef.value._mainData.mattresscode}`
+      // );
     }
   }),
   buttonDefault({

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

@@ -30,6 +30,7 @@ import ToastHistoryPrice from "@/components/ToastWidget/HistoryPrice/index.vue";
 import { useRouter } from "vue-router";
 import { useGlobalStore } from "@/stores/modules/global";
 import { storeToRefs } from "pinia";
+import { CheckLock } from "@/api/modules/common";
 // import { title } from "process";
 
 interface defaultState {
@@ -6038,7 +6039,7 @@ export const useHooks = (t?: any) => {
     }
   };
 
-  const gotoErpapi = (_cur, type) => {
+  const gotoErpapi = async (_cur, type) => {
     try {
       // if (_cur.yw_flag == 1) {
       //   throw new Error(_cur.mattresscode + ":已业务补充审核,无法修改");
@@ -6054,6 +6055,8 @@ export const useHooks = (t?: any) => {
       return false;
     }
 
+    await CheckLock({ keyword: "MattressInterface", billid: _cur.mattressid });
+
     router.push({
       path: `/erpapi/mattressInterface/edit/${_cur.mattressid}`,
       query: {

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

@@ -129,6 +129,7 @@ import { useUserStore } from "@/stores/modules/user";
 import LjDrawerQuoteList from "./components/QuoteListNew.vue";
 import { storeToRefs } from "pinia";
 import { formatTime } from "@/utils/index";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 const { t } = useI18n();
 const router = useRouter();
@@ -149,6 +150,7 @@ const {
 const { toExcelQuote, toExcelQuoteNew } = useHooksCpQuote();
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 const { userInfo } = useUserStore();
+const { pageCheckRefresh, pageCheckOpen } = usePageRouter();
 
 // const initParams = ref({});
 const dialogVisible = ref(false);
@@ -451,7 +453,8 @@ const action: detailAction[] = [
         return;
       }
 
-      router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
+      pageCheckOpen(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`, "MattressQuote", _cur.mattressid);
+      // router.push(`/mattressQuote/edit?id=${_cur.mattressid}&code=${_cur.mattresscode}`);
     }
   }),
   buttonDefault({

+ 9 - 2
JLHWEB/src/views/quote/softbedQuote/detail.vue

@@ -106,6 +106,7 @@ import { useUserStore } from "@/stores/modules/user";
 import BedConfigModal from "./components/BedConfigModal.vue";
 import ErpMtrlPriceDialog from "@/views/system/selector/erpMtrlPrice/index.vue";
 import SoftBedTemplateDialog from "@/views/system/selector/softbedTemplate/index.vue";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 const { t } = useI18n();
 const route = useRoute();
@@ -146,6 +147,7 @@ const {
   GetSoftBedFormulaMapper
 } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
+const { pageCheckRefresh } = usePageRouter();
 
 const initParams = ref({ billid: 0 as Number });
 
@@ -326,9 +328,14 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: item => {
-      router.replace(
-        `/softbedQuote/edit?id=${LjDetailRef.value._mainData.softbed_id}&code=${LjDetailRef.value._mainData.softbed_code}`
+      pageCheckRefresh(
+        `/softbedQuote/edit?id=${LjDetailRef.value._mainData.softbed_id}&code=${LjDetailRef.value._mainData.softbed_code}`,
+        "SoftBedQuote",
+        LjDetailRef.value._mainData.softbed_id
       );
+      // router.replace(
+      //   `/softbedQuote/edit?id=${LjDetailRef.value._mainData.softbed_id}&code=${LjDetailRef.value._mainData.softbed_code}`
+      // );
     }
   }),
   buttonDefault({

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

@@ -38,6 +38,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
 import { detailAction } from "@/components/LjDetail/interface";
 import { useUserStore } from "@/stores/modules/user";
 import { getCurrentRecords } from "@/utils/index";
+import { usePageRouter } from "@/hooks/usePageRouter";
 
 const { t } = useI18n();
 const router = useRouter();
@@ -45,6 +46,7 @@ const globalStore = useGlobalStore();
 const { columns, orderStatus, VxeTableRef, initParams, onAudit, onCAudit, onDelete, onShowFormula } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 const { userInfo } = useUserStore();
+const { pageCheckOpen } = usePageRouter();
 
 const showHeadboard = ref(true);
 const showNightstand = ref(true);
@@ -142,7 +144,9 @@ const action: detailAction[] = [
         ElMessage.warning("单据已审核,不能修改");
         return;
       }
-      router.push(`/softbedQuote/edit?id=${_cur.softbed_id}&code=${_cur.softbed_code}`);
+
+      pageCheckOpen(`/softbedQuote/edit?id=${_cur.softbed_id}&code=${_cur.softbed_code}`, "SoftBedQuote", _cur.softbed_id);
+      // router.push(`/softbedQuote/edit?id=${_cur.softbed_id}&code=${_cur.softbed_code}`);
     }
   }),
   buttonDefault({