From 08147093f959fbb9cea12e63f728e3cf1b214c4d Mon Sep 17 00:00:00 2001 From: 陈鑫涛 <10125295+chen-xintao97@user.noreply.gitee.com> Date: Tue, 9 Sep 2025 10:32:41 +0800 Subject: [PATCH] 快速报价 --- src/components/Common/Typesetting/typesetting.js | 33 ++++++++++++++++++++++++++------- src/components/QuickQuote/index.jsx | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------------------------------------------------- src/routes/mobile/IndexMobile.js | 8 ++++++-- 3 files changed, 121 insertions(+), 59 deletions(-) diff --git a/src/components/Common/Typesetting/typesetting.js b/src/components/Common/Typesetting/typesetting.js index 3f523b4..2f276b5 100644 --- a/src/components/Common/Typesetting/typesetting.js +++ b/src/components/Common/Typesetting/typesetting.js @@ -21,6 +21,7 @@ const Typesetting = props => { textSize, isMobile, } = props; + const hasExecutedRef = useRef(true); if (!slaveRowData) return; let { dSBLB = 0, // 上边留白 @@ -39,8 +40,23 @@ const Typesetting = props => { sSvgPath, dL = 0, dW = 0, + dD = 0, } = slaveRowData; const { masterData, selectedNode, slaveData } = state; + const { sBillNo } = props.masterData + + useEffect(() => { + if (sBillNo) { + if (hasExecutedRef.current) { + hasExecutedRef.current = false + } else { + // 第一次跳过 + hasExecutedRef.current = true; + } + } else { + hasExecutedRef.current = false + } + }, [sBillNo]); if (!masterData) return; // 如果是卷筒类 那么上下左右留白等于左留白 if (selectedNode && selectedNode.sTypeKey === "juantong") { @@ -94,8 +110,8 @@ const Typesetting = props => { // 确认是竖向排列还是横向排列 const L = slaveRowData.dL ? Number(dL) : Number(masterData?.dLength) || 0; const W = slaveRowData.dW ? Number(dW) : masterData?.dWidth || 0; - const H = masterData?.dWidth || 0; - const D = masterData?.dHeight || 0; + const H = slaveRowData.dD ? Number(dD) : masterData?.dWidth || 0; + const D = slaveRowData.dD ? Number(dD) : masterData?.dHeight || 0; // 动态计算公式值 const evaluateFormula = (formula, variables) => { if (!formula) return 0; // 如果公式为空,返回0 @@ -149,7 +165,7 @@ const Typesetting = props => { slaveNewData.forEach(x => { let key = 0; if (x.sAssignFormula) { - key = parseFloat(evaluateFormula(x.sAssignFormula, variables)).toFixed(2) || 0; + key = slaveRowData[x.sName]; } else { key = slaveRowData[x.sName]; } @@ -307,7 +323,9 @@ const Typesetting = props => { useEffect(() => { if (Number(slaveRowData.sTypes) === 9) { if (L > 0 && W > 0 && H > 0) { - const { width, height } = calculateCupUnfoldDimensions(L, W, D); + const lengths = evaluateFormula(sLengthFormula, variabless) + const widths = evaluateFormula(sWidthFormula, variabless) + const { width, height } = calculateCupUnfoldDimensions(lengths, widths, D); // 确保新值与旧值不同时才更新 if (width && height) { setInnerWidth(Number(width.toFixed(2))); @@ -351,8 +369,8 @@ const Typesetting = props => { (isVertical ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset : Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset)) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量 const innerWidthCombined = - (isVertical ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset) + dYBJJ; - + (isVertical ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset); + const style = { width: `${outerWidth}px`, height: `${outerHeight}px`, @@ -727,7 +745,7 @@ const Typesetting = props => { } const newDProductQty = masterData.dProductQty; const dMaterialsKQty = slaveDataDetail.dMaterialsKQty || 1; - + // if (Number(materialLength) < 100) return '' if ( dPartsLength !== innerWidth || newMaterialLength !== materialLength || @@ -853,6 +871,7 @@ const Typesetting = props => { setIsModalOpen(false); }; + return ( <> {isShow ? ( diff --git a/src/components/QuickQuote/index.jsx b/src/components/QuickQuote/index.jsx index 900f79b..f6ac77f 100644 --- a/src/components/QuickQuote/index.jsx +++ b/src/components/QuickQuote/index.jsx @@ -81,12 +81,10 @@ const QuickQuoteEvent = props => { masterData.sCustomerName = sCustomerName; masterData.sCustomerId = sCustomerId; } - return { ...result, masterData, slaveData: slaveDataNew, manyData: manyDataNew }; }; const sQuoConfig = commonUtils.convertStrToObj(props.masterData.sQuoConfig, {}); - const [state, setState] = useState(addState.onGetFilterState(sQuoConfig, true)); const { formData = [], masterConfig } = state; const { bLinkFieledClick } = props; @@ -199,7 +197,6 @@ const QuickQuoteEvent = props => { sBackProcessData, }; }); - setState(pre => { return { ...pre, slaveData: slaveDataNew }; }); @@ -275,8 +272,8 @@ const QuickQuoteEvent = props => { // } if (name === "master") { - const { showName: sTreeNodeName } = selectedNode; - + + const { showName: sTreeNodeName } = selectedNode || {}; const masterDataNew = { ...masterData, ...changeValue }; masterDataNew.handleType = masterDataNew.handleType || "update"; masterDataNew.sId = masterDataNew.sId || commonUtils.createSid(); @@ -287,9 +284,9 @@ const QuickQuoteEvent = props => { dProductQty: changeValue.dProductQty, })); } - if (sFieldName === "dLength" || sFieldName === "dWidth" || sFieldName === "dHeight") { - if (props.currentBoxModel) { + if (sTreeNodeName) { + if (props.currentBoxModel) { const boxModel = props.currentBoxModel.replace("slaveUp", "").replace("slaveDown", ""); const iIndex = slaveData.findIndex(item => item.sTreeNodeName === sTreeNodeName && item.sBoxModel === boxModel); const sColumnNameConfig = commonUtils.convertStrToObj(slaveData[iIndex].sColumnNameConfig, []).map(item => ({ @@ -300,18 +297,22 @@ const QuickQuoteEvent = props => { ...slaveData[iIndex], upAbleConfigsExtra: sColumnNameConfig, }; + } else { + if (!slaveData[0]) return; + const sColumnNameConfig = commonUtils.convertStrToObj(slaveData[0].sColumnNameConfig, []).map(item => ({ + ...item, + iColValue: item.iColValue || 6, + })); + slaveData[0] = { + ...slaveData[0], + upAbleConfigsExtra: sColumnNameConfig, + }; + } } else { - if (!slaveData[0]) return; - const sColumnNameConfig = commonUtils.convertStrToObj(slaveData[0].sColumnNameConfig, []).map(item => ({ - ...item, - iColValue: item.iColValue || 6, - })); - slaveData[0] = { - ...slaveData[0], - upAbleConfigsExtra: sColumnNameConfig, - }; + masterDataNew[sFieldName] = changeValue[sFieldName]; } } + setState(pre => ({ ...pre, masterData: masterDataNew, ...extraState })); } else if (name.includes("slave")) { const boxModel = name.replace("slaveUp", "").replace("slaveDown", ""); @@ -566,6 +567,7 @@ const QuickQuoteEvent = props => { } setState(pre => ({ ...pre, masterData: masterDataNew, ...extraState })); } + }; addState.onDataChange = onDataChange; @@ -1063,6 +1065,8 @@ const QuickQuoteEvent = props => { processPrintDataRow.sParentId = masterData.sId; processPrintDataRow.sControlId = partsDataRow.sId; // processPrintDataRow.sSlaveId = ' '; + processPrintDataRow.sColorSerialMemo = JSON.stringify([{ sId: partInfo.sColorId, sName: partInfo.sColor, dColor: partInfo.iColor }]); + processData.push(processPrintDataRow); // 配套工序 if (bProcessAssort) { @@ -1126,6 +1130,9 @@ const QuickQuoteEvent = props => { } // processAfterDataRow.sSlaveId = ' '; + if (process.sColor) { + processAfterDataRow.sColorSerialMemo = JSON.stringify([{ sId: process.sColorId, sName: process.sColor, dColor: process.iColor }]); + } processData.push(processAfterDataRow); // 配套工序 if (bProcessAssort) { @@ -1338,6 +1345,7 @@ const QuickQuoteEvent = props => { // 入口 const QuickQuote = baseProps => { const props = QuickQuoteEvent(baseProps); + const [treeClassName, setTreeClassName] = useState(""); // 监听页面滚动事件 @@ -1376,6 +1384,7 @@ const QuickQuote = baseProps => { // 树形组件 const TreeComponent = props => { + const { treeData = [], selectedNode = {}, slaveConfig } = props.state; if (!treeData.length) return ""; @@ -1500,7 +1509,7 @@ const TreeComponent = props => { ...addState, sPrintConfig: downAbleConfigs.find(item => item.sType === "1" && item.sName === "胶印"), downAbleConfigs: downAbleConfigs - .filter(item => item.sType === "2") + .filter(item => item.sType === "2" || item.sType === "0") .map((item, index) => ({ ...item, sName: `sParams${index}`, @@ -1527,7 +1536,6 @@ const TreeComponent = props => { masterData: { ...props.masterData, sFormId: "101251240115016076506222050" }, }); } - console.log(selectedNode, 'selectedNode'); getDropDownData(props); }, [selectedNode.sId, commonUtils.isEmptyObject(slaveConfig)]); @@ -1577,15 +1585,17 @@ const ContentComponent = props => { sAllPartsName = showName; } const hasAutoSetDefault = useRef(false); + useEffect(() => { hasAutoSetDefault.current = false; }, [selectedNode]); // 2. 监听两个依赖:sAllPartsNameDefault 与 slaveData + const {sBillNo} = props.masterData useEffect(() => { if ( !hasAutoSetDefault.current && // 尚未执行 selectedNode?.sAllPartsNameDefault?.length && // 有默认值 - props.state.slaveData?.length // 子表数据已就位 + props.state.slaveData?.length && !sBillNo // 子表数据已就位 ) { const boxModelList = sAllPartsName.split(','); const { slaveData } = props.state; @@ -1636,7 +1646,6 @@ const ContentComponent = props => { }); } }, [selectedNode?.sAllPartsNameDefault, props.state.slaveData]); - const boxModelList = sAllPartsName.split(","); const [activeKey, setActiveKey] = useState(0); @@ -1741,8 +1750,10 @@ const ContentComponent = props => { // 主表组件 const MasterComponent = props => { + const { masterConfig, masterData = {}, selectedNode = {} } = props.state; const { app } = props; + if (!masterConfig) return ""; const { userinfo } = app; @@ -1762,12 +1773,7 @@ const MasterComponent = props => { } }); const JosnAbleConfigs = JSON.parse(JSON.stringify(ableConfigs)); - // 处理长宽样式 - // selectedNode?.bBox && selectedNode.sTypeKey !== "kapai" && selectedNode?.bBox && selectedNode.sProductType !== "不干胶" - // ? ableConfigs - // : ableConfigs.filter(x => x.sName !== "dHeight"); const { sStripType = 0 } = selectedNode; - // {"0":"长宽高","1":"高宽"} ,0显示长宽高,1显示宽高 const viewConfigs = Number(sStripType) === 0 ? JosnAbleConfigs : JosnAbleConfigs.filter(x => x.sName !== "dHeight"); if (Number(sStripType) === 0) { viewConfigs.forEach(item => { @@ -1797,6 +1803,7 @@ const MasterComponent = props => { } } } + const viewProps = { ...props, viewConfigs: viewConfigs, @@ -1836,6 +1843,7 @@ const MasterComponent = props => { // 盒型组件 const BoxComponent = props => { + const { dividerProps, state, boxModel } = props; const { masterData = {}, @@ -1851,6 +1859,7 @@ const BoxComponent = props => { const { bBox } = selectedNode; const [boxTypeList, setBoxTypeList] = useState([]); + const sQuoConfig = commonUtils.convertStrToObj(props.masterData.sQuoConfig, {}); // 卡牌类卷筒类默认使用矩形 当是核价保存过的需要在主表数据加载完后在赋值 let slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === boxModel) || {}; const { sBillNo } = slaveRowData; @@ -2080,7 +2089,6 @@ const BoxComponent = props => { // const upViewProps11 = getUpViewPropsByITag(11); // 印刷参数表单 let upViewProps12 = getUpViewPropsByITag(12); - const filterConditions = { juantong: x => x.sName === "iPage" || @@ -2106,7 +2114,8 @@ const BoxComponent = props => { } // 拼板信息表单 - const upViewProps20 = getUpViewPropsByITag(20); + let upViewProps20 = getUpViewPropsByITag(20); + // 如果是卷筒类需要单独处理 const { sBackProcessData = [] } = slaveRowData; @@ -2277,7 +2286,7 @@ const BoxComponent = props => { })), tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs }, iColValueView: 24, - viewRow: masterData, + viewRow: { ...masterData, sId : masterData.sId || "123" }, getViewRow: config => { return productProcessInfo.find(item => item[config.sName]) || {}; }, @@ -2325,7 +2334,18 @@ const BoxComponent = props => { const [materialLength, setMaterialLength] = useState(0); const [materialWidth, setMaterialWidth] = useState(0); - // 使用 useCallback 确保回调函数的稳定性 + // 使用 防抖防止输出数据错误 + const debounceTimer = useRef(null); + + const debouncedHandleSaveState = useCallback( + (...args) => { + clearTimeout(debounceTimer.current); + debounceTimer.current = setTimeout(() => { + handleSaveState(...args); + }, 500); + }, + [handleSaveState] + ); const handleSaveState = ( length, width, @@ -2346,12 +2366,7 @@ const BoxComponent = props => { ) => { // 查找符合条件的索引 const { selectedNode } = props.state; - const index = slaveData?.findIndex(x => x.sTreeNodeName === selectedNode.showName && x.sBoxModel === props.boxModel); - // 判断展长展宽是否可以放下原纸 - const isDPartsLength = - slaveData[index]?.dPartsLength < slaveData[index]?.dMaxLength && slaveData[index]?.dPartsWidth < slaveData[index]?.dMaxWidth; - const dProductQtys = props.state.masterData.dProductQty || 0; if (index !== undefined && index !== -1) { // 计算开数 // 获取原始对象并创建一个新的对象进行更新 @@ -2359,8 +2374,8 @@ const BoxComponent = props => { ...slaveData[index], materialLength: dWlcd, materialWidth: dWlkd, - dMachineLength: length, // 上机长 - dMachineWidth: width, // 上机宽 + dMachineLength: dWlcd, // 上机长 + dMachineWidth: dWlkd, // 上机宽 sMaterialsStyle: `${slaveData[index]?.dWlcd || 0}*${slaveData[index]?.dWlkd || 0}`, // 原纸尺寸 sMachineStyle: `${length || slaveData[index].materialLength}*${width || slaveData[index].materialWidth}`, // 开料尺寸为计算的排版尺寸 sMaterialRate: (((length * width) / (slaveData[index].dWlcd * slaveData[index].dWlkd)) * 100).toFixed(2), @@ -2405,10 +2420,12 @@ const BoxComponent = props => { ...juantongConfig, }; // 更新状态 - props.setState(prevState => ({ - ...prevState, - slaveData: slaveData.map((item, i) => (i === index ? newSlaveData : item)), - })); + setTimeout(() => { + props.setState(prevState => ({ + ...prevState, + slaveData: slaveData.map((item, i) => (i === index ? newSlaveData : item)), + })); + }, 200); } setMaterialLength(length); @@ -2459,12 +2476,13 @@ const BoxComponent = props => { slaveRowData.sName === "卡牌" ) { const slaveNewData = slaveRowData.upAbleConfigsExtra || JSON.parse(slaveRowData.sColumnNameConfig); + const slaveRowDatas = sBillNo ? sQuoConfig?.slaveData?.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === boxModel) || {} : slaveRowData; const tables = [ { name: "盒型类别", value: slaveRowData.sBoxType, type: null }, { name: "盒身", value: slaveRowData.sBoxBody, type: slaveRowData.sTypes }, { name: "盒长", value: slaveRowData.dL ? slaveRowData.dL : masterData.dLength ? Number(masterData.dLength) : 0, type: null }, { name: "盒宽", value: slaveRowData.dW ? slaveRowData.dW : masterData.dWidth ? Number(masterData.dWidth) : 0, type: null }, - { name: "盒高", value: masterData.dHeight ? Number(masterData.dHeight) : 0, type: null }, + { name: "盒高", value: slaveRowData.dD ? slaveRowData.dD : masterData.dHeight ? Number(masterData.dHeight) : 0, type: null }, ]; const titleList1 = [ { name: "上方盒舌", value: "dSFHS" }, @@ -2517,7 +2535,7 @@ const BoxComponent = props => { slaveNewData.forEach(x => { let key = 0; if (x.sAssignFormula) { - key = evaluateFormula(x.sAssignFormula, variables); + key = sBillNo ? slaveRowData[x.sName] : evaluateFormula(x.sAssignFormula, variables); slaveRowData[x.sName] = key; } else { if (x.sTypes && x.sTypes.includes('09')) { @@ -2578,7 +2596,6 @@ const BoxComponent = props => { dSvgBoxHeight: 200, showNew: 1, }; - // upViewProps.viewRow = const isShowImg = boxList.find(x => x.sName === "盒身")?.type !== "" || false; @@ -2771,7 +2788,7 @@ const BoxComponent = props => {
- +
@@ -2914,7 +2931,6 @@ const PrintParamsComponent = props => { })); }, }; - result.push(
@@ -3613,7 +3629,7 @@ const BackendParamsExtraComponent = props => { ...props, viewConfigs: viewConfigs.map(item => ({ ...item, - costomStyle: styles.sParamConfig, + costomStyle: `${styles.sParamConfig} ${item.showName?.length > 4 ? 'sParamConfigLong' : ""}`, })), tableConfig: { ...slaveConfig, gdsconfigformslave: viewConfigs }, iColValueView: 24, @@ -3629,9 +3645,31 @@ const BackendParamsExtraComponent = props => { ); }, tableName: `sBackendParams${sBoxModel}`, - getSqlDropDownData: (...args) => { + getSqlDropDownData: async (...args) => { const showConfig = args[2]; - const { sParamDropDown = "", sName } = showConfig; + const { sDropDownType, sParamDropDown = "", sName, sFieldName } = showConfig; + if (sDropDownType === "sql" && sParamDropDown?.toLowerCase()?.includes("select")) { + args[2] = { + ...showConfig, + showDropDown: sParamDropDown, + }; + delete args[2].sId; + const result = await props.getSqlDropDownData(...args); + const { dropDownData } = result; + const temp = { + ...result, + dropDownData: dropDownData.map(item => ({ + ...item, + // sId: item.sValue, + value: item.sValue, + sParam: showConfig.sParam, + [sName]: item.sValue, + sParamKey: sName, + sFieldName, + })), + }; + return temp; + } const dropDownData = sParamDropDown.split(","); if (dropDownData?.length) { return { @@ -3747,6 +3785,7 @@ const GetBestAlgorithm = props => { sSvgPath, dL = 0, dW = 0, + dD = 0, } = slaveRowData; if (selectedNode && selectedNode.sTypeKey === "juantong") { dXBLB = dSBLB; @@ -3762,8 +3801,8 @@ const GetBestAlgorithm = props => { let outerHeight = Number(slaveDataDetail?.dMaxWidth); // 默认取最大上机尺寸 const L = slaveRowData.dL ? Number(dL) : Number(masterData?.dLength) || 0; const W = slaveRowData.dW ? Number(dW) : masterData?.dWidth || 0; - const H = masterData?.dWidth || 0; - const D = masterData?.dHeight || 0; + const H = slaveRowData.dD ? Number(dD) : masterData?.dWidth || 0; + const D = slaveRowData.dD ? Number(dD) : masterData?.dHeight || 0; // 动态计算公式值 const evaluateFormula = (formula, variables) => { if (!formula) return 0; // 如果公式为空,返回0 diff --git a/src/routes/mobile/IndexMobile.js b/src/routes/mobile/IndexMobile.js index b683d36..db3d0b7 100644 --- a/src/routes/mobile/IndexMobile.js +++ b/src/routes/mobile/IndexMobile.js @@ -96,15 +96,19 @@ class IndexMobile extends React.Component { } componentDidMount() { // 监听系统返回键 + const bExitAgain = commonFunc.showLocalMessage(this.props, 'bExitAgain', '再按一次退出应用'); const { plus } = window; plus?.key?.addEventListener('backbutton', () => { if (location.pathname === '/indexMobile') { // 首页双击返回 if (this.backPressedOnce) { - plus.runtime.quit(); + // 把应用切换到后台运行 + // plus.runtime.quit(); // 直接退出应用 + const main = plus?.android?.runtimeMainActivity(); + main?.moveTaskToBack(false); // false:仅隐藏,不销毁 } else { this.backPressedOnce = true; - plus.nativeUI.toast('再按一次退出应用'); + plus.nativeUI.toast(bExitAgain); setTimeout(() => { this.backPressedOnce = false; }, 2000); } } else { -- libgit2 0.22.2