Parcourir la source

1、修复软床报价内测问题

iggy il y a 1 mois
Parent
commit
987302b6a2

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

@@ -37,7 +37,7 @@ namespace JLHHJSvr.Com.Model
 
         #region 辅助
         public string pzname { get; set; }
-        public string pzmxname { get; set; }
+        public string formulaname { get; set; }
         #endregion
     }
 

+ 1 - 1
JLHHJSvr/Excutor/AuditSoftBedQuoteExcutor.cs

@@ -31,7 +31,7 @@ namespace JLHHJSvr.Excutor
             {
                 con.Open();
 
-                var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd);
+                var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd,new HelperBase.Context() { tokendata = tokendata });
 
                 using (cmd.Transaction = con.BeginTransaction())
                 {

+ 1 - 1
JLHHJSvr/Excutor/DeleteSoftBedQuoteExcutor.cs

@@ -31,7 +31,7 @@ namespace JLHHJSvr.Excutor
             {
                 con.Open();
 
-                var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd);
+                var softBedHelper = HelperBase.GetHelper<SoftBedHelper>(cmd,new HelperBase.Context() { tokendata = tokendata });
 
                 using (cmd.Transaction = con.BeginTransaction())
                 {

+ 51 - 33
JLHHJSvr/Helper/SoftBedHelper.cs

@@ -30,7 +30,7 @@ namespace JLHHJSvr.Helper
         {
             fields = fields ?? @"softbed_id,softbed_code,softbed_relcode,softbed_name,deptid,create_date,create_emp,mtrlmode,mtrltype,has_headboard,has_nightstand,has_bedframe,is_template,
                                 template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,money_type,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
-                                dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version";
+                                dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version,flag,audit_date,audit_emp,update_date,update_emp";
             var bill = new u_softbed() { softbed_id = billid };
 			if (DbSqlHelper.SelectOne(cmd, bill, fields) == 0) return null;
 			return bill;
@@ -45,7 +45,7 @@ namespace JLHHJSvr.Helper
         public List<u_softbed_mx> GetSoftBedMxList(int billid,string fields = null)
         {
             fields = fields ?? @"softbed_id,printid,formulaid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
-                                useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,pzmxname";
+                                useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,formulaname";
             var mxlist = new List<u_softbed_mx>();
 
             var selectStr = @"SELECT u_softbed_mx.softbed_id
@@ -72,9 +72,11 @@ namespace JLHHJSvr.Helper
 									,u_softbed_mx.price_formula_str
 									,u_softbed_mx.cost_price
 									,u_softbed_mx.cost_amt
-									,u_configure_code.name AS pzname
+									,ISNULL(u_configure_code.name,'') AS pzname
+									,ISNULL(u_softbed_formula.formulaname,'') AS formulaname
 								FROM u_softbed_mx
 								LEFT JOIN u_configure_code ON u_softbed_mx.pzid = u_configure_code.pzid
+								LEFT JOIN u_softbed_formula ON u_softbed_mx.formulaid = u_softbed_formula.formulaid
 								";
 
             DbSqlHelper.SelectJoin(cmd, selectStr, "softbed_id = @billid", new Dictionary<string, object>() { { "@billid", billid } }, "has_type,printid", fields, 0, 0, mxlist);
@@ -306,8 +308,8 @@ namespace JLHHJSvr.Helper
                             template_id,template_code,template_name,commission,taxes,taxrate,other_rate,extras_cost,money_type,moneyrate,dscrp,costamt,nottax_factory_cost,nottax_dept_cost,
                             dept_cost,foreign_cost,total_mtrl_cost,total_hr_cost,total_cost,version";
 
-			var mx_fields = @"softbed_id,printid,pzid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
-							useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt,pzname,pzmxname";
+			var mx_fields = @"softbed_id,printid,pzid,formulaid,mtrlid,mtrlname,mtrlcode,mtrlmode,unit,has_type,allow_edit,cutting_length,cutting_width,cutting_qty,
+							useqty,use_formula,use_formula_str,actual_useqty,loss_rate,price,price_formula,price_formula_str,cost_price,cost_amt";
 
 			if(softbed.softbed_id == 0)
 			{
@@ -438,15 +440,17 @@ namespace JLHHJSvr.Helper
                 {
 					if (codeMx.pzid == 0) continue;
                     // 判断是否有标准
-                    cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND ifdft = 1";
+                    cmd.CommandText = @"SELECT COUNT(*) FROM u_configure_codemx WHERE pzid = @pzid AND printid = @printid AND ifdft = 1";
                     cmd.Parameters.Clear();
                     cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
+                    cmd.Parameters.AddWithValue("@printid", codeMx.printid);
 					if(Convert.ToInt32(cmd.ExecuteScalar()) > 0)
 					{
-						cmd.CommandText = @"UPDATE u_configure_codemx SET ifdft = 0 WHERE pzid = @pzid AND ifdft = 1";
+						cmd.CommandText = @"UPDATE u_configure_codemx SET ifdft = 0 WHERE pzid = @pzid AND printid = @printid AND ifdft = 1";
                         cmd.Parameters.Clear();
                         cmd.Parameters.AddWithValue("@pzid", codeMx.pzid);
-						cmd.ExecuteNonQuery();
+                        cmd.Parameters.AddWithValue("@printid", codeMx.printid);
+                        cmd.ExecuteNonQuery();
                     }
 
                     codeMx.ifdft = 1;
@@ -473,6 +477,7 @@ namespace JLHHJSvr.Helper
 								,u_configure_code.inputtype
 								,LTRIM(RTRIM(u_configure_type.contfigtypename)) AS contfigtypename
 								,u_configure_code.typeid
+								,u_configure_codemx.ifdft
 							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";
@@ -509,7 +514,7 @@ namespace JLHHJSvr.Helper
 			{
 				whereList.AddRange(extraWheres);
 			}
-			DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), null, "typeid,pzid,printid", "typeid,pzid,printid,pzcodemx,namemx,pzname,pzcode,contfigtypename", 0, 0, codeMxList);
+			DbSqlHelper.SelectJoin(cmd, selectStr, ListEx.GetWhereStr(whereList), null, "typeid,pzid,printid", "typeid,pzid,printid,pzcodemx,namemx,pzname,pzcode,contfigtypename,ifdft", 0, 0, codeMxList);
 
 			// 部件选配项
             var codeMap = new Dictionary<int, u_configure_code>();
@@ -524,7 +529,7 @@ namespace JLHHJSvr.Helper
 						name = codeMx.pzname,
                         contfigtypename = codeMx.contfigtypename,
 						pzcode = codeMx.pzcode,
-						typeid = codeMx.pzid,
+						typeid = codeMx.typeid,
                         codeMxList = new List<u_configure_codemx>()
                     };
 
@@ -640,34 +645,50 @@ namespace JLHHJSvr.Helper
 		public void CalCulateFormula(u_softbed softbed)
 		{
 			InitSoftBed(softbed);
-
 			InitReplaceMents(softbed);
 
+            decimal total_mtrl_cost = 0, total_hr_cost = 0;
             foreach (var mx in softbed.mxList)
 			{
-				InitMxReplaceMents(softbed, mx);
+                InitMxReplaceMents(softbed, mx);
 
 				formula.CalculateAll();
 
-				// 成本单价
-				mx.cost_price = formula.GetFormulaItem("【成本单价】").value;
+                // 转换后的文本公式
+                mx.use_formula_str = formula.GetFormulaItem("【实际用量】").formula_transform;
+                mx.price_formula_str = formula.GetFormulaItem("【成本单价】").formula_transform;
+
+                // 成本单价
+                mx.cost_price = formula.GetFormulaItem("【成本单价】").value;
 				// 实际用量
 				mx.actual_useqty = formula.GetFormulaItem("【实际用量】").value;
                 // 成本金额
                 mx.cost_amt = formula.GetFormulaItem("【成本金额】").value;
 				// 总材料成本
-				softbed.total_mtrl_cost += mx.cost_amt;
+				total_mtrl_cost += mx.cost_amt;
 				// 总人力成本
-				softbed.total_hr_cost += 0;
+				total_hr_cost += 0;
             }
-
+			softbed.total_mtrl_cost = total_mtrl_cost;
+			softbed.total_hr_cost = total_hr_cost;
 			softbed.total_cost = formula.GetFormulaItem("【车间成本】").value;
+
+			softbed.nottax_factory_cost = formula.GetFormulaItem("【不含税出厂价】").value;
+			softbed.nottax_dept_cost = formula.GetFormulaItem("【部门不含税价】").value;
+			softbed.dept_cost = formula.GetFormulaItem("【部门含税价】").value;
+			softbed.taxes = formula.GetFormulaItem("【税金】").value;
+			softbed.foreign_cost = formula.GetFormulaItem("【外币价】").value;
+            //formula.CalculateAll();
         }
 
 		private void InitSoftBed(u_softbed softbed)
 		{
             var dept = Cache.GetData<int, u_dept, DeptMapping>(softbed.deptid);
 
+			//
+            softbed.dept_profitrate = dept.profitrate;
+
+			//
             softbed.moneyrate = softbed.moneyrate <= 0 ? 1 : softbed.moneyrate;
             softbed.commission = softbed.commission <= 0 ? 1 : softbed.commission;
             softbed.taxrate = softbed.taxrate <= 0 ? 1 : softbed.taxrate;
@@ -708,35 +729,32 @@ namespace JLHHJSvr.Helper
         }
 
 		private void InitReplaceMents(u_softbed softbed)
-		{
-			// 公式变量
-			formula.AddFormulaItem("【不含税出厂价】", "【车间成本】*(【工厂利润率】+【外销加点】)");
-			formula.AddFormulaItem("【部门不含税价】", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】+【FOB】");
-			formula.AddFormulaItem("【部门含税价】", "【部门不含税价】*【税率】");
-			formula.AddFormulaItem("【税金】", "【部门不含税价】* (【税率】-1)");
-			formula.AddFormulaItem("【外币价】", "【部门含税价】/【汇率】");
-
-			// 常量变量
-			formula.AddFormulaItem("【部门利润率】", softbed.dept_profitrate);
+        {
+            // 常量变量
+            formula.AddFormulaItem("【部门利润率】", softbed.dept_profitrate);
 			formula.AddFormulaItem("【佣金点数】", softbed.commission);
 			formula.AddFormulaItem("【额外点数】", softbed.other_rate);
 			formula.AddFormulaItem("【额外费用】", softbed.extras_cost);
 			formula.AddFormulaItem("【汇率】", softbed.moneyrate);
 			formula.AddFormulaItem("【税率】", softbed.taxrate);
-			formula.AddFormulaItem("【FOB】", 0);
+            formula.AddFormulaItem("【工厂利润率】", 1);
+            formula.AddFormulaItem("【FOB】", 0);
 			formula.AddFormulaItem("【外销加点】", 0);
             formula.AddFormulaItem("【总材料成本】", softbed.total_mtrl_cost);
             formula.AddFormulaItem("【总人力成本】", softbed.total_hr_cost);
-            formula.AddFormulaItem("【车间成本】", softbed.total_cost);
+
+            // 公式变量
+            formula.AddFormulaItem("【不含税出厂价】", "【车间成本】*(【工厂利润率】+【外销加点】)");
+            formula.AddFormulaItem("【部门不含税价】", "【不含税出厂价】/【部门利润率】/( 1 - (【佣金点数】- 1))*【额外点数】+【FOB】");
+            formula.AddFormulaItem("【部门含税价】", "【部门不含税价】*【税率】");
+            formula.AddFormulaItem("【税金】", "【部门不含税价】* (【税率】-1)");
+            formula.AddFormulaItem("【外币价】", "【部门含税价】/【汇率】");
         }
 
         private void InitMxReplaceMents(u_softbed softbed,u_softbed_mx mx)
         {
 			// 默认公式变量
-            formula.AddFormulaItem("【总材料成本】", 0);
-            formula.AddFormulaItem("【总人力费用】",0);
-            formula.AddFormulaItem("【额外费用】", 0);
-			formula.AddFormulaItem("【车间成本】", "【总材料成本】 + 【总人力费用】 + 【额外费用】");
+			formula.AddFormulaItem("【车间成本】", "【总材料成本】 + 【总人力成本】 + 【额外费用】");
             formula.AddFormulaItem("【成本单价】", "【材料单价】*1");
             formula.AddFormulaItem("【实际用量】", "【用料量】*(1 + 【损耗率】)");
             formula.AddFormulaItem("【成本金额】", "【实际用量】 * 【成本单价】");

+ 8 - 8
JLHHJSvr/Tools/CalculateFormula.cs

@@ -24,8 +24,8 @@ namespace JLHHJSvr.Tools
             if(_formula.ContainsKey(item.formula_name))
             {
                 _formula.Remove(item.formula_name);
-                _formula.Add(item.formula_name,item);
             }
+            _formula.Add(item.formula_name, item);
         }
 
         public void AddFormulaItem(string name,decimal value)
@@ -35,8 +35,7 @@ namespace JLHHJSvr.Tools
 
         public void AddFormulaItem(string name, string formula)
         {
-            var formulaItem = new FormulaItem() { formula_name = name, formula = formula,isConst = false };
-            AddFormulaItem(formulaItem);
+            AddFormulaItem(new FormulaItem() { formula_name = name, formula = formula, isConst = false });
         }
 
         public FormulaItem GetFormulaItem(string name,bool isConst = false)
@@ -54,15 +53,15 @@ namespace JLHHJSvr.Tools
             foreach (var name in sorted)
             {
                 var item = _formula[name];
-                item.formula = ConvertToEnglishSymbols(item.formula);
                 // 常量直接赋值
                 if (item.isConst)
                 {
-                    item.formula_transform = item.formula;
-                    item.value = Convert.ToDecimal(item.formula);
+                    //item.formula_transform = item.formula;
+                    //item.value = Convert.ToDecimal(item.formula);
                     continue;
                 }
                 // 变量公式
+                item.formula = ConvertToEnglishSymbols(item.formula);
                 string expanded = ExpandFormula(item.formula, _formula);
                 item.formula_transform = expanded;
 
@@ -85,7 +84,7 @@ namespace JLHHJSvr.Tools
 
                 foreach (var name in dict.Keys)
                 {
-                    if (name == kv.Key) continue;
+                    if (name == kv.Key || kv.Value.isConst) continue;
                     if (Regex.IsMatch(kv.Value.formula, name))
                     {
                         deps.Add(name);
@@ -140,7 +139,7 @@ namespace JLHHJSvr.Tools
         {
             foreach (var kv in dict)
             {
-                formula = Regex.Replace(formula, $"【{kv.Key}】", kv.Value.value.ToString());
+                formula = Regex.Replace(formula, kv.Key, kv.Value.value.ToString());
             }
             return formula;
         }
@@ -171,6 +170,7 @@ namespace JLHHJSvr.Tools
             try
             {
                 formula.value = LJExprParser.Parse(formula.formula_transform).Result.DecimalValue;
+                formula.isConst = true;
             }
             catch (Exception ex)
             {

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

@@ -1415,6 +1415,7 @@ export namespace SoftBed {
   export interface ResSoftBed {
     softbed: any;
     mxList: any[];
+    typeList: any[];
   }
   export interface ResGetSoftBedMxList {
     billid: number;

+ 1 - 1
JLHWEB/src/api/modules/quote.ts

@@ -278,7 +278,7 @@ export const ShowSoftBedQuoteFml = (params: Mattress.ReqSaveMattressInterface) =
 /**
  * @name 软床报价:显示公式
  */
-export const GetSoftBedMxList = (params: SoftBed.ReqSoftBed) => {
+export const GetSoftBedMxList = (params: SoftBed.ResGetSoftBedMxList) => {
   return http.post<SoftBed.ResSoftBed>(PORT1 + `/GetSoftBedMxList`, params);
 };
 

+ 3 - 1
JLHWEB/src/views/quote/softbedQuote/components/BedConfigModal.vue

@@ -6,7 +6,7 @@
       </div>
     </template>
 
-    <div class="checkbox-area">
+    <div class="checkbox-area" v-if="userInfo.usermode !== 1">
       <el-checkbox v-model="showHeadboardModel" label="床头" border></el-checkbox>
       <el-checkbox v-model="showNightstandModel" label="床头柜" border></el-checkbox>
       <el-checkbox v-model="showBedframeModel" label="床架" border></el-checkbox>
@@ -49,6 +49,8 @@
 import { PropType, computed } from "vue";
 import ConfigSection from "./ConfigSection.vue";
 import LjDialogNew from "@/components/LjDialog/index-new.vue";
+import { useUserStore } from "@/stores/modules/user";
+const { userInfo } = useUserStore();
 
 interface ConfigValue {
   printid: number;

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

@@ -90,6 +90,7 @@
     @cancel="isModalVisible = false"
   />
   <ErpMtrlPriceDialog ref="ErpMtrlPriceDialogRef" v-bind="ErpMtrlPriceDialogProps" />
+  <SoftBedTemplateDialog ref="SoftBedTemplateDialogRef" v-bind="SoftBedTemplateDialogProps" />
 </template>
 
 <script setup lang="tsx" name="softBedQuoteDetail">
@@ -104,6 +105,7 @@ import { useHooks } from "./hooks/index";
 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";
 
 const { t } = useI18n();
 const route = useRoute();
@@ -130,6 +132,8 @@ const {
   configValueOptionsMap,
   ErpMtrlPriceDialogProps,
   ErpMtrlPriceDialogRef,
+  SoftBedTemplateDialogRef,
+  SoftBedTemplateDialogProps,
   partsConfig,
   detail_getData,
   toAddMx,
@@ -340,7 +344,7 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: item => {
-      const list = [{ softbed_id: softBed.value.softbed_id }];
+      const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
       onDelete(list, () => {
         tabRemove(route.fullPath);
         router.replace("/softbedQuote");
@@ -363,8 +367,10 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: item => {
-      const list = [{ softbed_id: softBed.value.softbed_id }];
-      onAudit(list);
+      const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
+      onAudit(list, () => {
+        LjDetailRef.value.refresh();
+      });
     }
   }),
   buttonDefault({
@@ -383,8 +389,10 @@ const orderDefaultAction = [
       return "";
     },
     clickFunc: item => {
-      const list = [{ softbed_id: softBed.value.softbed_id }];
-      onCAudit(list);
+      const list = [{ softbed_id: LjDetailRef.value._mainData.softbed_id }];
+      onCAudit(list, () => {
+        LjDetailRef.value.refresh();
+      });
     }
   }),
   buttonDefault({
@@ -424,7 +432,6 @@ const funcAfterMound = async (data: any) => {
   }
 
   detail_getData(initParams.value);
-
   GetSoftBedFormulaMapper();
 };
 </script>

+ 137 - 37
JLHWEB/src/views/quote/softbedQuote/hooks/index.tsx

@@ -92,6 +92,7 @@ interface defaultState {
   ErpMtrlPriceDialogRef: any;
   ErpMtrlPriceDialogProps: any;
   softBedFormulaEnum: any[];
+  deptEnum: any[];
 }
 
 /**
@@ -129,7 +130,8 @@ export const useHooks = (t?: any) => {
     configValueOptionsMap: {},
     ErpMtrlPriceDialogRef: null,
     ErpMtrlPriceDialogProps: {},
-    softBedFormulaEnum: []
+    softBedFormulaEnum: [],
+    deptEnum: []
   });
   // 表格配置项
   const columns: ColumnProps<any>[] = [
@@ -160,6 +162,7 @@ export const useHooks = (t?: any) => {
         const data = (await getDeptList({})).datatable.map(t => {
           return { ...t, label: t.deptname, value: t.deptid };
         });
+        state.deptEnum = data;
         return { data };
       },
       search: {
@@ -676,7 +679,7 @@ export const useHooks = (t?: any) => {
       title: "财务底价"
     },
     {
-      field: "total_material_cost",
+      field: "total_mtrl_cost",
       basicinfo: {
         span: 1,
         row: 1,
@@ -795,14 +798,23 @@ export const useHooks = (t?: any) => {
       datatype: "checkbox",
       editRender: {},
       editColRender: (scope: any) => {
-        const { column, row, status } = scope;
+        const { row } = scope;
+        const { _mainData } = state.LjDetailRef;
         if (Number(row.allow_edit) == 0) {
           row.allow_edit = 0;
         }
 
+        const _disabled = !row.allow_edit && !_mainData.is_template;
+
         return (
           <>
-            <el-checkbox v-model={row.allow_edit} true-value={1} false-value={0} class="vxe-edit-col-middle"></el-checkbox>
+            <el-checkbox
+              v-model={row.allow_edit}
+              true-value={1}
+              false-value={0}
+              class="vxe-edit-col-middle"
+              disabled={_disabled}
+            ></el-checkbox>
           </>
         );
       }
@@ -827,7 +839,13 @@ export const useHooks = (t?: any) => {
         const options = state[targetArray]?.map(item => <el-option key={item.pzid} label={item.pzname} value={item} />) || [];
 
         return (
-          <el-select v-model={row.pzid} disabled={_disabled} valueKey={"pzid"} clearable={true}>
+          <el-select
+            v-model={row.pzname}
+            disabled={_disabled}
+            valueKey={"pzid"}
+            clearable={true}
+            onChange={val => fModelChosePzName(row, val)}
+          >
             {options}
           </el-select>
         );
@@ -838,7 +856,9 @@ export const useHooks = (t?: any) => {
       title: "公式名",
       width: 160,
       enum: async () => {
-        const data = (await GetSoftBedFormulaMapper()).datatable;
+        const data = (await GetSoftBedFormulaMapper()).datatable.map(t => {
+          return { ...t, label: t.formulaname, value: t.formulaid };
+        });
         state.softBedFormulaEnum = data;
         return { data };
       },
@@ -875,17 +895,19 @@ export const useHooks = (t?: any) => {
       editRender: {},
       editColRender: (scope: any) => {
         const { $table, column, row, status } = scope;
-        let field = column.field;
+        const { _mainData } = state.LjDetailRef;
         let _label = column.title;
         let params = {
           keyword: row.mtrlcode
         };
+        const _disabled = !row.allow_edit && !_mainData.is_template;
 
         return (
           <ErpMtrlPriceSelect
             value={row.mtrlid}
             {...params}
             clearable
+            disabled={_disabled}
             placeholder={_label}
             onOpenModal={() => fModelChoseMtrlErp(row, params)}
             onSelect={val => rModelSetMtrlErp(row, val)}
@@ -944,7 +966,15 @@ export const useHooks = (t?: any) => {
     {
       field: "useqty",
       title: "理论用料量",
-      datatype: "number"
+      datatype: "number",
+      editRender: {},
+      editColRender: (scope: any) => {
+        const { $table, column, row, status } = scope;
+        const { _mainData } = state.LjDetailRef;
+
+        let _disabled = !Boolean(row.allow_edit) && !Boolean(_mainData.is_template);
+        return <el-input v-model={scope.row.useqty} type="number" disabled={_disabled}></el-input>;
+      }
     },
     {
       field: "use_formula",
@@ -1015,6 +1045,11 @@ export const useHooks = (t?: any) => {
     }
 
     const result = await GetSoftBedMxList(params);
+    if (state.orderStatus === "copy") {
+      result.softbed.softbed_id = 0;
+      result.softbed.softbed_code = "";
+    }
+    //
     state.softBed = [result.softbed];
     state.softBedMx = result.mxList;
     state.headBoardMx = result.mxList.filter(item => item.has_type === 1);
@@ -1035,11 +1070,11 @@ export const useHooks = (t?: any) => {
     if (result.typeList?.length > 0) {
       for (const item of result.typeList) {
         if (item.contfigtypename.includes("床头柜")) {
-          handleConfigItem(item, state.nightstandConfigOptions);
+          handleConfigItem(item, state.nightstandConfigOptions, state.partsConfig.nightstand);
         } else if (item.contfigtypename.includes("床架")) {
-          handleConfigItem(item, state.bedframeConfigOptions);
+          handleConfigItem(item, state.bedframeConfigOptions, state.partsConfig.bedframe);
         } else if (item.contfigtypename.includes("床头")) {
-          handleConfigItem(item, state.headboardConfigOptions);
+          handleConfigItem(item, state.headboardConfigOptions, state.partsConfig.headboard);
         }
       }
     }
@@ -1051,14 +1086,23 @@ export const useHooks = (t?: any) => {
       state.isModalVisible = true;
     });
   };
-  const handleConfigItem = (item: any, targetArray: any[]) => {
+  const handleConfigItem = (item: any, targetOption: any[], targetConfig: any[]) => {
     if (item.codeList?.length > 0) {
       for (const code of item.codeList) {
-        targetArray.push({ pzid: code.pzid, pzname: code.name });
+        targetOption.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));
+
+            // 自动添加标准选配值
+            targetConfig.push(
+              ...code.codeMxList
+                .filter(t => t.ifdft === 1)
+                .map(t => {
+                  return { pzid: t.pzid, selectedId: t.printid, selectedValue: t.namemx };
+                })
+            );
           }
         }
       }
@@ -1085,9 +1129,10 @@ export const useHooks = (t?: any) => {
    */
   const onSave = async cb => {
     const { _mainData } = state.LjDetailRef;
-    const headboard_table = state.VxeTableHeadBoardMxRef.element.getTableData();
-    const nightstand_table = state.VxeTableNightStandMxRef.element.getTableData();
-    const bedframe_table = state.VxeTableBedFrameMxRef.element.getTableData();
+
+    const { fullData: headboard_table } = state.VxeTableHeadBoardMxRef?.element.getTableData();
+    const { fullData: nightstand_table } = state.VxeTableNightStandMxRef?.element.getTableData();
+    const { fullData: bedframe_table } = state.VxeTableBedFrameMxRef?.element.getTableData();
 
     const _softbed = cloneDeep(_mainData);
     const _mxList = [];
@@ -1095,13 +1140,28 @@ export const useHooks = (t?: any) => {
     _softbed.mxList = _mxList;
     _softbed.codeMxList = _codeMxList;
 
-    if (headboard_table && headboard_table.length > 0) _mxList.push(headboard_table);
-    if (nightstand_table && nightstand_table.length > 0) _mxList.push(nightstand_table);
-    if (bedframe_table && bedframe_table.length > 0) _mxList.push(bedframe_table);
+    if (headboard_table && headboard_table.length > 0) _mxList.push(...headboard_table);
+    if (nightstand_table && nightstand_table.length > 0) _mxList.push(...nightstand_table);
+    if (bedframe_table && bedframe_table.length > 0) _mxList.push(...bedframe_table);
 
-    if (_softbed.has_headboard) _codeMxList.push(...state.partsConfig.headboard);
-    if (_softbed.has_nightstand) _codeMxList.push(...state.partsConfig.nightstand);
-    if (_softbed.has_bedframe) _codeMxList.push(...state.partsConfig.bedframe);
+    if (_softbed.has_headboard)
+      _codeMxList.push(
+        ...state.partsConfig.headboard.map(t => {
+          return { pzid: t.pzid, printid: t.selectedId };
+        })
+      );
+    if (_softbed.has_nightstand)
+      _codeMxList.push(
+        ...state.partsConfig.nightstand.map(t => {
+          return { pzid: t.pzid, printid: t.selectedId };
+        })
+      );
+    if (_softbed.has_bedframe)
+      _codeMxList.push(
+        ...state.partsConfig.bedframe.map(t => {
+          return { pzid: t.pzid, printid: t.selectedId };
+        })
+      );
 
     transformData(_softbed);
 
@@ -1136,7 +1196,7 @@ export const useHooks = (t?: any) => {
   /**
    * 审核报价
    */
-  const onAudit = (list: any) => {
+  const onAudit = (list: any, cb?: Function) => {
     ElMessageBox.confirm("是否确定要审核单据吗?", "询问", {
       confirmButtonText: "是",
       cancelButtonText: "否",
@@ -1145,7 +1205,7 @@ export const useHooks = (t?: any) => {
       .then(() => {
         AuditSoftBedQuote({ list, type: 1 }).then(() => {
           ElMessage.success(t("sys.api.operationSuccess"));
-          state.VxeTableRef.refresh();
+          cb && cb();
         });
       })
       .catch((e: TypeError) => {
@@ -1158,7 +1218,7 @@ export const useHooks = (t?: any) => {
   /**
    * 撤审报价
    */
-  const onCAudit = (list: any) => {
+  const onCAudit = (list: any, cb?: Function) => {
     ElMessageBox.confirm("是否确定要撤审单据吗?", "询问", {
       confirmButtonText: "是",
       cancelButtonText: "否",
@@ -1167,6 +1227,7 @@ export const useHooks = (t?: any) => {
       .then(() => {
         AuditSoftBedQuote({ list, type: 0 }).then(() => {
           ElMessage.success(t("sys.api.operationSuccess"));
+          cb && cb();
           state.VxeTableRef.refresh();
         });
       })
@@ -1247,12 +1308,10 @@ export const useHooks = (t?: any) => {
    * @description 获取部门汇率 和  折扣率
    */
   const wf_get_moneyrate_discount = (val: any) => {
-    const { _mainData, enumMap } = state.LjDetailRef;
+    const { _mainData } = state.LjDetailRef;
 
-    let deptEnum = enumMap.get("deptid");
-    console.log("deptEnum :>> ", deptEnum);
-    if (deptEnum) {
-      let depItem = deptEnum.find((item: any) => item.deptid == _mainData.deptid);
+    if (state.deptEnum) {
+      let depItem = state.deptEnum.find((item: any) => item.deptid == _mainData.deptid);
       if (depItem) {
         let _moneyrate = !depItem.moneyrate || Number(depItem.moneyrate) == 0 ? 1 : depItem.moneyrate;
         if (val == 0 || !_mainData.money_type) {
@@ -1299,13 +1358,46 @@ export const useHooks = (t?: any) => {
    * @param data 当前数据
    * @param item 当前选择的数据
    */
-  const rModelSetTemplate = (data: any, item: any) => {
-    data.template_id = Number(item.softbed_id);
-    data.template_code = item.softbed_code;
-    data.template_name = item.softbed_name;
-    data.has_headboard = Number(item.has_headboard);
-    data.has_nightstand = Number(item.has_nightstand);
-    data.has_bedframe = Number(item.has_bedframe);
+  const rModelSetTemplate = async (data: any, item: any) => {
+    // 获取明细
+    const result = await GetSoftBedMxList({ billid: Number(item.softbed_id) });
+    const coverList = [
+      "deptid",
+      "mtrlmode",
+      "mtrltype",
+      "commission",
+      "taxes",
+      "taxrate",
+      "other_rate",
+      "extras_cost",
+      "money_type",
+      "moneyrate",
+      "dscrp",
+      "costamt",
+      "nottax_factory_cost",
+      "nottax_dept_cost",
+      "dept_cost",
+      "foreign_cost",
+      "total_mtrl_cost",
+      "total_hr_cost",
+      "total_cost"
+    ];
+    //
+    data.template_id = result.softbed.softbed_id;
+    data.template_code = result.softbed.softbed_code;
+    data.template_name = result.softbed.softbed_name;
+    data.has_headboard = Number(result.softbed.has_headboard);
+    data.has_nightstand = Number(result.softbed.has_nightstand);
+    data.has_bedframe = Number(result.softbed.has_bedframe);
+    //
+    for (const key of coverList) {
+      data[key] = result.softbed[key];
+    }
+    //
+    state.softBedMx = result.mxList;
+    state.headBoardMx = result.mxList.filter(item => item.has_type === 1);
+    state.nightStandMx = result.mxList.filter(item => item.has_type === 2);
+    state.bedFrameMx = result.mxList.filter(item => item.has_type === 4);
   };
   /**
    * 清空选择参数
@@ -1427,6 +1519,14 @@ export const useHooks = (t?: any) => {
     data.price_formula = val.price_formula;
   };
 
+  /**
+   * @description 选择公式返回
+   */
+  const fModelChosePzName = (data: any, val: any) => {
+    data.pzid = val.pzid;
+    data.pzname = val.pzname;
+  };
+
   return {
     ...toRefs(state),
     columns,

+ 8 - 3
JLHWEB/src/views/quote/softbedQuote/index.vue

@@ -53,7 +53,7 @@ import { getCurrentRecords } from "@/utils/index";
 const { t } = useI18n();
 const router = useRouter();
 const globalStore = useGlobalStore();
-const { columns, orderStatus, VxeTableRef, initParams, onAudit, onCAudit, onDelete, onShowFormula } = useHooks();
+const { columns, orderStatus, VxeTableRef, initParams, onAudit, onCAudit, onDelete, onShowFormula } = useHooks(t);
 const { CheckPower, CheckOption, buttonNew, buttonDefault } = useAuthButtons(t);
 const { userInfo } = useUserStore();
 
@@ -241,7 +241,9 @@ const action: detailAction[] = [
       let list = curRecords.map((item: any) => {
         return { softbed_id: Number(item.softbed_id) };
       });
-      onAudit(list);
+      onAudit(list, () => {
+        VxeTableRef.value.refresh();
+      });
     }
   }),
   buttonDefault({
@@ -261,7 +263,10 @@ const action: detailAction[] = [
       let list = curRecords.map((item: any) => {
         return { softbed_id: Number(item.softbed_id) };
       });
-      onCAudit(list);
+      onCAudit(list),
+        () => {
+          VxeTableRef.value.refresh();
+        };
     }
   }),
   buttonDefault({