Commit 94d79e64083ef25aa2a2534b336c0a1a863a0b46
1 parent
1d6da65a
新增成品工序额外参数配置;
Showing
1 changed file
with
97 additions
and
32 deletions
src/components/QuickQuote/index.jsx
| @@ -491,7 +491,31 @@ const QuickQuoteEvent = props => { | @@ -491,7 +491,31 @@ const QuickQuoteEvent = props => { | ||
| 491 | } else if (name === "finished") { | 491 | } else if (name === "finished") { |
| 492 | const { productProcessInfo = [] } = masterData; | 492 | const { productProcessInfo = [] } = masterData; |
| 493 | const dropDownDataSelected = dropDownData.find(item => item.sId === changeValue[sFieldName]); | 493 | const dropDownDataSelected = dropDownData.find(item => item.sId === changeValue[sFieldName]); |
| 494 | - dropDownDataSelected && (dropDownDataSelected[sFieldName] = dropDownDataSelected.sProcessName); | 494 | + if (dropDownDataSelected !== undefined) { |
| 495 | + dropDownDataSelected[sFieldName] = dropDownDataSelected.sProcessName; | ||
| 496 | + // 后道参数额外配置 | ||
| 497 | + const { sParamConfig: sParamConfigStr } = dropDownDataSelected || {}; | ||
| 498 | + const sParamConfig = commonUtils.convertStrToObj(sParamConfigStr, []); | ||
| 499 | + extraState.backendParamsConfig = sParamConfig; | ||
| 500 | + extraState.backendConfig = { sParentFieldsName: sFieldName }; | ||
| 501 | + const sBackendParams = sParamConfig | ||
| 502 | + .map(item => { | ||
| 503 | + const { sParamDefault, sParam, sFieldName, iOrder } = item; | ||
| 504 | + return !sParamDefault | ||
| 505 | + ? "" | ||
| 506 | + : { | ||
| 507 | + sId: commonUtils.createSid(), | ||
| 508 | + value: sParamDefault, | ||
| 509 | + sParam: sParam, | ||
| 510 | + [`sParam${iOrder}`]: sParamDefault, | ||
| 511 | + ...(sFieldName ? { [sFieldName]: sParamDefault } : {}), | ||
| 512 | + sParamKey: sFieldName || `sParam${iOrder}`, | ||
| 513 | + }; | ||
| 514 | + }) | ||
| 515 | + .filter(item => item !== ""); | ||
| 516 | + dropDownDataSelected.sBackendParams = sBackendParams; | ||
| 517 | + } | ||
| 518 | + | ||
| 495 | const iIndex = productProcessInfo.findIndex(item => item.sProductClassifyId === dropDownData[0].sProductClassifyId); | 519 | const iIndex = productProcessInfo.findIndex(item => item.sProductClassifyId === dropDownData[0].sProductClassifyId); |
| 496 | if (iIndex === -1) { | 520 | if (iIndex === -1) { |
| 497 | dropDownDataSelected !== undefined && productProcessInfo.push(dropDownDataSelected); | 521 | dropDownDataSelected !== undefined && productProcessInfo.push(dropDownDataSelected); |
| @@ -687,7 +711,7 @@ const QuickQuoteEvent = props => { | @@ -687,7 +711,7 @@ const QuickQuoteEvent = props => { | ||
| 687 | 711 | ||
| 688 | const errMsgList = []; | 712 | const errMsgList = []; |
| 689 | const masterConfigMust = masterConfig?.gdsconfigformslave.filter(item => item.bVisible && item.bNotEmpty); | 713 | const masterConfigMust = masterConfig?.gdsconfigformslave.filter(item => item.bVisible && item.bNotEmpty); |
| 690 | - if (!masterConfigMust) return | 714 | + if (!masterConfigMust) return; |
| 691 | const checkResult = masterConfigMust.filter(item => !masterData[item.sName]); | 715 | const checkResult = masterConfigMust.filter(item => !masterData[item.sName]); |
| 692 | if (checkResult.length) { | 716 | if (checkResult.length) { |
| 693 | errMsgList.push( | 717 | errMsgList.push( |
| @@ -1091,6 +1115,18 @@ const QuickQuoteEvent = props => { | @@ -1091,6 +1115,18 @@ const QuickQuoteEvent = props => { | ||
| 1091 | processProductDataRow.iOrder = iOrder + 1; | 1115 | processProductDataRow.iOrder = iOrder + 1; |
| 1092 | processProductDataRow.sId = commonUtils.createSid(); | 1116 | processProductDataRow.sId = commonUtils.createSid(); |
| 1093 | processProductDataRow.sParentId = masterData.sId; | 1117 | processProductDataRow.sParentId = masterData.sId; |
| 1118 | + | ||
| 1119 | + const sBackendParams = process.sBackendParams || []; | ||
| 1120 | + if (sBackendParams.length) { | ||
| 1121 | + const sQuoParams = sBackendParams.map(item => ({ | ||
| 1122 | + sParamKey: item.sParamKey, | ||
| 1123 | + sParamName: item.sParam, | ||
| 1124 | + sParamValue: item.value !== undefined ? item.value : "", | ||
| 1125 | + bSelfCbx: !(item.value === "" || item.value === undefined), | ||
| 1126 | + })); | ||
| 1127 | + processProductDataRow.sQuoParams = JSON.stringify(sQuoParams); | ||
| 1128 | + } | ||
| 1129 | + | ||
| 1094 | // processProductDataRow.sSlaveId = ' '; | 1130 | // processProductDataRow.sSlaveId = ' '; |
| 1095 | processData.push(processProductDataRow); | 1131 | processData.push(processProductDataRow); |
| 1096 | // 配套工序 | 1132 | // 配套工序 |
| @@ -1997,7 +2033,10 @@ const BoxComponent = props => { | @@ -1997,7 +2033,10 @@ const BoxComponent = props => { | ||
| 1997 | const { productProcessInfo = [] } = masterData; | 2033 | const { productProcessInfo = [] } = masterData; |
| 1998 | const finishedViewProps = { | 2034 | const finishedViewProps = { |
| 1999 | ...props, | 2035 | ...props, |
| 2000 | - viewConfigs: finishedConfigs, | 2036 | + viewConfigs: finishedConfigs.map(config => ({ |
| 2037 | + ...config, | ||
| 2038 | + costomStyle: productProcessInfo.find(item => item[config.sName])?.sParamConfig ? styles.sParamConfig : "", | ||
| 2039 | + })), | ||
| 2001 | tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs }, | 2040 | tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs }, |
| 2002 | iColValueView: 24, | 2041 | iColValueView: 24, |
| 2003 | viewRow: masterData, | 2042 | viewRow: masterData, |
| @@ -2023,6 +2062,17 @@ const BoxComponent = props => { | @@ -2023,6 +2062,17 @@ const BoxComponent = props => { | ||
| 2023 | 2062 | ||
| 2024 | return props.getSqlDropDownData(...args); | 2063 | return props.getSqlDropDownData(...args); |
| 2025 | }, | 2064 | }, |
| 2065 | + onCostomClick: (showConfig, { target }) => { | ||
| 2066 | + const className = target.getAttribute("class"); | ||
| 2067 | + const nodeName = target.nodeName; | ||
| 2068 | + if (className?.includes("select") && nodeName === "DIV") return; | ||
| 2069 | + | ||
| 2070 | + props.setState(pre => ({ | ||
| 2071 | + ...pre, | ||
| 2072 | + backendParamsConfig: commonUtils.convertStrToObj(productProcessInfo.find(item => item[showConfig.sName])?.sParamConfig, []), | ||
| 2073 | + backendConfig: { sParentFieldsName: showConfig.sName }, | ||
| 2074 | + })); | ||
| 2075 | + }, | ||
| 2026 | }; | 2076 | }; |
| 2027 | 2077 | ||
| 2028 | const boxProps = { | 2078 | const boxProps = { |
| @@ -2770,37 +2820,36 @@ const ManyComponent = props => { | @@ -2770,37 +2820,36 @@ const ManyComponent = props => { | ||
| 2770 | // 核价事件 | 2820 | // 核价事件 |
| 2771 | const onCalcPrice = () => { | 2821 | const onCalcPrice = () => { |
| 2772 | const { state } = props; | 2822 | const { state } = props; |
| 2773 | - const { masterData = {}, slaveConfig, slaveData = [], selectedNode = {}, backendConfig = {}, boxModelKey = 0, bestAlgorithm,activeKey } = state; | ||
| 2774 | - const {bBox} = selectedNode | 2823 | + const { masterData = {}, slaveConfig, slaveData = [], selectedNode = {}, backendConfig = {}, boxModelKey = 0, bestAlgorithm, activeKey } = state; |
| 2824 | + const { bBox } = selectedNode; | ||
| 2775 | if (bBox && activeKey === 0) { | 2825 | if (bBox && activeKey === 0) { |
| 2776 | const radios = GetBestAlgorithm(props); | 2826 | const radios = GetBestAlgorithm(props); |
| 2777 | slaveData[boxModelKey] = { | 2827 | slaveData[boxModelKey] = { |
| 2778 | ...slaveData[boxModelKey], | 2828 | ...slaveData[boxModelKey], |
| 2779 | radioValue: radios.sCode, | 2829 | radioValue: radios.sCode, |
| 2780 | }; | 2830 | }; |
| 2781 | - props.setState(pre => ({ ...pre, slaveData, bestAlgorithm: commonUtils.createSid(),onCalcPrices:true })); | 2831 | + props.setState(pre => ({ ...pre, slaveData, bestAlgorithm: commonUtils.createSid(), onCalcPrices: true })); |
| 2782 | } else { | 2832 | } else { |
| 2783 | - const addState = { | ||
| 2784 | - ...props.onGetAllDelData(), | ||
| 2785 | - manyDataCache: [], | ||
| 2786 | - }; | ||
| 2787 | - props.onSaveState({ | ||
| 2788 | - masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" }, | ||
| 2789 | - calcPriceTime: commonUtils.createSid(), | ||
| 2790 | - ...addState, | ||
| 2791 | - }); | ||
| 2792 | - props.setState(pre => ({ ...pre,onCalcPrices:false })); | 2833 | + const addState = { |
| 2834 | + ...props.onGetAllDelData(), | ||
| 2835 | + manyDataCache: [], | ||
| 2836 | + }; | ||
| 2837 | + props.onSaveState({ | ||
| 2838 | + masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" }, | ||
| 2839 | + calcPriceTime: commonUtils.createSid(), | ||
| 2840 | + ...addState, | ||
| 2841 | + }); | ||
| 2842 | + props.setState(pre => ({ ...pre, onCalcPrices: false })); | ||
| 2793 | } | 2843 | } |
| 2794 | - | 2844 | + |
| 2795 | // setTimeout(() => { | 2845 | // setTimeout(() => { |
| 2796 | 2846 | ||
| 2797 | // }, 500); | 2847 | // }, 500); |
| 2798 | - | ||
| 2799 | }; | 2848 | }; |
| 2800 | - const { bestAlgorithm,onCalcPrices } = state; | 2849 | + const { bestAlgorithm, onCalcPrices } = state; |
| 2801 | useEffect(() => { | 2850 | useEffect(() => { |
| 2802 | - if (!bestAlgorithm) return | ||
| 2803 | - if (!onCalcPrices) return | 2851 | + if (!bestAlgorithm) return; |
| 2852 | + if (!onCalcPrices) return; | ||
| 2804 | const addState = { | 2853 | const addState = { |
| 2805 | ...props.onGetAllDelData(), | 2854 | ...props.onGetAllDelData(), |
| 2806 | manyDataCache: [], | 2855 | manyDataCache: [], |
| @@ -2811,7 +2860,7 @@ const ManyComponent = props => { | @@ -2811,7 +2860,7 @@ const ManyComponent = props => { | ||
| 2811 | calcPriceTime: commonUtils.createSid(), | 2860 | calcPriceTime: commonUtils.createSid(), |
| 2812 | ...addState, | 2861 | ...addState, |
| 2813 | }); | 2862 | }); |
| 2814 | - }, [bestAlgorithm,onCalcPrices]); | 2863 | + }, [bestAlgorithm, onCalcPrices]); |
| 2815 | useEffect(() => { | 2864 | useEffect(() => { |
| 2816 | if (props.calcPriceTime) { | 2865 | if (props.calcPriceTime) { |
| 2817 | props.onSaveState({ calcPriceTime: undefined }); | 2866 | props.onSaveState({ calcPriceTime: undefined }); |
| @@ -3246,7 +3295,8 @@ const BoxModelSelectedModal = props => { | @@ -3246,7 +3295,8 @@ const BoxModelSelectedModal = props => { | ||
| 3246 | // 后道参数额外配置 | 3295 | // 后道参数额外配置 |
| 3247 | const BackendParamsExtraComponent = props => { | 3296 | const BackendParamsExtraComponent = props => { |
| 3248 | const { state, slaveConfig } = props; | 3297 | const { state, slaveConfig } = props; |
| 3249 | - const { backendParamsConfig = [], backendConfig = {}, slaveData, selectedNode } = state; | 3298 | + const { backendParamsConfig = [], backendConfig = {}, slaveData, selectedNode, masterData = {} } = state; |
| 3299 | + | ||
| 3250 | if (!backendParamsConfig.length) return ""; | 3300 | if (!backendParamsConfig.length) return ""; |
| 3251 | 3301 | ||
| 3252 | const { sParentFieldsName, sBoxModel, printParamsId } = backendConfig; | 3302 | const { sParentFieldsName, sBoxModel, printParamsId } = backendConfig; |
| @@ -3254,7 +3304,9 @@ const BackendParamsExtraComponent = props => { | @@ -3254,7 +3304,9 @@ const BackendParamsExtraComponent = props => { | ||
| 3254 | const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === sBoxModel) || {}; | 3304 | const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === sBoxModel) || {}; |
| 3255 | const { sBackProcessData = [] } = slaveRowData; | 3305 | const { sBackProcessData = [] } = slaveRowData; |
| 3256 | 3306 | ||
| 3257 | - if (sParentFieldsName !== "sPrint" && !sBackProcessData.some(item => item[sParentFieldsName])) return ""; | 3307 | + const { productProcessInfo = [] } = masterData; |
| 3308 | + | ||
| 3309 | + if (sParentFieldsName !== "sPrint" && ![...sBackProcessData, ...productProcessInfo].some(item => item[sParentFieldsName])) return ""; | ||
| 3258 | 3310 | ||
| 3259 | const viewConfigs = backendParamsConfig.map(item => ({ | 3311 | const viewConfigs = backendParamsConfig.map(item => ({ |
| 3260 | ...item, | 3312 | ...item, |
| @@ -3277,7 +3329,11 @@ const BackendParamsExtraComponent = props => { | @@ -3277,7 +3329,11 @@ const BackendParamsExtraComponent = props => { | ||
| 3277 | if (sParentFieldsName === "sPrint") { | 3329 | if (sParentFieldsName === "sPrint") { |
| 3278 | return [slaveRowData, ...sBackProcessData].find(item => item.sId === printParamsId); | 3330 | return [slaveRowData, ...sBackProcessData].find(item => item.sId === printParamsId); |
| 3279 | } | 3331 | } |
| 3280 | - return sBackProcessData.find(item => item[sParentFieldsName])?.sBackendParams?.find(item => item.sParam === config.showName) || {}; | 3332 | + return ( |
| 3333 | + [...sBackProcessData, ...productProcessInfo] | ||
| 3334 | + .find(item => item[sParentFieldsName]) | ||
| 3335 | + ?.sBackendParams?.find(item => item.sParam === config.showName) || {} | ||
| 3336 | + ); | ||
| 3281 | }, | 3337 | }, |
| 3282 | tableName: `sBackendParams${sBoxModel}`, | 3338 | tableName: `sBackendParams${sBoxModel}`, |
| 3283 | getSqlDropDownData: (...args) => { | 3339 | getSqlDropDownData: (...args) => { |
| @@ -3322,7 +3378,9 @@ const BackendParamsExtraComponent = props => { | @@ -3322,7 +3378,9 @@ const BackendParamsExtraComponent = props => { | ||
| 3322 | return; | 3378 | return; |
| 3323 | } | 3379 | } |
| 3324 | 3380 | ||
| 3325 | - const iIndex1 = slaveData[iIndex].sBackProcessData.findIndex(item => item[sParentFieldsName]); | 3381 | + const sBData = sBoxModel ? slaveData[iIndex].sBackProcessData : productProcessInfo; |
| 3382 | + | ||
| 3383 | + const iIndex1 = sBData.findIndex(item => item[sParentFieldsName]); | ||
| 3326 | const showConfig = viewConfigs.find(item => item.sName === sFieldName); | 3384 | const showConfig = viewConfigs.find(item => item.sName === sFieldName); |
| 3327 | const dropDownDataSelected = dropDownData?.length | 3385 | const dropDownDataSelected = dropDownData?.length |
| 3328 | ? dropDownData.find(item => item.sId === changeValue[sFieldName]) | 3386 | ? dropDownData.find(item => item.sId === changeValue[sFieldName]) |
| @@ -3335,22 +3393,29 @@ const BackendParamsExtraComponent = props => { | @@ -3335,22 +3393,29 @@ const BackendParamsExtraComponent = props => { | ||
| 3335 | if (!dropDownDataSelected) return; | 3393 | if (!dropDownDataSelected) return; |
| 3336 | dropDownDataSelected[sFieldName] = dropDownDataSelected.value; | 3394 | dropDownDataSelected[sFieldName] = dropDownDataSelected.value; |
| 3337 | const { sParam } = dropDownDataSelected; | 3395 | const { sParam } = dropDownDataSelected; |
| 3338 | - const { sBackendParams = [] } = slaveData[iIndex].sBackProcessData[iIndex1]; | 3396 | + const { sBackendParams = [] } = sBData[iIndex1]; |
| 3339 | const iIndex2 = sBackendParams.findIndex(item => item.sParam === sParam); | 3397 | const iIndex2 = sBackendParams.findIndex(item => item.sParam === sParam); |
| 3340 | if (iIndex2 !== -1) { | 3398 | if (iIndex2 !== -1) { |
| 3341 | sBackendParams[iIndex2] = dropDownDataSelected; | 3399 | sBackendParams[iIndex2] = dropDownDataSelected; |
| 3342 | } else { | 3400 | } else { |
| 3343 | sBackendParams.push(dropDownDataSelected); | 3401 | sBackendParams.push(dropDownDataSelected); |
| 3344 | } | 3402 | } |
| 3345 | - slaveData[iIndex].sBackProcessData[iIndex1].sBackendParams = sBackendParams; | 3403 | + sBData[iIndex1].sBackendParams = sBackendParams; |
| 3346 | if (!showConfig.sName?.startsWith("sParams")) { | 3404 | if (!showConfig.sName?.startsWith("sParams")) { |
| 3347 | - slaveData[iIndex].sBackProcessData[iIndex1][showConfig.sName] = dropDownDataSelected[showConfig.sName]; | ||
| 3348 | - const { dManualLength, dManualWidth } = slaveData[iIndex].sBackProcessData[iIndex1]; | 3405 | + sBData[iIndex1][showConfig.sName] = dropDownDataSelected[showConfig.sName]; |
| 3406 | + const { dManualLength, dManualWidth } = sBData[iIndex1]; | ||
| 3349 | if (dManualLength !== undefined && dManualWidth !== undefined) { | 3407 | if (dManualLength !== undefined && dManualWidth !== undefined) { |
| 3350 | - slaveData[iIndex].sBackProcessData[iIndex1].dManualValue = dManualLength * dManualWidth; | 3408 | + sBData[iIndex1].dManualValue = dManualLength * dManualWidth; |
| 3351 | } | 3409 | } |
| 3352 | } | 3410 | } |
| 3353 | - props.setState(pre => ({ ...pre, slaveData, ...extraState })); | 3411 | + |
| 3412 | + if (sBoxModel) { | ||
| 3413 | + slaveData[iIndex].sBackProcessData = sBData; | ||
| 3414 | + props.setState(pre => ({ ...pre, slaveData, ...extraState })); | ||
| 3415 | + } else { | ||
| 3416 | + masterData.productProcessInfo = sBData; | ||
| 3417 | + props.setState(pre => ({ ...pre, masterData, ...extraState })); | ||
| 3418 | + } | ||
| 3354 | }, | 3419 | }, |
| 3355 | }; | 3420 | }; |
| 3356 | 3421 |