浏览代码

1、更新软床报价代码

iggy 11 小时之前
父节点
当前提交
0d6c7b7a20

+ 1 - 0
JLHHJSvr/Com/GetSoftBedConfigureList.cs

@@ -22,5 +22,6 @@ namespace JLHHJSvr.Com
 
     public sealed class GetSoftBedConfigureListResponse : LJResponse
     {
+        public List<u_configure_type> typeList { get; set; }
     }
 }

+ 6 - 0
JLHHJSvr/Com/Model/u_configure_code.cs

@@ -70,5 +70,11 @@ namespace JLHHJSvr.Com.Model
         /// 部件选配项值
         /// </summary>
         public List<u_configure_codemx> codeMxList { get; set; }
+        #region 辅助
+        /// <summary>
+        /// 部件选配类型名
+        /// </summary>
+        public string contfigtypename { get; set; }
+        #endregion
     }
 }

+ 3 - 0
JLHHJSvr/Com/Model/u_configure_codemx.cs

@@ -69,6 +69,9 @@ namespace JLHHJSvr.Com.Model
 
         #region 辅助
         public string pzname { get; set; }
+        public string pzcode { get; set; }
+        public int? typeid { get; set; }
+        public string contfigtypename { get; set; }
         #endregion
     }
 }

+ 4 - 1
JLHHJSvr/Com/Model/u_configure_type.cs

@@ -42,6 +42,9 @@ namespace JLHHJSvr.Com.Model
         /// 修改时间
         /// </summary>
         public DateTime? moddate { get; set; }
-
+        /// <summary>
+        /// 部件选配项
+        /// </summary>
+        public List<u_configure_code> codeList { get; set; }
     }
 }

+ 1 - 13
JLHHJSvr/Excutor/GetSoftBedConfigureListExcutor.cs

@@ -31,19 +31,7 @@ namespace JLHHJSvr.Excutor
                 con.Open();
 
                 var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd);
-
-                if(request.softbed.softbed_id > 0)
-                {
-                    // 模版配置获取
-                    var _softbed = softBedHelper.GetSoftBed(request.softbed.softbed_id, "softbed_id,softbed_code,has_headboard,has_nightstand,has_bedframe");
-
-                    string prefix = $"{_softbed.softbed_code}|";
-                }
-
-                cmd.CommandText = @"SELECT * FROM u_configure_type WHERE LTRIM(RTRIM(configurename)) = @configurename";
-                cmd.Parameters.Clear();
-                cmd.Parameters.AddWithValue("@configurename", "");
-
+                rslt.typeList = softBedHelper.GetSoftBedConfigureList(request.softbed);
             }
         }
     }

+ 1 - 0
JLHHJSvr/GlobalVar/GlobalVar.cs

@@ -259,6 +259,7 @@ namespace JLHHJSvr
                 excutorManager.AddMap("DeleteSoftBedQuote", typeof(DeleteSoftBedQuoteRequest), new DeleteSoftBedQuoteExcutor()); // 删除软床报价
                 excutorManager.AddMap("AuditSoftBedQuote", typeof(AuditSoftBedQuoteRequest), new AuditSoftBedQuoteExcutor()); // 审核软床报价
                 excutorManager.AddMap("GetSoftBedMxList", typeof(GetSoftBedMxListRequest), new GetSoftBedMxListExcutor()); // 审核软床报价
+                excutorManager.AddMap("GetSoftBedConfigureList", typeof(GetSoftBedConfigureListRequest), new GetSoftBedConfigureListExcutor()); // 获取软床报价部件选配
             }
             catch (Exception ex)
             {

+ 59 - 11
JLHHJSvr/Helper/SoftBedHelper.cs

@@ -331,20 +331,22 @@ namespace JLHHJSvr.Helper
                 baseInfoHelper.SaveConfigureType(configure);
             }
         }
