diff --git a/src/mobile/quotation/detailNew.jsx b/src/mobile/quotation/detailNew.jsx index 079a982..cdaa2ea 100644 --- a/src/mobile/quotation/detailNew.jsx +++ b/src/mobile/quotation/detailNew.jsx @@ -93,7 +93,7 @@ const QuickQuoteEvent = props => { const configUrl = `${commonConfig.server_host}business/getModelBysId/${sModelsId}?sModelsId=${sModelsId}`; commonServices .getService(props.token, configUrl) - .then(({ data: masterReturn }) => { + .then(async ({ data: masterReturn }) => { if (masterReturn.code === 1) { const formData = masterReturn.dataset.rows[0].formData; const masterConfig = formData.find(x => x.sTbName === "QuoQuotationmaster"); @@ -1294,7 +1294,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { sClientType: "1", loading: false, sSysLogSrcId: masterData.sId, - }); + },props); props.onSaveState({ slaveData, packData, @@ -1343,6 +1343,7 @@ const handleCalculation = async (bSave, nextProps, isWait, props) => { }; /** 按钮操作事件 */ const handleButtonClick = async (name, props) => { + console.log("🚀 ~ handleButtonClick ~ props:", props) if (name === "BtnDraft") { const { masterConfig, @@ -1351,7 +1352,7 @@ const handleButtonClick = async (name, props) => { slaveData, slaveDelData, controlConfig, - controlData, + controlData, // 需要 controlDelData, materialsConfig, materialsData, @@ -1363,7 +1364,7 @@ const handleButtonClick = async (name, props) => { colorData, colorDelData, packConfig, - packData, + packData, // 需要 packDelData, } = props; const data = []; @@ -1507,22 +1508,96 @@ const handleButtonClick = async (name, props) => { if (commonUtils.isNotEmptyObject(packConfig)) { data.push(commonBusiness.mergeData("pack", packConfig.sTbName, packData, packDelData)); } + // 核价后保存 props.onSaveData({ data, sClientType: "1", loading: false, sSysLogSrcId: masterData.sId, bIsUnCcg: false, - }); + },props); } }; const handleSaveData = async (params, props) => { - console.log("🚀 ~ handleSaveData ~ params:", params); + const { + token, + sModelsId, + currentId, + masterData, + masterConfig, + slaveConfig, + checkConfig, + billnosetting, + app, + sModelsType, + controlConfig, + materialsConfig, + processConfig, + colorConfig, + packConfig, + orderDetailConfig, + dispatch, + slaveChildConfig, + } = props; + const { userinfo } = app; + const { copyTo } = app.currentPane; + const onSendSocketMessage = props.handleSendSocketMessage; + const BtnSave = commonFunc.showMessage(app.commonConst, "BtnSave"); /* 保存 */ + params.optName = BtnSave; + const returnData = await commonBusiness.saveData({ token, value: params, sModelsId }); + if (commonUtils.isNotEmptyObject(returnData)) { + if (commonUtils.isNotEmptyObject(copyTo)) { + const { slaveData } = copyTo; + const sIdArray = []; + slaveData.forEach(item => { + const redisKey = item.sSlaveId; + sIdArray.push(redisKey); + }); + const sId = sIdArray.toString(); + onSendSocketMessage("copyfinish", "noAction", sId, userinfo.sId, null, null); + } + onSendSocketMessage("release", "noAction", currentId, userinfo.sId, null, null); + props.onSaveState({ + enabled: false, + currentId: masterData.sId, + }); + // 保存后更新panes,currentPane的checkedId,防止浏览器刷新时重新又变成新增。 + const iPaneIndex = app.panes.findIndex(item => item.key === app.currentPane.key); + app.panes[iPaneIndex].checkedId = masterData.sId; + app.currentPane.checkedId = masterData.sId; + // dispatch({ type: "app/savePanesAndCurrentPane", payload: { panes: app.panes, currentPane: app.currentPane } }); + + // if (billnosetting.bAutoCheck) { + // await this.handleAudit(1); + // } else { + // await this.handleGetData(masterConfig, slaveConfig, checkConfig); + // if ((sModelsType.includes("sales/salesOrder") || sModelsType.includes("manufacture/workOrder")) && !commonUtils.isEmpty(controlConfig)) { + // await this.handleGetMemoData(controlConfig, materialsConfig, processConfig, colorConfig, packConfig); + // } else if (sModelsType === "purchase/purchaseOrder") { + // await this.handleGetOneMemoData("orderDetail", orderDetailConfig); + // } else if (sModelsType === "sales/salesSgoods" && !commonUtils.isEmpty(slaveChildConfig)) { + // await this.handleGetOneMemoData("slaveChild", slaveChildConfig); + // } + // if (this.props.app.currentPane.refresh !== undefined) { + // this.props.app.currentPane.refresh(); + // } + // } + props.onSaveState({ + loading: false, + }); + return true; + } else { + props.onSaveState({ + loading: false, + }); + return false; + } }; const getProps = baseProps => { const { location, quotationData, app, sModelsId } = baseProps; const { token } = app; const [state, setState] = useState(null); + const [isInitialized, setIsInitialized] = useState(false); const getSqlDropDownData = async (formId, name, showConfig, record, sKeyUpFilterName, pageNum) => { const url = `${commonConfig.server_host}business/getSelectLimit/${showConfig.sId}?sModelsId=${sModelsId}`; const body = { @@ -1562,24 +1637,69 @@ const getProps = baseProps => { return newState; // 返回新的状态,可能未修改 }); }; + const { slaveData = [], packData = [], colorData = [], controlData = [], processData = [], materialsData = [] } = baseProps; - const slaveData = []; - let slaveRow = {}; - slaveRow.handleType = "add"; - slaveRow.sId = commonUtils.createSid(); - slaveRow.key = commonUtils.createSid(); - slaveRow.sParentId = commonUtils.createSid(); - slaveRow.sNodeId = commonUtils.createSid(); - slaveRow.bDefault = false; - slaveRow.iOrder = 1; - slaveData.push(slaveRow); + // 在组件挂载时初始化数据 + useEffect(() => { + if (!isInitialized) { + const slaveRow = { + handleType: "add", + sId: commonUtils.createSid(), + key: commonUtils.createSid(), + sParentId: commonUtils.createSid(), + sNodeId: commonUtils.createSid(), + bDefault: false, + iOrder: 1, + }; + slaveData.push(slaveRow); + + const packRow = { + sId: commonUtils.createSid(), + handleType: "add", + sSlaveId: commonUtils.createSid(), + iOrder: 1, + sParentId: commonUtils.createSid(), + sControlId: commonUtils.createSid(), + dProductQty: 0, + dCombineQty: 1, + }; + packData.push(packRow); + const controlRow = { + dSumPQty: 2, + iPrintMode: 0, + iPositiveColor: 4, + iOppositeColor: 4, + sSlaveId: " ", + iPrintModePo: 2, + handleType: "add", + sId: commonUtils.createSid(), + sParentId: commonUtils.createSid(), + key: commonUtils.createSid(), + bDefault: false, + iOrder: 1, + sCombinedMemo: "合版信息", + sAllId: commonUtils.createSid(), + dPartsQty: 0, + }; + controlData.push(controlRow); + setState(prevState => ({ + ...prevState, + slaveData, + packData, + controlData, + colorData, + processData, + materialsData, + })); + setIsInitialized(true); + } + }, [isInitialized]); return { ...baseProps, selectedNode: quotationData, manyDataCache: [], token: baseProps.app.token, - slaveData, getSqlDropDownData, onMaterialsChange: handleMaterialsChange, sortData, diff --git a/src/mobile/quotation/master.jsx b/src/mobile/quotation/master.jsx new file mode 100644 index 0000000..d6380d8 --- /dev/null +++ b/src/mobile/quotation/master.jsx @@ -0,0 +1,5 @@ +import React, { useEffect, useState } from "react"; +const QuotationAllMaster = baseProps =>{ + +} +export default QuotationAllMaster; \ No newline at end of file