Commit 9af7a5d6c9545e63695f57b3d5b1696c03a674f9

Authored by 陈鑫涛
2 parents a8d427f4 94d79e64

Merge branch 'main' of http://git.xlyprint.cn/zhangz/xlyUmi into main

src/components/QuickQuote/index.jsx
... ... @@ -491,7 +491,31 @@ const QuickQuoteEvent = props => {
491 491 } else if (name === "finished") {
492 492 const { productProcessInfo = [] } = masterData;
493 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 519 const iIndex = productProcessInfo.findIndex(item => item.sProductClassifyId === dropDownData[0].sProductClassifyId);
496 520 if (iIndex === -1) {
497 521 dropDownDataSelected !== undefined && productProcessInfo.push(dropDownDataSelected);
... ... @@ -687,7 +711,7 @@ const QuickQuoteEvent = props => {
687 711  
688 712 const errMsgList = [];
689 713 const masterConfigMust = masterConfig?.gdsconfigformslave.filter(item => item.bVisible && item.bNotEmpty);
690   - if (!masterConfigMust) return
  714 + if (!masterConfigMust) return;
691 715 const checkResult = masterConfigMust.filter(item => !masterData[item.sName]);
692 716 if (checkResult.length) {
693 717 errMsgList.push(
... ... @@ -1091,6 +1115,18 @@ const QuickQuoteEvent = props => {
1091 1115 processProductDataRow.iOrder = iOrder + 1;
1092 1116 processProductDataRow.sId = commonUtils.createSid();
1093 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 1130 // processProductDataRow.sSlaveId = ' ';
1095 1131 processData.push(processProductDataRow);
1096 1132 // 配套工序
... ... @@ -1997,7 +2033,10 @@ const BoxComponent = props => {
1997 2033 const { productProcessInfo = [] } = masterData;
1998 2034 const finishedViewProps = {
1999 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 2040 tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs },
2002 2041 iColValueView: 24,
2003 2042 viewRow: masterData,
... ... @@ -2023,6 +2062,17 @@ const BoxComponent = props => {
2023 2062  
2024 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 2078 const boxProps = {
... ... @@ -2770,37 +2820,36 @@ const ManyComponent = props => {
2770 2820 // 核价事件
2771 2821 const onCalcPrice = () => {
2772 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 2825 if (bBox && activeKey === 0) {
2776 2826 const radios = GetBestAlgorithm(props);
2777 2827 slaveData[boxModelKey] = {
2778 2828 ...slaveData[boxModelKey],
2779 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 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 2845 // setTimeout(() => {
2796 2846  
2797 2847 // }, 500);
2798   -
2799 2848 };
2800   - const { bestAlgorithm,onCalcPrices } = state;
  2849 + const { bestAlgorithm, onCalcPrices } = state;
2801 2850 useEffect(() => {
2802   - if (!bestAlgorithm) return
2803   - if (!onCalcPrices) return
  2851 + if (!bestAlgorithm) return;
  2852 + if (!onCalcPrices) return;
2804 2853 const addState = {
2805 2854 ...props.onGetAllDelData(),
2806 2855 manyDataCache: [],
... ... @@ -2811,7 +2860,7 @@ const ManyComponent = props => {
2811 2860 calcPriceTime: commonUtils.createSid(),
2812 2861 ...addState,
2813 2862 });
2814   - }, [bestAlgorithm,onCalcPrices]);
  2863 + }, [bestAlgorithm, onCalcPrices]);
2815 2864 useEffect(() => {
2816 2865 if (props.calcPriceTime) {
2817 2866 props.onSaveState({ calcPriceTime: undefined });
... ... @@ -3246,7 +3295,8 @@ const BoxModelSelectedModal = props => {
3246 3295 // 后道参数额外配置
3247 3296 const BackendParamsExtraComponent = props => {
3248 3297 const { state, slaveConfig } = props;
3249   - const { backendParamsConfig = [], backendConfig = {}, slaveData, selectedNode } = state;
  3298 + const { backendParamsConfig = [], backendConfig = {}, slaveData, selectedNode, masterData = {} } = state;
  3299 +
3250 3300 if (!backendParamsConfig.length) return "";
3251 3301  
3252 3302 const { sParentFieldsName, sBoxModel, printParamsId } = backendConfig;
... ... @@ -3254,7 +3304,9 @@ const BackendParamsExtraComponent = props => {
3254 3304 const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === sBoxModel) || {};
3255 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 3311 const viewConfigs = backendParamsConfig.map(item => ({
3260 3312 ...item,
... ... @@ -3277,7 +3329,11 @@ const BackendParamsExtraComponent = props => {
3277 3329 if (sParentFieldsName === "sPrint") {
3278 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 3338 tableName: `sBackendParams${sBoxModel}`,
3283 3339 getSqlDropDownData: (...args) => {
... ... @@ -3322,7 +3378,9 @@ const BackendParamsExtraComponent = props => {
3322 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 3384 const showConfig = viewConfigs.find(item => item.sName === sFieldName);
3327 3385 const dropDownDataSelected = dropDownData?.length
3328 3386 ? dropDownData.find(item => item.sId === changeValue[sFieldName])
... ... @@ -3335,22 +3393,29 @@ const BackendParamsExtraComponent = props => {
3335 3393 if (!dropDownDataSelected) return;
3336 3394 dropDownDataSelected[sFieldName] = dropDownDataSelected.value;
3337 3395 const { sParam } = dropDownDataSelected;
3338   - const { sBackendParams = [] } = slaveData[iIndex].sBackProcessData[iIndex1];
  3396 + const { sBackendParams = [] } = sBData[iIndex1];
3339 3397 const iIndex2 = sBackendParams.findIndex(item => item.sParam === sParam);
3340 3398 if (iIndex2 !== -1) {
3341 3399 sBackendParams[iIndex2] = dropDownDataSelected;
3342 3400 } else {
3343 3401 sBackendParams.push(dropDownDataSelected);
3344 3402 }
3345   - slaveData[iIndex].sBackProcessData[iIndex1].sBackendParams = sBackendParams;
  3403 + sBData[iIndex1].sBackendParams = sBackendParams;
3346 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 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  
... ...