Commit f63da69c1c70faf880a79ea2715fc4ad52e31d91
1 parent
394ae7c0
快速报价app
Showing
2 changed files
with
1282 additions
and
83 deletions
src/mobile/quotation/detailNew.jsx
| 1 | 1 | import { useRef, useEffect, useState, useCallback, useMemo } from "react"; |
| 2 | 2 | import { history } from "umi"; |
| 3 | -import { Toast, Input, Tabs, Selector, Grid, Image, Button, Checkbox, Switch, Dialog } from "antd-mobile"; | |
| 3 | +import { Toast, Input, Tabs, Selector, Grid, Image, Button, Checkbox, Switch, Dialog, Radio } from "antd-mobile"; | |
| 4 | 4 | import { AddOutline, MinusOutline, EditFill } from "antd-mobile-icons"; |
| 5 | 5 | import commonConfig from "@/utils/config"; |
| 6 | 6 | import * as commonServices from "@/services/services"; |
| ... | ... | @@ -17,6 +17,7 @@ import { cloneDeep } from "lodash"; |
| 17 | 17 | import moment from "moment"; |
| 18 | 18 | const QuickQuoteEvent = props => { |
| 19 | 19 | const { location, selectedNode, sModelsId } = props; |
| 20 | + const [isDraftSaved, setIsDraftSaved] = useState(props.isDraftSaved || false); | |
| 20 | 21 | // const selectedNode = JSON.parse(location.state).quotationData; |
| 21 | 22 | const addState = {}; |
| 22 | 23 | |
| ... | ... | @@ -142,6 +143,7 @@ const QuickQuoteEvent = props => { |
| 142 | 143 | }; |
| 143 | 144 | |
| 144 | 145 | addState.onDataChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => { |
| 146 | + const { mastersId } = props; | |
| 145 | 147 | const { masterData = {}, slaveData = [], selectedNode = {} } = state; |
| 146 | 148 | const extraState = { |
| 147 | 149 | calcPriceFinished: false, |
| ... | ... | @@ -151,7 +153,7 @@ const QuickQuoteEvent = props => { |
| 151 | 153 | if (name === "master") { |
| 152 | 154 | let masterDataNew = { ...masterData, ...changeValue }; |
| 153 | 155 | masterDataNew.handleType = masterDataNew.handleType || "update"; |
| 154 | - masterDataNew.sId = masterDataNew.sId || commonUtils.createSid(); | |
| 156 | + masterDataNew.sId = commonUtils.createSid(); | |
| 155 | 157 | if (sFieldName === "dProductQty") { |
| 156 | 158 | setState(pre => ({ |
| 157 | 159 | ...pre, |
| ... | ... | @@ -302,7 +304,7 @@ const QuickQuoteEvent = props => { |
| 302 | 304 | const cpProcessName = productProcessInfo.map(item => item.sProcessName).join(","); |
| 303 | 305 | const masterDataNew = { ...masterData, cpProcessName, productProcessInfo }; |
| 304 | 306 | masterDataNew.handleType = masterDataNew.handleType || "update"; |
| 305 | - masterDataNew.sId = masterDataNew.sId || commonUtils.createSid(); | |
| 307 | + masterDataNew.sId = commonUtils.createSid(); // 目前默认是新增 | |
| 306 | 308 | setState(pre => ({ ...pre, masterData: masterDataNew, ...extraState })); |
| 307 | 309 | } |
| 308 | 310 | }; |
| ... | ... | @@ -338,8 +340,6 @@ const QuickQuoteEvent = props => { |
| 338 | 340 | |
| 339 | 341 | // 存草稿 |
| 340 | 342 | const onSaveDraft = (nextState = state, nextProps = props) => { |
| 341 | - console.log(nextProps,'stateNew'); | |
| 342 | - | |
| 343 | 343 | const { masterData = {} } = nextState; |
| 344 | 344 | const { sProductName, sProductNo, sCustomerName, sCustomerId, sCustomerNo } = masterData; |
| 345 | 345 | if (!sProductName || !sCustomerName) { |
| ... | ... | @@ -349,10 +349,12 @@ const QuickQuoteEvent = props => { |
| 349 | 349 | }); |
| 350 | 350 | return; |
| 351 | 351 | } |
| 352 | + const type = isDraftSaved ? "add" : "update"; | |
| 353 | + | |
| 352 | 354 | props.onSaveState( |
| 353 | 355 | { |
| 354 | 356 | ...addState.onGetAllDelData(), |
| 355 | - masterData: { ...nextProps.masterData, sQuoConfig: JSON.stringify(addState.onGetFilterState(nextState)) }, | |
| 357 | + masterData: { ...nextProps.masterData, handleType: type, sQuoConfig: JSON.stringify(addState.onGetFilterState(nextState)) }, | |
| 356 | 358 | slaveData: nextProps.slaveData.map(item => { |
| 357 | 359 | return { |
| 358 | 360 | ...item, |
| ... | ... | @@ -364,6 +366,7 @@ const QuickQuoteEvent = props => { |
| 364 | 366 | handleType: "add", |
| 365 | 367 | }; |
| 366 | 368 | }), |
| 369 | + isDraftSaved: true, | |
| 367 | 370 | controlData: nextProps.controlData.map(item => { |
| 368 | 371 | return { |
| 369 | 372 | ...item, |
| ... | ... | @@ -402,11 +405,13 @@ const QuickQuoteEvent = props => { |
| 402 | 405 | }; |
| 403 | 406 | }), |
| 404 | 407 | loading: true, |
| 408 | + isSaveDraft: true, | |
| 405 | 409 | }, |
| 406 | - (newState) => { | |
| 407 | - console.log(newState,'newState'); | |
| 408 | - | |
| 409 | - props.onButtonClick("BtnDraft", { ...props,...newState }); | |
| 410 | + newState => { | |
| 411 | + if (newState) { | |
| 412 | + props.onButtonClick("BtnDraft", { ...props, ...newState }); | |
| 413 | + setIsDraftSaved(true); | |
| 414 | + } | |
| 410 | 415 | } |
| 411 | 416 | ); |
| 412 | 417 | }; |
| ... | ... | @@ -853,6 +858,7 @@ const QuickQuoteEvent = props => { |
| 853 | 858 | const masterProps = { |
| 854 | 859 | ...props, |
| 855 | 860 | }; |
| 861 | + setState(pre => ({ ...pre, newNextProps: { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData } })); | |
| 856 | 862 | const result = await props.handleCalculation( |
| 857 | 863 | false, |
| 858 | 864 | { ...masterProps, ...newState, manyqtysConfig: state.manyConfig, manyqtysData: state.manyData }, |
| ... | ... | @@ -877,7 +883,6 @@ const QuickQuoteEvent = props => { |
| 877 | 883 | // stateNew nextProps |
| 878 | 884 | onSaveDraft(preNew, stateNew); |
| 879 | 885 | }); |
| 880 | - console.log("🚀 ~ addState.handleCalcPrice= ~ stateNew:", stateNew) | |
| 881 | 886 | return preNew; |
| 882 | 887 | }); |
| 883 | 888 | } else { |
| ... | ... | @@ -927,7 +932,7 @@ const QuickQuoteEvent = props => { |
| 927 | 932 | const QuotationAllprogressDetail = baseProps => { |
| 928 | 933 | // const masterProps = getProps(baseProps); |
| 929 | 934 | const props = QuickQuoteEvent(baseProps); |
| 930 | - const { selectedNode, location, quotationData, app, sModelsId } = props; | |
| 935 | + const { selectedNode, slaveConfig, quotationData, app, sModelsId, masterData } = props; | |
| 931 | 936 | const { showName, sUnit } = quotationData; |
| 932 | 937 | const timeRef = useRef(0); |
| 933 | 938 | |
| ... | ... | @@ -966,7 +971,7 @@ const QuotationAllprogressDetail = baseProps => { |
| 966 | 971 | return { |
| 967 | 972 | ...pre, |
| 968 | 973 | ...addState, |
| 969 | - masterData: { ...quotationData, sProductName: showName, sProductUnit: sUnit }, | |
| 974 | + masterData: { sProductName: showName, sProductUnit: sUnit, ...masterData }, | |
| 970 | 975 | // downAbleConfigs: downAbleConfigs |
| 971 | 976 | // .filter(item => item.sType === "2") |
| 972 | 977 | // .map((item, index) => ({ |
| ... | ... | @@ -1639,32 +1644,7 @@ const BoxComponent = props => { |
| 1639 | 1644 | ); |
| 1640 | 1645 | }; |
| 1641 | 1646 | const { loading } = props; |
| 1642 | - // 核价事件 | |
| 1643 | - const onCalcPrice = () => { | |
| 1644 | - const addState = { | |
| 1645 | - ...props.onGetAllDelData(), | |
| 1646 | - manyDataCache: [], | |
| 1647 | - }; | |
| 1648 | - // const data = { | |
| 1649 | - // masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" }, | |
| 1650 | - // ...addState, | |
| 1651 | - // }; | |
| 1652 | - // props.onSaveState( | |
| 1653 | - // pre => ({ ...pre, ...data }), | |
| 1654 | - // (newState) => { | |
| 1655 | - // props.handleCalcPrice(); | |
| 1656 | - // } | |
| 1657 | - // ); | |
| 1658 | - props.onSaveState( | |
| 1659 | - { | |
| 1660 | - masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" }, | |
| 1661 | - ...addState, | |
| 1662 | - }, | |
| 1663 | - () => { | |
| 1664 | - props.handleCalcPrice(); | |
| 1665 | - } | |
| 1666 | - ); | |
| 1667 | - }; | |
| 1647 | + | |
| 1668 | 1648 | return ( |
| 1669 | 1649 | <div> |
| 1670 | 1650 | <Selector |
| ... | ... | @@ -1772,28 +1752,6 @@ const BoxComponent = props => { |
| 1772 | 1752 | 多数量报价 |
| 1773 | 1753 | <EditFill color="#BFBFBF" style={{ marginLeft: "1rem" }} /> |
| 1774 | 1754 | </div> |
| 1775 | - | |
| 1776 | - {/* <Button color="primary" fill="solid" loading={loading} onClick={props.onAdd}> | |
| 1777 | - 新报价 | |
| 1778 | - </Button> | |
| 1779 | - <Button | |
| 1780 | - color="primary" | |
| 1781 | - fill="solid" | |
| 1782 | - loading={loading} | |
| 1783 | - onClick={() => { | |
| 1784 | - props.onSaveDraft(); | |
| 1785 | - }} | |
| 1786 | - > | |
| 1787 | - 存草稿 | |
| 1788 | - </Button> */} | |
| 1789 | - <div> | |
| 1790 | - <Button color="primary" fill="solid" onClick={onCalcPrice} size="small" style={{ marginRight: "1rem" }}> | |
| 1791 | - 核价 | |
| 1792 | - </Button> | |
| 1793 | - <Button color="success" size="small"> | |
| 1794 | - 确认下单数量 | |
| 1795 | - </Button> | |
| 1796 | - </div> | |
| 1797 | 1755 | </div> |
| 1798 | 1756 | <ManyComponent {...props}></ManyComponent> |
| 1799 | 1757 | </div> |
| ... | ... | @@ -2004,6 +1962,7 @@ const ManyComponent = props => { |
| 2004 | 1962 | const { masterData = {}, calcPriceLoading, calcPriceFinished, manyData = [] } = state; |
| 2005 | 1963 | const [submitLoading, setSubmitLoading] = useState(false); |
| 2006 | 1964 | const [processPercent, setProcessPercent] = useState(0); |
| 1965 | + const [selectedRadio, setSelectedRadio] = useState(null); | |
| 2007 | 1966 | // 根据主表数量更改多数量表 |
| 2008 | 1967 | useEffect(() => { |
| 2009 | 1968 | const baseCount = masterData.dProductQty || 1000; |
| ... | ... | @@ -2026,6 +1985,7 @@ const ManyComponent = props => { |
| 2026 | 1985 | props.onSaveState({ |
| 2027 | 1986 | manyDataCache: [], |
| 2028 | 1987 | }); |
| 1988 | + // setSelectedRadio(baseCount+'') | |
| 2029 | 1989 | }, [masterData.dProductQty, manyData.length]); |
| 2030 | 1990 | useEffect(() => { |
| 2031 | 1991 | if (calcPriceLoading) { |
| ... | ... | @@ -2053,9 +2013,81 @@ const ManyComponent = props => { |
| 2053 | 2013 | enabled: false, |
| 2054 | 2014 | }; |
| 2055 | 2015 | const { headerColumn, data } = tableProps; |
| 2016 | + useEffect(() => { | |
| 2017 | + if(!data.length) return | |
| 2018 | + setSelectedRadio(data[0].dManyQty); | |
| 2019 | + }, [data]); | |
| 2020 | + // 核价事件 | |
| 2021 | + const onCalcPrice = () => { | |
| 2022 | + const addState = { | |
| 2023 | + ...props.onGetAllDelData(), | |
| 2024 | + manyDataCache: [], | |
| 2025 | + }; | |
| 2026 | + props.onSaveState( | |
| 2027 | + { | |
| 2028 | + masterData: { ...props.masterData, handleType: props.masterData.handleType || "update" }, | |
| 2029 | + ...addState, | |
| 2030 | + }, | |
| 2031 | + () => { | |
| 2032 | + props.handleCalcPrice(); | |
| 2033 | + } | |
| 2034 | + ); | |
| 2035 | + }; | |
| 2036 | + const handleRadioChange = selectedRowKeys => { | |
| 2037 | + setSelectedRadio(selectedRowKeys.dManyQty); | |
| 2038 | + 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 | + }); | |
| 2042 | + setState(pre => ({ | |
| 2043 | + ...pre, | |
| 2044 | + manySelectedRowKeys: selectedRowKeys, | |
| 2045 | + dQuickQuoteProductQty: dProductQty, | |
| 2046 | + })); | |
| 2047 | + }; | |
| 2056 | 2048 | return ( |
| 2057 | 2049 | <div> |
| 2050 | + <div> | |
| 2051 | + <Button | |
| 2052 | + color="primary" | |
| 2053 | + fill="solid" | |
| 2054 | + loading={loading || calcPriceLoading} | |
| 2055 | + loadingText="核价中" | |
| 2056 | + onClick={onCalcPrice} | |
| 2057 | + size="small" | |
| 2058 | + style={{ marginRight: "1rem" }} | |
| 2059 | + > | |
| 2060 | + 核价 | |
| 2061 | + </Button> | |
| 2062 | + <Button | |
| 2063 | + color="success" | |
| 2064 | + size="small" | |
| 2065 | + loading={loading || submitLoading} | |
| 2066 | + disabled={!calcPriceFinished} | |
| 2067 | + onClick={() => { | |
| 2068 | + props.onSaveState( | |
| 2069 | + { | |
| 2070 | + ...props.onGetAllDelData(), | |
| 2071 | + masterData: { | |
| 2072 | + ...props.masterData, | |
| 2073 | + handleType: props.masterData.handleType || "update", | |
| 2074 | + sQuoConfig: JSON.stringify(props.onGetFilterState(state)), | |
| 2075 | + }, | |
| 2076 | + dQuickQuoteProductQty: state.dQuickQuoteProductQty, | |
| 2077 | + loading: true, | |
| 2078 | + }, | |
| 2079 | + () => { | |
| 2080 | + setSubmitLoading(true); | |
| 2081 | + props.onSubmit(undefined, props); | |
| 2082 | + } | |
| 2083 | + ); | |
| 2084 | + }} | |
| 2085 | + > | |
| 2086 | + 确认下单数量 | |
| 2087 | + </Button> | |
| 2088 | + </div> | |
| 2058 | 2089 | <div className={styles.tableBox}> |
| 2090 | + <div style={{ width: "1rem" }}></div> | |
| 2059 | 2091 | {headerColumn.map(item => { |
| 2060 | 2092 | return <div className={styles.tableHeader}>{item.title}</div>; |
| 2061 | 2093 | })} |
| ... | ... | @@ -2064,7 +2096,10 @@ const ManyComponent = props => { |
| 2064 | 2096 | {data && data.length |
| 2065 | 2097 | ? data.map(item => { |
| 2066 | 2098 | return ( |
| 2067 | - <div className={styles.tableBox}> | |
| 2099 | + <div className={styles.tableBox} onClick={() => handleRadioChange(item)}> | |
| 2100 | + <div style={{ width: "1rem", "--icon-size": "1.375rem", "--font-size": "1rem", "--gap": "0.5rem" }}> | |
| 2101 | + <Radio checked={selectedRadio === item.dManyQty} /> | |
| 2102 | + </div> | |
| 2068 | 2103 | <div className={styles.tableBody}>{item.dManyQty}</div> |
| 2069 | 2104 | <div className={styles.tableBody}>{item.dPrintMoney}</div> |
| 2070 | 2105 | <div className={styles.tableBody}>{item.dAfterProcessMoney}</div> | ... | ... |
src/mobile/quotation/master.jsx
| ... | ... | @@ -53,10 +53,10 @@ const masterEvent = props => { |
| 53 | 53 | const controlConfig = formData.find(x => x.sTbName === "QuoQuotationcontrol"); |
| 54 | 54 | |
| 55 | 55 | let colorConfig = {}; |
| 56 | - const colorConfigTrue = formData.find(item => item.sTbName === "quoquotationparam"); | |
| 57 | - if (commonUtils.isNotEmptyObject(colorConfigTrue)) { | |
| 58 | - colorConfig = { ...colorConfigTrue }; | |
| 59 | - } | |
| 56 | + // const colorConfigTrue = formData.find(item => item.sTbName === "quoquotationparam"); | |
| 57 | + // if (commonUtils.isNotEmptyObject(colorConfigTrue)) { | |
| 58 | + // colorConfig = { ...colorConfigTrue }; | |
| 59 | + // } | |
| 60 | 60 | |
| 61 | 61 | const packConfig = formData.find(item => item.sTbName === "quoquotationcontrolcombine"); |
| 62 | 62 | |
| ... | ... | @@ -86,16 +86,17 @@ const masterEvent = props => { |
| 86 | 86 | }); |
| 87 | 87 | }, []); |
| 88 | 88 | |
| 89 | - const onSaveState = (updateFunction, callback) => { | |
| 89 | + const handleSaveState = (newValues, callback) => { | |
| 90 | 90 | setState(prevState => { |
| 91 | - let newState = prevState; | |
| 92 | - if (typeof updateFunction === "function") { | |
| 93 | - newState = updateFunction(prevState); | |
| 94 | - } | |
| 91 | + const mergedState = { ...prevState, ...newValues }; | |
| 92 | + // 确保回调在状态更新后执行 | |
| 95 | 93 | if (typeof callback === "function") { |
| 96 | - callback(newState); | |
| 94 | + // 使用 setTimeout 确保回调在下一个事件循环中执行 | |
| 95 | + setTimeout(() => { | |
| 96 | + callback(mergedState); | |
| 97 | + }, 0); | |
| 97 | 98 | } |
| 98 | - return { ...newState }; | |
| 99 | + return mergedState; | |
| 99 | 100 | }); |
| 100 | 101 | }; |
| 101 | 102 | |
| ... | ... | @@ -149,7 +150,7 @@ const masterEvent = props => { |
| 149 | 150 | handleType: "add", |
| 150 | 151 | iPositiveColor: 4, |
| 151 | 152 | maxBillNo: "sBillNo", |
| 152 | - sFormId: sModelsId, | |
| 153 | + sFormId: commonUtils.createSid(), | |
| 153 | 154 | sId: commonUtils.createSid(), |
| 154 | 155 | }; |
| 155 | 156 | setState(prevState => ({ |
| ... | ... | @@ -161,6 +162,7 @@ const masterEvent = props => { |
| 161 | 162 | processData, |
| 162 | 163 | materialsData, |
| 163 | 164 | masterData, |
| 165 | + mastersId: masterData.sId, | |
| 164 | 166 | })); |
| 165 | 167 | |
| 166 | 168 | setIsInitialized(true); |
| ... | ... | @@ -181,12 +183,14 @@ const masterEvent = props => { |
| 181 | 183 | onMaterialsChange: handleMaterialsChange, |
| 182 | 184 | sortData, |
| 183 | 185 | handleCalculation, |
| 184 | - onSaveState, | |
| 186 | + onSaveState: handleSaveState, | |
| 185 | 187 | onSaveData: handleSaveData, |
| 186 | - onButtonClick: handleButtonClick, | |
| 188 | + onSubmit: handleSave, | |
| 189 | + // onButtonClick: handleButtonClick, | |
| 187 | 190 | ...state, |
| 188 | 191 | }; |
| 189 | 192 | }; |
| 193 | +// 遍历下所有配置sButtonEnabled的字段,生成配置 | |
| 190 | 194 | |
| 191 | 195 | const sortData = (tableData, processData) => { |
| 192 | 196 | processData.sort((g1, g2) => { |
| ... | ... | @@ -334,6 +338,7 @@ const handleMaterialsChange = async (tableDataRow, sModelsId, masterData, change |
| 334 | 338 | }; |
| 335 | 339 | // 计算数量 |
| 336 | 340 | const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 341 | + | |
| 337 | 342 | const dataUrl = `${commonConfig.server_host}business/addQuotationsheet?sModelsId=${nextProps.sModelsId}`; |
| 338 | 343 | const { |
| 339 | 344 | masterConfig, |
| ... | ... | @@ -433,6 +438,12 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 433 | 438 | handleType: dQuickQuoteProductQty ? "add" : item.handleType, |
| 434 | 439 | }; |
| 435 | 440 | }); |
| 441 | + manyqtysData.forEach((x, i) => { | |
| 442 | + if (i !== 0) { | |
| 443 | + x.sParentId = manyqtysData[0].sParentId; | |
| 444 | + } | |
| 445 | + }); | |
| 446 | + | |
| 436 | 447 | if (cacheIndex === -1 && manyqtysData?.some(item => item.manyData)) { |
| 437 | 448 | addState.manyDataCache = manyqtysData.map((item, index) => { |
| 438 | 449 | let result = {}; |
| ... | ... | @@ -488,6 +499,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 488 | 499 | /* 计算成功后自动调用保存 */ |
| 489 | 500 | if (bSave) { |
| 490 | 501 | const data = []; |
| 502 | + masterData.handleType = "update"; | |
| 491 | 503 | data.push(commonBusiness.mergeData("master", masterConfig.sTbName, [masterData])); |
| 492 | 504 | data.push(commonBusiness.mergeData("slave", slaveConfig.sTbName, slaveData, slaveDelData)); |
| 493 | 505 | data.push(commonBusiness.mergeData("control", controlConfig.sTbName, controlData, controlDelData)); |
| ... | ... | @@ -500,6 +512,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 500 | 512 | |
| 501 | 513 | data.push(commonBusiness.mergeData("color", colorConfig.sTbName, colorData, colorDelData)); |
| 502 | 514 | data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData)); |
| 515 | + | |
| 503 | 516 | props.onSaveData( |
| 504 | 517 | { |
| 505 | 518 | data, |
| ... | ... | @@ -721,9 +734,6 @@ const handleButtonClick = async (name, props) => { |
| 721 | 734 | if (commonUtils.isNotEmptyObject(packConfig)) { |
| 722 | 735 | data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData)); |
| 723 | 736 | } |
| 724 | - console.log(data,props, "onSaveData"); | |
| 725 | - | |
| 726 | - return; | |
| 727 | 737 | // 核价后保存 |
| 728 | 738 | props.onSaveData( |
| 729 | 739 | { |
| ... | ... | @@ -760,7 +770,7 @@ const handleSaveData = async (params, props) => { |
| 760 | 770 | } = props; |
| 761 | 771 | const { userinfo } = app; |
| 762 | 772 | const { copyTo } = app.currentPane; |
| 763 | - const onSendSocketMessage = props.handleSendSocketMessage; | |
| 773 | + // const onSendSocketMessage = props.handleSendSocketMessage; | |
| 764 | 774 | const BtnSave = commonFunc.showMessage(app.commonConst, "BtnSave"); /* 保存 */ |
| 765 | 775 | params.optName = BtnSave; |
| 766 | 776 | const returnData = await commonBusiness.saveData({ token, value: params, sModelsId }); |
| ... | ... | @@ -773,9 +783,12 @@ const handleSaveData = async (params, props) => { |
| 773 | 783 | sIdArray.push(redisKey); |
| 774 | 784 | }); |
| 775 | 785 | const sId = sIdArray.toString(); |
| 776 | - onSendSocketMessage("copyfinish", "noAction", sId, userinfo.sId, null, null); | |
| 786 | + // onSendSocketMessage("copyfinish", "noAction", sId, userinfo.sId, null, null); | |
| 777 | 787 | } |
| 778 | - onSendSocketMessage("release", "noAction", currentId, userinfo.sId, null, null); | |
| 788 | + // onSendSocketMessage("release", "noAction", currentId, userinfo.sId, null, null); | |
| 789 | + Toast.show({ | |
| 790 | + content: "保存成功", | |
| 791 | + }); | |
| 779 | 792 | props.onSaveState({ |
| 780 | 793 | enabled: false, |
| 781 | 794 | currentId: masterData.sId, |
| ... | ... | @@ -812,6 +825,1157 @@ const handleSaveData = async (params, props) => { |
| 812 | 825 | return false; |
| 813 | 826 | } |
| 814 | 827 | }; |
| 828 | +// 保存 | |
| 829 | +const handleSave = async (skipCalculation, props) => { | |
| 830 | + /* 验证成功 */ | |
| 831 | + const { | |
| 832 | + masterConfig, | |
| 833 | + masterData, | |
| 834 | + slaveConfig, | |
| 835 | + slaveData, | |
| 836 | + slaveDelData, | |
| 837 | + controlConfig, | |
| 838 | + controlData, | |
| 839 | + controlDelData, | |
| 840 | + colorConfig, | |
| 841 | + colorData, | |
| 842 | + colorDelData, | |
| 843 | + materialsConfig, | |
| 844 | + materialsData, | |
| 845 | + materialsDelData, | |
| 846 | + processConfig, | |
| 847 | + processData, | |
| 848 | + processDelData, | |
| 849 | + app, | |
| 850 | + manyqtysConfig, | |
| 851 | + manyqtysData, | |
| 852 | + manyqtysDelData, | |
| 853 | + packConfig, | |
| 854 | + packData, | |
| 855 | + packDelData, | |
| 856 | + } = props; | |
| 857 | + if (commonUtils.isEmptyArr(slaveData)) { | |
| 858 | + // message.warning(`从表${commonFunc.showMessage(props.app.commonConst, "isNotNull")}`); | |
| 859 | + props.onSaveState({ | |
| 860 | + loading: false, | |
| 861 | + }); | |
| 862 | + return; | |
| 863 | + } | |
| 864 | + if ( | |
| 865 | + !commonBusiness.validateTable(slaveConfig, slaveData, props) || | |
| 866 | + !commonBusiness.validateTable(controlConfig, controlData, props) || | |
| 867 | + !commonBusiness.validateTable(materialsConfig, materialsData, props) || | |
| 868 | + !commonBusiness.validateTable(processConfig, processData, props) || | |
| 869 | + !commonBusiness.validateTable(colorConfig, colorData, props) || | |
| 870 | + !commonBusiness.validateTable(packConfig, packData, props) | |
| 871 | + ) { | |
| 872 | + props.onSaveState({ | |
| 873 | + loading: false, | |
| 874 | + }); | |
| 875 | + return; | |
| 876 | + } | |
| 877 | + const data = []; | |
| 878 | + data.push(commonBusiness.mergeData("master", masterConfig.sTbName, [masterData])); | |
| 879 | + data.push(commonBusiness.mergeData("slave", slaveConfig.sTbName, slaveData, slaveDelData)); | |
| 880 | + data.push(commonBusiness.mergeData("control", controlConfig.sTbName, controlData, controlDelData)); | |
| 881 | + data.push(commonBusiness.mergeData("materials", materialsConfig.sTbName, materialsData, materialsDelData)); | |
| 882 | + data.push(commonBusiness.mergeData("process", processConfig.sTbName, processData, processDelData)); | |
| 883 | + | |
| 884 | + if (commonUtils.isNotEmptyObject(manyqtysConfig)) { | |
| 885 | + data.push(commonBusiness.mergeData("manyqtys", manyqtysConfig.sTbName, manyqtysData, manyqtysDelData)); | |
| 886 | + } | |
| 887 | + | |
| 888 | + data.push(commonBusiness.mergeData("color", colorConfig.sTbName, colorData, colorDelData)); | |
| 889 | + data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData)); | |
| 890 | + let skipFlag = 1; /* 默认不调用自动计算 若column有值 代表数据有更改 为0则调用自动计算 */ | |
| 891 | + if (commonUtils.isNotEmptyArr(data)) { | |
| 892 | + for (const table of data) { | |
| 893 | + for (const key of Object.keys(table)) { | |
| 894 | + if (key.includes("column")) { | |
| 895 | + /* 只要一个column有值 代表有更改 要走自动计算 */ | |
| 896 | + if (commonUtils.isNotEmptyArr(table[key])) { | |
| 897 | + skipFlag = 0; | |
| 898 | + break; | |
| 899 | + } | |
| 900 | + } | |
| 901 | + } | |
| 902 | + if (skipFlag === 0) { | |
| 903 | + /* skipFlag=0 代表不自动计算 */ | |
| 904 | + break; | |
| 905 | + } | |
| 906 | + } | |
| 907 | + } | |
| 908 | + if ((skipFlag === 0 || masterData.bNoVerify) && !skipCalculation) { | |
| 909 | + handleCalculation(true, props.state.newNextProps, false, props); | |
| 910 | + } else { | |
| 911 | + props.onSaveData({ | |
| 912 | + data, | |
| 913 | + sClientType: "1", | |
| 914 | + loading: false, | |
| 915 | + sSysLogSrcId: masterData.sId, | |
| 916 | + }); | |
| 917 | + } | |
| 918 | +}; | |
| 919 | +/** 表格数据更改 */ | |
| 920 | +// name 不写完整的state名称作用为了要用到total // (name, changeValue, sId, dropDownData) | |
| 921 | +const handleTableChange = async (name, sFieldName, changeValue, sId, dropDownData, props) => { | |
| 922 | + /* 从CommonBase获取默认参数 */ | |
| 923 | + if (name === "slave") { | |
| 924 | + const { sModelsId, [`${name}Data`]: tableData, masterConfig, controlConfig, controlData: controlDataOld, masterData, app, packData } = props; | |
| 925 | + const { dNetMoney } = app.decimals; | |
| 926 | + let tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 927 | + if (tableDataRow === undefined) return; | |
| 928 | + const iIndex = tableData.findIndex(item => item.sId === sId); | |
| 929 | + tableData[iIndex] = tableDataRow; | |
| 930 | + | |
| 931 | + let bCkxNoTaxProcessPrice = "0"; | |
| 932 | + const filterData = app.systemData.filter(item => item.sName === "CkxNoTaxProcessPrice"); | |
| 933 | + if (commonUtils.isNotEmptyArr(filterData) && filterData.length > 0) { | |
| 934 | + bCkxNoTaxProcessPrice = filterData[0].sValue; | |
| 935 | + } | |
| 936 | + const dCurrencyRate = commonUtils.convertIsNotNumToNumber1(tableDataRow.dCurrencyRate); /* 汇率 */ | |
| 937 | + | |
| 938 | + const addState = {}; | |
| 939 | + /* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */ | |
| 940 | + let bProductQtySelf = false; | |
| 941 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 942 | + const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bProductQtySelf"); | |
| 943 | + if (iIndex > -1) { | |
| 944 | + bProductQtySelf = true; | |
| 945 | + } | |
| 946 | + } | |
| 947 | + if (sFieldName === "dProductQty" || sFieldName === "dGiveQty" || sFieldName === "dStockupQty") { | |
| 948 | + let dPartsQty = 0; | |
| 949 | + tableData.forEach(item => { | |
| 950 | + if (bProductQtySelf) { | |
| 951 | + dPartsQty += commonUtils.isNull(item.dProductQty, 0); | |
| 952 | + } else { | |
| 953 | + dPartsQty += commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); | |
| 954 | + } | |
| 955 | + }); | |
| 956 | + /* 找到所有一级部件 */ | |
| 957 | + const controlRootData = commonUtils.isNotEmptyArr(controlDataOld) | |
| 958 | + ? controlDataOld.filter(item => commonUtils.isEmpty(item.sControlParentId)) | |
| 959 | + : []; | |
| 960 | + if (commonUtils.isNotEmptyArr(controlRootData)) { | |
| 961 | + controlRootData.forEach(item => { | |
| 962 | + let itemNew = { ...item }; | |
| 963 | + /* 父级的dPartsQty为dPartsQty */ | |
| 964 | + itemNew.dPartsQty = dPartsQty; | |
| 965 | + itemNew = singlePQtyChange(itemNew); | |
| 966 | + /* 找到子部件 */ | |
| 967 | + const controlChildData = controlDataOld.filter( | |
| 968 | + itemOld => commonUtils.isNotEmptyObject(itemOld.sAllId) && itemOld.sAllId.indexOf(item.sId) > -1 && itemOld.sId !== item.sId | |
| 969 | + ); | |
| 970 | + if (commonUtils.isNotEmptyArr(controlChildData)) { | |
| 971 | + const { dMachineQty } = itemNew; | |
| 972 | + controlChildData.forEach(child => { | |
| 973 | + let tableDataRow = { ...child }; | |
| 974 | + const iIndex = controlDataOld.findIndex(item => item.sId === child.sId); | |
| 975 | + if (iIndex > -1) { | |
| 976 | + /* 子部件部件数量为父部件上机数量 */ | |
| 977 | + tableDataRow.dPartsQty = dMachineQty; | |
| 978 | + tableDataRow = singlePQtyChange(tableDataRow); | |
| 979 | + controlDataOld[iIndex] = tableDataRow; | |
| 980 | + } | |
| 981 | + }); | |
| 982 | + } | |
| 983 | + const addStata = {}; | |
| 984 | + addStata.dPartsQty = dPartsQty; | |
| 985 | + const iRootIndex = controlDataOld.findIndex(itemControl => itemControl.sId === item.sId); | |
| 986 | + controlDataOld[iRootIndex] = { ...controlDataOld[iRootIndex], ...itemNew }; | |
| 987 | + }); | |
| 988 | + } | |
| 989 | + addState.controlData = controlDataOld; | |
| 990 | + } else if (sFieldName === "sCustomerId" || sFieldName === "sCustomerNo" || sFieldName === "sCustomerName") { | |
| 991 | + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductId', []); | |
| 992 | + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductNo', []); | |
| 993 | + // commonUtils.setStoreDropDownData(sModelsId, 'slave', 'sProductName', []); | |
| 994 | + tableDataRow.sProductId = ""; | |
| 995 | + tableDataRow.sProductNo = ""; | |
| 996 | + tableDataRow.sProductName = ""; | |
| 997 | + tableData[iIndex] = tableDataRow; | |
| 998 | + } else if ( | |
| 999 | + (sFieldName === "dProductMoney" || sFieldName === "dProductPrice" || sFieldName === "dProductForeignMoney") && | |
| 1000 | + !commonUtils.isEmpty(tableDataRow.dStandardMoney) | |
| 1001 | + ) { | |
| 1002 | + let dProductMoney = commonUtils.isNull(tableDataRow.dProductMoney, 0); | |
| 1003 | + | |
| 1004 | + if (sFieldName === "dProductForeignMoney") { | |
| 1005 | + const dProductForeignMoney = commonUtils.isNull(tableDataRow.dProductForeignMoney, 0); | |
| 1006 | + dProductMoney = commonUtils.convertFixNum(dCurrencyRate !== 0 ? dProductForeignMoney * dCurrencyRate : 0, dNetMoney); /* 本位币金额 */ | |
| 1007 | + } | |
| 1008 | + /* 不启用工序价格不含税 则计算利润时 无需减掉含税金额 */ | |
| 1009 | + if (bCkxNoTaxProcessPrice === "0") { | |
| 1010 | + tableDataRow.dProfitMoney = commonUtils.convertFixNum( | |
| 1011 | + commonUtils.isNull(dProductMoney, 0) - | |
| 1012 | + commonUtils.isNull(tableDataRow.dStandardMoney, 0) - | |
| 1013 | + commonUtils.isNull(masterData.dPackMoney, 0) - | |
| 1014 | + commonUtils.isNull(masterData.dTransportMoney, 0), | |
| 1015 | + dNetMoney | |
| 1016 | + ); | |
| 1017 | + } else { | |
| 1018 | + tableDataRow.dProfitMoney = commonUtils.convertFixNum( | |
| 1019 | + commonUtils.isNull(dProductMoney, 0) - | |
| 1020 | + commonUtils.isNull(tableDataRow.dProductTaxMoney, 0) - | |
| 1021 | + commonUtils.isNull(tableDataRow.dStandardMoney, 0) - | |
| 1022 | + commonUtils.isNull(masterData.dPackMoney, 0) - | |
| 1023 | + commonUtils.isNull(masterData.dTransportMoney, 0), | |
| 1024 | + dNetMoney | |
| 1025 | + ); | |
| 1026 | + } | |
| 1027 | + // eslint-disable-next-line no-mixed-operators | |
| 1028 | + tableDataRow.dProfitRate = | |
| 1029 | + commonUtils.isNull(tableDataRow.dStandardMoney, 0) !== 0 | |
| 1030 | + ? commonUtils.convertFixNum( | |
| 1031 | + (commonUtils.isNull(tableDataRow.dProfitMoney, 0) / commonUtils.isNull(tableDataRow.dStandardMoney, 0)) * 100, | |
| 1032 | + 2 | |
| 1033 | + ) | |
| 1034 | + : 0; | |
| 1035 | + } else if (sFieldName === "dProfitRate" && !commonUtils.isEmpty(tableDataRow.dStandardMoney)) { | |
| 1036 | + /* 利润 = 标准金额 dStandMoney * 利润率 dProfitRate */ | |
| 1037 | + tableDataRow.dProfitMoney = commonUtils.convertFixNum( | |
| 1038 | + commonUtils.isNull(tableDataRow.dStandardMoney, 0) * (commonUtils.isNull(tableDataRow.dProfitRate, 0) / 100), | |
| 1039 | + dNetMoney | |
| 1040 | + ); | |
| 1041 | + if (bCkxNoTaxProcessPrice === "0") { | |
| 1042 | + /* 不启用 则计算利润时 无需减掉含税金额 */ | |
| 1043 | + tableDataRow.dProductMoney = commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0); | |
| 1044 | + } else { | |
| 1045 | + /* 启用工序价格含税 代表金额已含税 */ | |
| 1046 | + // eslint-disable-next-line no-mixed-operators | |
| 1047 | + tableDataRow.dProductMoney = commonUtils.convertFixNum( | |
| 1048 | + (commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) * (1 + tableDataRow.dTaxRate / 100), | |
| 1049 | + dNetMoney | |
| 1050 | + ); | |
| 1051 | + } | |
| 1052 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, "Product", "dProductMoney", masterData, tableDataRow); | |
| 1053 | + } else if (sFieldName === "dTaxRate" || sFieldName === "sTaxId" || sFieldName === "sTaxName") { | |
| 1054 | + // eslint-disable-next-line no-mixed-operators | |
| 1055 | + const iIndex = app.systemData.findIndex(item => item.sName === "CkxNoTaxProcessPrice"); | |
| 1056 | + if (iIndex > -1 && app.systemData[iIndex] === "1") { | |
| 1057 | + if ( | |
| 1058 | + !commonUtils.isEmpty(tableDataRow.dStandardMoney) && | |
| 1059 | + !commonUtils.isEmpty(tableDataRow.dProfitMoney) && | |
| 1060 | + !commonUtils.isEmpty(tableDataRow.dTaxRate) | |
| 1061 | + ) { | |
| 1062 | + // eslint-disable-next-line no-mixed-operators | |
| 1063 | + tableDataRow.dProductMoney = commonUtils.convertFixNum( | |
| 1064 | + (commonUtils.isNull(tableDataRow.dStandardMoney, 0) + commonUtils.isNull(tableDataRow.dProfitMoney, 0)) * | |
| 1065 | + (1 + tableDataRow.dTaxRate / 100), | |
| 1066 | + dNetMoney | |
| 1067 | + ); | |
| 1068 | + tableDataRow = commonBusiness.getCalculateAllMoney(app, "Product", "dProductMoney", masterData, tableDataRow); | |
| 1069 | + } | |
| 1070 | + } | |
| 1071 | + } else if (sFieldName === "sProductId" || sFieldName === "sProductNo" || sFieldName === "sProductName") { | |
| 1072 | + // const productIdDropDown = commonUtils.getStoreDropDownData(sModelsId, 'slave', sFieldName); | |
| 1073 | + const iProductIdIndex = dropDownData.findIndex(item => item.sId === tableData[0].sProductId); | |
| 1074 | + if (tableDataRow.handleType === "add" && iProductIdIndex > -1 && tableDataRow.sProductId !== tableDataRow.sProductName) { | |
| 1075 | + if (!commonUtils.isEmpty(tableDataRow.sProductId) && commonUtils.isEmptyArr(controlDataOld)) { | |
| 1076 | + const changeData = dropDownData[iProductIdIndex]; | |
| 1077 | + const sParentId = commonUtils.isEmpty(changeData) ? "" : changeData.sParentId; | |
| 1078 | + if (!commonUtils.isEmpty(sParentId)) { | |
| 1079 | + const iIndex = masterConfig.gdsconfigformslave.findIndex(item => item.sName === "sProductClassifyName"); | |
| 1080 | + if (iIndex > -1) { | |
| 1081 | + let dProductQty = 0; | |
| 1082 | + tableData.forEach(item => { | |
| 1083 | + if (bProductQtySelf) { | |
| 1084 | + dProductQty += commonUtils.isNull(item.dProductQty, 0); | |
| 1085 | + } else { | |
| 1086 | + dProductQty += | |
| 1087 | + commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); | |
| 1088 | + } | |
| 1089 | + }); | |
| 1090 | + const sqlDropDownData = await props.getSqlDropDownData(sModelsId, "master", masterConfig.gdsconfigformslave[iIndex]); | |
| 1091 | + const dropDownData = sqlDropDownData.dropDownData; | |
| 1092 | + const [changeData] = dropDownData.filter(item => item.sId === sParentId); | |
| 1093 | + const sAllPartsName = commonUtils.isEmpty(changeData) ? "" : changeData.sAllPartsName; | |
| 1094 | + if (commonUtils.isNotEmptyStr(sAllPartsName)) { | |
| 1095 | + const sAssignFieldObj = sAllPartsName.split(","); | |
| 1096 | + const controlData = []; | |
| 1097 | + for (const child of sAssignFieldObj) { | |
| 1098 | + let allTableData = {}; | |
| 1099 | + allTableData = {}; | |
| 1100 | + allTableData.master = masterData; | |
| 1101 | + allTableData.slave = commonUtils.isEmptyArr(tableData) ? {} : tableData[0]; | |
| 1102 | + const tableDataRow = commonFunc.getDefaultData(controlConfig, allTableData); | |
| 1103 | + tableDataRow.handleType = "add"; | |
| 1104 | + tableDataRow.sId = commonUtils.createSid(); | |
| 1105 | + tableDataRow.sParentId = masterData && masterData.sId ? masterData.sId : null; | |
| 1106 | + tableDataRow.key = tableDataRow.sId; | |
| 1107 | + tableDataRow.bDefault = false; | |
| 1108 | + tableDataRow.iOrder = controlData.length + 1; | |
| 1109 | + tableDataRow.sPartsName = child; | |
| 1110 | + tableDataRow.dPartsQty = dProductQty; | |
| 1111 | + tableDataRow.sAllId = tableDataRow.sId; | |
| 1112 | + tableDataRow.sControlParentId = ""; | |
| 1113 | + controlData.push(tableDataRow); | |
| 1114 | + } | |
| 1115 | + addState.controlData = controlData; | |
| 1116 | + } | |
| 1117 | + } | |
| 1118 | + } | |
| 1119 | + } | |
| 1120 | + } | |
| 1121 | + /* 从表产品改变带动合版表产品与部件表合版信息 同步改变 */ | |
| 1122 | + const controlDataNew = commonUtils.isNotEmptyArr(addState.controlData) ? addState.controlData : controlDataOld; | |
| 1123 | + /* 如果packData只有一条数据 则同步合版数据 及增加控制表合版备注 */ | |
| 1124 | + if (commonUtils.isNotEmptyArr(packData) && packData.length === 1 && packData[0].sSlaveId === tableDataRow.sId) { | |
| 1125 | + let packDataRow = packData[0]; | |
| 1126 | + const sControlId = packDataRow.sControlId; | |
| 1127 | + packDataRow = handlePackDataAdd(tableDataRow, 0, sControlId); | |
| 1128 | + packDataRow.dCombineQty = 1; | |
| 1129 | + packData[0] = { ...packData[0], ...packDataRow }; | |
| 1130 | + | |
| 1131 | + if (commonUtils.isNotEmptyObject(packData[0])) { | |
| 1132 | + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[0]; | |
| 1133 | + const tableCombineSelectedData = []; | |
| 1134 | + const jsonObj = {}; | |
| 1135 | + jsonObj.sId = sId; | |
| 1136 | + jsonObj.sProductNo = sProductNo; /* 产品编号 */ | |
| 1137 | + jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */ | |
| 1138 | + jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */ | |
| 1139 | + jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */ | |
| 1140 | + jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */ | |
| 1141 | + tableCombineSelectedData.push(jsonObj); | |
| 1142 | + const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) | |
| 1143 | + ? JSON.stringify(tableCombineSelectedData) | |
| 1144 | + : ""; /* JSON对象转换为字符串存放到合版信息中 */ | |
| 1145 | + // const controlDataNew =commonUtils.isNotEmptyArr(addState.controlData)? addState.controlData: controlDataOld; | |
| 1146 | + if (commonUtils.isNotEmptyArr(controlDataNew)) { | |
| 1147 | + const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId); | |
| 1148 | + if (iControlIndex > -1) { | |
| 1149 | + controlDataNew[iControlIndex].sCombinedMemo = sCombinedMemo; | |
| 1150 | + controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName; | |
| 1151 | + } | |
| 1152 | + addState.controlData = controlDataNew; | |
| 1153 | + } | |
| 1154 | + } | |
| 1155 | + } else if (packData.length > 1) { | |
| 1156 | + const packFilterData = packData.filter(item => item.sSlaveId === tableDataRow.sId); | |
| 1157 | + if (commonUtils.isNotEmptyArr(packFilterData)) { | |
| 1158 | + packFilterData.forEach((itemPack, index) => { | |
| 1159 | + let packDataRow = itemPack; | |
| 1160 | + const sControlId = packDataRow.sControlId; | |
| 1161 | + packDataRow = handlePackDataAdd(tableDataRow, 0, sControlId); | |
| 1162 | + // packDataRow.dCombineQty = 1; | |
| 1163 | + const pIndex = packData.findIndex(item => item.sId === itemPack.sId); | |
| 1164 | + if (pIndex > -1) { | |
| 1165 | + packData[pIndex] = { ...packData[pIndex], ...packDataRow }; /* 根据选中的从表 找到所有的合版数据,将合版数据中的产品换成切换后的产品 */ | |
| 1166 | + let sCombinedMemoStr = ""; /* 将控制表合版信息中的产品换成新选择的产品 */ | |
| 1167 | + if (commonUtils.isNotEmptyArr(controlDataNew)) { | |
| 1168 | + const iControlIndex = controlDataNew.findIndex(item => item.sId === sControlId); | |
| 1169 | + if (iControlIndex > -1) { | |
| 1170 | + sCombinedMemoStr = controlDataNew[iControlIndex].sCombinedMemo; | |
| 1171 | + if (sCombinedMemoStr) { | |
| 1172 | + const sCombinedMemoArr = commonUtils.isNotEmptyObject(sCombinedMemoStr) ? JSON.parse(sCombinedMemoStr) : {}; | |
| 1173 | + if (commonUtils.isNotEmptyArr(sCombinedMemoArr)) { | |
| 1174 | + const iIndex = sCombinedMemoArr.findIndex(item => item.sId === itemPack.sId); | |
| 1175 | + if (iIndex > -1) { | |
| 1176 | + const addState = {}; | |
| 1177 | + addState.sProductId = tableDataRow.sProductId; /* 产品id */ | |
| 1178 | + addState.sCustomerId = tableDataRow.sCustomerId; /* 客户id */ | |
| 1179 | + addState.sCustomerName = tableDataRow.sCustomerName; /* 客户名称 */ | |
| 1180 | + addState.sProductName = tableDataRow.sProductName; /* 产品名称 */ | |
| 1181 | + addState.sProductNo = tableDataRow.sProductNo; /* 产品编号 */ | |
| 1182 | + sCombinedMemoArr[iIndex] = { ...sCombinedMemoArr[iIndex], ...addState }; | |
| 1183 | + const sCombinedMemo = commonUtils.isNotEmptyArr(sCombinedMemoArr) | |
| 1184 | + ? JSON.stringify(sCombinedMemoArr) | |
| 1185 | + : ""; /* JSON对象转换为字符串存放到合版信息中 */ | |
| 1186 | + controlDataNew[iControlIndex].sCombinedMemo = sCombinedMemo; | |
| 1187 | + controlDataNew[iControlIndex].sPartsName = tableDataRow.sProductName; | |
| 1188 | + } | |
| 1189 | + } | |
| 1190 | + } | |
| 1191 | + } | |
| 1192 | + } | |
| 1193 | + } | |
| 1194 | + }); | |
| 1195 | + addState.controlData = controlDataNew; | |
| 1196 | + } | |
| 1197 | + } | |
| 1198 | + addState.packData = packData; | |
| 1199 | + } | |
| 1200 | + props.onSaveState({ [`${name}Data`]: tableData, ...addState }); | |
| 1201 | + } else if (name === "control") { | |
| 1202 | + const { | |
| 1203 | + [`${name}Data`]: tableData, | |
| 1204 | + materialsData: materialsDataOld, | |
| 1205 | + processData: processDataOld, | |
| 1206 | + sModelsType, | |
| 1207 | + packData, | |
| 1208 | + slaveSelectedRowKeys, | |
| 1209 | + slaveData, | |
| 1210 | + } = props; | |
| 1211 | + let tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 1212 | + if (tableDataRow === undefined) return; | |
| 1213 | + if ( | |
| 1214 | + sFieldName === "dSinglePQty" || | |
| 1215 | + sFieldName === "dPartsQty" || | |
| 1216 | + sFieldName === "dSumPQty" || | |
| 1217 | + sFieldName === "iPrintModePo" || | |
| 1218 | + sFieldName === "iPrintMode" || | |
| 1219 | + sFieldName === "iPrintModePo" || | |
| 1220 | + sFieldName === "iPositiveColor" || | |
| 1221 | + sFieldName === "iPositiveSpecialColor" || | |
| 1222 | + sFieldName === "iOppositeColor" || | |
| 1223 | + sFieldName === "iOppositeSpecialColor" | |
| 1224 | + ) { | |
| 1225 | + if (sFieldName === "iPrintModePo") { | |
| 1226 | + if (tableDataRow.iPrintModePo === 0) { | |
| 1227 | + tableDataRow.iPrintMode = 3; | |
| 1228 | + if (tableDataRow.iPositiveColor === 0) { | |
| 1229 | + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor; | |
| 1230 | + tableDataRow.iOppositeColor = 0; | |
| 1231 | + tableDataRow.iOppositeSpecialColor = 0; | |
| 1232 | + } else { | |
| 1233 | + tableDataRow.iOppositeColor = 0; | |
| 1234 | + tableDataRow.iOppositeSpecialColor = 0; | |
| 1235 | + } | |
| 1236 | + } else if (tableDataRow.iPrintModePo === 1) { | |
| 1237 | + tableDataRow.iPrintMode = 3; | |
| 1238 | + if (tableDataRow.iPositiveColor === 0) { | |
| 1239 | + tableDataRow.iPositiveColor = 0; | |
| 1240 | + tableDataRow.iPositiveSpecialColor = 0; | |
| 1241 | + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? 4 : tableDataRow.iOppositeColor; | |
| 1242 | + } else { | |
| 1243 | + tableDataRow.iPositiveColor = 0; | |
| 1244 | + tableDataRow.iPositiveSpecialColor = 0; | |
| 1245 | + } | |
| 1246 | + } else { | |
| 1247 | + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor; | |
| 1248 | + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor; | |
| 1249 | + } | |
| 1250 | + } else if (sFieldName === "iPrintMode") { | |
| 1251 | + if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) { | |
| 1252 | + tableDataRow.iPositiveColor = | |
| 1253 | + commonUtils.isEmpty(tableDataRow.iPositiveColor) || tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor; | |
| 1254 | + tableDataRow.iOppositeColor = tableDataRow.iPositiveColor; | |
| 1255 | + tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor; | |
| 1256 | + } else if (tableDataRow.iPrintMode === 2) { | |
| 1257 | + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor; | |
| 1258 | + tableDataRow.iOppositeColor = tableDataRow.iOppositeColor === 0 ? tableDataRow.iPositiveColor : tableDataRow.iOppositeColor; | |
| 1259 | + } else if (tableDataRow.iPrintMode === 3) { | |
| 1260 | + tableDataRow.iPositiveColor = tableDataRow.iPositiveColor === 0 ? 4 : tableDataRow.iPositiveColor; | |
| 1261 | + tableDataRow.iOppositeColor = 0; | |
| 1262 | + tableDataRow.iOppositeSpecialColor = 0; | |
| 1263 | + } else if (tableDataRow.iPrintMode === 4) { | |
| 1264 | + tableDataRow.iPositiveColor = 0; | |
| 1265 | + tableDataRow.iPositiveSpecialColor = 0; | |
| 1266 | + tableDataRow.iOppositeColor = 0; | |
| 1267 | + tableDataRow.iOppositeSpecialColor = 0; | |
| 1268 | + } | |
| 1269 | + } else if (sFieldName === "iPositiveColor" || sFieldName === "iPositiveSpecialColor") { | |
| 1270 | + if (tableDataRow.iPrintMode === 0 || tableDataRow.iPrintMode === 1) { | |
| 1271 | + tableDataRow.iOppositeColor = tableDataRow.iPositiveColor; | |
| 1272 | + tableDataRow.iOppositeSpecialColor = tableDataRow.iPositiveSpecialColor; | |
| 1273 | + } | |
| 1274 | + } else if (sFieldName === "dSinglePQty") { | |
| 1275 | + /* 排版数改变时 如果该控制表合版数据只有一条 则改变packData该条的拼版数 改变备注 */ | |
| 1276 | + if (commonUtils.isNotEmptyArr(packData)) { | |
| 1277 | + const packFilterData = packData.filter(item => item.sControlId === tableDataRow.sId); | |
| 1278 | + if (commonUtils.isNotEmptyArr(packFilterData) && packFilterData.length === 1) { | |
| 1279 | + const iIndex = packData.findIndex(itemPack => itemPack.sId === packFilterData[0].sId); | |
| 1280 | + const addState = {}; | |
| 1281 | + if (tableDataRow.dSinglePQty > 0) { | |
| 1282 | + addState.dCombineQty = tableDataRow.dSinglePQty; | |
| 1283 | + addState.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? "update" : tableDataRow.handleType; | |
| 1284 | + if (iIndex > -1) { | |
| 1285 | + packData[iIndex] = { ...packData[iIndex], ...addState }; | |
| 1286 | + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[iIndex]; | |
| 1287 | + const tableCombineSelectedData = []; | |
| 1288 | + const jsonObj = {}; | |
| 1289 | + jsonObj.sId = sId; | |
| 1290 | + jsonObj.sProductNo = sProductNo; /* 产品编号 */ | |
| 1291 | + jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */ | |
| 1292 | + jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */ | |
| 1293 | + jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */ | |
| 1294 | + jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */ | |
| 1295 | + tableCombineSelectedData.push(jsonObj); | |
| 1296 | + const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) | |
| 1297 | + ? JSON.stringify(tableCombineSelectedData) | |
| 1298 | + : ""; /* JSON对象转换为字符串存放到合版信息中 */ | |
| 1299 | + tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息"; | |
| 1300 | + } | |
| 1301 | + } | |
| 1302 | + } | |
| 1303 | + } | |
| 1304 | + } | |
| 1305 | + tableDataRow = singlePQtyChange(tableDataRow); | |
| 1306 | + /* 上机数量改变时,子级部件数量同步改变 */ | |
| 1307 | + const { dMachineQty } = tableDataRow; | |
| 1308 | + /* 查找该节的所有子节点,将上机数量改为部件数量 */ | |
| 1309 | + tableData.forEach((item, index) => { | |
| 1310 | + if (commonUtils.isNotEmptyObject(item.sAllId) && item.sAllId.indexOf(tableDataRow.sId) > -1 && item.sId !== tableDataRow.sId) { | |
| 1311 | + const addstate = {}; | |
| 1312 | + addstate.dPartsQty = dMachineQty; | |
| 1313 | + tableData[index] = { ...tableData[index], ...addstate }; | |
| 1314 | + } | |
| 1315 | + }); | |
| 1316 | + } | |
| 1317 | + if ( | |
| 1318 | + sFieldName === "dPartsLength" || | |
| 1319 | + sFieldName === "dPartsWidth" || | |
| 1320 | + sFieldName === "dMachineLength" || | |
| 1321 | + sFieldName === "dMachineWidth" || | |
| 1322 | + sFieldName === "sPrintingPlate" || | |
| 1323 | + sFieldName === "sCutMethod" || | |
| 1324 | + sFieldName === "sSpineDirection" || | |
| 1325 | + sFieldName === "iPrintMode" || | |
| 1326 | + sFieldName === "dBite" || | |
| 1327 | + sFieldName === "dBlood" | |
| 1328 | + ) { | |
| 1329 | + /* 计算材料开数 */ | |
| 1330 | + if (true) { | |
| 1331 | + // if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1332 | + // dProductLength = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[0] : 0; | |
| 1333 | + // dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */ | |
| 1334 | + // dProductLength = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductLength : 0; /* 产品长 */ | |
| 1335 | + // dProductWidth = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[1] : 0; | |
| 1336 | + // dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */ | |
| 1337 | + // dProductWidth = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductWidth : 0; /* 产品宽 */ | |
| 1338 | + // } | |
| 1339 | + | |
| 1340 | + let slaveDataRow = {}; | |
| 1341 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1342 | + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { | |
| 1343 | + slaveDataRow = slaveData[0]; | |
| 1344 | + } else if (commonUtils.isEmptyObject(tableDataRow.sCombinedMemo) || tableDataRow.sCombinedMemo === "合版信息") { | |
| 1345 | + const iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); | |
| 1346 | + if (iIndex > -1) { | |
| 1347 | + slaveDataRow = slaveData[iIndex]; | |
| 1348 | + } | |
| 1349 | + } else { | |
| 1350 | + const iIndex = slaveData.findIndex(item => tableDataRow.sCombinedMemo.includes(item.sProductNo)); | |
| 1351 | + if (iIndex > -1) { | |
| 1352 | + slaveDataRow = slaveData[iIndex]; | |
| 1353 | + } | |
| 1354 | + } | |
| 1355 | + } | |
| 1356 | + if (commonUtils.isNotEmptyObject(slaveDataRow)) { | |
| 1357 | + /* 如果有展开尺寸 则取展开尺寸 否则取产品规格 */ | |
| 1358 | + let sProductStyle = ""; | |
| 1359 | + if (slaveDataRow.sPartsStyle) { | |
| 1360 | + sProductStyle = slaveDataRow.sPartsStyle; | |
| 1361 | + } else if (slaveDataRow.sProductStyle) { | |
| 1362 | + sProductStyle = slaveDataRow.sProductStyle; | |
| 1363 | + } | |
| 1364 | + if (sProductStyle) { | |
| 1365 | + let dProductLength = !commonUtils.isEmpty(sProductStyle) && sProductStyle.split("*").length > 1 ? sProductStyle.split("*")[0] : 0; | |
| 1366 | + dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */ | |
| 1367 | + dProductLength = typeof dProductLength === "number" && !isNaN(dProductLength) ? dProductLength : 0; /* 产品长 */ | |
| 1368 | + let dProductWidth = !commonUtils.isEmpty(sProductStyle) && sProductStyle.split("*").length > 1 ? sProductStyle.split("*")[1] : 0; | |
| 1369 | + dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */ | |
| 1370 | + dProductWidth = typeof dProductLength === "number" && !isNaN(dProductLength) ? dProductWidth : 0; /* 产品宽 */ | |
| 1371 | + tableDataRow.dPartsWidth = dProductLength; | |
| 1372 | + tableDataRow.dPartsLength = dProductWidth; | |
| 1373 | + /* 控制表增加 如果 产品长>产品宽 sSpineDirection 默认1 否则 2 */ | |
| 1374 | + if (dProductLength > dProductWidth) { | |
| 1375 | + tableDataRow.sSpineDirection = "2"; /* 短书脊 */ | |
| 1376 | + } else { | |
| 1377 | + tableDataRow.sSpineDirection = "1"; /* 长书脊 */ | |
| 1378 | + } | |
| 1379 | + tableDataRow.sCutMethod = "2"; /* 默认四边裁 */ | |
| 1380 | + tableDataRow.sPrintingPlate = "1"; /* 默认四边裁 */ | |
| 1381 | + } | |
| 1382 | + } | |
| 1383 | + | |
| 1384 | + const dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsWidth, 0)); /* 产品长 */ | |
| 1385 | + const dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dPartsLength, 0)); /* 产品宽 */ | |
| 1386 | + const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */ | |
| 1387 | + const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */ | |
| 1388 | + // const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */ | |
| 1389 | + // const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */ | |
| 1390 | + | |
| 1391 | + /* 算材料开数 */ | |
| 1392 | + // const mapMaterialsKQty = this.props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth); | |
| 1393 | + // if (commonUtils.isNotEmptyObject(mapMaterialsKQty)) { | |
| 1394 | + // const dMaterialsKQty = mapMaterialsKQty.totalNum; | |
| 1395 | + // tableDataRow.dMaterialsKQty = dMaterialsKQty; | |
| 1396 | + // } | |
| 1397 | + | |
| 1398 | + /* 根据裁切方式、脊背方向、版式方向进行计算排版数 */ | |
| 1399 | + if (dProductLength !== 0 && dProductWidth !== 0) { | |
| 1400 | + const dSinglePQty = props.onResolveSinglePQty(tableDataRow); | |
| 1401 | + if (commonUtils.isNotEmptyNumber(dSinglePQty)) { | |
| 1402 | + tableDataRow.dSinglePQty = dSinglePQty; | |
| 1403 | + } | |
| 1404 | + } | |
| 1405 | + /* 算拼版数 */ | |
| 1406 | + // if (dProductLength !== 0 && dProductWidth !== 0) { | |
| 1407 | + // const mapSinglePQty = this.props.onResolveMachineComposing(dProductLength, dProductWidth, dMachineLength, dMachineWidth); | |
| 1408 | + // if (commonUtils.isNotEmptyObject(mapSinglePQty)) { | |
| 1409 | + // const dSinglePQty = mapSinglePQty.totalNum; | |
| 1410 | + // tableDataRow.dSinglePQty = dSinglePQty; | |
| 1411 | + // } | |
| 1412 | + // } | |
| 1413 | + | |
| 1414 | + if (commonUtils.isNotEmptyArr(packData)) { | |
| 1415 | + const packFilterData = packData.filter(item => item.sControlId === tableDataRow.sId); | |
| 1416 | + if (commonUtils.isNotEmptyArr(packFilterData) && packFilterData.length === 1) { | |
| 1417 | + const iIndex = packData.findIndex(itemPack => itemPack.sId === packFilterData[0].sId); | |
| 1418 | + const addState = {}; | |
| 1419 | + if (tableDataRow.dSinglePQty > 0) { | |
| 1420 | + addState.dCombineQty = tableDataRow.dSinglePQty; | |
| 1421 | + addState.handleType = commonUtils.isEmpty(tableDataRow.handleType) ? "update" : tableDataRow.handleType; | |
| 1422 | + if (iIndex > -1) { | |
| 1423 | + packData[iIndex] = { ...packData[iIndex], ...addState }; | |
| 1424 | + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packData[iIndex]; | |
| 1425 | + const tableCombineSelectedData = []; | |
| 1426 | + const jsonObj = {}; | |
| 1427 | + jsonObj.sId = sId; | |
| 1428 | + jsonObj.sProductNo = sProductNo; /* 产品编号 */ | |
| 1429 | + jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */ | |
| 1430 | + jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */ | |
| 1431 | + jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */ | |
| 1432 | + jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */ | |
| 1433 | + tableCombineSelectedData.push(jsonObj); | |
| 1434 | + const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) | |
| 1435 | + ? JSON.stringify(tableCombineSelectedData) | |
| 1436 | + : ""; /* JSON对象转换为字符串存放到合版信息中 */ | |
| 1437 | + tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息"; | |
| 1438 | + } | |
| 1439 | + } | |
| 1440 | + } | |
| 1441 | + } else { | |
| 1442 | + /* packData没数据时 */ | |
| 1443 | + const packDataRow = handlePackDataAdd(slaveItem, 0, tableDataRow.sId, "add"); | |
| 1444 | + packDataRow.dCombineQty = tableDataRow.dSinglePQty; | |
| 1445 | + packDataRow.dFactProductQty = commonUtils.isNull(slaveItem.dProductQty, 0); /* 排版数为1时,实际生产数 = 产品数 */ | |
| 1446 | + if (tableDataRow.dSinglePQty > 0) { | |
| 1447 | + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packDataRow; | |
| 1448 | + const tableCombineSelectedData = []; | |
| 1449 | + const jsonObj = {}; | |
| 1450 | + jsonObj.sId = sId; | |
| 1451 | + jsonObj.sProductNo = sProductNo; /* 产品编号 */ | |
| 1452 | + jsonObj.dCombineQty = commonUtils.isNotEmptyNumber(dCombineQty) ? dCombineQty : 0; /* 排版数 */ | |
| 1453 | + jsonObj.dProductQty = commonUtils.isNotEmptyNumber(dProductQty) ? dProductQty : 0; /* 生产数 */ | |
| 1454 | + jsonObj.dFactProductQty = commonUtils.isNotEmptyNumber(dFactProductQty) ? dFactProductQty : 0; /* 实际生产数 */ | |
| 1455 | + jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */ | |
| 1456 | + tableCombineSelectedData.push(jsonObj); | |
| 1457 | + const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) | |
| 1458 | + ? JSON.stringify(tableCombineSelectedData) | |
| 1459 | + : ""; /* JSON对象转换为字符串存放到合版信息中 */ | |
| 1460 | + tableDataRow.sCombinedMemo = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : "合版信息"; | |
| 1461 | + packData.push(packDataRow); | |
| 1462 | + } | |
| 1463 | + } | |
| 1464 | + } | |
| 1465 | + } else if (sModelsType.includes("quotation/quotation")) { | |
| 1466 | + /* 计算材料开数 */ | |
| 1467 | + // if (sFieldName === 'dMachineLength' || sFieldName === 'dMachineWidth' || sFieldName === 'dMaterialsLength' || sFieldName === 'dMaterialsWidth') { | |
| 1468 | + // let dProductLength = 0; /* 产品长 */ | |
| 1469 | + // let dProductWidth = 0; /* 产品宽 */ | |
| 1470 | + // if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1471 | + // dProductLength = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[0] : 0; | |
| 1472 | + // dProductLength = commonUtils.convertStrToNumber(commonUtils.isNull(dProductLength, 0)); /* 产品长 */ | |
| 1473 | + // dProductLength = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductLength : 0; /* 产品长 */ | |
| 1474 | + // dProductWidth = !commonUtils.isEmpty(slaveData[0].sProductStyle) && slaveData[0].sProductStyle.split('*').length === 2 ? slaveData[0].sProductStyle.split('*')[1] : 0; | |
| 1475 | + // dProductWidth = commonUtils.convertStrToNumber(commonUtils.isNull(dProductWidth, 0)); /* 产品宽 */ | |
| 1476 | + // dProductWidth = (typeof dProductLength === 'number' && !isNaN(dProductLength)) ? dProductWidth : 0; /* 产品宽 */ | |
| 1477 | + // } | |
| 1478 | + // const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */ | |
| 1479 | + // const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */ | |
| 1480 | + // const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */ | |
| 1481 | + // const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */ | |
| 1482 | + // | |
| 1483 | + // /* 算材料开数 */ | |
| 1484 | + // const mapMaterialsKQty = this.props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth); | |
| 1485 | + // if (commonUtils.isNotEmptyObject(mapMaterialsKQty)) { | |
| 1486 | + // const dMaterialsKQty = mapMaterialsKQty.totalNum; | |
| 1487 | + // tableDataRow.dMaterialsKQty = dMaterialsKQty; | |
| 1488 | + // } | |
| 1489 | + // | |
| 1490 | + // /* 算拼版数 */ | |
| 1491 | + // if (dProductLength !== 0 && dProductWidth !== 0) { | |
| 1492 | + // const mapSinglePQty = this.props.onResolveMachineComposing(dProductLength, dProductWidth, dMachineLength, dMachineWidth); | |
| 1493 | + // if (commonUtils.isNotEmptyObject(mapSinglePQty)) { | |
| 1494 | + // const dSinglePQty = mapSinglePQty.totalNum; | |
| 1495 | + // tableDataRow.dSinglePQty = dSinglePQty; | |
| 1496 | + // } | |
| 1497 | + // } | |
| 1498 | + // } | |
| 1499 | + } | |
| 1500 | + const materialsData = []; | |
| 1501 | + const processData = []; | |
| 1502 | + materialsDataOld.forEach(item => { | |
| 1503 | + const itemNew = { ...item }; | |
| 1504 | + if (itemNew.sControlId === sId) { | |
| 1505 | + itemNew.sPartsName = tableDataRow.sPartsName; | |
| 1506 | + } | |
| 1507 | + materialsData.push(itemNew); | |
| 1508 | + }); | |
| 1509 | + processDataOld.forEach(item => { | |
| 1510 | + const itemNew = { ...item }; | |
| 1511 | + if (itemNew.sControlId === sId) { | |
| 1512 | + itemNew.sPartsName = tableDataRow.sPartsName; | |
| 1513 | + } | |
| 1514 | + processData.push(itemNew); | |
| 1515 | + }); | |
| 1516 | + const materialsDataNew = sortData(tableData, materialsData); | |
| 1517 | + const processDataNew = sortData(tableData, processData); | |
| 1518 | + if (sFieldName === "sPartsName") { | |
| 1519 | + /* 部件名称与子部件同步 */ | |
| 1520 | + const { sPartsName } = tableDataRow; | |
| 1521 | + const { treeSelectedKeys, treeData } = props; | |
| 1522 | + if (commonUtils.isNotEmptyArr(treeSelectedKeys)) { | |
| 1523 | + handleSearchNodes(treeSelectedKeys[0], treeData, sPartsName); | |
| 1524 | + } | |
| 1525 | + } | |
| 1526 | + const iIndex = tableData.findIndex(item => item.sId === sId); | |
| 1527 | + tableData[iIndex] = tableDataRow; | |
| 1528 | + props.onSaveState({ [`${name}Data`]: tableData, materialsData: materialsDataNew, processData: processDataNew, packData }); | |
| 1529 | + } else if (name === "materials") { | |
| 1530 | + const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, app, sModelsId } = props; | |
| 1531 | + const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 1532 | + if (tableDataRow === undefined) return; | |
| 1533 | + if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === "dMaterialsStockAuxiliaryQty") > -1) { | |
| 1534 | + const urlMaterialsStock = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; | |
| 1535 | + const valueMaterialsStock = { | |
| 1536 | + sProName: "Sp_Inventory_MaterialsInventoryV56", | |
| 1537 | + paramsMap: { | |
| 1538 | + sMaterialsGuid: tableDataRow.sMaterialsId, | |
| 1539 | + sMaterialsStyle: tableDataRow.sMaterialsStyle, | |
| 1540 | + sWarehouseGuid: tableDataRow.sWarehouseId, | |
| 1541 | + sLocationalGuid: tableDataRow.sLocationId, | |
| 1542 | + sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId, | |
| 1543 | + sDefine_no: tableDataRow.sDefineNo, | |
| 1544 | + sDefine_no2: tableDataRow.sDefineNo2, | |
| 1545 | + iGetQty: 1, | |
| 1546 | + iHasZero: 1, | |
| 1547 | + }, | |
| 1548 | + }; | |
| 1549 | + const returnDataMaterialsStock = (await commonServices.postValueService(app.token, valueMaterialsStock, urlMaterialsStock)).data; | |
| 1550 | + if (returnDataMaterialsStock.code === 1) { | |
| 1551 | + tableDataRow.dMaterialsStockAuxiliaryQty = returnDataMaterialsStock.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty; | |
| 1552 | + } | |
| 1553 | + } | |
| 1554 | + if (Object.keys(changeValue).length > 0 && Object.keys(changeValue).findIndex(item => item === "dMaterialsStockAvailableQty") > -1) { | |
| 1555 | + const urlMaterialsAvailableQty = `${commonConfig.server_host}business/getProData?sModelsId=${sModelsId}`; | |
| 1556 | + const valueMaterialsAvailableQty = { | |
| 1557 | + sProName: "Sp_Inventory_MaterialsInventoryV56", | |
| 1558 | + paramsMap: { | |
| 1559 | + sMaterialsGuid: tableDataRow.sMaterialsId, | |
| 1560 | + sMaterialsStyle: tableDataRow.sMaterialsStyle, | |
| 1561 | + sWarehouseGuid: tableDataRow.sWarehouseId, | |
| 1562 | + sLocationalGuid: tableDataRow.sLocationId, | |
| 1563 | + sWarehouseLocationGuid: tableDataRow.sWarehouseLocationId, | |
| 1564 | + sDefine_no: tableDataRow.sDefineNo, | |
| 1565 | + sDefine_no2: tableDataRow.sDefineNo2, | |
| 1566 | + iGetQty: 2, | |
| 1567 | + iHasZero: 1, | |
| 1568 | + }, | |
| 1569 | + }; | |
| 1570 | + const returnDataMaterialsAvailableQty = (await commonServices.postValueService(app.token, valueMaterialsAvailableQty, urlMaterialsAvailableQty)) | |
| 1571 | + .data; | |
| 1572 | + if (returnDataMaterialsAvailableQty.code === 1) { | |
| 1573 | + tableDataRow.dMaterialsStockAvailableQty = returnDataMaterialsAvailableQty.dataset.rows[0].dataSet.outData[0].dAuxiliaryQty; | |
| 1574 | + } | |
| 1575 | + } | |
| 1576 | + const iIndex = tableData.findIndex(item => item.sId === sId); | |
| 1577 | + if (iIndex > -1) { | |
| 1578 | + tableData[iIndex] = tableDataRow; | |
| 1579 | + } | |
| 1580 | + if (sFieldName === "sType") { | |
| 1581 | + if (tableData[iIndex].sType === "2") { | |
| 1582 | + tableData[iIndex].sControlId = ""; | |
| 1583 | + tableData[iIndex].sPartsName = ""; | |
| 1584 | + } else { | |
| 1585 | + const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys) | |
| 1586 | + ? -1 | |
| 1587 | + : controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]); | |
| 1588 | + if (iControlIndex > -1) { | |
| 1589 | + tableData[iIndex].sControlId = controlData[iControlIndex].sId; | |
| 1590 | + tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName; | |
| 1591 | + } | |
| 1592 | + } | |
| 1593 | + } | |
| 1594 | + props.onSaveState({ [`${name}Data`]: tableData }); | |
| 1595 | + } else if (name === "materials0" || name === "materials1" || name === "materials2" || name === "materials0Child") { | |
| 1596 | + name = "materials"; | |
| 1597 | + const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, materials0Data, materials0SelectedRowKeys } = props; | |
| 1598 | + let oldRowMap = {}; | |
| 1599 | + if (sFieldName === "sInkBOM") { | |
| 1600 | + const iOldIndex = tableData.findIndex(item => item.sId === sId); | |
| 1601 | + if (iOldIndex > -1) { | |
| 1602 | + const tableDataOldRow = JSON.parse(JSON.stringify(tableData[iOldIndex])); | |
| 1603 | + oldRowMap = { | |
| 1604 | + sInkBOMId: tableDataOldRow.sInkBOMId, | |
| 1605 | + sInkBOMsSlaveId: tableDataOldRow.sInkBOMsSlaveId, | |
| 1606 | + sInkBOMsMaterialsId: tableDataOldRow.sInkBOMsMaterialsId, | |
| 1607 | + }; | |
| 1608 | + } | |
| 1609 | + } | |
| 1610 | + const tableDataRow = await props.onDataChange("materials", sFieldName, changeValue, sId, dropDownData, true); | |
| 1611 | + | |
| 1612 | + if (tableDataRow === undefined) return; | |
| 1613 | + tableDataRow.oldRowMap = oldRowMap; | |
| 1614 | + | |
| 1615 | + const iIndex = tableData.findIndex(item => item.sId === sId); | |
| 1616 | + if (iIndex > -1) { | |
| 1617 | + tableData[iIndex] = tableDataRow; | |
| 1618 | + } | |
| 1619 | + props.onSaveState({ [`${name}Data`]: tableData }); | |
| 1620 | + } else if (name === "materialsChild") { | |
| 1621 | + /* 替代料 */ | |
| 1622 | + name = "materials"; | |
| 1623 | + const { [`${name}Data`]: tableData, controlData, controlSelectedRowKeys, materials0Data, materials0SelectedRowKeys } = props; | |
| 1624 | + const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 1625 | + if (sFieldName === "dPackageQty") { | |
| 1626 | + if (commonUtils.isNotEmptyArr(controlSelectedRowKeys)) { | |
| 1627 | + const iControlIndex = controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]); | |
| 1628 | + if (iControlIndex > -1) { | |
| 1629 | + tableDataRow.dAuxiThousheetQty = ((controlData[iControlIndex].dSinglePQty * 1000.0) / tableDataRow.dPackageQty).toFixed(3); | |
| 1630 | + } | |
| 1631 | + } | |
| 1632 | + } | |
| 1633 | + if (tableDataRow === undefined) return; | |
| 1634 | + const iIndex = tableData.findIndex(item => item.sId === sId); | |
| 1635 | + if (iIndex > -1) { | |
| 1636 | + tableData[iIndex] = tableDataRow; | |
| 1637 | + } | |
| 1638 | + props.onSaveState({ [`${name}Data`]: tableData }); | |
| 1639 | + } else if (name === "process") { | |
| 1640 | + const { | |
| 1641 | + [`${name}Data`]: tableData, | |
| 1642 | + sModelsId, | |
| 1643 | + masterData, | |
| 1644 | + slaveData, | |
| 1645 | + controlData, | |
| 1646 | + controlSelectedRowKeys, | |
| 1647 | + materialsData, | |
| 1648 | + processConfig, | |
| 1649 | + token, | |
| 1650 | + } = props; | |
| 1651 | + let { processDelData, materialsDelData } = props; | |
| 1652 | + const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 1653 | + if (tableDataRow === undefined) return; | |
| 1654 | + let iIndex = tableData.findIndex(item => item.sId === sId); | |
| 1655 | + let tableDataRowOld = {}; | |
| 1656 | + let iMaterialsIndex = -1; | |
| 1657 | + let sControlId = ""; | |
| 1658 | + if (iIndex > -1) { | |
| 1659 | + iMaterialsIndex = materialsData.findIndex( | |
| 1660 | + item => item.sControlId === tableData[iIndex].sControlId && item.sProcessId === tableData[iIndex].sProcessId | |
| 1661 | + ); | |
| 1662 | + tableDataRowOld = tableData[iIndex]; | |
| 1663 | + tableData[iIndex] = tableDataRow; | |
| 1664 | + sControlId = tableData[iIndex].sControlId; | |
| 1665 | + } | |
| 1666 | + const addState = {}; | |
| 1667 | + if (sFieldName === "sProcessId" || sFieldName.includes("sProcessName")) { | |
| 1668 | + const bProcessAssort = true; | |
| 1669 | + let returnProcessAssort = []; | |
| 1670 | + let processAssignAssort = ""; | |
| 1671 | + let dropDownDataProcessName; | |
| 1672 | + const sProcessParamStriIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === "sProcessParamStr" && item.bVisible); | |
| 1673 | + if (sProcessParamStriIndex > -1 && commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) { | |
| 1674 | + tableData[iIndex].sProcessParamStr = "工艺参数"; | |
| 1675 | + } else if (sProcessParamStriIndex > -1) { | |
| 1676 | + tableData[iIndex].sProcessParamStr = ""; | |
| 1677 | + } | |
| 1678 | + /* 设置工艺参数下拉 */ | |
| 1679 | + if (commonUtils.isNotEmptyObject(tableData[iIndex].sProcessParam)) { | |
| 1680 | + tableData[iIndex] = { ...tableData[iIndex], ...commonUtils.convertStrToObj(tableData[iIndex].sProcessParam) }; | |
| 1681 | + } | |
| 1682 | + | |
| 1683 | + if (bProcessAssort) { | |
| 1684 | + const dataUrl = `${commonConfig.server_host}salesorder/getProcessAssort?sModelsId=${sModelsId}`; | |
| 1685 | + const dataProcessAssort = (await commonServices.postValueService(token, {}, dataUrl)).data; | |
| 1686 | + if (dataProcessAssort.code === 1) { | |
| 1687 | + returnProcessAssort = dataProcessAssort.dataset.rows[0].processassort; | |
| 1688 | + const iIndex = processConfig.gdsconfigformslave.findIndex(item => item.sName === "sProcessName"); | |
| 1689 | + if (iIndex > -1) { | |
| 1690 | + const sqlDropDownData = await props.getSqlDropDownData(sModelsId, "slave", processConfig.gdsconfigformslave[iIndex]); | |
| 1691 | + dropDownDataProcessName = sqlDropDownData.dropDownData; | |
| 1692 | + processAssignAssort = processConfig.gdsconfigformslave[iIndex].sAssignField; | |
| 1693 | + } | |
| 1694 | + } | |
| 1695 | + } | |
| 1696 | + const iControlIndex = commonUtils.isEmptyArr(controlSelectedRowKeys) | |
| 1697 | + ? -1 | |
| 1698 | + : controlData.findIndex(item => item.sId === controlSelectedRowKeys[0]); | |
| 1699 | + // 配套工序 | |
| 1700 | + if (bProcessAssort) { | |
| 1701 | + const newCopyTo = {}; | |
| 1702 | + newCopyTo.master = masterData; | |
| 1703 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 1704 | + newCopyTo.slave = slaveData[0]; | |
| 1705 | + } | |
| 1706 | + /* 切换工序时 先删除原工序配套工序 */ | |
| 1707 | + if (commonUtils.isEmptyArr(processDelData)) { | |
| 1708 | + processDelData = []; | |
| 1709 | + } | |
| 1710 | + if (commonUtils.isEmptyArr(materialsDelData)) { | |
| 1711 | + materialsDelData = []; | |
| 1712 | + } | |
| 1713 | + returnProcessAssort | |
| 1714 | + .filter(item => item.sParentId === tableDataRowOld.sProcessId) | |
| 1715 | + .forEach(itemProcessAssort => { | |
| 1716 | + const iProcessIndex = tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === sControlId); | |
| 1717 | + if (iProcessIndex > -1) { | |
| 1718 | + const processDataRow = tableData[iProcessIndex]; | |
| 1719 | + tableData.splice(iProcessIndex, 1); | |
| 1720 | + processDataRow.handleType = "del"; | |
| 1721 | + processDelData.push(processDataRow); | |
| 1722 | + /* 删除配套材料 */ | |
| 1723 | + const iMaterialsIndex = materialsData.findIndex( | |
| 1724 | + item => item.sMaterialsName === processDataRow.sProcessName && item.sControlId === sControlId | |
| 1725 | + ); | |
| 1726 | + if (iMaterialsIndex > -1) { | |
| 1727 | + const materialsDataRow = materialsData[iMaterialsIndex]; | |
| 1728 | + materialsData.splice(iMaterialsIndex, 1); | |
| 1729 | + materialsDataRow.handleType = "del"; | |
| 1730 | + materialsDelData.push(materialsDataRow); | |
| 1731 | + } | |
| 1732 | + } | |
| 1733 | + }); | |
| 1734 | + if (commonUtils.isNotEmptyArr(processDelData)) { | |
| 1735 | + addState.processDelData = processDelData; | |
| 1736 | + } | |
| 1737 | + if (commonUtils.isNotEmptyArr(materialsDelData)) { | |
| 1738 | + addState.materialsDelData = materialsDelData; | |
| 1739 | + } | |
| 1740 | + iIndex = tableData.findIndex(item => item.sId === tableDataRow.sId); | |
| 1741 | + returnProcessAssort | |
| 1742 | + .filter(item => item.sParentId === tableDataRow.sProcessId) | |
| 1743 | + .forEach(itemProcessAssort => { | |
| 1744 | + const iIndex = dropDownDataProcessName.findIndex(item => item.sId === itemProcessAssort.sProcessId); | |
| 1745 | + if (iIndex > -1) { | |
| 1746 | + const iNewProcessIndex = | |
| 1747 | + dropDownDataProcessName[iIndex].sType === "3" | |
| 1748 | + ? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) | |
| 1749 | + : tableData.findIndex( | |
| 1750 | + item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId | |
| 1751 | + ); | |
| 1752 | + if (iIndex > -1 && iNewProcessIndex < 0) { | |
| 1753 | + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值 | |
| 1754 | + processRow = { ...processRow, ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo) }; // 取赋值字段 | |
| 1755 | + processRow.handleType = "add"; | |
| 1756 | + processRow.sId = commonUtils.createSid(); | |
| 1757 | + processRow.sParentId = masterData.sId; | |
| 1758 | + processRow.sType = dropDownDataProcessName[iIndex].sType; | |
| 1759 | + if (iControlIndex > -1 && processRow.sType !== "3") { | |
| 1760 | + processRow.sControlId = controlData[iControlIndex].sId; | |
| 1761 | + processRow.sPartsName = controlData[iControlIndex].sPartsName; | |
| 1762 | + } | |
| 1763 | + // const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 1764 | + // if (iSlaveIndex > -1) { | |
| 1765 | + // processRow.sSlaveId = slaveData[iSlaveIndex].sId; | |
| 1766 | + // } | |
| 1767 | + tableData.push(processRow); | |
| 1768 | + | |
| 1769 | + if (itemProcessAssort.sType === "all") { | |
| 1770 | + controlData | |
| 1771 | + .filter(item => item.sId !== controlData[iControlIndex].sId) | |
| 1772 | + .forEach(controlTableRow => { | |
| 1773 | + const iNewProcessIndex = | |
| 1774 | + dropDownDataProcessName[iIndex].sType === "3" | |
| 1775 | + ? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId) | |
| 1776 | + : tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId); | |
| 1777 | + if (iNewProcessIndex < 0) { | |
| 1778 | + let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值 | |
| 1779 | + processRow = { | |
| 1780 | + ...processRow, | |
| 1781 | + ...commonFunc.getAssignFieldValue(processAssignAssort, dropDownDataProcessName[iIndex], newCopyTo), | |
| 1782 | + }; // 取赋值字段 | |
| 1783 | + processRow.handleType = "add"; | |
| 1784 | + processRow.sId = commonUtils.createSid(); | |
| 1785 | + processRow.sParentId = masterData.sId; | |
| 1786 | + processRow.sType = dropDownDataProcessName[iIndex].sType; | |
| 1787 | + if (iControlIndex > -1 && processRow.sType !== "3") { | |
| 1788 | + processRow.sControlId = controlTableRow.sId; | |
| 1789 | + processRow.sPartsName = controlTableRow.sPartsName; | |
| 1790 | + } | |
| 1791 | + // const iSlaveIndex = slaveData.findIndex(item => item.sId === slaveSelectedRowKeys[0]); | |
| 1792 | + // if (iSlaveIndex > -1) { | |
| 1793 | + // processRow.sSlaveId = slaveData[iSlaveIndex].sId; | |
| 1794 | + // } | |
| 1795 | + tableData.push(processRow); | |
| 1796 | + } | |
| 1797 | + }); | |
| 1798 | + } | |
| 1799 | + } | |
| 1800 | + } | |
| 1801 | + }); | |
| 1802 | + } | |
| 1803 | + if (tableData[iIndex].sType === "3") { | |
| 1804 | + tableData[iIndex].sControlId = ""; | |
| 1805 | + tableData[iIndex].sPartsName = ""; | |
| 1806 | + } else if (iControlIndex > -1) { | |
| 1807 | + tableData[iIndex].sControlId = controlData[iControlIndex].sId; | |
| 1808 | + tableData[iIndex].sPartsName = controlData[iControlIndex].sPartsName; | |
| 1809 | + if (iMaterialsIndex > -1) { | |
| 1810 | + materialsData[iMaterialsIndex].sProcessId = tableData[iIndex].sProcessId; | |
| 1811 | + materialsData[iMaterialsIndex].sProcessTbId = tableData[iIndex].sId; | |
| 1812 | + materialsData[iMaterialsIndex].sMaterialsProcessName = tableData[iIndex].sProcessName; | |
| 1813 | + } | |
| 1814 | + } | |
| 1815 | + } | |
| 1816 | + props.onSaveState({ [`${name}Data`]: tableData, materialsSelectedRowKeys: [], ...addState }); | |
| 1817 | + } else if (name === "pack") { | |
| 1818 | + const { packData, packSelectedRowKeys } = props; | |
| 1819 | + const tableDataRow = await props.onDataChange(name, sFieldName, changeValue, sId, dropDownData, true); | |
| 1820 | + if (tableDataRow === undefined) return; | |
| 1821 | + const iIndex = packData.findIndex(item => item.sId === sId); | |
| 1822 | + packData[iIndex] = tableDataRow; | |
| 1823 | + if (sFieldName === "dCombineQty" || sFieldName === "dProductQty") { | |
| 1824 | + handleGetdFactProductQty(packSelectedRowKeys, packData); | |
| 1825 | + props.onSaveState({ packData }); | |
| 1826 | + } | |
| 1827 | + } else { | |
| 1828 | + props.onDataChange(name, sFieldName, changeValue, sId, dropDownData); | |
| 1829 | + } | |
| 1830 | +}; | |
| 1831 | +const singlePQtyChange = tableDataRow => { | |
| 1832 | + const bZfZf = tableDataRow.iPrintMode === 2; // 正反版 | |
| 1833 | + const bSample = tableDataRow.dSumPQty >= 4; // 样本 | |
| 1834 | + tableDataRow.iPrintModePo = tableDataRow.iPrintMode <= 2 ? 2 : tableDataRow.iPrintMode === 3 ? 0 : -1; | |
| 1835 | + | |
| 1836 | + if (bSample) { | |
| 1837 | + if (tableDataRow.dSinglePQty > 0) { | |
| 1838 | + tableDataRow.dPlateQty = Math.ceil(tableDataRow.dSumPQty / tableDataRow.dSinglePQty); | |
| 1839 | + } | |
| 1840 | + | |
| 1841 | + if (bZfZf && tableDataRow.iPrintModePo === 2) { | |
| 1842 | + // 双面样本,正反 | |
| 1843 | + if (tableDataRow.dPlateQty < 2) { | |
| 1844 | + // 不管建议放正自翻版了,点方式什么是什么 | |
| 1845 | + tableDataRow.dPlateQty = 2; | |
| 1846 | + tableDataRow.iStick = Math.ceil(commonUtils.isNull(tableDataRow.dPlateQty, 0) / 2); | |
| 1847 | + tableDataRow.dSumPlateQty = | |
| 1848 | + tableDataRow.iStick * | |
| 1849 | + (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + | |
| 1850 | + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + | |
| 1851 | + commonUtils.isNull(tableDataRow.iOppositeColor, 0) + | |
| 1852 | + commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0)); | |
| 1853 | + } else { | |
| 1854 | + if (tableDataRow.iPrintModePo !== 2) { | |
| 1855 | + // 单面样本 | |
| 1856 | + tableDataRow.dPlateQty = Math.ceil((commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty); | |
| 1857 | + tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty); | |
| 1858 | + tableDataRow.dSumPlateQty = | |
| 1859 | + tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0)); | |
| 1860 | + } else { | |
| 1861 | + tableDataRow.dPlateQty = Math.ceil( | |
| 1862 | + commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1) | |
| 1863 | + ); | |
| 1864 | + tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty / 2); | |
| 1865 | + } | |
| 1866 | + tableDataRow.dSumPlateQty = | |
| 1867 | + tableDataRow.iStick * | |
| 1868 | + (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + | |
| 1869 | + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + | |
| 1870 | + commonUtils.isNull(tableDataRow.iOppositeColor, 0) + | |
| 1871 | + commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0)); | |
| 1872 | + } | |
| 1873 | + } else { | |
| 1874 | + if (tableDataRow.iPrintModePo !== 2) { | |
| 1875 | + // 单面样本 | |
| 1876 | + tableDataRow.dPlateQty = Math.ceil((commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / tableDataRow.dSinglePQty); | |
| 1877 | + } else { | |
| 1878 | + tableDataRow.dPlateQty = Math.ceil( | |
| 1879 | + commonUtils.isNull(tableDataRow.dSumPQty, 0) / commonUtils.isNull(commonUtils.nullIf(tableDataRow.dSinglePQty, 0), 1) | |
| 1880 | + ); | |
| 1881 | + } | |
| 1882 | + tableDataRow.iStick = Math.ceil(tableDataRow.dPlateQty); | |
| 1883 | + tableDataRow.dSumPlateQty = | |
| 1884 | + tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0)); | |
| 1885 | + } | |
| 1886 | + if (tableDataRow.iStick > 0 && tableDataRow.dSinglePQty > 0) { | |
| 1887 | + tableDataRow.dMachineQty = commonUtils.convertFixNum( | |
| 1888 | + (commonUtils.isNull(tableDataRow.dPartsQty, 0) * commonUtils.isNull(tableDataRow.dSumPQty, 0) * 0.5) / | |
| 1889 | + tableDataRow.dSinglePQty / | |
| 1890 | + tableDataRow.iStick, | |
| 1891 | + 0 | |
| 1892 | + ); | |
| 1893 | + tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick; | |
| 1894 | + } | |
| 1895 | + } else { | |
| 1896 | + tableDataRow.iStick = 1; | |
| 1897 | + tableDataRow.dSumPlateQty = | |
| 1898 | + tableDataRow.iStick * | |
| 1899 | + (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + | |
| 1900 | + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + | |
| 1901 | + commonUtils.isNull(tableDataRow.iOppositeColor, 0) + | |
| 1902 | + commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0)); | |
| 1903 | + if (bZfZf && tableDataRow.iPrintModePo === 2) { | |
| 1904 | + tableDataRow.dPlateQty = 2; | |
| 1905 | + tableDataRow.dSumPlateQty = | |
| 1906 | + tableDataRow.iStick * | |
| 1907 | + (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + | |
| 1908 | + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0) + | |
| 1909 | + commonUtils.isNull(tableDataRow.iOppositeColor, 0) + | |
| 1910 | + commonUtils.isNull(tableDataRow.iOppositeSpecialColor, 0)); | |
| 1911 | + } else { | |
| 1912 | + tableDataRow.dPlateQty = 1; | |
| 1913 | + tableDataRow.dSumPlateQty = | |
| 1914 | + tableDataRow.iStick * (commonUtils.isNull(tableDataRow.iPositiveColor, 0) + commonUtils.isNull(tableDataRow.iPositiveSpecialColor, 0)); | |
| 1915 | + } | |
| 1916 | + | |
| 1917 | + if (tableDataRow.dSinglePQty > 0) { | |
| 1918 | + if (tableDataRow.iPage > 1) { | |
| 1919 | + // 笔记本 用 非样本 来做, 倍率是每页都一样才可以用 原先 /2 是指页数, 现在直接按张数 | |
| 1920 | + tableDataRow.dMachineQty = commonUtils.convertFixNum((tableDataRow.dPartsQty * tableDataRow.iPage) / tableDataRow.dSinglePQty, 0); | |
| 1921 | + } else { | |
| 1922 | + tableDataRow.dMachineQty = commonUtils.convertFixNum(commonUtils.isNull(tableDataRow.dPartsQty, 0) / tableDataRow.dSinglePQty, 0); | |
| 1923 | + tableDataRow.dSumMachineQty = tableDataRow.dMachineQty * tableDataRow.iStick; | |
| 1924 | + } | |
| 1925 | + } | |
| 1926 | + } | |
| 1927 | + | |
| 1928 | + /* 计算材料开数 */ | |
| 1929 | + // const dMachineLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineLength, 0)); /* 上机长 */ | |
| 1930 | + // const dMachineWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMachineWidth, 0)); /* 上机宽 */ | |
| 1931 | + // const dMaterialsLength = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsLength, 0)); /* 材料长 */ | |
| 1932 | + // const dMaterialsWidth = commonUtils.convertStrToNumber(commonUtils.isNull(tableDataRow.dMaterialsWidth, 0)); /* 材料宽 */ | |
| 1933 | + // const sResult = this.props.onResolveMachineComposing(dMachineLength, dMachineWidth, dMaterialsLength, dMaterialsWidth); | |
| 1934 | + // if (commonUtils.isNotEmptyObject(sResult)) { | |
| 1935 | + // const dMaterialsKQty = sResult.totalNum; | |
| 1936 | + // tableDataRow.dMaterialsKQty = dMaterialsKQty; | |
| 1937 | + // } | |
| 1938 | + | |
| 1939 | + return tableDataRow; | |
| 1940 | +}; | |
| 1941 | +const handlePackDataAdd = (item, index, sControlId, handleType) => { | |
| 1942 | + const tableDataRow = {}; | |
| 1943 | + if (handleType === "add") { | |
| 1944 | + tableDataRow.sId = commonUtils.createSid(); | |
| 1945 | + tableDataRow.handleType = "add"; | |
| 1946 | + tableDataRow.sSlaveId = item.sId; | |
| 1947 | + tableDataRow.iOrder = item.iOrder; | |
| 1948 | + } | |
| 1949 | + tableDataRow.sParentId = item.sParentId; | |
| 1950 | + if (commonUtils.isNotEmptyObject(sControlId)) { | |
| 1951 | + tableDataRow.sControlId = sControlId; | |
| 1952 | + } | |
| 1953 | + // if (commonUtils.isNotEmptyObject(index)) { | |
| 1954 | + // tableDataRow.iOrder = index + 1; | |
| 1955 | + // } | |
| 1956 | + tableDataRow.sProductId = item.sProductId; /* 产品id */ | |
| 1957 | + tableDataRow.sCustomerId = item.sCustomerId; /* 客户id */ | |
| 1958 | + tableDataRow.sCustomerName = item.sCustomerName; /* 客户名称 */ | |
| 1959 | + tableDataRow.sProductName = item.sProductName; /* 产品名称 */ | |
| 1960 | + tableDataRow.sProductNo = item.sProductNo; /* 产品编号 */ | |
| 1961 | + /* 主表配置bProductQtyAdd 则代表产品数量不叠加备货数 赠送数 */ | |
| 1962 | + let bProductQtySelf = false; | |
| 1963 | + if (commonUtils.isNotEmptyObject(props.masterConfig) && commonUtils.isNotEmptyArr(props.masterConfig.gdsconfigformslave)) { | |
| 1964 | + const iIndex = props.masterConfig.gdsconfigformslave.findIndex(item => item.sControlName === "bProductQtySelf"); | |
| 1965 | + if (iIndex > -1) { | |
| 1966 | + bProductQtySelf = true; | |
| 1967 | + } | |
| 1968 | + } | |
| 1969 | + if (bProductQtySelf) { | |
| 1970 | + tableDataRow.dProductQty = commonUtils.isNull(item.dProductQty, 0); | |
| 1971 | + } else { | |
| 1972 | + tableDataRow.dProductQty = | |
| 1973 | + commonUtils.isNull(item.dProductQty, 0) + commonUtils.isNull(item.dGiveQty, 0) + commonUtils.isNull(item.dStockupQty, 0); /* 生产数量 */ | |
| 1974 | + } | |
| 1975 | + tableDataRow.sProductUnit = item.sProductUnit; /* 单位 */ | |
| 1976 | + tableDataRow.sProductStyle = item.sProductStyle; /* 产品规格 */ | |
| 1977 | + return tableDataRow; | |
| 1978 | +}; | |
| 815 | 1979 | const QuotationAllMaster = baseProps => { |
| 816 | 1980 | const props = masterEvent(baseProps); |
| 817 | 1981 | if (!props) { |
| ... | ... | @@ -821,6 +1985,6 @@ const QuotationAllMaster = baseProps => { |
| 821 | 1985 | return null; |
| 822 | 1986 | } |
| 823 | 1987 | |
| 824 | - return <QuotationAllprogressDetail {...props} />; | |
| 1988 | + return <QuotationAllprogressDetail {...props} onDataChange={handleTableChange} onButtonClick={handleButtonClick} />; | |
| 825 | 1989 | }; |
| 826 | 1990 | export default QuotationAllMaster; | ... | ... |