-		public List<u_configure_code> GetSoftBedConfigureCodeList(u_softbed softbed)
+		public List<u_configure_type> GetSoftBedConfigureList(u_softbed softbed)
 		{
-			var codeList = new List<u_configure_code>();
+			var codeMxList = new List<u_configure_codemx>();
 
-			var selectStr = @"SELECT LTRIM(RTRIM(u_configure_type.configurename)) AS configurename
-								,u_configure_code.typeid
-								,u_configure_code.pzid
-								,u_configure_code.name
+			var selectStr = @"SELECT u_configure_codemx.pzid
+								,u_configure_codemx.printid
+								,u_configure_codemx.pzcodemx
+								,u_configure_codemx.namemx
+								,u_configure_code.name AS pzname
 								,u_configure_code.pzcode
 								,u_configure_code.inputtype
-							FROM u_configure_code
-							INNER JOIN u_configure_type ON u_configure_code.typeid = u_configure_type.configureid
-							WHERE LTRIM(RTRIM(u_configure_type.configurename)) IN ()";
-
+								,LTRIM(RTRIM(u_configure_type.contfigtypename)) AS contfigtypename
+								,u_configure_code.typeid
+							FROM u_configure_codemx
+							INNER JOIN u_configure_code ON u_configure_codemx.pzid = u_configure_code.pzid
+							INNER JOIN u_configure_type ON u_configure_code.typeid = u_configure_type.contfigtypeid";
 			var whereList = new List<string>();
 			var nameList = new List<string>();
             if (softbed.softbed_id > 0)
@@ -372,8 +374,54 @@ namespace JLHHJSvr.Helper
 
 			if(nameList.Count > 0)
 			{
-				whereList.Add($"LTRIM(RTRIM(u_configure_type.configurename)) IN {ListEx.getString(nameList)}");
+				whereList.Add($"LTRIM(RTRIM(u_configure_type.contfigtypename)) IN {ListEx.getString(nameList)}");
 			}
+			DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), null, "typeid,pzid,printid", "typeid,pzid,printid,pzcodemx,namemx,pzname,pzcode,contfigtypename", 0, 0, codeMxList);
+
+			// 部件选配项
+            var codeMap = new Dictionary<int, u_configure_code>();
+			foreach(var codeMx in codeMxList)
+			{
+                int pzid = codeMx.pzid.Value;
+                if (!codeMap.TryGetValue(pzid, out var config))
+                {
+                    config = new u_configure_code
+                    {
+                        pzid = pzid,
+						name = codeMx.pzname,
+                        contfigtypename = codeMx.contfigtypename,
+						pzcode = codeMx.pzcode,
+						typeid = codeMx.pzid,
+                        codeMxList = new List<u_configure_codemx>()
+                    };
+
+                    codeMap.Add(pzid, config);
+                }
+
+                config.codeMxList.Add(codeMx);
+            }
+
+			// 部件选配类型
+			var typeMap = new Dictionary<int, u_configure_type>();
+			foreach(var code in codeMap.Values.ToList())
+			{
+                int typeid = code.typeid.Value;
+                if (!typeMap.TryGetValue(typeid, out var config))
+                {
+                    config = new u_configure_type
+                    {
+                        contfigtypeid = typeid,
+                        contfigtypename = code.contfigtypename,
+                        codeList = new List<u_configure_code>()
+                    };
+
+                    typeMap.Add(typeid, config);
+                }
+
+                config.codeList.Add(code);
+            }
+
+			return typeMap.Values.ToList();
         }
 		/// <summary>
 		/// 复制软床报价

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

@@ -1400,6 +1400,12 @@ export namespace Mattress {
     formulas_bednet: any;
     differ?: any;
   }
