Commit 7c13492d9cba9310fa82b2e89295568fd78d63e8
1 parent
760f81c7
1.这边对账的时候 会走未清的勾选过来 先保存 后面如发现遗漏 需要直接在保存的单据上再把未对账数据源选上去(即不愿意删除整个单据 再重新未清勾选) 采购 销售…
…目前配置都没问题 但是运费对账是三张表 第三张表没法 赋值过来 麻烦处理下
Showing
1 changed file
with
176 additions
and
5 deletions
src/components/Common/CommonSubBillEvent.js
| ... | ... | @@ -6711,15 +6711,186 @@ export default (ChildComponent) => { |
| 6711 | 6711 | return tableData; |
| 6712 | 6712 | }; |
| 6713 | 6713 | |
| 6714 | + handleGetTmpInfoData = async (currentPaneName, tableConfig, selectData, name) => { | |
| 6715 | + const { sModelsId, app } = this.props; | |
| 6716 | + const { slaveConfig, [`${name}Data`]: tableData, [`${name}Config`]: tempConfig = {} } = this.props; | |
| 6717 | + let { slaveData: slaveDataOld, masterData, slaveDelData } = this.props; | |
| 6718 | + if (commonUtils.isNotEmptyObject(tableConfig) && commonUtils.isNotEmptyObject(tableConfig.sButtonParam)) { | |
| 6719 | + const sTmpInfoConfig = tableConfig; | |
| 6720 | + const sButtonParam = tableConfig.sButtonParam; | |
| 6721 | + const btn = commonUtils.isNotEmptyObject(sButtonParam) && commonUtils.isJSON(sButtonParam) ? JSON.parse(sButtonParam) : {}; | |
| 6722 | + const sProName = commonUtils.isNotEmptyObject(btn) ? btn.sproName : ""; | |
| 6723 | + console.log('btn', tableConfig, btn, name); | |
| 6724 | + | |
| 6725 | + const sTmpInfoBySqlBtnName = commonUtils.isNotEmptyObject(btn) ? btn.sControlName : ""; | |
| 6726 | + console.log('sTmpInfoBySqlBtnName', sTmpInfoBySqlBtnName); | |
| 6727 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | |
| 6728 | + if (commonUtils.isNotEmptyObject(sTmpInfoConfig)) { | |
| 6729 | + if (sTmpInfoBySqlBtnName?.includes("sTmpInfoBySql")) { | |
| 6730 | + /* 走TmpInfo逻辑 */ | |
| 6731 | + const newCopyTo = {}; | |
| 6732 | + newCopyTo.master = masterData; | |
| 6733 | + /* 找到自定义TempInfo配置 */ | |
| 6734 | + const btnConfig = tempConfig?.gdsconfigformslave.filter(item => item.sControlName.includes(sTmpInfoBySqlBtnName)); | |
| 6735 | + const btnControlName = btnConfig[0].sControlName; | |
| 6736 | + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`; | |
| 6737 | + const sConfigformId = commonUtils.isEmpty(btnConfig) ? "" : btnConfig[0].sParentId; | |
| 6738 | + const sControlName = commonUtils.isNotEmptyObject(sTmpInfoBySqlBtnName) ? sTmpInfoBySqlBtnName : "TmpInfoBySql"; | |
| 6739 | + const sAssignField = btnConfig[0].sAssignField; | |
| 6740 | + const sActiveKeyNew = btnConfig[0].sActiveKey; | |
| 6741 | + let sRowData = selectData; | |
| 6742 | + if (name === "master" && sTmpInfoBySqlBtnName.includes("_update")) { | |
| 6743 | + const { slaveData } = this.state; | |
| 6744 | + if (commonUtils.isNotEmptyArr(slaveData)) { | |
| 6745 | + sRowData = [...sRowData, ...slaveData]; | |
| 6746 | + } | |
| 6747 | + } | |
| 6748 | + const values = { sConfigformId, sControlName, sRowData }; | |
| 6749 | + if (true) { | |
| 6750 | + const dataReturn = (await commonServices.postValueService(app.token, values, dataUrl)).data; | |
| 6751 | + const allReturnMap = {}; | |
| 6752 | + if (dataReturn.code === 1) { | |
| 6753 | + const returnData = dataReturn.dataset.rows[0]; | |
| 6754 | + if (commonUtils.isNotEmptyObject(returnData)) { | |
| 6755 | + for (const key of Object.keys(returnData)) { | |
| 6756 | + const sName = `${key}Data`; | |
| 6757 | + const sDelName = `${key}DelData`; | |
| 6758 | + // allReturnMap[sName] = returnData[key]; | |
| 6759 | + let { [`${key}Data`]: oldData = [], [`${key}DelData`]: oldDelData } = this.props; | |
| 6760 | + if (commonUtils.isEmptyArr(oldDelData)) { | |
| 6761 | + oldDelData = []; | |
| 6762 | + } | |
| 6763 | + if (commonUtils.isEmptyArr(oldData)) { | |
| 6764 | + oldData = []; | |
| 6765 | + } | |
| 6766 | + if (sTmpInfoBySqlBtnName.includes("_edit")) { | |
| 6767 | + /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | |
| 6768 | + /* 对应字段 */ | |
| 6769 | + const sActiveKey = sTmpInfoConfig.sActiveKey; | |
| 6770 | + const keyData = returnData[key]; | |
| 6771 | + let newData = []; | |
| 6772 | + if (commonUtils.isNotEmptyArr(keyData)) { | |
| 6773 | + keyData.forEach(child => { | |
| 6774 | + const filterData = oldData.filter(item => item[sActiveKeyNew] !== child[sActiveKeyNew]); | |
| 6775 | + if (commonUtils.isNotEmptyArr(filterData) && filterData.length === oldData.length) { | |
| 6776 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | |
| 6777 | + tableRow.sId = commonUtils.createSid(); | |
| 6778 | + tableRow.sParentId = masterData.sId; | |
| 6779 | + tableRow.handleType = "add"; | |
| 6780 | + newData.push(tableRow); | |
| 6781 | + } else { | |
| 6782 | + /* 相同的根据赋值字段覆盖 */ | |
| 6783 | + const iIndex = oldData.findIndex(item => item[sActiveKeyNew] === child[sActiveKeyNew]); | |
| 6784 | + if (iIndex > -1) { | |
| 6785 | + if (sAssignField) { | |
| 6786 | + oldData[iIndex] = { ...oldData[iIndex], ...commonFunc.getAssignFieldValue(sAssignField, child) }; | |
| 6787 | + } else { | |
| 6788 | + oldData[iIndex] = { ...oldData[iIndex], ...child }; | |
| 6789 | + } | |
| 6790 | + oldData[iIndex].handleType = commonUtils.isEmpty(oldData[iIndex].handleType) ? "update" : oldData[iIndex].handleType; | |
| 6791 | + } | |
| 6792 | + } | |
| 6793 | + }); | |
| 6794 | + newData = oldData.concat(newData); | |
| 6795 | + } | |
| 6796 | + } else if (sTmpInfoBySqlBtnName.includes("_del")) { | |
| 6797 | + /* 替换 根据对应字段对比 相同的不管 不同的插入 */ | |
| 6798 | + /* 对应字段 */ | |
| 6799 | + oldData.forEach(child => { | |
| 6800 | + child.handleType = "del"; | |
| 6801 | + oldDelData.push(child); | |
| 6802 | + }); | |
| 6803 | + allReturnMap[sDelName] = oldDelData; | |
| 6804 | + oldData = []; | |
| 6805 | + const keyData = returnData[key]; | |
| 6806 | + if (commonUtils.isNotEmptyArr(keyData)) { | |
| 6807 | + keyData.forEach(child => { | |
| 6808 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | |
| 6809 | + tableRow.sId = commonUtils.createSid(); | |
| 6810 | + if (sName === "slaveData" && !tableRow.sSqlConditionId) { | |
| 6811 | + tableRow.sSqlConditionId = tableRow.sId; | |
| 6812 | + } | |
| 6813 | + tableRow.sParentId = masterData.sId; | |
| 6814 | + tableRow.handleType = "add"; | |
| 6815 | + oldData.push(tableRow); | |
| 6816 | + }); | |
| 6817 | + } | |
| 6818 | + allReturnMap[sName] = oldData; | |
| 6819 | + } else if (btnControlName?.includes("add")) { | |
| 6820 | + const keyData = returnData[key]; | |
| 6821 | + if (commonUtils.isNotEmptyArr(keyData)) { | |
| 6822 | + keyData.forEach(child => { | |
| 6823 | + const tableRow = { ...child, ...commonFunc.getAssignFieldValue(sAssignField, child) }; // 取赋值字段111 | |
| 6824 | + tableRow.sId = commonUtils.createSid(); | |
| 6825 | + tableRow.sParentId = masterData.sId; | |
| 6826 | + tableRow.handleType = "add"; | |
| 6827 | + oldData.push(tableRow); | |
| 6828 | + }); | |
| 6829 | + } | |
| 6830 | + console.log('keyde2', sName, oldData); | |
| 6831 | + allReturnMap[sName] = oldData; | |
| 6832 | + } else if (sTmpInfoBySqlBtnName.includes("_update")) { | |
| 6833 | + /* 更新字段 */ | |
| 6834 | + const keyData = returnData[key]; | |
| 6835 | + if (commonUtils.isNotEmptyArr(keyData) && sActiveKeyNew) { | |
| 6836 | + const [linkField, onchangeField] = sActiveKeyNew.split(","); | |
| 6837 | + const tableName = key.split("_update")[0]; | |
| 6838 | + const { [`${tableName}Data`]: tableData = [] } = this.state; | |
| 6839 | + | |
| 6840 | + for (let i = 0; i < keyData.length; i++) { | |
| 6841 | + const child = keyData[i]; | |
| 6842 | + const tableDataFilter = tableData.filter(item => item[linkField] === child[linkField]); | |
| 6843 | + for (let j = 0; j < tableDataFilter.length; j++) { | |
| 6844 | + const item = tableDataFilter[j]; | |
| 6845 | + const iIndex = tableData.findIndex(row => row.sId === item.sId); | |
| 6846 | + tableData[iIndex] = { ...item, ...child }; | |
| 6847 | + if (onchangeField && this.state.onEventDataChange) { | |
| 6848 | + const { sId, [onchangeField]: fieldsValue } = tableData[iIndex]; | |
| 6849 | + window.tmpSlaveData = tableData; | |
| 6850 | + tableData[iIndex] = await this.state.onEventDataChange( | |
| 6851 | + "slave", | |
| 6852 | + onchangeField, | |
| 6853 | + { [onchangeField]: fieldsValue }, | |
| 6854 | + sId, | |
| 6855 | + [], | |
| 6856 | + true | |
| 6857 | + ); | |
| 6858 | + window.tmpSlaveData = null; | |
| 6859 | + } | |
| 6860 | + } | |
| 6861 | + } | |
| 6862 | + allReturnMap[`${tableName}Data`] = tableData; | |
| 6863 | + } | |
| 6864 | + } else { | |
| 6865 | + allReturnMap[sName] = returnData[key]; | |
| 6866 | + } | |
| 6867 | + } | |
| 6868 | + if (commonUtils.isNotEmptyArr(allReturnMap.masterData) && Array.isArray(allReturnMap.masterData)) { | |
| 6869 | + allReturnMap.masterData = allReturnMap.masterData[0]; | |
| 6870 | + } | |
| 6871 | + console.log('1212', allReturnMap); | |
| 6872 | + this.props.onSaveState({ ...allReturnMap }); | |
| 6873 | + } | |
| 6874 | + } else { | |
| 6875 | + this.getServiceError(dataReturn); | |
| 6876 | + } | |
| 6877 | + } | |
| 6878 | + } | |
| 6879 | + } else { | |
| 6880 | + message.error("请正确配置自定义按钮!"); | |
| 6881 | + } | |
| 6882 | + } | |
| 6883 | + }; | |
| 6714 | 6884 | /* 送货单个性化弹窗 选择数据带到从表字表 */ |
| 6715 | 6885 | handleSelectCommonPopup = async (currentPaneName, selectConfig, selectData, tbName) => { |
| 6716 | - const { | |
| 6717 | - [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, sModelsId, sModelsType, slaveSelectedRowKeys, slaveData, | |
| 6718 | - } = this.props; | |
| 6719 | - let { slaveChildData, [`${tbName}Data`]: tableData, app, token } = this.props; | |
| 6886 | + const { [`${tbName}SelectedRowKeys`]: tableSelectedRowKeys, masterData, sModelsId, sModelsType, slaveSelectedRowKeys, slaveData } = this.props; | |
| 6887 | + let { slaveChildData, [`${tbName}Data`]: tableData, app, token } = this.props; | |
| 6720 | 6888 | const iIndex = commonUtils.isNotEmptyArr(tableSelectedRowKeys) ? tableData.findIndex(item => item.sId === tableSelectedRowKeys[0]) : -1; |
| 6721 | 6889 | let dProductQty = 0; |
| 6722 | - if (selectConfig && (selectConfig.sControlName.includes('BtnPopup1Deliver') || selectConfig?.sControlName.includes('Sub'))) { | |
| 6890 | + /* 点击确定后调用getTmpInfo数据获取数据源塞入不同的数据集中 */ | |
| 6891 | + if (commonUtils.isNotEmptyObject(selectConfig) && commonUtils.isNotEmptyObject(selectConfig.sButtonParam)) { | |
| 6892 | + await this.handleGetTmpInfoData(currentPaneName, selectConfig, selectData, tbName); | |
| 6893 | + } else if (selectConfig && (selectConfig.sControlName.includes('BtnPopup1Deliver') || selectConfig?.sControlName.includes('Sub'))) { | |
| 6723 | 6894 | if (commonUtils.isNotEmptyArr(selectData)) { |
| 6724 | 6895 | // eslint-disable-next-line no-unused-vars |
| 6725 | 6896 | selectData.forEach(async (item, index) => { | ... | ... |