Commit 766b9b79556817442932a5c8b5de2057be7642a9
1 parent
ab46dc9a
核价
Showing
2 changed files
with
142 additions
and
17 deletions
src/mobile/quotation/detailNew.jsx
| ... | ... | @@ -93,7 +93,7 @@ const QuickQuoteEvent = props => { |
| 93 | 93 | const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}`; |
| 94 | 94 | commonServices |
| 95 | 95 | .getService(props.token, configUrl) |
| 96 | - .then(({ data: masterReturn }) => { | |
| 96 | + .then(async ({ data: masterReturn }) => { | |
| 97 | 97 | if (masterReturn.code === 1) { |
| 98 | 98 | const formData = masterReturn.dataset.rows[0].formData; |
| 99 | 99 | const masterConfig = formData.find(x => x.sTbName === "QuoQuotationmaster"); |
| ... | ... | @@ -1294,7 +1294,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 1294 | 1294 | sClientType: "1", |
| 1295 | 1295 | loading: false, |
| 1296 | 1296 | sSysLogSrcId: masterData.sId, |
| 1297 | - }); | |
| 1297 | + },props); | |
| 1298 | 1298 | props.onSaveState({ |
| 1299 | 1299 | slaveData, |
| 1300 | 1300 | packData, |
| ... | ... | @@ -1343,6 +1343,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { |
| 1343 | 1343 | }; |
| 1344 | 1344 | /** 按钮操作事件 */ |
| 1345 | 1345 | const handleButtonClick = async (name, props) => { |
| 1346 | + console.log("🚀 ~ handleButtonClick ~ props:", props) | |
| 1346 | 1347 | if (name === "BtnDraft") { |
| 1347 | 1348 | const { |
| 1348 | 1349 | masterConfig, |
| ... | ... | @@ -1351,7 +1352,7 @@ const handleButtonClick = async (name, props) => { |
| 1351 | 1352 | slaveData, |
| 1352 | 1353 | slaveDelData, |
| 1353 | 1354 | controlConfig, |
| 1354 | - controlData, | |
| 1355 | + controlData, // 需要 | |
| 1355 | 1356 | controlDelData, |
| 1356 | 1357 | materialsConfig, |
| 1357 | 1358 | materialsData, |
| ... | ... | @@ -1363,7 +1364,7 @@ const handleButtonClick = async (name, props) => { |
| 1363 | 1364 | colorData, |
| 1364 | 1365 | colorDelData, |
| 1365 | 1366 | packConfig, |
| 1366 | - packData, | |
| 1367 | + packData, // 需要 | |
| 1367 | 1368 | packDelData, |
| 1368 | 1369 | } = props; |
| 1369 | 1370 | const data = []; |
| ... | ... | @@ -1507,22 +1508,96 @@ const handleButtonClick = async (name, props) => { |
| 1507 | 1508 | if (commonUtils.isNotEmptyObject(packConfig)) { |
| 1508 | 1509 | data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData)); |
| 1509 | 1510 | } |
| 1511 | + // 核价后保存 | |
| 1510 | 1512 | props.onSaveData({ |
| 1511 | 1513 | data, |
| 1512 | 1514 | sClientType: "1", |
| 1513 | 1515 | loading: false, |
| 1514 | 1516 | sSysLogSrcId: masterData.sId, |
| 1515 | 1517 | bIsUnCcg: false, |
| 1516 | - }); | |
| 1518 | + },props); | |
| 1517 | 1519 | } |
| 1518 | 1520 | }; |
| 1519 | 1521 | const handleSaveData = async (params, props) => { |
| 1520 | - console.log("🚀 ~ handleSaveData ~ params:", params); | |
| 1522 | + const { | |
| 1523 | + token, | |
| 1524 | + sModelsId, | |
| 1525 | + currentId, | |
| 1526 | + masterData, | |
| 1527 | + masterConfig, | |
| 1528 | + slaveConfig, | |
| 1529 | + checkConfig, | |
| 1530 | + billnosetting, | |
| 1531 | + app, | |
| 1532 | + sModelsType, | |
| 1533 | + controlConfig, | |
| 1534 | + materialsConfig, | |
| 1535 | + processConfig, | |
| 1536 | + colorConfig, | |
| 1537 | + packConfig, | |
| 1538 | + orderDetailConfig, | |
| 1539 | + dispatch, | |
| 1540 | + slaveChildConfig, | |
| 1541 | + } = props; | |
| 1542 | + const { userinfo } = app; | |
| 1543 | + const { copyTo } = app.currentPane; | |
| 1544 | + const onSendSocketMessage = props.handleSendSocketMessage; | |
| 1545 | + const BtnSave = commonFunc.showMessage(app.commonConst, "BtnSave"); /* 保存 */ | |
| 1546 | + params.optName = BtnSave; | |
| 1547 | + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId }); | |
| 1548 | + if (commonUtils.isNotEmptyObject(returnData)) { | |
| 1549 | + if (commonUtils.isNotEmptyObject(copyTo)) { | |
| 1550 | + const { slaveData } = copyTo; | |
| 1551 | + const sIdArray = []; | |
| 1552 | + slaveData.forEach(item => { | |
| 1553 | + const redisKey = item.sSlaveId; | |
| 1554 | + sIdArray.push(redisKey); | |
| 1555 | + }); | |
| 1556 | + const sId = sIdArray.toString(); | |
| 1557 | + onSendSocketMessage("copyfinish", "noAction", sId, userinfo.sId, null, null); | |
| 1558 | + } | |
| 1559 | + onSendSocketMessage("release", "noAction", currentId, userinfo.sId, null, null); | |
| 1560 | + props.onSaveState({ | |
| 1561 | + enabled: false, | |
| 1562 | + currentId: masterData.sId, | |
| 1563 | + }); | |
| 1564 | + // 保存后更新panes,currentPane的checkedId,防止浏览器刷新时重新又变成新增。 | |
| 1565 | + const iPaneIndex = app.panes.findIndex(item => item.key === app.currentPane.key); | |
| 1566 | + app.panes[iPaneIndex].checkedId = masterData.sId; | |
| 1567 | + app.currentPane.checkedId = masterData.sId; | |
| 1568 | + // dispatch({ type: "app/savePanesAndCurrentPane", payload: { panes: app.panes, currentPane: app.currentPane } }); | |
| 1569 | + | |
| 1570 | + // if (billnosetting.bAutoCheck) { | |
| 1571 | + // await this.handleAudit(1); | |
| 1572 | + // } else { | |
| 1573 | + // await this.handleGetData(masterConfig, slaveConfig, checkConfig); | |
| 1574 | + // if ((sModelsType.includes("sales/salesOrder") || sModelsType.includes("manufacture/workOrder")) && !commonUtils.isEmpty(controlConfig)) { | |
| 1575 | + // await this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig); | |
| 1576 | + // } else if (sModelsType === "purchase/purchaseOrder") { | |
| 1577 | + // await this.handleGetOneMemoData("orderDetail", orderDetailConfig); | |
| 1578 | + // } else if (sModelsType === "sales/salesSgoods" && !commonUtils.isEmpty(slaveChildConfig)) { | |
| 1579 | + // await this.handleGetOneMemoData("slaveChild", slaveChildConfig); | |
| 1580 | + // } | |
| 1581 | + // if (this.props.app.currentPane.refresh !== undefined) { | |
| 1582 | + // this.props.app.currentPane.refresh(); | |
| 1583 | + // } | |
| 1584 | + // } | |
| 1585 | + props.onSaveState({ | |
| 1586 | + loading: false, | |
| 1587 | + }); | |
| 1588 | + return true; | |
| 1589 | + } else { | |
| 1590 | + props.onSaveState({ | |
| 1591 | + loading: false, | |
| 1592 | + }); | |
| 1593 | + return false; | |
| 1594 | + } | |
| 1521 | 1595 | }; |
| 1522 | 1596 | const getProps = baseProps => { |
| 1523 | 1597 | const { location, quotationData, app, sModelsId } = baseProps; |
| 1524 | 1598 | const { token } = app; |
| 1525 | 1599 | const [state, setState] = useState(null); |
| 1600 | + const [isInitialized, setIsInitialized] = useState(false); | |
| 1526 | 1601 | const getSqlDropDownData = async (formId, name, showConfig, record, sKeyUpFilterName, pageNum) => { |
| 1527 | 1602 | const url = `${commonConfig.server_host}business/getSelectLimit/${showConfig.sId}?sModelsId=${sModelsId}`; |
| 1528 | 1603 | const body = { |
| ... | ... | @@ -1562,24 +1637,69 @@ const getProps = baseProps => { |
| 1562 | 1637 | return newState; // 返回新的状态,可能未修改 |
| 1563 | 1638 | }); |
| 1564 | 1639 | }; |
| 1640 | + const { slaveData = [], packData = [], colorData = [], controlData = [], processData = [], materialsData = [] } = baseProps; | |
| 1565 | 1641 | |
| 1566 | - const slaveData = []; | |
| 1567 | - let slaveRow = {}; | |
| 1568 | - slaveRow.handleType = "add"; | |
| 1569 | - slaveRow.sId = commonUtils.createSid(); | |
| 1570 | - slaveRow.key = commonUtils.createSid(); | |
| 1571 | - slaveRow.sParentId = commonUtils.createSid(); | |
| 1572 | - slaveRow.sNodeId = commonUtils.createSid(); | |
| 1573 | - slaveRow.bDefault = false; | |
| 1574 | - slaveRow.iOrder = 1; | |
| 1575 | - slaveData.push(slaveRow); | |
| 1642 | + // 在组件挂载时初始化数据 | |
| 1643 | + useEffect(() => { | |
| 1644 | + if (!isInitialized) { | |
| 1645 | + const slaveRow = { | |
| 1646 | + handleType: "add", | |
| 1647 | + sId: commonUtils.createSid(), | |
| 1648 | + key: commonUtils.createSid(), | |
| 1649 | + sParentId: commonUtils.createSid(), | |
| 1650 | + sNodeId: commonUtils.createSid(), | |
| 1651 | + bDefault: false, | |
| 1652 | + iOrder: 1, | |
| 1653 | + }; | |
| 1654 | + slaveData.push(slaveRow); | |
| 1655 | + | |
| 1656 | + const packRow = { | |
| 1657 | + sId: commonUtils.createSid(), | |
| 1658 | + handleType: "add", | |
| 1659 | + sSlaveId: commonUtils.createSid(), | |
| 1660 | + iOrder: 1, | |
| 1661 | + sParentId: commonUtils.createSid(), | |
| 1662 | + sControlId: commonUtils.createSid(), | |
| 1663 | + dProductQty: 0, | |
| 1664 | + dCombineQty: 1, | |
| 1665 | + }; | |
| 1666 | + packData.push(packRow); | |
| 1667 | + const controlRow = { | |
| 1668 | + dSumPQty: 2, | |
| 1669 | + iPrintMode: 0, | |
| 1670 | + iPositiveColor: 4, | |
| 1671 | + iOppositeColor: 4, | |
| 1672 | + sSlaveId: " ", | |
| 1673 | + iPrintModePo: 2, | |
| 1674 | + handleType: "add", | |
| 1675 | + sId: commonUtils.createSid(), | |
| 1676 | + sParentId: commonUtils.createSid(), | |
| 1677 | + key: commonUtils.createSid(), | |
| 1678 | + bDefault: false, | |
| 1679 | + iOrder: 1, | |
| 1680 | + sCombinedMemo: "合版信息", | |
| 1681 | + sAllId: commonUtils.createSid(), | |
| 1682 | + dPartsQty: 0, | |
| 1683 | + }; | |
| 1684 | + controlData.push(controlRow); | |
| 1685 | + setState(prevState => ({ | |
| 1686 | + ...prevState, | |
| 1687 | + slaveData, | |
| 1688 | + packData, | |
| 1689 | + controlData, | |
| 1690 | + colorData, | |
| 1691 | + processData, | |
| 1692 | + materialsData, | |
| 1693 | + })); | |
| 1576 | 1694 | |
| 1695 | + setIsInitialized(true); | |
| 1696 | + } | |
| 1697 | + }, [isInitialized]); | |
| 1577 | 1698 | return { |
| 1578 | 1699 | ...baseProps, |
| 1579 | 1700 | selectedNode: quotationData, |
| 1580 | 1701 | manyDataCache: [], |
| 1581 | 1702 | token: baseProps.app.token, |
| 1582 | - slaveData, | |
| 1583 | 1703 | getSqlDropDownData, |
| 1584 | 1704 | onMaterialsChange: handleMaterialsChange, |
| 1585 | 1705 | sortData, | ... | ... |