Commit f5da3dfc1496db01a3a881ad5a375b6a12e7b351

Authored by 陈鑫涛
1 parent d5f1f871

快速报价app

src/components/QuickQuote/index.jsx
... ... @@ -436,7 +436,7 @@ const QuickQuoteEvent = props => {
436 436 loading: true,
437 437 },
438 438 () => {
439   - props.onButtonClick("BtnDraft", true);
  439 + props.onButtonClick("BtnDraft");
440 440 }
441 441 );
442 442 };
... ... @@ -763,17 +763,6 @@ const QuickQuoteEvent = props => {
763 763 processAfterDataRow.sId = commonUtils.createSid();
764 764 processAfterDataRow.sParentId = masterData.sId;
765 765 processAfterDataRow.sControlId = partsDataRow.sId;
766   -
767   - const sBackendParams = process.sBackendParams || [];
768   - if (sBackendParams.length) {
769   - const sQuoParams = sBackendParams.map(item => ({
770   - sParamName: item.sParam,
771   - sParamValue: item.value !== undefined ? item.value : "",
772   - bSelfCbx: !(item.value === "" || item.value === undefined),
773   - }));
774   - processAfterDataRow.sQuoParams = JSON.stringify(sQuoParams);
775   - }
776   -
777 766 // processAfterDataRow.sSlaveId = ' ';
778 767 processData.push(processAfterDataRow);
779 768 // 配套工序
... ...
src/mobile/quotation/detailNew.jsx
... ... @@ -858,7 +858,16 @@ const QuickQuoteEvent = props => {
858 858 const masterProps = {
859 859 ...props,
860 860 };
861   - setState(pre => ({ ...pre, newNextProps: { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData } }));
  861 + setState(pre => ({
  862 + ...pre,
  863 + newNextProps: {
  864 + dQuickQuoteProductQty: state.dQuickQuoteProductQty,
  865 + ...masterProps,
  866 + ...newState,
  867 + manyqtysConfig: state.manyConfig,
  868 + manyqtysData: state.manyData,
  869 + },
  870 + }));
862 871 const result = await props.handleCalculation(
863 872 false,
864 873 { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData },
... ... @@ -938,6 +947,8 @@ const QuotationAllprogressDetail = baseProps => {
938 947  
939 948 useEffect(() => {
940 949 const getDropDownData = async props => {
  950 + const showDownConfig = props.state.slaveConfig?.gdsconfigformslave.find(item => item.sControlName === "BtnDownConfig");
  951 + const downAbleConfigs = await getSqlDropDownData({ ...showDownConfig });
941 952 props.setState(pre => {
942 953 const { slaveData = [], slaveConfig } = pre;
943 954 const addState = {};
... ... @@ -972,27 +983,27 @@ const QuotationAllprogressDetail = baseProps => {
972 983 ...pre,
973 984 ...addState,
974 985 masterData: { sProductName: showName, sProductUnit: sUnit, ...masterData },
975   - // downAbleConfigs: downAbleConfigs
976   - // .filter(item => item.sType === "2")
977   - // .map((item, index) => ({
978   - // ...item,
979   - // sName: `sParams${index}`,
980   - // iColValue: item.iColValue || 4,
981   - // sVisColumnName: "sProcessName",
982   - // })),
983   - // finishedConfigs: downAbleConfigs
984   - // .filter(item => item.sType === "3")
985   - // .map((item, index) => ({
986   - // ...item,
987   - // sName: `sParams${index}`,
988   - // iColValue: item.iColValue || 4,
989   - // sVisColumnName: "sProcessName",
990   - // })),
  986 + downAbleConfigs: downAbleConfigs
  987 + .filter(item => item.sType === "2")
  988 + .map((item, index) => ({
  989 + ...item,
  990 + sName: `sParams${index}`,
  991 + iColValue: item.iColValue || 4,
  992 + sVisColumnName: "sProcessName",
  993 + })),
  994 + finishedConfigs: downAbleConfigs
  995 + .filter(item => item.sType === "3")
  996 + .map((item, index) => ({
  997 + ...item,
  998 + sName: `sParams${index}`,
  999 + iColValue: item.iColValue || 4,
  1000 + sVisColumnName: "sProcessName",
  1001 + })),
991 1002 };
992 1003 });
993 1004 };
994 1005 getDropDownData(props);
995   - }, []);
  1006 + }, [props.state.slaveConfig]);
996 1007 const getSqlDropDownData = async ({ sId }) => {
997 1008 const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`;
998 1009 const body = {
... ... @@ -1008,20 +1019,7 @@ const QuotationAllprogressDetail = baseProps => {
1008 1019 // 取上机尺寸
1009 1020 return commonUtils.convertStrToObj(sColumnNameConfigStr, []);
1010 1021 };
1011   - useEffect(() => {
1012   - const getData = async props => {
1013   - const showDownConfig = props.state.slaveConfig?.gdsconfigformslave.find(item => item.sControlName === "BtnDownConfig");
1014   - const downAbleConfigs = await getSqlDropDownData({ ...showDownConfig });
1015   - // downAbleConfigs.forEach((x, i) => {
1016   - // x.sName = "sParams" + i;
1017   - // });
1018   - props.setState(pre => ({
1019   - ...pre,
1020   - downAbleConfigs,
1021   - }));
1022   - };
1023   - getData(props);
1024   - }, [props.state.slaveConfig]);
  1022 +
1025 1023 return (
1026 1024 <div className={styles.quotationDetailBox}>
1027 1025 <QuotationDetail {...props} />
... ... @@ -1180,27 +1178,41 @@ const QuotationTabs = props =&gt; {
1180 1178 boxModel: activeKey,
1181 1179 };
1182 1180 return (
1183   - <Tabs
1184   - activeKey={activeKey}
1185   - onChange={key => {
1186   - setActiveKey(key);
1187   - }}
1188   - >
1189   - {sAllPartsNameList && sAllPartsNameList.length
1190   - ? sAllPartsNameList.map((pane, index) => (
1191   - <Tabs.Tab key={pane} title={pane}>
1192   - <BoxComponent {...tabsProps} paneKey={pane} />
1193   - </Tabs.Tab>
1194   - ))
1195   - : ""}
1196   - </Tabs>
  1181 + <div>
  1182 + <div>
  1183 + <Tabs
  1184 + activeKey={activeKey}
  1185 + onChange={key => {
  1186 + setActiveKey(key);
  1187 + }}
  1188 + >
  1189 + {sAllPartsNameList && sAllPartsNameList.length
  1190 + ? sAllPartsNameList.map((pane, index) => (
  1191 + <Tabs.Tab key={pane} title={pane}>
  1192 + <BoxComponent {...tabsProps} paneKey={pane} />
  1193 + </Tabs.Tab>
  1194 + ))
  1195 + : ""}
  1196 + </Tabs>
  1197 + </div>
  1198 + </div>
1197 1199 );
1198 1200 };
1199 1201  
1200 1202 // 内容
1201 1203 const BoxComponent = props => {
1202 1204 const { state, boxModel } = props;
1203   - const { activeKey, slaveConfig, masterData, selectedNode, boxConfig, downAbleConfigs = [], slaveData } = state || {};
  1205 + const {
  1206 + activeKey,
  1207 + slaveConfig,
  1208 + masterData,
  1209 + selectedNode,
  1210 + boxConfig,
  1211 + downAbleConfigs = [],
  1212 + downAbleExtraConfigs = [],
  1213 + finishedConfigs = [],
  1214 + slaveData,
  1215 + } = state || {};
1204 1216 const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === boxModel) || {};
1205 1217 const { sModelsId } = props;
1206 1218 const [selectList, setSelectList] = useState([]);
... ... @@ -1401,29 +1413,22 @@ const BoxComponent = props =&gt; {
1401 1413  
1402 1414 // 后道参数
1403 1415 const { sBackProcessData } = slaveRowData || [];
1404   - const [downAbleConfigsNew, setDownAbleConfigsNew] = useState([]);
1405   - useEffect(() => {
1406   - setDownAbleConfigsNew(downAbleConfigs);
1407   - }, [downAbleConfigs]);
  1416 + const downAbleConfigsNew = downAbleConfigs.reduce((pre, cur) => {
  1417 + const childConfigs = downAbleExtraConfigs.filter(item => item.sParentName === cur.showName);
  1418 + pre.push(cur, ...childConfigs);
  1419 + return pre;
  1420 + }, []);
1408 1421 // 初始化状态,存储每个 Switch 的状态
1409 1422 const [switchStates, setSwitchStates] = useState(null);
1410 1423 useEffect(() => {
1411 1424 if (!sBackProcessData) return;
1412   - const newSwitchStates = downAbleConfigsNew
1413   - .filter(item => item.sPartsName === boxModel || !item.sPartsName)
1414   - .reduce((acc, item, index) => {
1415   - acc[item.sName] = sBackProcessData ? sBackProcessData[index][item.sName] !== "" : false;
1416   - return acc;
1417   - }, {});
  1425 + const newSwitchStates = downAbleConfigsNew;
1418 1426  
1419 1427 setSwitchStates(newSwitchStates);
1420 1428 }, [downAbleConfigsNew, boxModel]); // 依赖数组
1421 1429  
1422 1430 // 处理 Switch 变化的函数
1423 1431 const handleSwitchChange = (item, val) => {
1424   - // const dropDownData = JSON.parse(item.sChineseDropDown)
1425   - // console.log("🚀 ~ handleSwitchChange ~ dropDownData:", dropDownData)
1426   - // const dropDownDataSelected = dropDownData.find(item => item.sId === changeValue[sFieldName]);
1427 1432 setSwitchStates({
1428 1433 ...switchStates,
1429 1434 [item.sName]: val,
... ... @@ -1435,10 +1440,9 @@ const BoxComponent = props =&gt; {
1435 1440 .map((item, i) => ({
1436 1441 ...item,
1437 1442 isSelect: switchStates ? switchStates[item.sName] : false,
1438   - sName: "sParams" + i,
  1443 + // sName: "sParams" + i,
1439 1444 sProductClassifyId: item.sId,
1440 1445 }));
1441   -
1442 1446 const downViewProps = {
1443 1447 ...props,
1444 1448 viewConfigs: downViewConfigs,
... ... @@ -1447,7 +1451,23 @@ const BoxComponent = props =&gt; {
1447 1451 viewRow: slaveRowData,
1448 1452 tableName: `slaveDown${boxModel}`,
1449 1453 };
1450   -
  1454 + // 获取sType为3的
  1455 + const { productProcessInfo = [] } = masterData;
  1456 + const finishedViewProps = {
  1457 + ...props,
  1458 + viewConfigs: finishedConfigs
  1459 + .filter(item => item.sPartsName === boxModel || !item.sPartsName)
  1460 + .map((item, i) => ({
  1461 + ...item,
  1462 + isSelect: switchStates ? switchStates[item.sName] : false,
  1463 + // sName: "sParams" + i,
  1464 + sProductClassifyId: item.sId,
  1465 + })),
  1466 + tableConfig: { ...slaveConfig, gdsconfigformslave: finishedConfigs },
  1467 + iColValueView: 24,
  1468 + viewRow: masterData,
  1469 + tableName: "finished",
  1470 + };
1451 1471 const calcMethodData = commonUtils.convertStrToObj(slaveRowData?.sColumnNameConfigExclusion, []);
1452 1472 const radioValue = calcMethodData[0]?.sCode;
1453 1473 const [materialLength, setMaterialLength] = useState(0);
... ... @@ -1729,22 +1749,42 @@ const BoxComponent = props =&gt; {
1729 1749 <EditFill color="#BFBFBF" style={{ marginLeft: "1rem" }} />
1730 1750 </div>
1731 1751  
1732   - {downViewProps.viewConfigs.map((x, i) => (
1733   - <div>
1734   - <div className={styles.backBox}>
1735   - <div className={styles.backEnd}>{x.showName}</div>
1736   - <Switch checked={switchStates ? switchStates[x.sName] : ""} onChange={val => handleSwitchChange(x, val)} />
1737   - <div className={styles.customer} style={{ marginTop: "0", marginLeft: "2rem", width: "40%" }}>
1738   - {switchStates && switchStates[x.sName] ? (
1739   - <SelectInput {...downViewProps} itemDetail={{ ...x, sVisColumnName: "sProcessName", sDropDownType: "sql" }} downIndex={i} />
1740   - ) : (
1741   - ""
1742   - )}
  1752 + {downViewProps && downViewProps.viewConfigs && downViewProps.viewConfigs.length
  1753 + ? downViewProps.viewConfigs.map((x, i) => (
  1754 + <div>
  1755 + <div className={styles.backBox}>
  1756 + <div className={styles.backEnd}>{x.showName}</div>
  1757 + <Switch checked={switchStates ? switchStates[x.sName] : ""} onChange={val => handleSwitchChange(x, val)} />
  1758 + <div className={styles.customer} style={{ marginTop: "0", marginLeft: "2rem", width: "40%" }}>
  1759 + {switchStates && switchStates[x.sName] ? (
  1760 + <SelectInput {...downViewProps} itemDetail={{ ...x, sVisColumnName: "sProcessName", sDropDownType: "sql" }} downIndex={i} />
  1761 + ) : (
  1762 + ""
  1763 + )}
  1764 + </div>
  1765 + </div>
  1766 + {getTableCloum(i, x)}
1743 1767 </div>
1744   - </div>
1745   - {getTableCloum(i, x)}
1746   - </div>
1747   - ))}
  1768 + ))
  1769 + : ""}
  1770 + {finishedConfigs && finishedConfigs.viewConfigs && finishedConfigs.viewConfigs.length
  1771 + ? finishedConfigs.viewConfigs.map((x, i) => (
  1772 + <div>
  1773 + <div className={styles.backBox}>
  1774 + <div className={styles.backEnd}>{x.showName}</div>
  1775 + <Switch checked={switchStates ? switchStates[x.sName] : ""} onChange={val => handleSwitchChange(x, val)} />
  1776 + <div className={styles.customer} style={{ marginTop: "0", marginLeft: "2rem", width: "40%" }}>
  1777 + {switchStates && switchStates[x.sName] ? (
  1778 + <SelectInput {...downViewProps} itemDetail={{ ...x, sVisColumnName: "sProcessName", sDropDownType: "sql" }} downIndex={i} />
  1779 + ) : (
  1780 + ""
  1781 + )}
  1782 + </div>
  1783 + </div>
  1784 + {getTableCloum(i, x)}
  1785 + </div>
  1786 + ))
  1787 + : ""}
1748 1788 </div>
1749 1789 <div>
1750 1790 <div className={styles.projectBtn}>
... ... @@ -1959,7 +1999,7 @@ const MaterialsComponent = props =&gt; {
1959 1999 // 多数量组件
1960 2000 const ManyComponent = props => {
1961 2001 const { state, setState, enabled, loading } = props;
1962   - const { masterData = {}, calcPriceLoading, calcPriceFinished, manyData = [] } = state;
  2002 + const { masterData = {}, calcPriceLoading, calcPriceFinished, manyData = [], dQuickQuoteProductQty } = state;
1963 2003 const [submitLoading, setSubmitLoading] = useState(false);
1964 2004 const [processPercent, setProcessPercent] = useState(0);
1965 2005 const [selectedRadio, setSelectedRadio] = useState(null);
... ... @@ -2013,10 +2053,11 @@ const ManyComponent = props =&gt; {
2013 2053 enabled: false,
2014 2054 };
2015 2055 const { headerColumn, data } = tableProps;
  2056 + // 监听父组件状态变化
2016 2057 useEffect(() => {
2017   - if(!data.length) return
2018   - setSelectedRadio(data[0].dManyQty);
2019   - }, [data]);
  2058 + if (!data.length) return;
  2059 + setSelectedRadio(Number(props.state.dQuickQuoteProductQty) || data[0].dProductQty);
  2060 + }, [props.state.dQuickQuoteProductQty]); // 直接监听父组件的
2020 2061 // 核价事件
2021 2062 const onCalcPrice = () => {
2022 2063 const addState = {
... ... @@ -2034,20 +2075,21 @@ const ManyComponent = props =&gt; {
2034 2075 );
2035 2076 };
2036 2077 const handleRadioChange = selectedRowKeys => {
2037   - setSelectedRadio(selectedRowKeys.dManyQty);
2038 2078 const dProductQty = manyData.find(item => item.sId === selectedRowKeys.sId).dManyQty;
2039   - props.slaveData?.forEach(slaveRowData => {
2040   - props.onDataChange0("slave", "dProductQty", { dProductQty }, slaveRowData.sId, [], props);
2041   - });
  2079 + // 这一步导致了点击数量没有变化
  2080 + // props.slaveData?.forEach(slaveRowData => {
  2081 + // props.onDataChange0("slave", "dProductQty", { dProductQty }, slaveRowData.sId, [], props);
  2082 + // });
2042 2083 setState(pre => ({
2043 2084 ...pre,
2044   - manySelectedRowKeys: selectedRowKeys,
  2085 + manySelectedRowKeys: selectedRowKeys.sId,
2045 2086 dQuickQuoteProductQty: dProductQty,
2046 2087 }));
  2088 + setSelectedRadio(dProductQty);
2047 2089 };
2048 2090 return (
2049 2091 <div>
2050   - <div style={{marginBottom:'1rem',textAlign:'right'}}>
  2092 + <div style={{ marginBottom: "1rem", textAlign: "right" }}>
2051 2093 <Button
2052 2094 color="primary"
2053 2095 fill="solid"
... ...
src/mobile/quotation/master.jsx
... ... @@ -408,7 +408,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) =&gt; {
408 408 masterData.sFormId = nextProps.masterData.sFormId;
409 409 masterData.sBillNo = nextProps.masterData.sBillNo;
410 410 }
411   - masterData.handleType = masterData.sBillNo ? "update" : "add";
  411 + masterData.handleType = nextProps.handleType && nextProps.handleType === 'update' ? "update" : "add";
412 412 if (masterData.handleType === "update" && !commonUtils.isEmpty(sMakePerson)) {
413 413 masterData.sMakePerson = sMakePerson;
414 414 }
... ... @@ -535,6 +535,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) =&gt; {
535 535 ...addState,
536 536 });
537 537 } else {
  538 + masterData.handleType = 'update'
538 539 if (isWait) {
539 540 return {
540 541 slaveData,
... ... @@ -545,6 +546,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) =&gt; {
545 546 manyqtysData,
546 547 loading: false,
547 548 packData,
  549 + handleType:'update',
548 550 ...addState,
549 551 };
550 552 } else {
... ... @@ -558,6 +560,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) =&gt; {
558 560 loading: false,
559 561 packData,
560 562 ...addState,
  563 + handleType:'update'
561 564 });
562 565 }
563 566 // message.success(commonFunc.getConfigShowName(masterConfig, "BtnCalculation") + commonFunc.showMessage(app.commonConst, "handleSuccess"));
... ... @@ -908,7 +911,7 @@ const handleSave = async (skipCalculation, props) =&gt; {
908 911 }
909 912 }
910 913 if ((skipFlag === 0 || masterData.bNoVerify) && !skipCalculation) {
911   - handleCalculation(true, props.state.newNextProps, false, props);
  914 + handleCalculation(true, props, false, props);
912 915 } else {
913 916 props.onSaveData({
914 917 data,
... ...