Jelajahi Sumber

更新工厂利润率代码

MY 6 bulan lalu
induk
melakukan
e0e7bd9df1

+ 1 - 1
JLHHJSvr/Com/SaveProfitrate.cs

@@ -20,7 +20,7 @@ namespace JLHHJSvr.Com
         /// <summary>
         /// 工厂利润率信息信息
         /// </summary>
-        public u_factory_profitrate profitrate { get; set; }
+        public List<u_factory_profitrate> list { get; set; }
     }
 
     public sealed class SaveProfitrateResponse : LJResponse

+ 33 - 26
JLHHJSvr/Excutor/SaveProfitrateExcutor.cs

@@ -23,16 +23,19 @@ namespace JLHHJSvr.Excutor
                 return;
             }
 
-            if (request.profitrate == null)
+            if (!request.list.Any())
             {
                 rslt.ErrMsg = "未提交工厂利润率信息";
                 return;
             }
 
-            if (request.profitrate.profitrate < 0)
+            foreach(var profitrate in request.list)
             {
-                rslt.ErrMsg = "利润率有误,请检查!";
-                return;
+                if (profitrate.profitrate < 0)
+                {
+                    rslt.ErrMsg = "利润率有误,请检查!";
+                    return;
+                }
             }
 
             using (var con = new SqlConnection(GlobalVar.ConnectionString))
@@ -42,35 +45,39 @@ namespace JLHHJSvr.Excutor
 
                 var dtNow = DateTime.Now;
 
-                cmd.CommandText = @"SELECT COUNT(*) AS cnt
-                                    FROM u_factory_profitrate
-                                    WHERE u_factory_profitrate.deptid = @deptid
-	                                    AND u_factory_profitrate.bednettypeid_mattresstypeid = @typid
-	                                    AND u_factory_profitrate.bednet_or_mattress = @kind";
-                cmd.Parameters.Clear();
-                cmd.Parameters.AddWithValue("@deptid", request.profitrate.deptid);
-                cmd.Parameters.AddWithValue("@typid", request.profitrate.bednettypeid_mattresstypeid);
-                cmd.Parameters.AddWithValue("@kind", request.profitrate.bednet_or_mattress);
-                var cnt = Convert.ToInt32(cmd.ExecuteScalar());
-
                 using (cmd.Transaction = con.BeginTransaction())
                 {
                     try
                     {
-                        if(cnt <= 0)
+                        foreach (var profitrate in request.list)
                         {
-                            AutoInit.AutoInitS(cmd, request.profitrate);
+                            cmd.CommandText = @"SELECT COUNT(*) AS cnt
+                                    FROM u_factory_profitrate
+                                    WHERE u_factory_profitrate.deptid = @deptid
+	                                    AND u_factory_profitrate.bednettypeid_mattresstypeid = @typid
+	                                    AND u_factory_profitrate.bednet_or_mattress = @kind";
+                            cmd.Parameters.Clear();
+                            cmd.Parameters.AddWithValue("@deptid", profitrate.deptid);
+                            cmd.Parameters.AddWithValue("@typid", profitrate.bednettypeid_mattresstypeid);
+                            cmd.Parameters.AddWithValue("@kind", profitrate.bednet_or_mattress);
+                            var cnt = Convert.ToInt32(cmd.ExecuteScalar());
 
-                            request.profitrate.createtime = dtNow;
-                            request.profitrate.createby = tokendata.username;
+                            if (cnt <= 0)
+                            {
+                                AutoInit.AutoInitS(cmd, profitrate);
 
-                            var fields = "deptid,bednet_or_mattress,bednettypeid_mattresstypeid,createtime,profitrate,createby";
-                            DbSqlHelper.Insert(cmd, "u_factory_profitrate", null, request.profitrate, fields);
-                        } else
-                        {
-                            //修改
-                            var fields = "profitrate";
-                            DbSqlHelper.Update(cmd, "u_factory_profitrate", null, request.profitrate, "deptid,bednet_or_mattress,bednettypeid_mattresstypeid", fields);
+                                profitrate.createtime = dtNow;
+                                profitrate.createby = tokendata.username;
+
+                                var fields = "deptid,bednet_or_mattress,bednettypeid_mattresstypeid,createtime,profitrate,createby";
+                                DbSqlHelper.Insert(cmd, "u_factory_profitrate", null, profitrate, fields);
+                            }
+                            else
+                            {
+                                //修改
+                                var fields = "profitrate";
+                                DbSqlHelper.Update(cmd, "u_factory_profitrate", null, profitrate, "deptid,bednet_or_mattress,bednettypeid_mattresstypeid", fields);
+                            }
                         }
 
                         cmd.Transaction.Commit();

+ 1 - 1
JLHWEB/src/api/interface/index.ts

@@ -1080,7 +1080,7 @@ export namespace SalePrice {
   }
 
   export interface ReqSaveProfitrate {
-    profitrate: any;
+    list: any[];
   }
 
   export interface ResSaveProfitrate {

+ 17 - 5
JLHWEB/src/views/saleprice/profitrate/index.vue

@@ -67,7 +67,7 @@ const tableProps = {
 };
 
 const { t } = useI18n();
-const { VxeTableRef, LjDetailRef, columns } = useHooks(t);
+const { VxeTableRef, LjDetailRef, columns, fSave } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 
 const initParams = ref({ kind: 0 });
@@ -95,11 +95,23 @@ const orderEditAction = [
     label: t("common.saveText"),
     icon: "iconsave-01",
     clickFunc: item => {
-      // fSaveDept({ dept: LjDetailRef.value?.infoParam }).then(() => {
-      //   LjDrawerRef.value.hide();
-      // });
+      const save_data = LjDetailRef.value?._mainData;
+      // 重组数据
+      const list = [];
+      for (let key in save_data) {
+        if (key.indexOf("profitrate_") > -1) {
+          list.push({
+            deptid: save_data.deptid,
+            bednet_or_mattress: initParams.value.kind,
+            bednettypeid_mattresstypeid: parseInt(save_data[key.replace("profitrate", "bednettype")]),
+            profitrate: save_data[key]
+          });
+        }
+      }
 
-      console.log("LjDetailRef.value?.infoParam :>>>>>", LjDetailRef.value);
+      fSave({ list }).then(() => {
+        LjDrawerRef.value.hide();
+      });
     }
   })
 ];