Pārlūkot izejas kodu

1、新增复制粘贴部件配置值功能
2、修复保存床垫报价副规格自动带出主规格的L1编码问题

MY 1 dienu atpakaļ
vecāks
revīzija
bc57412af6

+ 37 - 0
JLHHJSvr/Com/CopyConfigureCodeMxList.cs

@@ -0,0 +1,37 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.Com.Model;
+using LJLib.Net.SPI.Com;
+
+namespace JLHHJSvr.Com
+{
+    /// <summary>
+    /// 保存车辆信息
+    /// </summary>
+    public sealed class CopyConfigureCodeMxListRequest : ILJRequest<CopyConfigureCodeMxListResponse>
+    {
+        public override string GetApiName()
+        {
+            return "CopyConfigureCodeMxList";
+        }
+        public string token { get; set; }
+        /// <summary>
+        /// 粘贴主体 - 部件选配项
+        /// </summary>
+        public u_configure_code subject { get; set; }
+        /// <summary>
+        /// 部件选配项明细定义
+        /// </summary>
+        public List<u_configure_codemx> mxList { get; set; }
+        /// <summary>
+        /// 粘贴类型 0 - 覆盖粘贴 1 - 补充粘贴
+        /// </summary>
+        public byte type { get; set; }
+    }
+
+    public sealed class CopyConfigureCodeMxListResponse : LJResponse
+    {
+    }
+}

+ 1 - 1
JLHHJSvr/Com/Model/u_configure_codemx.cs

