From f5da3dfc1496db01a3a881ad5a375b6a12e7b351 Mon Sep 17 00:00:00 2001 From: 陈鑫涛 <10125295+chen-xintao97@user.noreply.gitee.com> Date: Tue, 17 Jun 2025 13:40:08 +0800 Subject: [PATCH] 快速报价app --- src/components/QuickQuote/index.jsx | 13 +------------ src/mobile/quotation/detailNew.jsx | 218 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------- src/mobile/quotation/master.jsx | 7 +++++-- 3 files changed, 136 insertions(+), 102 deletions(-) diff --git a/src/components/QuickQuote/index.jsx b/src/components/QuickQuote/index.jsx index a90103d..897109e 100644 --- a/src/components/QuickQuote/index.jsx +++ b/src/components/QuickQuote/index.jsx @@ -436,7 +436,7 @@ const QuickQuoteEvent = props => { loading: true, }, () => { - props.onButtonClick("BtnDraft", true); + props.onButtonClick("BtnDraft"); } ); }; @@ -763,17 +763,6 @@ const QuickQuoteEvent = props => { processAfterDataRow.sId = commonUtils.createSid(); processAfterDataRow.sParentId = masterData.sId; processAfterDataRow.sControlId = partsDataRow.sId; - - const sBackendParams = process.sBackendParams || []; - if (sBackendParams.length) { - const sQuoParams = sBackendParams.map(item => ({ - sParamName: item.sParam, - sParamValue: item.value !== undefined ? item.value : "", - bSelfCbx: !(item.value === "" || item.value === undefined), - })); - processAfterDataRow.sQuoParams = JSON.stringify(sQuoParams); - } - // processAfterDataRow.sSlaveId = ' '; processData.push(processAfterDataRow); // 配套工序 diff --git a/src/mobile/quotation/detailNew.jsx b/src/mobile/quotation/detailNew.jsx index 34efce3..7689629 100644 --- a/src/mobile/quotation/detailNew.jsx +++ b/src/mobile/quotation/detailNew.jsx @@ -858,7 +858,16 @@ const QuickQuoteEvent = props => { const masterProps = { ...props, }; - setState(pre => ({ ...pre, newNextProps: { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData } })); + setState(pre => ({ + ...pre, + newNextProps: { + dQuickQuoteProductQty: state.dQuickQuoteProductQty, + ...masterProps, + ...newState, + manyqtysConfig: state.manyConfig, + manyqtysData: state.manyData, + }, + })); const result = await props.handleCalculation( false, { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData }, @@ -938,6 +947,8 @@ const QuotationAllprogressDetail = baseProps => { useEffect(() => { const getDropDownData = async props => { + const showDownConfig = props.state.slaveConfig?.gdsconfigformslave.find(item => item.sControlName === "BtnDownConfig"); + const downAbleConfigs = await getSqlDropDownData({ ...showDownConfig }); props.setState(pre => { const { slaveData = [], slaveConfig } = pre; const addState = {}; @@ -972,27 +983,27 @@ const QuotationAllprogressDetail = baseProps => { ...pre, ...addState, masterData: { sProductName: showName, sProductUnit: sUnit, ...masterData }, - // downAbleConfigs: downAbleConfigs - // .filter(item => item.sType === "2") - // .map((item, index) => ({ - // ...item, - // sName: `sParams${index}`, - // iColValue: item.iColValue || 4, - // sVisColumnName: "sProcessName", - // })), - // finishedConfigs: downAbleConfigs - // .filter(item => item.sType === "3") - // .map((item, index) => ({ - // ...item, - // sName: `sParams${index}`, - // iColValue: item.iColValue || 4, - // sVisColumnName: "sProcessName", - // })), + downAbleConfigs: downAbleConfigs + .filter(item => item.sType === "2") + .map((item, index) => ({ + ...item, + sName: `sParams${index}`, + iColValue: item.iColValue || 4, + sVisColumnName: "sProcessName", + })), + finishedConfigs: downAbleConfigs + .filter(item => item.sType === "3") + .map((item, index) => ({ + ...item, + sName: `sParams${index}`, + iColValue: item.iColValue || 4, + sVisColumnName: "sProcessName", + })), }; }); }; getDropDownData(props); - }, []); + }, [props.state.slaveConfig]); const getSqlDropDownData = async ({ sId }) => { const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`; const body = { @@ -1008,20 +1019,7 @@ const QuotationAllprogressDetail = baseProps => { // 取上机尺寸 return commonUtils.convertStrToObj(sColumnNameConfigStr, []); }; - useEffect(() => { - const getData = async props => { - const showDownConfig = props.state.slaveConfig?.gdsconfigformslave.find(item => item.sControlName === "BtnDownConfig"); - const downAbleConfigs = await getSqlDropDownData({ ...showDownConfig }); - // downAbleConfigs.forEach((x, i) => { - // x.sName = "sParams" + i; - // }); - props.setState(pre => ({ - ...pre, - downAbleConfigs, - })); - }; - getData(props); - }, [props.state.slaveConfig]); + return (
@@ -1180,27 +1178,41 @@ const QuotationTabs = props => { boxModel: activeKey, }; return ( - { - setActiveKey(key); - }} - > - {sAllPartsNameList && sAllPartsNameList.length - ? sAllPartsNameList.map((pane, index) => ( - - - - )) - : ""} - +
+
+ { + setActiveKey(key); + }} + > + {sAllPartsNameList && sAllPartsNameList.length + ? sAllPartsNameList.map((pane, index) => ( + + + + )) + : ""} + +
+
); }; // 内容 const BoxComponent = props => { const { state, boxModel } = props; - const { activeKey, slaveConfig, masterData, selectedNode, boxConfig, downAbleConfigs = [], slaveData } = state || {}; + const { + activeKey, + slaveConfig, + masterData, + selectedNode, + boxConfig, + downAbleConfigs = [], + downAbleExtraConfigs = [], + finishedConfigs = [], + slaveData, + } = state || {}; const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === boxModel) || {}; const { sModelsId } = props; const [selectList, setSelectList] = useState([]); @@ -1401,29 +1413,22 @@ const BoxComponent = props => { // 后道参数 const { sBackProcessData } = slaveRowData || []; - const [downAbleConfigsNew, setDownAbleConfigsNew] = useState([]); - useEffect(() => { - setDownAbleConfigsNew(downAbleConfigs); - }, [downAbleConfigs]); + const downAbleConfigsNew = downAbleConfigs.reduce((pre, cur) => { + const childConfigs = downAbleExtraConfigs.filter(item => item.sParentName === cur.showName); + pre.push(cur, ...childConfigs); + return pre; + }, []); // 初始化状态,存储每个 Switch 的状态 const [switchStates, setSwitchStates] = useState(null); useEffect(() => { if (!sBackProcessData) return; - const newSwitchStates = downAbleConfigsNew - .filter(item => item.sPartsName === boxModel || !item.sPartsName) - .reduce((acc, item, index) => { - acc[item.sName] = sBackProcessData ? sBackProcessData[index][item.sName] !== "" : false; - return acc; - }, {}); + const newSwitchStates = downAbleConfigsNew; setSwitchStates(newSwitchStates); }, [downAbleConfigsNew, boxModel]); // 依赖数组 // 处理 Switch 变化的函数 const handleSwitchChange = (item, val) => { - // const dropDownData = JSON.parse(item.sChineseDropDown) - // console.log("🚀 ~ handleSwitchChange ~ dropDownData:", dropDownData) - // const dropDownDataSelected = dropDownData.find(item => item.sId === changeValue[sFieldName]); setSwitchStates({ ...switchStates, [item.sName]: val, @@ -1435,10 +1440,9 @@ const BoxComponent = props => { .map((item, i) => ({ ...item, isSelect: switchStates ? switchStates[item.sName] : false, - sName: "sParams" + i, + // sName: "sParams" + i, sProductClassifyId: item.sId, })); - const downViewProps = { ...props, viewConfigs: downViewConfigs, @@ -1447,7 +1451,23 @@ const BoxComponent = props => { viewRow: slaveRowData, tableName: `slaveDown${boxModel}`, }; - + // 获取sType为3的 + const { productProcessInfo = [] } = masterData; + const finishedViewProps = { + ...props, + viewConfigs: finishedConfigs + .filter(item => item.sPartsName === boxModel || !item.sPartsName) + .map((item, i) => ({ + ...item, + isSelect: switchStates ? switchStates[item.sName] : false, + // sName: "sParams" + i, + sProductClassifyId: item.sId, + })), + tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs }, + iColValueView: 24, + viewRow: masterData, + tableName: "finished", + }; const calcMethodData = commonUtils.convertStrToObj(slaveRowData?.sColumnNameConfigExclusion, []); const radioValue = calcMethodData[0]?.sCode; const [materialLength, setMaterialLength] = useState(0); @@ -1729,22 +1749,42 @@ const BoxComponent = props => {
- {downViewProps.viewConfigs.map((x, i) => ( -
-
-
{x.showName}
- handleSwitchChange(x, val)} /> -
- {switchStates && switchStates[x.sName] ? ( - - ) : ( - "" - )} + {downViewProps && downViewProps.viewConfigs && downViewProps.viewConfigs.length + ? downViewProps.viewConfigs.map((x, i) => ( +
+
+
{x.showName}
+ handleSwitchChange(x, val)} /> +
+ {switchStates && switchStates[x.sName] ? ( + + ) : ( + "" + )} +
+
+ {getTableCloum(i, x)}
-
- {getTableCloum(i, x)} -
- ))} + )) + : ""} + {finishedConfigs && finishedConfigs.viewConfigs && finishedConfigs.viewConfigs.length + ? finishedConfigs.viewConfigs.map((x, i) => ( +
+
+
{x.showName}
+ handleSwitchChange(x, val)} /> +
+ {switchStates && switchStates[x.sName] ? ( + + ) : ( + "" + )} +
+
+ {getTableCloum(i, x)} +
+ )) + : ""}
@@ -1959,7 +1999,7 @@ const MaterialsComponent = props => { // 多数量组件 const ManyComponent = props => { const { state, setState, enabled, loading } = props; - const { masterData = {}, calcPriceLoading, calcPriceFinished, manyData = [] } = state; + const { masterData = {}, calcPriceLoading, calcPriceFinished, manyData = [], dQuickQuoteProductQty } = state; const [submitLoading, setSubmitLoading] = useState(false); const [processPercent, setProcessPercent] = useState(0); const [selectedRadio, setSelectedRadio] = useState(null); @@ -2013,10 +2053,11 @@ const ManyComponent = props => { enabled: false, }; const { headerColumn, data } = tableProps; + // 监听父组件状态变化 useEffect(() => { - if(!data.length) return - setSelectedRadio(data[0].dManyQty); - }, [data]); + if (!data.length) return; + setSelectedRadio(Number(props.state.dQuickQuoteProductQty) || data[0].dProductQty); + }, [props.state.dQuickQuoteProductQty]); // 直接监听父组件的 // 核价事件 const onCalcPrice = () => { const addState = { @@ -2034,20 +2075,21 @@ const ManyComponent = props => { ); }; const handleRadioChange = selectedRowKeys => { - setSelectedRadio(selectedRowKeys.dManyQty); const dProductQty = manyData.find(item => item.sId === selectedRowKeys.sId).dManyQty; - props.slaveData?.forEach(slaveRowData => { - props.onDataChange0("slave", "dProductQty", { dProductQty }, slaveRowData.sId, [], props); - }); + // 这一步导致了点击数量没有变化 + // props.slaveData?.forEach(slaveRowData => { + // props.onDataChange0("slave", "dProductQty", { dProductQty }, slaveRowData.sId, [], props); + // }); setState(pre => ({ ...pre, - manySelectedRowKeys: selectedRowKeys, + manySelectedRowKeys: selectedRowKeys.sId, dQuickQuoteProductQty: dProductQty, })); + setSelectedRadio(dProductQty); }; return (
-
+