+}
+
+export namespace SoftBed {
+  export interface ReqSoftBed {
+    softbed: any;
+  }
   export interface ResSoftBed {
     softbed: any;
     mxList: any[];
@@ -1407,4 +1413,7 @@ export namespace Mattress {
   export interface ResGetSoftBedMxList {
     billid: number;
   }
+  export interface ResGetSoftBedConfigureList {
+    typeList: any[];
+  }
 }

+ 10 - 3
JLHWEB/src/api/modules/quote.ts

@@ -1,4 +1,4 @@
-import { Mattress } from "@/api/interface/index";
+import { Mattress, SoftBed } from "@/api/interface/index";
 import { PORT1 } from "@/api/config/servicePort";
 import http from "@/api";
 
@@ -278,6 +278,13 @@ export const ShowSoftBedQuoteFml = (params: Mattress.ReqSaveMattressInterface) =
 /**
  * @name 软床报价:显示公式
  */
-export const GetSoftBedMxList = (params: Mattress.ResGetSoftBedMxList) => {
-  return http.post<Mattress.ResSoftBed>(PORT1 + `/GetSoftBedMxList`, params);
+export const GetSoftBedMxList = (params: SoftBed.ReqSoftBed) => {
+  return http.post<SoftBed.ResSoftBed>(PORT1 + `/GetSoftBedMxList`, params);
+};
+
+/**
+ * @name 软床报价:获取软床报价部件选配
+ */
+export const GetSoftBedConfigureList = (params: SoftBed.ReqSoftBed) => {
+  return http.post<SoftBed.ResGetSoftBedConfigureList>(PORT1 + `/GetSoftBedConfigureList`, params);
 };

+ 9 - 7
JLHWEB/src/views/quote/softbedQuote/components/BedConfigModal.vue

@@ -17,7 +17,7 @@
         v-if="showHeadboardModel"
         part-name="床头"
         v-model:selectedConfigItems="partsConfig.headboard"
-        :configItemOptions="configItemOptions"
+        :configItemOptions="headboardConfigOptions"
         :configValueOptionsMap="configValueOptionsMap"
       />
 
@@ -25,7 +25,7 @@
         v-if="showNightstandModel"
         part-name="床头柜"
         v-model:selectedConfigItems="partsConfig.nightstand"
-        :configItemOptions="configItemOptions"
+        :configItemOptions="nightstandConfigOptions"
         :configValueOptionsMap="configValueOptionsMap"
       />
 
@@ -33,7 +33,7 @@
         v-if="showBedframeModel"
         part-name="床架"
         v-model:selectedConfigItems="partsConfig.bedframe"
-        :configItemOptions="configItemOptions"
+        :configItemOptions="bedframeConfigOptions"
         :configValueOptionsMap="configValueOptionsMap"
       />
     </div>
@@ -52,7 +52,7 @@ import LjDialogNew from "@/components/LjDialog/index-new.vue";
 
 interface ConfigValue {
   printid: number;
-  pznamemx: string;
+  namemx: string;
 }
 interface ConfigItemOption {
   pzid: number;
@@ -67,6 +67,10 @@ const props = defineProps({
   showHeadboard: { type: Boolean, default: true },
   showNightstand: { type: Boolean, default: true },
   showBedframe: { type: Boolean, default: false },
+  headboardConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
+  nightstandConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
+  bedframeConfigOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
+  configValueOptionsMap: { type: Object as PropType<Record<number, ConfigValue[]>>, required: true },
   partsConfig: {
     type: Object as PropType<{
       headboard: SelectedConfigItem[];
@@ -74,9 +78,7 @@ const props = defineProps({
       bedframe: SelectedConfigItem[];
     }>,
     required: true
-  },
-  configItemOptions: { type: Array as PropType<ConfigItemOption[]>, required: true },
-  configValueOptionsMap: { type: Object as PropType<Record<number, ConfigValue[]>>, required: true }
+  }
 });
 
 const emit = defineEmits([

+ 9 - 5
JLHWEB/src/views/quote/softbedQuote/components/ConfigSection.vue

@@ -17,7 +17,7 @@
 
       <!-- 配置值选择 -->
       <el-select v-model="item.selectedValue" placeholder="选择选配值" size="small" class="select-config-value">
-        <el-option v-for="opt in valueListByPzid(item.pzid)" :key="opt.printid" :label="opt.pznamemx" :value="opt.pznamemx" />
+        <el-option v-for="opt in valueListByPzid(item.pzid)" :key="opt.printid" :label="opt.namemx" :value="opt.namemx" />
       </el-select>
 
       <i class="iconfont icontrash-01 delete-icon" @click="removeConfigItem(index)" title="删除选配项" />
@@ -31,10 +31,11 @@
 
 <script setup lang="ts">
 import { ref, PropType, watch } from "vue";
+import { ElMessage } from "element-plus";
 
 interface ConfigValue {
   printid: number;
-  pznamemx: string;
+  namemx: string;
 }
 interface ConfigItemOption {
   pzid: number;
@@ -60,7 +61,7 @@ const valueListByPzid = (pzid: number) => {
 
 const onConfigItemChange = (item: SelectedConfigItem) => {
   const options = valueListByPzid(item.pzid);
-  item.selectedValue = options.length > 0 ? options[0].pznamemx : "";
+  item.selectedValue = options.length > 0 ? options[0].namemx : "";
 };
 
 const removeConfigItem = (index: number) => {
@@ -70,14 +71,17 @@ const removeConfigItem = (index: number) => {
 };
 
 const addConfigItem = () => {
-  if (props.configItemOptions.length === 0) return;
+  if (props.configItemOptions.length === 0) {
+    ElMessage.error(`${props.partName}没有设置相关选配项`);
+    return;
+  }
 
   const defaultPzid = props.configItemOptions[0].pzid;
   const defaultValues = props.configValueOptionsMap[defaultPzid] || [];
 
   const newItem: SelectedConfigItem = {
     pzid: defaultPzid,
-    selectedValue: defaultValues.length > 0 ? defaultValues[0].pznamemx : ""
+    selectedValue: defaultValues.length > 0 ? defaultValues[0].namemx : ""
   };
 
   emit("update:selectedConfigItems", [...props.selectedConfigItems, newItem]);

+ 13 - 40
JLHWEB/src/views/quote/softbedQuote/detail.vue

@@ -76,7 +76,9 @@
     v-model:showNightstand="showNightstand"
     v-model:showBedframe="showBedframe"
     v-model:partsConfig="partsConfig"
-    :configItemOptions="allConfigItemOptions"
+    :headboardConfigOptions="headboardConfigOptions"
+    :nightstandConfigOptions="nightstandConfigOptions"
+    :bedframeConfigOptions="bedframeConfigOptions"
     :configValueOptionsMap="configValueOptionsMap"
     @submit="onConfirmConfigureDialog"
     @cancel="isModalVisible = false"
@@ -114,6 +116,11 @@ const {
   showHeadboard,
   showBedframe,
   showNightstand,
+  headboardConfigOptions,
+  nightstandConfigOptions,
+  bedframeConfigOptions,
+  configValueOptionsMap,
+  partsConfig,
   detail_getData,
   toAddMx,
   toDelMx,
@@ -127,45 +134,11 @@ const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 
 const initParams = ref({ billid: 0 as Number });
 
-const allConfigItemOptions = reactive([
-  { pzid: 101, pzname: "颜色" },
-  { pzid: 201, pzname: "材质" },
-  { pzid: 301, pzname: "款式" },
-  { pzid: 401, pzname: "尺寸" },
-  { pzid: 501, pzname: "填充物" },
-  { pzid: 601, pzname: "靠背调节" }
-]);
-
-const configValueOptionsMap = reactive({
-  101: [
-    { printid: 1, pznamemx: "白色" },
-    { printid: 2, pznamemx: "红色" }
-  ],
-  201: [
-    { printid: 1, pznamemx: "皮质" },
-    { printid: 2, pznamemx: "布艺" }
-  ],
-  301: [{ printid: 1, pznamemx: "简约款" }],
-  401: [{ printid: 1, pznamemx: "1.8米" }],
-  501: [{ printid: 1, pznamemx: "记忆棉" }],
-  601: [{ printid: 1, pznamemx: "不可调节" }]
-});
-
-// 父组件维护 partsConfig,Modal 每次打开都会使用同一个对象(记忆性)
-const partsConfig = reactive({
-  headboard: [
-    { pzid: 101, selectedValue: "白色" },
-    { pzid: 201, selectedValue: "皮质" }
-  ],
-  nightstand: [
-    { pzid: 101, selectedValue: "白色" },
-    { pzid: 301, selectedValue: "欧式款" }
-  ],
-  bedframe: [
-    { pzid: 101, selectedValue: "灰色" },
-    { pzid: 401, selectedValue: "1.8米" }
-  ]
-});
+// const partsConfig = reactive({
+//   headboard: [],
+//   nightstand: [],
+//   bedframe: []
+// });
 
 const tabRemove: Function = inject("tabRemove") as Function;
 const { userInfo } = useUserStore();

+ 138 - 12
JLHWEB/src/views/quote/softbedQuote/hooks/index.tsx

@@ -1,6 +1,6 @@
 import { ref, reactive, computed, toRefs, nextTick } from "vue";
 import { ColumnProps } from "@/components/LjVxeTable/interface";
-import { GetSoftBedMxList, SaveSoftBedQuote } from "@/api/modules/quote";
+import { GetSoftBedMxList, SaveSoftBedQuote, GetSoftBedConfigureList } from "@/api/modules/quote";
 import { ALLOW_EDIT_STATE } from "@/config/index";
 import { ElButton, ElMessage, ElMessageBox, ElRow, ElCol, ElNotification } from "element-plus";
 import { AuditSoftBedQuote, DeleteSoftBedQuote } from "@/api/modules/quote";
@@ -9,6 +9,7 @@ import { CommonDynamicSelect } from "@/api/modules/common";
 import SoftBedSelect from "@/views/system/selector/softbedTemplate/select.vue";
 import { cloneDeep } from "lodash-es";
 import { getCurrentRecords } from "@/utils/index";
+import MtrldefSelect from "@/views/system/selector/mtrldefNoPrice/select.vue";
 interface defaultState {
   /**
    * @description 单据当前状态
@@ -82,6 +83,13 @@ interface defaultState {
    * @description 详情页部件配置选择弹窗
    */
   showBedframe: boolean;
+  partsConfig: any;
+  headboardConfigOptions: any[];
+  nightstandConfigOptions: any[];
+  bedframeConfigOptions: any[];
+  configValueOptionsMap: any;
+  MtrldefDialogRef: any;
+  MtrldefDialogProps: any;
 }
 
 /**
@@ -107,7 +115,18 @@ export const useHooks = (t?: any) => {
     showHeadboard: false,
     showNightstand: false,
     showBedframe: false,
-    initParams: { arg_softbed_id: 0 }
+    initParams: { arg_softbed_id: 0 },
+    partsConfig: {
+      headboard: [],
+      nightstand: [],
+      bedframe: []
+    },
+    headboardConfigOptions: [],
+    nightstandConfigOptions: [],
+    bedframeConfigOptions: [],
+    configValueOptionsMap: {},
+    MtrldefDialogRef: null,
+    MtrldefDialogProps: {}
   });
   // 表格配置项
   const columns: ColumnProps<any>[] = [
@@ -754,7 +773,9 @@ export const useHooks = (t?: any) => {
       field: "allow_edit",
       title: "业务修改",
       width: 80,
-      datatype: "checkbox"
+      align: "center",
+      datatype: "checkbox",
+      editRender: {}
     },
     {
       field: "pzname",
@@ -775,8 +796,29 @@ export const useHooks = (t?: any) => {
       field: "mtrlname",
       title: "物料名称规格",
       width: 400,
-      render: (scope: any) => {
-        return `${scope.row.mtrlname} ${scope.row.mtrlmode}`;
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row } = scope;
+        let _label = column.title;
+        let params = {};
+
+        return (
+          <>
+            <MtrldefSelect
+              value={row.mtrlid}
+              {...params}
+              clearable
+              placeholder={_label}
+              onOpenModal={() => fModelChoseMtrl(row, params)}
+              onSelect={val => rModelSetMtrl(row, val)}
+              onClear={() => rModelClearMtrl(row)}
+            >
+              {{
+                label: () => row.mtrlname
+              }}
+            </MtrldefSelect>
+          </>
+        );
       }
     },
     {
@@ -787,17 +829,20 @@ export const useHooks = (t?: any) => {
     {
       field: "cutting_length",
       title: "下料长(mm)",
-      datatype: "number"
+      datatype: "number",
+      editRender: {}
     },
     {
       field: "cutting_width",
       title: "下料宽(mm)",
-      datatype: "number"
+      datatype: "number",
+      editRender: {}
     },
     {
       field: "cutting_qty",
       title: "下料数量",
-      datatype: "number"
+      datatype: "number",
+      editRender: {}
     },
     {
       field: "useqty",
@@ -820,7 +865,8 @@ export const useHooks = (t?: any) => {
     {
       field: "loss_rate",
       title: "损耗率",
-      datatype: "number"
+      datatype: "number",
+      editRender: {}
     },
     {
       field: "price",
@@ -864,22 +910,50 @@ export const useHooks = (t?: any) => {
   /**
    * 打开部件配置弹窗
    */
-  const onOpenConfigureDialog = () => {
-    const { _mainData, enumMap } = state.LjDetailRef;
+  const onOpenConfigureDialog = async () => {
+    const { _mainData } = state.LjDetailRef;
+    const result = await GetSoftBedConfigureList({ softbed: _mainData });
+
+    if (result.typeList?.length > 0) {
+      for (const item of result.typeList) {
+        if (item.contfigtypename.includes("床头柜")) {
+          handleConfigItem(item, state.nightstandConfigOptions);
+        } else if (item.contfigtypename.includes("床架")) {
+          handleConfigItem(item, state.bedframeConfigOptions);
+        } else if (item.contfigtypename.includes("床头")) {
+          handleConfigItem(item, state.headboardConfigOptions);
+        }
+      }
+    }
+
     nextTick(() => {
       state.showHeadboard = Boolean(_mainData.has_headboard);
       state.showNightstand = Boolean(_mainData.has_nightstand);
       state.showBedframe = Boolean(_mainData.has_bedframe);
-
       state.isModalVisible = true;
     });
   };
+  const handleConfigItem = (item: any, targetArray: any[]) => {
+    if (item.codeList?.length > 0) {
+      for (const code of item.codeList) {
+        targetArray.push({ pzid: code.pzid, pzname: code.name });
+        if (code.pzid && code.pzid > 0) {
+          state.configValueOptionsMap[code.pzid] = [];
+          if (code.codeMxList?.length > 0) {
+            state.configValueOptionsMap[code.pzid].push(...code.codeMxList.filter(t => t.pzid === code.pzid));
+          }
+        }
+      }
+    }
+  };
   /**
    * 确认部件配置项值
    * @param params 返回内容
    */
   const onConfirmConfigureDialog = (params: any) => {
     const { _mainData } = state.LjDetailRef;
+
+    console.log("partsConfig :>>> ", state.partsConfig);
     nextTick(() => {
       _mainData.has_headboard = Number(state.showHeadboard);
       _mainData.has_nightstand = Number(state.showNightstand);
@@ -1131,6 +1205,58 @@ export const useHooks = (t?: any) => {
     return tableRef === state.VxeTableHeadBoardMxRef ? 1 : tableRef === state.VxeTableNightStandMxRef ? 2 : 4;
   };
 
+  /**
+   * @description 弹窗模块:客户选择
+   * @param data 当前数据
+   * @param status 当前订单状态
+   * @returns Promise
+   */
+  const fModelChoseMtrl = (data: any, params: any) => {
+    return new Promise((resolve, reject) => {
+      // if (!ALLOW_EDIT_STATE.includes(status)) return;
+
+      let _params = {
+        keyword: ""
+      };
+      state.MtrldefDialogProps = {
+        onSubmit: (res: any) => {
+          // submit
+          console.log("openCustDialog res", res);
+          nextTick(() => {
+            rModelSetMtrl(data, res.value[0]);
+            resolve(1);
+          });
+        },
+        onCancel: (error: any) => {
+          // cancel 回调
+          console.log("openCustDialog error", error);
+        }
+      };
+      state.MtrldefDialogRef.show(_params);
+    });
+  };
+
+  /**
+   * @description 数据赋值: 联系人
+   * @param data 当前数据
+   * @param item 当前选择的数据
+   */
+  const rModelSetMtrl = (data: any, item: any) => {
+    data.mtrlid = Number(item.mtrlid);
+    data.mtrlname = item.name;
+    // data.mtrlcode = item.mtrlcode;
+    // data.mtrlmode = item.mtrlmode;
+    data.unit = item.priceunit;
+  };
+
+  const rModelClearMtrl = (data: any) => {
+    data.mtrlid = 0;
+    data.mtrlname = "";
+    // data.mtrlcode = "";
+    // data.mtrlmode = "";
+    data.unit = "";
+  };
+
   return {
     ...toRefs(state),
     columns,