@@ -6,7 +6,7 @@ using System.Text;
 
 namespace JLHHJSvr.Com.Model
 {
-    [PK(new[] { "multipriceid" })]
+    [PK(new[] { "pzid,printid" })]
     public sealed class u_configure_codemx
     {
         /// <summary>

+ 121 - 0
JLHHJSvr/Excutor/CopyConfigureCodeMxListExcutor.cs

@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Text;
+using JLHHJSvr.BLL;
+using JLHHJSvr.Com;
+using JLHHJSvr.Com.Model;
+using JLHHJSvr.LJException;
+using JLHHJSvr.Tools;
+using LJLib.DAL.SQL;
+using LJLib.Net.SPI.Server;
+
+namespace JLHHJSvr.Excutor
+{
+    internal sealed class CopyConfigureCodeMxListExcutor : ExcutorBase<CopyConfigureCodeMxListRequest, CopyConfigureCodeMxListResponse>
+    {
+        protected override void ExcuteInternal(CopyConfigureCodeMxListRequest request, object state, CopyConfigureCodeMxListResponse rslt)
+        {
+            var tokendata = BllHelper.GetToken(request.token);
+            if (tokendata == null)
+            {
+                rslt.ErrMsg = "会话已经中断,请重新登录";
+                return;
+            }
+
+            if(request.subject == null)
+            {
+                rslt.ErrMsg = "未提交部件选配项";
+                return;
+            }
+
+            if(request.subject.typeid == null || request.subject.typeid <= 0)
+            {
+                rslt.ErrMsg = "部件选配类型ID错误";
+                return;
+            }
+
+            if (request.subject.pzid == null || request.subject.pzid <= 0)
+            {
+                rslt.ErrMsg = "部件选配选配项ID错误";
+                return;
+            }
+
+            if (request.mxList == null || !request.mxList.Any())
+            {
+                rslt.ErrMsg = "未提交部件选配值";
+                return;
+            }
+
+            using (var con = new SqlConnection(GlobalVar.ConnectionString))
+            using (var cmd = con.CreateCommand())
+            {
+                con.Open();
+
+                var c_type = new u_configure_type() { contfigtypeid = request.subject.typeid };
+                DbSqlHelper.SelectOne(cmd, c_type, "flag");
+
+                if(c_type.flag == 1)
+                {
+                    throw new LJCommonException("已经技审,不能修改!");
+                }
+
+                foreach(var mx in request.mxList)
+                {
+                    AutoInit.AutoInitS(cmd, mx);
+                }
+
+                using (cmd.Transaction = con.BeginTransaction(System.Data.IsolationLevel.Serializable))
+                {
+                    try
+                    {
+                        int _printid = 0;
+
+                        if (request.type == 1)
+                        {
+                            // 覆盖
+                            cmd.CommandText = @"DELETE FROM u_configure_codemx WHERE pzid = @pzid";
+                            cmd.Parameters.Clear();
+                            cmd.Parameters.AddWithValue("@pzid", request.subject.pzid);
+                            cmd.ExecuteNonQuery();
+                        }
+                        else
+                        {
+                            // 补充
+                            var codeMxList = new List<u_configure_codemx>();
+                            DbSqlHelper.Select(cmd, "u_configure_codemx", "pzid = @pzid", new Dictionary<string, object>() { { "@pzid", request.subject.pzid } }, "printid", 0, 0, codeMxList, null, "pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade");
+
+                            cmd.CommandText = @"SELECT ISNULL(MAX(printid),0) AS printid FROM u_configure_codemx WITH (UPDLOCK) WHERE pzid = @pzid";
+                            cmd.Parameters.Clear();
+                            cmd.Parameters.AddWithValue("@pzid", request.subject.pzid);
+                            using (var reader = cmd.ExecuteReader())
+                            {
+                                if (reader.Read())
+                                {
+                                    _printid = Convert.ToInt32(reader["printid"]);
+                                }
+                            }
+                        }
+
+                        foreach (var mx in request.mxList)
+                        {
+                            mx.printid = ++_printid;
+                            mx.pzid = request.subject.pzid;
+
+                            var fields = @"pzid,printid,pzcodemx,namemx,gradestr,mtrlcode,price,ifdft,MCostRate,ProfitRate,dscrp,ifuse,ifnoch,pricerate,packqty,packvol,price_pz,grade";
+                            DbSqlHelper.Insert(cmd, "u_configure_codemx", null, mx, fields);
+                        }
+
+                        cmd.Transaction.Commit();
+                    }
+                    catch (Exception ex)
+                    {
+                        cmd.Transaction?.Rollback();
+                        rslt.ErrMsg = ex.Message;
+                    }
+                }
+            }
+        }
+    }
+}

+ 4 - 4
JLHHJSvr/Excutor/SaveMattressExcutor.cs

@@ -123,7 +123,7 @@ namespace JLHHJSvr.Excutor
                     {
                         rslt.mxmessage = new List<string>();
 
-                        rslt.mxmessage = toSaveMattress(cmd, request.mattress, request.mattressMx, request.extraProcesses, request.extraCosts, tokendata);
+                        rslt.mxmessage = toSaveMattress(cmd, request.mattress, request.mattressMx, request.extraProcesses, request.extraCosts, tokendata,true);
 
                         rslt.mattressid = request.mattress.mattressid;
                         rslt.mattresscode = request.mattress.mattresscode;
@@ -437,7 +437,7 @@ namespace JLHHJSvr.Excutor
                                     #endregion
                                 }
 
-                                toSaveMattress(cmd, _mattress, _mattressMx, request.extraProcesses, request.extraCosts, tokendata);
+                                toSaveMattress(cmd, _mattress, _mattressMx, request.extraProcesses, request.extraCosts, tokendata,false);
                             }
                         }
 
@@ -456,7 +456,7 @@ namespace JLHHJSvr.Excutor
             }
         }
 
