From fb596e372d6e7eb2bba377d57ce2703b252da753 Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Tue, 23 Jun 2026 17:07:06 +0800 Subject: [PATCH] 新增commonSubBill功能 --- src/components/Common/CommonComponent/index.js | 2 +- src/components/Common/CommonHooks/useCommonBase.js | 148 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---- src/components/Common/CommonTable/index.js | 237 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------- src/mes/common/commonModelComponent/index.js | 29 +++++++++++++++-------------- src/mes/common/commonOperationBarComponent/MesToolbar.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--- src/mes/common/commonOperationBarComponent/index.js | 25 +++++++++++++++++-------- 6 files changed, 398 insertions(+), 136 deletions(-) diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index 13fd3cb..b010303 100644 --- a/src/components/Common/CommonComponent/index.js +++ b/src/components/Common/CommonComponent/index.js @@ -1518,7 +1518,7 @@ export default class CommonComponent extends Component { }, /* 数据改变回带到父组件 */ parser: (oldValue) => { const value = this.handleCheckNumberInnerInput(oldValue); - return value?.replace(/\$\s?|(,*)/g, ''); + return String(value || '').replace(/\$\s?|(,*)/g, ''); }, formatter: (value) => { if (value === '' || value === undefined || value === null || location.pathname.includes("indexPad")) { diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index 81c0743..0d72e5f 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -152,6 +152,7 @@ const useCommonBase = props => { }); addState1.slaveInfoList = slaveInfoList; } + const deferredItems = []; formData.forEach((item, index) => { if (index === 0) { item.sGrd = isChoosePlate ? 'master' : item.sGrd; @@ -160,6 +161,7 @@ const useCommonBase = props => { } else { const tablename = `slave${index - 2 < 0 ? '' : index - 2}`; if (item.bGrd && item.sTbName !== 'sysbillcheckresult' && item.bGrdVisible && index - 2 === 0) { + deferredItems.push({ item, tablename }); return } item.sGrd = isChoosePlate ? tablename : item.sGrd; @@ -170,6 +172,22 @@ const useCommonBase = props => { tabConfig[1].configList.push({ "sName": tablename, "sTabName": item[sLanguage], "showType": "table", "defaultEnabled": true, "bHideTitle": true }); } }); + deferredItems.forEach(({ item, tablename }) => { + item.sGrd = isChoosePlate ? tablename : item.sGrd; + tableList.push(tablename); + + if (!tabConfig[2]) { + tabConfig.push({ "configList": [], "mode": "advanced" }); + } + tabConfig[2].configList.push({ + "sName": tablename, + "sTabName": item[sLanguage], + "showType": "table", + "defaultEnabled": true, + "bHideTitle": true, + "slaveChild": true, + }); + }); formData[0].gdsconfigformslave.push({ sId: commonUtils.createSid(), sControlName: 'pageLayout', @@ -515,7 +533,7 @@ const useCommonBase = props => { const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== "tree") : ""; - // 如果state中存在slaveChildConfig 那么就是commonSubBill + // 如果state中存在slaveChildConfig 那么就是commonSubBill const slaveChild = state?.formData?.find(x => x.sId === state?.slaveChildConfig?.sId) const names = slaveChild && slaveChild.sGrd === name ? 'slaveChild' : name const addState = { @@ -3051,7 +3069,7 @@ const useCommonBase = props => { }; // 表格行新增 - const handleMesTableLineAdd = ({ tableName, callback, bAddFirst }) => { + const handleMesTableLineAdd = ({ tableName, callback, bAddFirst, slaveChild }) => { const { [`${tableName}Config`]: config = {}, [`${tableName}Data`]: data = [], @@ -3097,19 +3115,34 @@ const useCommonBase = props => { if (masterData.sId) { addRowData.sParentId = masterData.sId; } + if (tableName === 'slaveChild') { + /* 找到从表的sSqlConditionId */ + const { slaveSelectedRowKeys, slaveData } = state + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { + message.error('请选择父级!'); + return; + } + let iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); + if (iIndex > -1) { + addRowData.sSqlConditionId = slaveData[iIndex].sSqlConditionId; + } + } const newData = bAddFirst ? [addRowData, ...data] : [...data, addRowData]; const selectedRowKeys = [newSid]; const addState = {}; if (location.pathname.includes("indexPad")) { addState.enabled = true; } - + // const slaveChildData = slaveChild ? { + // [`${'slaveChild'}Data`]: newData, + // [`${'slaveChild'}SelectedRowKeys`]: selectedRowKeys + // } : {} handleSaveState( { ...addState, [`${tableName}Data`]: newData, - [`${tableName}SelectedRowKeys`]: selectedRowKeys + [`${tableName}SelectedRowKeys`]: selectedRowKeys, }, callback ); @@ -3143,6 +3176,17 @@ const useCommonBase = props => { tableDataRow.bDefault = false; tableDataRow.iOrder = commonUtils.isNotEmptyArr(tableData) ? iOrderMax + 1 : 1; tableDataRow.defaultAdded = tableData.length === 0; + if (name === 'slaveChild') { + /* 找到从表的sSqlConditionId */ + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { + message.error('请选择父级!'); + return; + } + let iIndex = slaveData.findIndex(item => slaveSelectedRowKeys.includes(item.sId)); + if (iIndex > -1) { + tableDataRow.sSqlConditionId = slaveData[iIndex].sSqlConditionId; + } + } if (isWait) { return tableDataRow; } else { @@ -3223,9 +3267,105 @@ const useCommonBase = props => { tableName, actionName: "mesTableLineDel" }); + if (tableName === 'slaveChild') { + const params = { + sFieldName: 'dAuxiliaryQty', + tableDataRow: commonUtils.isEmptyArr(nextProps.slaveChildData) ? [] : nextProps.slaveChildData[0], + } + // 汇总到从表方法 + handleWriteBack(params, nextProps); + // this.handleGroupDataByDefineNoAfterChange(); + } } ); }; + // 汇总 + const handleWriteBack = async (params, nextProps) => { + const { + sFieldName, + tableDataRow, + } = params; + const { + slaveSelectedRowKeys, + slaveData, + slaveChildConfig, + slaveChildData, + slave0SelectedRowKeys, + slave0Data, + } = nextProps; + if (commonUtils.isEmptyArr(slaveData)) { + return; + } + const addState = {}; + const sId = tableDataRow.sSqlConditionId || slaveSelectedRowKeys[0] || slaveData[0].sId; + const iSlaveIndex = slaveData.findIndex(item => item.sId === sId); + const slaveDataRow = slaveData[iSlaveIndex]; + const slaveChildFilter = slaveChildData.filter(item => item.sSqlConditionId === slaveDataRow.sSqlConditionId); + let iSlave0Index = commonUtils.isNotEmptyArr(slave0Data) ? (commonUtils.isNotEmptyArr(slave0SelectedRowKeys) ? + slave0Data.findIndex(item => slave0SelectedRowKeys.includes(item.sId)) : 0) : -1; + const slave0DataRow = iSlave0Index > -1 ? slave0Data[iSlave0Index] : {}; + // 需要汇总的字段 + const writeBackFields = ['dAuxiliaryQty', 'dProductQty', 'dArrivalQty', 'sBarcode', 'sDefineNo']; + + const bHasiType = slaveChildConfig.gdsconfigformslave.find(item => ['itype', 'iType'].includes(item.sName)); + if (bHasiType && ['dAuxiliaryQty', 'itype', 'iType', 'dProductQty'].includes(sFieldName)) { + // 需要汇总到从表的字段 1:dAuxiliaryQty,2:dEscrowQty,3:dGiveAuxiliaryQty + let dAuxiliaryQty = 0; + let dEscrowAuxiliaryQty = 0; + let dGiveAuxiliaryQty = 0; + let dProductQty = 0; + slaveChildFilter.forEach(item => { + const dataRow = item.sId === params.tableDataRow.sId ? params.tableDataRow : item; + const { itype, iType } = dataRow; + const type = itype !== undefined ? itype : iType !== undefined ? iType : 11; + + if (type === 1 || type === '1') { + dAuxiliaryQty += commonUtils.isNull(Number(dataRow.dAuxiliaryQty), 0); + } else if (type === 2 || type === '2') { + dEscrowAuxiliaryQty += commonUtils.isNull(Number(dataRow.dAuxiliaryQty), 0); + } else if (type === 3 || type === '3') { + dGiveAuxiliaryQty += commonUtils.isNull(Number(dataRow.dAuxiliaryQty), 0); + } else if (type === 10 || type === '10') { + dAuxiliaryQty += commonUtils.isNull(Number(dataRow.dProductQty), 0); + } else if (type === 11 || type === '11') { + dProductQty += commonUtils.isNull(Number(dataRow.dAuxiliaryQty), 0); + } else if (type === 12 || type === '12') { + dProductQty += commonUtils.isNull(Number(dataRow.dProductQty), 0); + } + }); + const iIndex = slaveData.findIndex(item => item.sId === sId); + let tableDataRow = {}; + tableDataRow = await this.handleTableChange('slave', 'dEscrowAuxiliaryQty', { dEscrowAuxiliaryQty }, sId, [], true); + slaveData[iIndex] = tableDataRow; + window.tmpSlaveData = slaveData; + tableDataRow = await this.handleTableChange('slave', 'dGiveAuxiliaryQty', { dGiveAuxiliaryQty }, sId, [], true); + slaveData[iIndex] = tableDataRow; + window.tmpSlaveData = slaveData; + tableDataRow = await this.handleTableChange('slave', 'dAuxiliaryQty', { dAuxiliaryQty }, sId, [], true); + slaveData[iIndex] = tableDataRow; + if (commonUtils.isNotEmptyObject(slave0DataRow)) { + const dSlave0AuxiliaryQty = slave0DataRow['dAuxiliaryQty']; + const table0DataRow = await this.handleTableChange('slave0', 'dAuxiliaryQty', { dSlave0AuxiliaryQty }, slave0DataRow.sId, [], true); + slave0Data[iSlave0Index] = table0DataRow; + addState.slave0Data = slave0Data; + } + if (slaveChildFilter.some(item => item.itype === 11 || item.iType === 11 || item.itype === 12 || item.iType === 12) || commonUtils.isEmptyArr(slaveChildFilter)) { + window.tmpSlaveData = slaveData; + tableDataRow = await this.handleTableChange('slave', 'dProductQty', { dProductQty }, sId, [], true); + slaveData[iIndex] = tableDataRow; + } + window.tmpSlaveData = null; + this.props.onSaveState({ slaveData, ...addState }); + } else if (bHasiType && writeBackFields.includes(sFieldName)) { + let dQty = 0; + slaveChildFilter.forEach(item => { + const dataRow = item.sId === tableDataRow.sId ? tableDataRow : item; + dQty += commonUtils.isNull(dataRow[sFieldName], 0); + }); + this.handleTableChange('slave', sFieldName, { [sFieldName]: dQty }, sId, [], false); + } + + } // 表格行复制 const handleMesTableLineCopy = ({ tableName, record, index, callback }) => { const { [`${tableName}Data`]: data = [] } = state; diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index 52ca27d..738d7bc 100644 --- a/src/components/Common/CommonTable/index.js +++ b/src/components/Common/CommonTable/index.js @@ -1490,7 +1490,7 @@ class CommonTableRc extends React.Component { name ) /* 选择行发生改变时调用的函数 */, getCheckboxProps: record => ({ - disabled: !!record.checkboxDisabled || record.bDisplayHighLight, + disabled: !!record?.checkboxDisabled || record?.bDisplayHighLight, style: record.bSum && commonConfig.hasSum ? { display: "none" } @@ -1562,6 +1562,7 @@ class CommonTableRc extends React.Component { getTableProps = () => { /* 给数据都添加上key */ const { tableColumn, dataSource } = this.state; + console.log("🚀 ~ CommonTableRc ~ dataSource:", dataSource) // 二级表头 const subTableColumn = tableColumn.reduce((result, item) => { if (commonUtils.isNotEmptyArr(item.children)) { @@ -2184,11 +2185,11 @@ class CommonTableRc extends React.Component { if (!bEnabled) return; let newValue = ""; - if (!value || value ==='/') { + if (!value || value === '/') { newValue = "✓"; } else if (["1", "✓"].includes(value)) { newValue = "✗"; - }else if (["0", "✗"].includes(value)) { + } else if (["0", "✗"].includes(value)) { newValue = "/"; } @@ -2260,11 +2261,11 @@ class CommonTableRc extends React.Component { ✗ ); - } else if (value === "3" || value === '/') { + } else if (value === "3" || value === '/') { return (
{ - setTimeout(() => { - let divs = document.getElementsByClassName("noInputInsert"); - if (divs.length) { - Array.prototype.forEach.call(divs, item => { - item.parentNode.parentNode.parentNode.parentNode.classList.add( - "insertTd" - ); - }); - } - }, 20); + if (this.props.slaveInfo || this.useVListNew) { + if (!this.uniqueId) { + this.uniqueId = this.props.formId + ? `${this.props.formId}_${lodash.uniqueId()}` + : lodash.uniqueId(); + } + if (!this.Vcomponents || window.vlistNewSearh) { + const { tableClassName } = this.state; + const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; + if (oTable) { + const oBody = oTable.querySelector(".ant-table-body"); + oBody && (oBody.scrollTop = 0); } - }); - } - components = { ...this.Vcomponents, ...components }; - } else { - // vid是多个列表在同个页面中,同时渲染会促发问题 - // vid不可以为随机数,随机数会导致双击时,点击的两个VList id不同 - if (!this.uniqueId) { - this.uniqueId = this.props.formId - ? `${this.props.formId}_${lodash.uniqueId()}` - : lodash.uniqueId(); - } - if (!this.Vcomponents1 || window.vlistNewSearh) { - const { tableClassName } = this.state; - const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; - if (oTable) { - const oBody = oTable.querySelector(".ant-table-body"); - oBody && (oBody.scrollTop = 0); - } - window.vlistNewSearh = null; - this.Vcomponents1 = VList({ - height: this.scrollY, - vid: this.uniqueId, - rowKey: this.rowKey, - onScroll: () => { - setTimeout(() => { - let divs = document.getElementsByClassName("noInputInsert"); - if (divs.length) { - Array.prototype.forEach.call(divs, item => { - item.parentNode.parentNode.parentNode.parentNode.classList.add( - "insertTd" - ); - }); - } - }, 20); + window.vlistNewSearh = null; + this.Vcomponents = VListNew({ + height: this.scrollY, + vid: this.uniqueId, + onScroll: () => { + setTimeout(() => { + let divs = document.getElementsByClassName("noInputInsert"); + if (divs.length) { + Array.prototype.forEach.call(divs, item => { + item.parentNode.parentNode.parentNode.parentNode.classList.add( + "insertTd" + ); + }); + } + }, 20); + } + }); + } + components = { ...this.Vcomponents, ...components }; + } else { + // vid是多个列表在同个页面中,同时渲染会促发问题 + // vid不可以为随机数,随机数会导致双击时,点击的两个VList id不同 + if (!this.uniqueId) { + this.uniqueId = this.props.formId + ? `${this.props.formId}_${lodash.uniqueId()}` + : lodash.uniqueId(); + } + if (!this.Vcomponents1 || window.vlistNewSearh) { + const { tableClassName } = this.state; + const oTable = document.querySelectorAll(`.${tableClassName}`)[0]; + if (oTable) { + const oBody = oTable.querySelector(".ant-table-body"); + oBody && (oBody.scrollTop = 0); } - }); + window.vlistNewSearh = null; + this.Vcomponents1 = VList({ + height: this.scrollY, + vid: this.uniqueId, + rowKey: this.rowKey, + onScroll: () => { + setTimeout(() => { + let divs = document.getElementsByClassName("noInputInsert"); + if (divs.length) { + Array.prototype.forEach.call(divs, item => { + item.parentNode.parentNode.parentNode.parentNode.classList.add( + "insertTd" + ); + }); + } + }, 20); + } + }); + } + components = { ...this.Vcomponents1, ...components }; } - components = { ...this.Vcomponents1, ...components }; - } } if (this.props.config && this.props.config.iFreezeColumn) { tableColumn.forEach((val, index) => { @@ -9923,7 +9924,7 @@ class CommonTableRc extends React.Component { if (searchText !== props.searchText) { stateValue.searchText = props.searchText; } - if (true || props.enabled) { + if (true || props.enabled) { const { config } = this.props; if (commonUtils.isNotEmptyObject(config)) { const productionRoute = @@ -10841,6 +10842,7 @@ class CommonTableRc extends React.Component { /* 获取table中的props */ const tableProps = this.getTableProps(); + console.log("🚀 ~ CommonTableRc ~ render ~ tableProps:", tableProps) let autoHeight = this.props.tableProps.AutoTableHeight; const realizeHeight = @@ -11166,13 +11168,33 @@ class CommonTableRc extends React.Component { this.setState({ affixMenuVisible: false }); } }; - let { mesTotalCount , mesPageSize, mesPageNum, isPagination} = this.props.tableProps || {}; + let { mesTotalCount, mesPageSize, mesPageNum, isPagination } = this.props.tableProps || {}; const handleMesPaginationChange = (page, pageSize) => { - this.props.onSaveState({ - mesPageNum: page, - mesPageSize: pageSize, - mesPageChange: true - }); + this.props.onSaveState({ + mesPageNum: page, + mesPageSize: pageSize, + mesPageChange: true + }); + } + + if (this.props?.name === 'slaveChild') { + tableProps.dataSource = tableProps.dataSource + .map(item => { + const { slaveSelectedRowKeys, slaveData } = this.props?.parentProps; + + if (commonUtils.isEmptyArr(slaveSelectedRowKeys)) { + return null; + } + + let iIndex = slaveData.findIndex(slaveItem => + slaveSelectedRowKeys.includes(slaveItem.sId) && + slaveItem.sSqlConditionId === item?.sSqlConditionId + ); + + return iIndex > -1 ? item : null; + }) + .filter(item => item !== null); // 过滤掉 null/undefined + } return ( @@ -11272,33 +11294,33 @@ class CommonTableRc extends React.Component { /> ) : ( -
+
+ {...tableProps} + addRow={addProps} + delProps={delProps} + tableLayout="fixed" + expandable={{ + expandedRowRender: + this.props.setExpandedRowRender === "Y" ? expandedRow : null, + defaultExpandAllRows: this.props.defaultExpandAllRows || null + }} + scroll={{ + x: this.scrollX, + y: !layoutScrollY ? this.scrollY : layoutScrollY + }} + summary={this.genFooter} + size="small" + sticky={this.sticky} + showSorterTooltip={false} + > -
-
- { - isPagination && - } -
+ +
+ { + isPagination && + } +
)}
@@ -11839,7 +11861,7 @@ const useCommonTableEvent = props => { // if (data?.length === 0) { // data.push({ sId: commonUtils.createSid() }); // } - handleSetIRowNum(data); + handleSetIRowNum(data, props); handleSetCheckboxDisabled({ ...props, getBtnDisabled }); // 限制多选框选择 handleSetCostomEnabledList({ ...props, allTableSelectedOneData }, data); setUpdateRowNumTime(pre => pre + 1); @@ -12165,9 +12187,10 @@ const CommonTable = baseProps => { return ; }; -const handleSetIRowNum = data => { +const handleSetIRowNum = (data, props) => { data.forEach((item, index) => { item.iRowNum = index + 1; + if (commonUtils.isNotEmptyArr(item.children)) { handleSetIRowNum(item.children); } @@ -12352,6 +12375,7 @@ const useGetTableBtnOprSetting = props => { list.forEach(btnType => { if (btnType.includes("add")) { resultTemp.mesAdd = params => { + console.log("🚀 ~ useGetTableBtnOprSetting ~ params:", params, props) const { sDefault: str } = btnTableAddConfig; let disabled = props.getBtnDisabled({ str, @@ -12391,7 +12415,8 @@ const useGetTableBtnOprSetting = props => { callback: props.bAddFirst ? scrollToTop(params.tableClassName) : scrollToBottom(params.tableClassName), - bAddFirst: props.bAddFirst + bAddFirst: props.bAddFirst, + slaveChild: props?.parentProps?.slaveChild }); } diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index f9c09e6..d6ddc51 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -282,7 +282,6 @@ const useCommonModelEvent = props => { // 特殊情况下处理下页面布局 pageLayout = handleGetFilterPageLayout(pageLayout); const [tableList, tabConfig] = pageLayout; - console.log("🚀 ~ useCommonModelEvent ~ tabConfig:", tabConfig, pageLayoutConfig, pageLayout) const colunmData = handleGetColumnData(tableList, true); let result = {}; if (!noGetData && sModelsId === '17211911815017669983448000') { @@ -413,7 +412,7 @@ const useCommonModelEvent = props => { const { masterConfig, sModelsId, masterData } = props; const { btnConfig = {}, copyToConfig = [], record = {} } = props?.parentProps || {} - if (masterData && masterData.sBillNo) return + if (masterData && masterData.sBillNo || masterData && masterData.sId) return let masterDataCopyTo = {}; for (const key in copyTo) { const tableData = copyTo[key]; @@ -542,7 +541,6 @@ const useCommonModelEvent = props => { } }; const handleGetDataPop = async (tableList = [], isWait, bInit) => { - console.log('handleGetData开始执行,tableList:', tableList); let addState = {}; for (let i = 0; i < tableList.length; i++) { const tableName = tableList[i]; @@ -752,7 +750,6 @@ const useCommonModelEvent = props => { item => item.sControlName === "bFirstlineSelected" && item.bVisible ); // 配置刷新数据时,配置 数据集名称+FirstlineSelected,默认选中首行数据。 - console.log('bFirstlineSelected', bFirstlineSelected); if (!bFirstlineSelected) { bFirstlineSelected = tableList.findIndex( @@ -1912,7 +1909,6 @@ const CommonModelComponent = props => { const sLanguage = userinfo.sLanguage; const pageRoute = formData?.[0]?.sName const getComponent = (config, index = 0) => { - console.log("🚀 ~ getComponent ~ config:", config, props) const { sName, sTabName, @@ -1920,7 +1916,8 @@ const CommonModelComponent = props => { defaultEnabled, bHideTitle, tableBtnsConfig, - children = [] + children = [], + slaveChild } = config; if (showType === "none") { @@ -1949,12 +1946,13 @@ const CommonModelComponent = props => { showType, // 展示类型(表单/表格) enabled: !bMesBill ? defaultEnabled : enabled, // 是否可编辑 sTabName, // 标题名称 - sName, // 配置对应的sGrd + sName: slaveChild ? 'slaveChild' : sName, // 配置对应的sGrd bHideTitle, //隐藏标题 tableBtnsConfig, // 表格按钮配置 - bFirstComponent: level === 0 && index === -1 + bFirstComponent: level === 0 && index === -1, + slaveChild }; - console.log("🚀 ~ getComponent ~ componentProps:", componentProps) + const commonDivHeight = useComputedCommonDivHeight(componentProps); return (
{ key={sName} > - {/* */} +
); } @@ -1998,9 +1996,9 @@ const CommonModelComponent = props => { extraStyle.flexDirection = 'column'; extraStyle.paddingTop = 5; } - const { sModelsId } = props; + const { sModelsId, slaveChildConfig } = props; const isNotTab = sModelsId === '12710101117119423319470' - + const subHeight = slaveChildConfig ? '' : '100%' return ( <>
@@ -2012,7 +2010,7 @@ const CommonModelComponent = props => { sBig5EntireTabName, mode, width = "100%", - height = "100%" + height = subHeight } = item; const sEntireTabNameNew = sLanguage === 'sEnglish' ? sEnglishEntireTabName : sLanguage === 'sBig5EntireTabName' ? sBig5EntireTabName : sEntireTabName; @@ -2035,7 +2033,7 @@ const CommonModelComponent = props => { // advancedStyle.border = "1px solid green"; // { width: "100%", height: level === 0 ? "100%" : "auto" } - if (configList.length === 1 && configList[0].showType !== "none") { + if (configList.length === 1 && configList[0].showType !== "none" && !configList[0].slaveChild) { if ( [ "维修申请记录", @@ -2056,6 +2054,7 @@ const CommonModelComponent = props => { ...props, sTabName: configList[0].sTabName }; + return ( <> @@ -2107,6 +2106,7 @@ const CommonModelComponent = props => { ) .map((config, index) => { const { sName, sEnglishTabName, sBig5TabName, sTabName } = config; + const sTabNewName = sLanguage === 'sEnglish' ? sEnglishTabName : sLanguage === 'sBig5' ? sBig5TabName : sTabName; let disabled = false; @@ -2134,6 +2134,7 @@ const CommonModelComponent = props => { props.salveWybz2Data?.[0]?.bSave === false || props.salveWybz2Data?.[0]?.bSave === 0; } + return ( { const { sModelType = '' } = currentMesPane; const { sControlName, sButtonParam } = btnConfig; const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); - console.log("🚀 ~ ToolbarFun ~ btnName:", btnName) if ((btnName.includes('btnscanface')) && !bMesBill) { handleScanFace(props); return true @@ -20,7 +19,6 @@ const ToolbarFun = async (props) => { } else if (btnName.includes('btnfooter')) { return false } - // const { sControlName } = btnConfig; // const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); let flag = 0; @@ -329,6 +327,8 @@ const ToolbarFun = async (props) => { } } else if (btnName.includes('tmpinfobysql')) { return false + } else if (btnName && btnName.includes('btncalc')) { + handleCalc(props, btnConfig) } @@ -859,7 +859,6 @@ const handleForceComplete = (props, name, createDate) => { } } } - console.log("singleRow:", singleRow); if (sIndex > -1) { if (target === "slaveInfo") { singleConfig = props.slaveInfoConfig.gdsconfigformslave[sIndex]; @@ -958,6 +957,94 @@ const handleForceComplete = (props, name, createDate) => { }); } }; +// subbill +const handleCalc = async (props, btnConfig) => { + const { masterConfig, masterData, sModelsId, } = props; + props.onSaveState({ pageLoading: true }); + + if (commonUtils.isNotEmptyObject(btnConfig)) { + /* 组装allTableData */ + const allTableMap = {}; + const allReturnMap = {}; + const slaveNameList = []; + /* 从props找到 所有的Config */ + if (commonUtils.isNotEmptyArr(props)) { + for (const key of Object.keys(props)) { + if (key.includes('Config') && !key.includes('onGet') && !key.includes('report')) { + const tablename = key.replace('Config', '').trim(); + slaveNameList.push(tablename); + } + } + } + + if (commonUtils.isNotEmptyArr(slaveNameList)) { + slaveNameList.forEach((name, index) => { + const tableConfig = props[name + 'Config']; /* 动态配置 */ + const tableData = props[name + 'Data']; /* 动态配置 */ + const tableSelectedRowKeys = props[name + 'SelectedRowKeys']; /* 选中Key */ + if (commonUtils.isNotEmptyObject(tableConfig)) { + allTableMap[name + '.' + tableConfig.sTbName] = tableData + } + + }) + const masterTbName = masterConfig.sTbName; + allTableMap['master.' + masterTbName] = masterData; + } + const sButtonParam = btnConfig.sButtonParam; + const btn = commonUtils.isJSON(sButtonParam) ? JSON.parse(sButtonParam) : ''; + const sProName = btn.sproName; + const url = `${commonConfig.server_host}calcprocedure/calc?sModelsId=${sModelsId}`; + const value = { + sProName, + sButtonParam, + allTableMap + }; + const dataReturn = (await commonServices.postValueService(props.app.token, value, url)).data; + if (dataReturn.code === 1) { + /* 数据操作 数据回传页面 */ + message.success('操作成功!'); + const returnData = dataReturn.dataset.rows[0]; + if (commonUtils.isNotEmptyArr(slaveNameList) && commonUtils.isNotEmptyObject(returnData)) { + slaveNameList.forEach((name, index) => { + const tableConfig = props[name + 'Config']; /* 动态配置 */ + let tableDelData = props[name + 'DelData']; + if (commonUtils.isEmptyArr(tableDelData)) { + tableDelData = []; + } + let tableDelDataNew = [] + let tableData = []; + if (commonUtils.isNotEmptyObject(tableConfig)) { + tableData = returnData[name + '.' + tableConfig.sTbName]; /* 动态配置 */ + if (commonUtils.isNotEmptyArr(tableData) && Array.isArray(tableData)) { + tableDelDataNew = tableData.filter(item => item.handleType === 'del'); + tableData = tableData.filter(item => item.handleType !== 'del'); + tableDelData = tableDelData.concat(tableDelDataNew); + } + + } + allReturnMap[name + 'Data'] = tableData; + allReturnMap[name + 'DelData'] = tableDelData; + }); + const masterTbName = masterConfig.sTbName; + allReturnMap.masterData = returnData['master.' + masterTbName]; + allReturnMap.masterData.enabled = true; + } + allReturnMap?.slaveChildData?.forEach(item => { + item.sSqlConditionId = allReturnMap?.slaveData?.[0].sSqlConditionId + }) + allReturnMap.slaveSelectedRowKeys = [allReturnMap?.slaveData?.[0].sId] + + props.onSaveState({ ...allReturnMap, pageLoading: false }); + } else if (dataReturn.code === -8 || dataReturn.code === 2) { + props.getServiceError(dataReturn); + props.onSaveState({ pageLoading: false }); + } else { /* 失败 */ + props.getServiceError(dataReturn); + props.onSaveState({ pageLoading: false }); + } + + } +} // 新增 const handleAdd = (props) => { const { slaveConfig } = props; diff --git a/src/mes/common/commonOperationBarComponent/index.js b/src/mes/common/commonOperationBarComponent/index.js index 57b0dae..8d116ce 100644 --- a/src/mes/common/commonOperationBarComponent/index.js +++ b/src/mes/common/commonOperationBarComponent/index.js @@ -92,13 +92,11 @@ const useCommonOperationBarComponentEvent = props => { const delayedOvertime = commonFunc.showLocalMessage(props, 'delayedOvertime', '延迟加班'); const cancelDelayedOvertime = commonFunc.showLocalMessage(props, 'cancelDelayedOvertime', '取消延迟加班'); - console.log(333333); // 走工具栏功能逻辑 if (await MesToolbar({ ...props, btnConfig: config })) { return; } - console.log(222222); // 自定义按钮事件 if ( @@ -110,7 +108,6 @@ const useCommonOperationBarComponentEvent = props => { }) ) return; - console.log(1111111); // 通用按钮处理 const { showName = "", sActiveKey = "" } = config; @@ -566,7 +563,7 @@ const useCommonOperationBarComponentEvent = props => { const { slaveSelectedRowKeys, slaveData, formData } = props const record = slaveData.find(item => slaveSelectedRowKeys?.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId)); -// !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout') + // !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout') // // 弹窗展示 props.onOpenCommonModal({ type: "commonModal", @@ -575,7 +572,7 @@ const useCommonOperationBarComponentEvent = props => { copyTo, sModelType: '/indexPage/commonBill', sParentConditions, - parentProps: {...props, record }, + parentProps: { ...props, record }, onOk: data => { console.log("=====onOk", data); }, @@ -602,7 +599,19 @@ const useCommonOperationBarComponentEvent = props => { const sRowData = slaveSelectedData.filter(x => x.sId === selectedRowKeys || x.sSlaveId === selectedRowKeys) /* 塞原始数据 */ if (commonUtils.isNotEmptyArr(slaveSelectedData)) { - copyTo.masterData = slaveSelectedData[0]; + delete slaveSelectedData?.[0]?.bCheck + const sAssignField = copyToConfig?.[0]?.sAssignField + let addSAssignField = { + ...commonFunc.getAssignFieldValue(sAssignField, props?.app?.userinfo) + } + copyTo.masterData = { + ...addSAssignField, + ...commonFunc.getAssignFieldValue(sAssignField, slaveSelectedData[0]), + handleType: "add", + sId: commonUtils.createSid(), + sFormId: sModelsId, + maxBillNo: "sBillNo", + };; copyTo.slaveData = slaveSelectedData; } const values = { sConfigformId, sControlName, sRowData }; @@ -621,7 +630,7 @@ const useCommonOperationBarComponentEvent = props => { let tableRow = {}; tableRow = { ...tableRow, ...commonFunc.getAssignFieldValue(sAssignField, item) }; // 取赋值字段 tableRow.sId = commonUtils.createSid(); - tableRow.sParentId = slaveSelectedData[0].sId; + tableRow.sParentId = copyTo.masterData.sId; tableRow.handleType = 'add'; newData.push(tableRow); }) @@ -1582,7 +1591,7 @@ const BarcodeComponent = props => { try { props.onExecInstructSet({ btnConfig, - nextProps: {scanCodeData: [{value: valueNew}]}, + nextProps: { scanCodeData: [{ value: valueNew }] }, // callback: () => { // if (commonUtils.isNotEmptyArr(searchProductConfig)) { // props.onSaveState({ -- libgit2 0.22.2