-        public List<string> toSaveMattress(SqlCommand cmd, u_mattress mattress, List<u_mattress_mx_mtrl> mattressMx, List<u_mattress_mx_extra> extraProcesses, List<u_mattress_mx_extra> extraCosts, TokenData tokendata)
+        public List<string> toSaveMattress(SqlCommand cmd, u_mattress mattress, List<u_mattress_mx_mtrl> mattressMx, List<u_mattress_mx_extra> extraProcesses, List<u_mattress_mx_extra> extraCosts, TokenData tokendata,bool iferpmtrl)
         {
             var helper = HelperBase.GetHelper<MattressHelper>(cmd, new HelperBase.Context() { tokendata = tokendata });
 
@@ -475,7 +475,7 @@ namespace JLHHJSvr.Excutor
 
             try
             {
-                helper.SaveMattress(mattress, mattressMx, extraProcesses, extraCosts, true);
+                helper.SaveMattress(mattress, mattressMx, extraProcesses, extraCosts, iferpmtrl);
 
                 if (mattress.copy_id != null && mattress.copy_id > 0)
                 {

+ 3 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -250,6 +250,9 @@ namespace JLHHJSvr
                 excutorManager.AddMap("SaveBedNetInterface", typeof(SaveBedNetInterfaceRequest), new SaveBedNetInterfaceExcutor());// 床网接口清单补充审核撤审
                 excutorManager.AddMap("RefreshBedNetInterface", typeof(RefreshBedNetInterfaceRequest), new RefreshBedNetInterfaceExcutor());// 刷新床网配置清单
                 excutorManager.AddMap("RefreshBedNetInterfaceQd", typeof(RefreshBedNetInterfaceQdRequest), new RefreshBedNetInterfaceQdExcutor());// 刷新床网清单
+
+                /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+                excutorManager.AddMap("CopyConfigureCodeMxList", typeof(CopyConfigureCodeMxListRequest), new CopyConfigureCodeMxListExcutor()); // 复制部件选配项值
             }
             catch (Exception ex)
             {

+ 2 - 0
JLHHJSvr/JLHHJSvr.csproj

@@ -97,6 +97,7 @@
     <Compile Include="Com\BanMtrlDef.cs" />
     <Compile Include="Com\BanMultiPrice.cs" />
     <Compile Include="Com\CommonDynamicSelect.cs" />
+    <Compile Include="Com\CopyConfigureCodeMxList.cs" />
     <Compile Include="Com\CopyMattressAudited.cs" />
     <Compile Include="Com\CopyMtrlDef.cs" />
     <Compile Include="Com\CoverMattressInterface.cs" />
@@ -313,6 +314,7 @@
     <Compile Include="Excutor\BanMtrlDefExcutor.cs" />
     <Compile Include="Excutor\BanMultiPriceExcutor.cs" />
     <Compile Include="Excutor\CommonDynamicSelectExcutor.cs" />
+    <Compile Include="Excutor\CopyConfigureCodeMxListExcutor.cs" />
     <Compile Include="Excutor\CopyMattressAuditedExcutor.cs" />
     <Compile Include="Excutor\CopyMtrlDefExcutor.cs" />
     <Compile Include="Excutor\CoverMattressInterfaceExcutor.cs" />

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

@@ -1216,6 +1216,11 @@ export namespace Basicinfo {
     successqty: number;
     allqty: number;
   }
+  export interface ReqCopyConfigureCodeMxList {
+    subject: any;
+    mxList: any[];
+    type: number;
+  }
 }
 
 export namespace SalePrice {

+ 6 - 0
JLHWEB/src/api/modules/basicinfo.ts

@@ -532,3 +532,9 @@ export const FormulaCheck = (params: Basicinfo.ReqFormulaCheck) => {
 export const ImportMtrlPrice = (params: any) => {
   return http.post<Basicinfo.ResimportMtrl>(PORT1 + `/ImportMtrlPriceByExcel`, params);
 };
+/**
+ * @name 复制部件选配项值值数据
+ */
+export const CopyConfigureCodeMxList = (params: Basicinfo.ReqCopyConfigureCodeMxList) => {
+  return http.post(PORT1 + `/CopyConfigureCodeMxList`, params);
+};

+ 5 - 1
JLHWEB/src/languages/modules/zh-cn/common.json

@@ -217,5 +217,9 @@
   "supplementBill": "清单补充",
   "supplementBillAudit": "清单补充审核",
   "supplementBillWidthrawAudit": "清单补充撤审",
-  "view": "查看"
+  "view": "查看",
+  "copy": "复制",
+  "paste": "粘贴",
+  "coverPaste": "覆盖粘贴",
+  "supplyPaste": "补充粘贴"
 }

+ 66 - 0
JLHWEB/src/stores/modules/copy.ts

@@ -0,0 +1,66 @@
+import { defineStore } from "pinia";
+import piniaPersistConfig from "@/config/piniaPersist";
+
+type CopyItem<T = any> = {
+  key?: string;
+  id: string;
+  data: T;
+  timestamp?: number;
+};
+
+export const useCopyStore = defineStore("copy", {
+  state: () => ({
+    // 支持多类型数据存储
+    items: [] as CopyItem[],
+    // 当前激活的剪贴板类型
+    activeType: "",
+    // 最大历史记录数
+    maxHistory: 10
+  }),
+  actions: {
+    // 泛型方法支持任意数据类型
+    copy<T>(
+      data: T,
+      options: {
+        key?: string;
+        id?: string;
+      } = {}
+    ) {
+      const { key = "default", id = crypto.randomUUID() } = options;
+
+      // 自动清理旧记录
+      if (this.items.length >= this.maxHistory) {
+        this.items.shift();
+      }
+
+      this.items.push({
+        id,
+        data,
+        timestamp: Date.now(),
+        key: key
+      });
+      this.activeType = key;
+    },
+
+    // 按类型获取数据
+    getByType<T>(key: string): CopyItem<T>[] {
+      return this.items.filter(item => item.key === key);
+    },
+
+    // 获取最新数据
+    getLatest<T>(key?: string): T | null {
+      const items = key ? this.getByType(key) : [...this.items];
+      return items.length ? items[items.length - 1].data : null;
+    },
+
+    // 清空指定类型数据
+    clear(key?: string) {
+      if (key) {
+        this.items = this.items.filter(item => item.key !== key);
+      } else {
+        this.items = [];
+      }
+    }
+  },
+  persist: piniaPersistConfig("global_copy", false)
+});

+ 96 - 2
JLHWEB/src/views/baseinfo/configure/hooks/index.tsx

@@ -8,9 +8,12 @@ import {
   SaveConfigureCodeMx,
   DeleteConfigureType,
   DeleteConfigureCode,
-  DeleteConfigureCodeMx
+  DeleteConfigureCodeMx,
+  CopyConfigureCodeMxList
 } from "@/api/modules/basicinfo";
 import { ElMessage, ElMessageBox } from "element-plus";
+import { localSet, localGet } from "@/utils/index";
+import { useCopyStore } from "@/stores/modules/copy";
 interface defaultState {
   /**
    * @description 单据当前状态
@@ -56,6 +59,8 @@ const state = reactive<defaultState>({
   LjDetailRightRef: null,
   VxeTableMxRef: null
 });
+const copyStore = useCopyStore();
+const COPY_KEY = "configure_codemx";
 /**
  * @description 表格多选数据操作
  * @param {String} rowKey 当表格可以多选时,所指定的 id
@@ -356,12 +361,101 @@ export const useHooks = (t?: any) => {
       });
   };
 
+  const fCopy = () => {
+    const checkDate = getTableRef(2)?.element.getCheckboxRecords();
+    if (checkDate.length === 0) {
+      ElMessage.error("请勾选要复制的数据!");
+      return;
+    }
+    copyStore.copy(
+      checkDate.map((item: any) => ({
+        pzcodemx: item.pzcodemx,
+        namemx: item.namemx
+      })),
+      { key: COPY_KEY }
+    );
+    ElMessage.success("复制成功!");
+  };
+
+  const fPaste = async (type: number) => {
+    const checkDate = getTableRef(1)?.element.getCurrentRecord();
+    const copyData = copyStore.getLatest<Array<{ pzcodemx: string; namemx: string }>>(COPY_KEY);
+
+    if (!copyData?.length) {
+      ElMessage.error("没有可粘贴的内容,请先执行复制功能");
+      return;
+    }
+
+    try {
+      if (type === 1) {
+        await handleOverwritePaste(checkDate, copyData, type);
+      } else {
+        await handleAppendPaste(checkDate, copyData, type);
+      }
+
+      ElMessage.success("粘贴成功!");
+      getTableRef(2)?.refresh();
+    } catch (error) {
+      if (error !== "cancel") {
+        console.error("粘贴操作出错:", error);
+      }
+    }
+  };
+
+  const handleOverwritePaste = async (subject: any, mxList: any[], type: number) => {
+    try {
+      await ElMessageBox.confirm("粘贴功能将清空原有的数据,是否继续?", "询问", {
+        confirmButtonText: "是",
+        cancelButtonText: "否",
+        type: "warning"
+      });
+      await CopyConfigureCodeMxList({ subject, mxList, type });
+    } catch {
+      ElMessage({ type: "info", message: "操作取消" });
+      throw "cancel"; // 特殊标记取消操作
+    }
+  };
+
+  const handleAppendPaste = async (subject: any, mxList: any[], type: number) => {
+    const tableData = getTableRef(2)?.element.getTableData().fullData;
+    const duplicateSet = new Set();
+    const duplicates = tableData.filter(a => {
+      const key = `${a.pzcodemx}|${a.namemx}`;
+      const isDuplicate = mxList.some(b => b.pzcodemx === a.pzcodemx && b.namemx === a.namemx);
+
+      if (isDuplicate && !duplicateSet.has(key)) {
+        duplicateSet.add(key);
+        return true;
+      }
+      return false;
+    });
+
+    if (duplicates.length > 0) {
+      try {
+        const duplicateList = duplicates.map(d => `${d.pzcodemx} ${d.namemx}`).join("、");
+        await ElMessageBox.confirm(`当前部件选配项值已有(${duplicateList}),补充黏贴后会出现重复数据,是否继续?`, "询问", {
+          confirmButtonText: "是",
+          cancelButtonText: "否",
+          type: "warning"
+        });
+        await CopyConfigureCodeMxList({ subject, mxList, type });
+      } catch {
+        ElMessage({ type: "info", message: "操作取消" });
+        throw "cancel"; // 特殊标记取消操作
+      }
+    } else {
+      await CopyConfigureCodeMxList({ subject, mxList, type });
+    }
+  };
+
   return {
     ...toRefs(state),
     columns_left,
     columns_mid,
     columns_right,
     fSave,
-    fDelete
+    fDelete,
+    fCopy,
+    fPaste
   };
 };

+ 6 - 2
JLHWEB/src/views/baseinfo/configure/index.vue

@@ -70,7 +70,9 @@
               <el-button-group>
                 <el-button @click="handleOpenNewRightTable">{{ $t("common.add") }}</el-button>
                 <el-button @click="fDelete(2)">{{ $t("common.delText") }}</el-button>
-                <!-- <el-button>{{ $t("common.disable") }}</el-button> -->
+                <el-button @click="fCopy">{{ $t("common.copy") }}</el-button>
+                <el-button @click="fPaste(0)">{{ $t("common.supplyPaste") }}</el-button>
+                <el-button @click="fPaste(1)">{{ $t("common.coverPaste") }}</el-button>
               </el-button-group>
             </template>
           </LjVxeTable>
@@ -150,7 +152,9 @@ const {
   columns_mid,
   columns_right,
   fSave,
-  fDelete
+  fDelete,
+  fCopy,
+  fPaste
 } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 

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

@@ -95,6 +95,7 @@ import { getCurrentRecords } from "@/utils/index";
 import { useUserStore } from "@/stores/modules/user";
 import LjDrawerQuoteList from "./components/QuoteListNew.vue";
 import { storeToRefs } from "pinia";
+import { formatTime } from "@/utils/index";
 
 const { t } = useI18n();
 const router = useRouter();
@@ -605,7 +606,10 @@ const action: detailAction[] = [
     label: t("common.dataTransmission"),
     power: 72,
     clickFunc: item => {
-      alert("功能维护中!");
+      // alert("功能维护中!");
+      const { $table } = getCurrentRecords(vxeTableRef.value);
+      const now = new Date();
+      $table?.openExport({ filename: `床垫报价_${formatTime(now, "{y}-{m}-{d}", false)}` });
     }
   }),
   buttonDefault({