diff --git a/src/components/Common/CommonBillEvent.js b/src/components/Common/CommonBillEvent.js index af313df..84a3874 100644 --- a/src/components/Common/CommonBillEvent.js +++ b/src/components/Common/CommonBillEvent.js @@ -7435,7 +7435,6 @@ export default (ChildComponent) => { materials0Data.push(tableDataRowAdd); }); } - console.log('222', materials0Data, copyToAssignField); if (commonUtils.isNotEmptyArr(materials0Data) && location.pathname.includes('processCardPackTableTree')) { /* 根据配置过滤数据 */ @@ -7649,7 +7648,6 @@ export default (ChildComponent) => { }); - console.log('放大镜确认数据:', tbName, tableData, materials0Data) this.props.onSaveState({ materials0Data }); } } else if (selectConfig.sControlName && selectConfig.sControlName.includes('BtnPopupMaterials')) { /* 报价单工序表放大镜 选择材料 */ diff --git a/src/components/Common/CommonComponent/index.js b/src/components/Common/CommonComponent/index.js index 689ffbf..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")) { @@ -1971,6 +1971,9 @@ export default class CommonComponent extends Component { extraClassName = "sideInfoTitle"; } } else { + if( this.props.showConfig.sName === 'sMemo'){ + extraClassName = "memoInfoTitle"; + } // if (showNameNew?.length > 7) { // titleStyle.fontSize = 14; // } else if (showNameNew?.length > 6) { diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js index 4fb0b6e..f548420 100644 --- a/src/components/Common/CommonHooks/useCommonBase.js +++ b/src/components/Common/CommonHooks/useCommonBase.js @@ -58,14 +58,17 @@ const useCommonBase = props => { const { sModelsId, app } = state; const isChoosePlate = sModelsId !== '12710101117087374661080' const formData = await handleGetModelConfig({ sModelsId }); - const addState = {}; + let addState = {}; let pageRoute = props.sModelType; // 如果是弹窗且没有pageLayout,则认为是commonBill if (commonUtils.isNotEmptyObject(props.parentProps) && formData.length && !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout')) { pageRoute = '/indexPage/commonBill'; } + if (formData.length && formData[0]?.sName.includes('/indexPage/commonSubBill')) { + pageRoute = formData[0]?.sName + } - if (formData.length && !props.currentContent && ['/indexPage/commonList', '/indexPage/commonBill'].includes(pageRoute) && !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout')) { + if (formData.length && !props.currentContent && ['/indexPage/commonList', '/indexPage/commonBill', '/indexPage/commonSubBill'].includes(pageRoute) && !formData[0].gdsconfigformslave.some(item => item.sControlName === 'pageLayout')) { if (pageRoute === '/indexPage/commonList') { formData[0].sGrd = isChoosePlate ? 'slave' : formData[0].sGrd; formData[0].gdsconfigformslave.push({ @@ -98,6 +101,102 @@ const useCommonBase = props => { }) addState.bMesBill = true; addState.copyTo = { master: { maxBillNo: 'sBillNo' } }; + } else if (pageRoute === '/indexPage/commonSubBill') { + const { sLanguage } = app.userinfo; + const [tableList, tabConfig] = [[], []]; + let addState1 = {} + const filterData = formData.filter(item => item.bGrd && item.sTbName !== 'sysbillcheckresult' && item.bGrdVisible); + if (commonUtils.isNotEmptyArr(filterData) && filterData.length > 1 && filterData.length === 2) { + const slaveChildConfig = filterData[1]; + const slaveChildColumn = commonFunc.getHeaderConfig(slaveChildConfig); + // handleGetOneMemoData('slaveChild', slaveChildConfig); + const slaveChildPageSize = commonUtils.isNotEmptyObject(slaveChildConfig) && commonUtils.isNotEmptyNumber(slaveChildConfig.iPageSize) && slaveChildConfig.iPageSize !== 0 ? + slaveChildConfig.iPageSize : commonConfig.pageSize; + addState1 = { + slaveChildConfig, + slaveChildColumn, + slaveChildPageSize, + }; + } else if (commonUtils.isNotEmptyArr(filterData) && filterData.length > 2) { + const slaveChildConfig = commonUtils.isNotEmptyArr(formData.filter(item => item.bGrd && item.sTbName !== 'sysbillcheckresult' && item.bGrdVisible && commonUtils.isNotEmptyObject(item.sChildTableName))) ? + formData.filter(item => item.bGrd && item.sTbName !== 'sysbillcheckresult' && item.bGrdVisible && commonUtils.isNotEmptyObject(item.sChildTableName))[0] : {}; + + const slaveChildColumn = commonUtils.isNotEmptyObject(slaveChildConfig) ? commonFunc.getHeaderConfig(slaveChildConfig) : []; + // handleGetOneMemoData('slaveChild', slaveChildConfig); + const slaveChildPageSize = commonUtils.isNotEmptyObject(slaveChildConfig) && commonUtils.isNotEmptyNumber(slaveChildConfig.iPageSize) && slaveChildConfig.iPageSize !== 0 ? + slaveChildConfig.iPageSize : commonConfig.pageSize; + addState1 = { + slaveChildConfig, + slaveChildColumn, + slaveChildPageSize, + }; + + // eslint-disable-next-line no-unused-vars + const addState2 = {}; + const memoDataList = []; + const slaveInfoList = []; + let slaveIndex = 0; + formData.forEach((item, index) => { + if (index >= 2 && commonUtils.isNotEmptyObject(item) && item.bGrd && item.bGrdVisible && commonUtils.isEmptyObject(item.sChildTableName)) { + addState1[`slave${slaveIndex}Config`] = item; + config[`slave${slaveIndex}Config`] = item; + addState1[`slave${slaveIndex}Column`] = commonFunc.getHeaderConfig(item); + memoDataList.push({ + name: `slave${slaveIndex}`, + config: item, + }); + slaveInfoList.push(`slave${slaveIndex}`); + // eslint-disable-next-line no-plusplus + slaveIndex++; + } + }); + addState1.slaveInfoList = slaveInfoList; + } + const deferredItems = []; + formData.forEach((item, index) => { + if (index === 0) { + item.sGrd = isChoosePlate ? 'master' : item.sGrd; + tableList.push('master'); + tabConfig.push({ "configList": [{ "sName": "master", "showType": "form", "bHideTitle": true, "defaultEnabled": true }], "mode": "advanced", "height": "auto", "width": "100%" }); + } 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; + tableList.push(tablename); + if (!tabConfig[1]) { + tabConfig.push({ "configList": [], "mode": "advanced" }); + } + 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', + sDefault: JSON.stringify([tableList, tabConfig]), + }) + + addState.bMesSubBill = true; + // addState.copyTo = { master: { maxBillNo: 'sBillNo' } }; + addState = { ...addState, ...addState1 }; } } @@ -195,7 +294,7 @@ const useCommonBase = props => { }) } else if (bFilterName !== undefined && bFilterCondition !== undefined && bFilterValue !== undefined) { const currentValue = masterData[bFilterName]; - flag = handleCompareValues(currentValue, bFilterValue, bFilterCondition); + // flag = handleCompareValues(currentValue, bFilterValue, bFilterCondition); } if (!flag) { break; @@ -287,6 +386,7 @@ const useCommonBase = props => { clearSelectData, isPagination, // mes的通用列表需要真分页,所以增加isPagination参数控制是否分页 } = params; + const { token, sModelsId, @@ -325,7 +425,7 @@ const useCommonBase = props => { } } } - if ( isPagination ) { + if (isPagination) { condition.pageSize = condition.pageSize || 10; /* 前台传入页数或者默认页数 */ condition.pageNum = condition.pageNum || 1; /* 前台传入页数或者默认页数 */ } @@ -378,23 +478,25 @@ const useCommonBase = props => { if (commonUtils.isNotEmptyObject(props.parentProps)) { pageRoute = '/indexPage/commonBill'; } - if (name === 'master' && pageRoute.includes('indexPage/commonBill')) { + if (name === 'master' && ['/indexPage/commonBill', 'indexPage/commonSubBill'].includes(pageRoute)) { // condition.sId = configDataId condition.pageNum = '' condition.pageSize = '' delete condition.sSqlCondition } - if (name.includes('slave') && pageRoute.includes('indexPage/commonBill')) { - delete condition.sSqlCondition + + if (name.includes('slave') && ['/indexPage/commonBill', '/indexPage/commonSubBill'].includes(pageRoute)) { delete condition.sId condition.sSqlCondition = { sParentId: condition?.sSqlCondition?.sParentId } + } // 只有弹窗没有不查询 - if (name === 'master' && sId === '' && props.parentProps && pageRoute.includes('indexPage/commonBill')) return + if (name === 'master' && (sId === '' || !sId) && props.parentProps && ['/indexPage/commonBill', '/indexPage/commonSubBill'].includes(pageRoute)) return const dataUrl = `${commonConfig.server_host }business/getBusinessDataByFormcustomId/${configDataId}?sModelsId=${sModelsId}&sName=${formSrcRoute}`; + const dataReturn = (await commonServices.postValueService( token, condition, @@ -431,13 +533,16 @@ const useCommonBase = props => { const filterConditionNew = commonUtils.isNotEmptyObject(filterCondition) ? filterCondition.filter(item => item.bFilterType !== "tree") : ""; + // 如果state中存在slaveChildConfig 那么就是commonSubBill + const slaveChild = state?.formData?.find(x => x.sId === state?.slaveChildConfig?.sId) + const names = slaveChild && slaveChild.sGrd === name ? 'slaveChild' : name const addState = { - [`${name}Data`]: returnData, - [`${name}TotalData`]: totalData, + [`${names}Data`]: returnData, + [`${names}TotalData`]: totalData, // [`${name}Pagination`]: returnPagination, - [`${name}FilterCondition`]: filterConditionNew, - [`${name}OrderBy`]: orderBy, - [`${name}SelectedRowKeys`]: tableSelectedRowKeys, + [`${names}FilterCondition`]: filterConditionNew, + [`${names}OrderBy`]: orderBy, + [`${names}SelectedRowKeys`]: tableSelectedRowKeys, menuChildData, pageLoading: false, iPageSize, @@ -451,19 +556,21 @@ const useCommonBase = props => { // 添加动态列数据 if (commonUtils.isNotEmptyArr(columnConfig)) { - addState[`${name}ColumnConfig`] = columnConfig; + addState[`${names}ColumnConfig`] = columnConfig; } const slaveSelectedData = []; - addState[`${name}SelectedData`] = slaveSelectedData; + addState[`${names}SelectedData`] = slaveSelectedData; /* 如果获取数据集时候 删除数据集有数据 则清空 */ if (commonUtils.isNotEmptyArr(tableDelData)) { - addState[`${name}DelData`] = []; + addState[`${names}DelData`] = []; } + if (isWait) { return addState; } { + handleSaveState(addState); } } else { @@ -2795,7 +2902,6 @@ const useCommonBase = props => { const { sControlName = "", sInstruct } = config; const sControlLowerName = sControlName.toLowerCase(); // 调用指令集 - console.log(sInstruct, 'sInstruct'); if (sInstruct) { handleExecInstructSet({ ...props, @@ -2971,7 +3077,7 @@ const useCommonBase = props => { }; // 表格行新增 - const handleMesTableLineAdd = ({ tableName, callback, bAddFirst }) => { + const handleMesTableLineAdd = ({ tableName, callback, bAddFirst, slaveChild }) => { const { [`${tableName}Config`]: config = {}, [`${tableName}Data`]: data = [], @@ -3017,19 +3123,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 ); @@ -3063,6 +3184,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 { @@ -3143,9 +3275,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; @@ -3488,7 +3716,6 @@ const useCommonBase = props => { handleOkDel(props); }; const handleBtnChoose = async (name, sControlName, chooseConfig, recordIndex, tableName) => { - console.log("🚀 ~ handleBtnChoose ~ chooseConfig:", name, sControlName, chooseConfig, recordIndex, tableName) return const { token } = props; const url = `${commonConfig.server_host}/gdsmodule/getGdsmoduleById/${chooseConfig.sActiveId}?sModelsId=${chooseConfig.sActiveId}`; diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js index 0f670ce..772d512 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" } @@ -2184,12 +2184,12 @@ class CommonTableRc extends React.Component { if (!bEnabled) return; let newValue = ""; - if (!value) { + if (!value || value === '/') { newValue = "✓"; } else if (["1", "✓"].includes(value)) { newValue = "✗"; - } else { - newValue = "✓"; + } else if (["0", "✗"].includes(value)) { + newValue = "/"; } const dataNew = [...this.props.data]; @@ -2260,6 +2260,22 @@ class CommonTableRc extends React.Component { ✗ ); + } else if (value === "3" || value === '/') { + return ( +
+ / +
+ ); } else { 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.noVlist && !noVlistController) { + 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) => { if (tableColumn[index].fixedHelp) { @@ -7747,6 +7763,7 @@ class CommonTableRc extends React.Component { } const cells = []; const cells1 = []; + if (totalData.length) { let summaryCellTotal = ""; summaryCellTotal = ( @@ -9904,7 +9921,7 @@ class CommonTableRc extends React.Component { if (searchText !== props.searchText) { stateValue.searchText = props.searchText; } - if (props.enabled) { + if (true || props.enabled) { const { config } = this.props; if (commonUtils.isNotEmptyObject(config)) { const productionRoute = @@ -11147,13 +11164,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 ( @@ -11253,33 +11290,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 && + } +
)}
@@ -11820,7 +11857,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); @@ -12146,9 +12183,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); } @@ -12288,7 +12326,7 @@ const useGetTableBtnOprSetting = props => { }; if (sDefault === '') { // sDefault = - const btnList = gdsconfigformslave.filter(item => item.bVisible && item.sControlName.includes('Btn')) + const btnList = gdsconfigformslave.filter(item => item.bVisible && item.sControlName.includes('Btn') && !item.sControlName.includes('BtnLeft')) sDefault = btnList?.map(item => { return getButtonName(item.sControlName.toLowerCase()) }).join(',') @@ -12372,7 +12410,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/components/Common/CommonTable/index.less b/src/components/Common/CommonTable/index.less index 4d61361..3bfc086 100644 --- a/src/components/Common/CommonTable/index.less +++ b/src/components/Common/CommonTable/index.less @@ -673,6 +673,15 @@ button.mesSave { cursor: default; user-select: none } +.xunjianNone{ + .flex(center, center); + .size(); + color: #efb700; + font-size: 24px; + cursor: default; + user-select: none + +} .xunjianEnabled { text-decoration: underline; @@ -766,5 +775,5 @@ button.mesSave { .btnIcon { width: 24px; height: 24px; - -} \ No newline at end of file + +} diff --git a/src/components/Common/CommonViewTable/index.js b/src/components/Common/CommonViewTable/index.js index a0f401a..e3588ef 100644 --- a/src/components/Common/CommonViewTable/index.js +++ b/src/components/Common/CommonViewTable/index.js @@ -308,7 +308,7 @@ class CommonViewTableRc extends Component { }, wrapperCol: { span: this.props?.sModelsId !== "17086722220003015078585693314000" ? 17 : 8, } }; - + /* 字段弹窗功能 */ let commonFieldPopupProps = {}; let commonFieldPopupTitle = "选择弹窗"; diff --git a/src/indexNew.less b/src/indexNew.less index 6a87200..cbf0b57 100644 --- a/src/indexNew.less +++ b/src/indexNew.less @@ -117,6 +117,12 @@ flex-flow: row nowrap; } + .memoInfoTitle{ + .ant-form-item-label:not(.skipFlexBasis) { + height: auto !important; // 干掉固定40px,由父flex拉伸高度 + } + } + .ant-form-item-label:not(.skipFlexBasis) { background-color: var(--form-label-bgColor, #EEEEEE) !important; // flex-basis: 160px !important; diff --git a/src/mes/common/commonModalComponent/index.js b/src/mes/common/commonModalComponent/index.js index bfc5a82..59a110d 100644 --- a/src/mes/common/commonModalComponent/index.js +++ b/src/mes/common/commonModalComponent/index.js @@ -6,7 +6,7 @@ import RouterComponent from "@/routes/mes/routerComponent"; import * as commonUtils from "@/utils/utils"; const CommonModalComponent = props => { - const bSmall = props?.sModelsId ==='17211911815017669983448000'; + const bSmall = props?.sModelsId ==='17211911815017669983448000' || props?.sModelsId === '172117190122117805553443590'; const { visible, title, diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 1a92365..ab402a5 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -256,6 +256,7 @@ const useCommonModelEvent = props => { }; const [refreshCount, setRefreshCount] = useState(0); + const [copyToInitialized, setCopyToInitialized] = useState(false); const sModelType = Array.isArray(formData) && formData.length > 0 ? (formData[0]?.sName || formData[0]?.sModelType || '') @@ -264,7 +265,6 @@ const useCommonModelEvent = props => { // 初始化事件 useEffect( async () => { - if (commonUtils.isNotEmptyArr(formData)) { let pageLayout = []; let addState = {}; @@ -285,10 +285,10 @@ const useCommonModelEvent = props => { const [tableList, tabConfig] = pageLayout; const colunmData = handleGetColumnData(tableList, true); let result = {}; - if(!noGetData && sModelsId === '17211911815017669983448000'){ + if (!noGetData && sModelsId === '17211911815017669983448000') { result = await handleGetDataPop(tableList, true, true) } else if (!commonUtils.isEmptyObject(copyTo)) { - result = await handleGetData(tableList, true, true); + result = await handleGetData(tableList, true, true, copyTo); } else if (noGetData) { result = await handleGetData( tableList.filter( @@ -413,7 +413,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 +542,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]; @@ -682,7 +681,7 @@ const useCommonModelEvent = props => { configData: config, condition: { sSqlCondition: { ...conditonValues, ...sFilterConditions }, - bFilter + bFilter, }, isWait: true }) || Promise.resolve({}); @@ -752,7 +751,6 @@ const useCommonModelEvent = props => { item => item.sControlName === "bFirstlineSelected" && item.bVisible ); // 配置刷新数据时,配置 数据集名称+FirstlineSelected,默认选中首行数据。 - console.log('bFirstlineSelected', bFirstlineSelected); if (!bFirstlineSelected) { bFirstlineSelected = tableList.findIndex( @@ -785,10 +783,11 @@ const useCommonModelEvent = props => { }; // 获取数据集 - const handleGetData = async (tableList = [], isWait, bInit) => { + const handleGetData = async (tableList = [], isWait, bInit, copyTo) => { let addState = {}; const { currentId } = props - const currentIds = currentId ? currentId : props?.parentProps?.record?.sId + const currentIds = currentId || props?.parentProps?.record?.sId; + for (let i = 0; i < tableList.length; i++) { const tableName = tableList[i]; const config = formData.find(item => item.sGrd === tableName); @@ -902,6 +901,7 @@ const useCommonModelEvent = props => { } const masterState = {}; + if (currentIds && tableName === 'master') { masterState.sId = currentIds; } @@ -915,14 +915,14 @@ const useCommonModelEvent = props => { isPagination = true } + const sSqlCondition = { ...sFilterConditions, ...conditonValues, } const result = (await props.onGetDataSet({ name: tableName, configData: config, condition: { ...masterState, - // sId: currentIds, - sSqlCondition: { ...conditonValues, ...sFilterConditions, }, + sSqlCondition, bFilter, pageNum: isPagination ? props?.mesPageNum || 1 : undefined, pageSize: isPagination ? props?.mesPageSize || 10 : undefined, @@ -983,9 +983,23 @@ const useCommonModelEvent = props => { if (tableName === "tableS0" && props.sSReserve1) { addState.sSReserve1 = undefined; } + + } + + // 只有弹窗首次打开时才执行 copyTo 数据回填,防止后续刷新覆盖当前数据 + if (!copyToInitialized && !commonUtils.isEmptyObject(copyTo) && copyTo?.isTmpinfobysql) { + tableList.forEach((item, index) => { + addState = { + ...addState, + enabled: true, + [`${tableList[index]}Data`]: index === 0 ? copyTo.masterData : copyTo['slave' + (index - 1 === 0 ? '' : index - 1) + 'Data'], + } + }) + setCopyToInitialized(true); } props.setTempRef({}, true); + if (isWait) { return addState; } else { @@ -1894,9 +1908,10 @@ const CommonModel = baseProps => { }; const CommonModelComponent = props => { - const { tabConfig = [], level, modelStyle, app, bMesBill, enabled, masterData, sModelsType } = props; + const { tabConfig = [], level, modelStyle, app, bMesBill, bMesSubBill, enabled, masterData, sModelsType, formData } = props; const { userinfo } = app; const sLanguage = userinfo.sLanguage; + const pageRoute = formData?.[0]?.sName const getComponent = (config, index = 0) => { const { sName, @@ -1905,7 +1920,8 @@ const CommonModelComponent = props => { defaultEnabled, bHideTitle, tableBtnsConfig, - children = [] + children = [], + slaveChild } = config; if (showType === "none") { @@ -1928,6 +1944,31 @@ const CommonModelComponent = props => { } else if (showType === "costom") { return ; } else { + if (pageRoute.includes('commonSubBill')) { + let componentProps = { + ...props, + showType, // 展示类型(表单/表格) + enabled: !bMesSubBill ? defaultEnabled : enabled, // 是否可编辑 + sTabName, // 标题名称 + sName: slaveChild ? 'slaveChild' : sName, // 配置对应的sGrd + bHideTitle, //隐藏标题 + tableBtnsConfig, // 表格按钮配置 + bFirstComponent: level === 0 && index === -1, + slaveChild + }; + + const commonDivHeight = useComputedCommonDivHeight(componentProps); + return ( +
+ + +
+ ); + } let componentProps = { ...props, showType, // 展示类型(表单/表格) @@ -1938,6 +1979,7 @@ const CommonModelComponent = props => { tableBtnsConfig, // 表格按钮配置 bFirstComponent: level === 0 && index === -1 }; + const commonDivHeight = useComputedCommonDivHeight(componentProps); return (
{ extraStyle.flexDirection = 'column'; extraStyle.paddingTop = 5; } - const { sModelsId } = props; + const { sModelsId, slaveChildConfig } = props; const isNotTab = sModelsId === '12710101117119423319470' - + const subHeight = slaveChildConfig ? '' : '100%' return ( <>
@@ -1972,7 +2014,7 @@ const CommonModelComponent = props => { sBig5EntireTabName, mode, width = "100%", - height = "100%" + height = subHeight } = item; const sEntireTabNameNew = sLanguage === 'sEnglish' ? sEnglishEntireTabName : sLanguage === 'sBig5EntireTabName' ? sBig5EntireTabName : sEntireTabName; @@ -1995,7 +2037,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 ( [ "维修申请记录", @@ -2016,6 +2058,7 @@ const CommonModelComponent = props => { ...props, sTabName: configList[0].sTabName }; + return ( <> @@ -2067,6 +2110,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; @@ -2094,6 +2138,7 @@ const CommonModelComponent = props => { props.salveWybz2Data?.[0]?.bSave === false || props.salveWybz2Data?.[0]?.bSave === 0; } + return ( { const { masterData, sModelsType, app } = props const { bCheck = false } = masterData || {} const imgSrc = commonBusiness.handleAddIcon(masterData, sModelsType, app); + return ( <> {sName === "master" ? ( @@ -2571,40 +2617,40 @@ const CommonTableComponent = props => { // showSizeChanger: !isSmall, // showQuickJumper: !isSmall, // }; - const { mesTotalCount , mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {}; - const tableProps = { - ...baseProps, - tableBtnsConfig: btnsConfig, - // tableBtnsWidth: '100px', - // tableBtnsConfig: (params) => { - // console.log('=====params', params); - // return btnsConfig; - // }, - onTableBtnClick, - tableProps: { - onChange: () => { }, - rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" || baseProps?.config?.sName?.includes('/indexPage/commonList') ? 'sSlaveId' : 'sId', - mesTotalCount, - mesPageSize, - mesPageNum, - isPagination, - // AutoTableHeight: 200 - }, - onViewClick: (tableName, sFieldName, record, index, config) => { - // 异常事件提报-提报信息-事件类型字段点击事件 - if (tableName === "slave" && sFieldName === "sClassifyName") { - props.onTableBtnClick({ - name: tableName, - record, - config - }); - } - }, - onViewChoose: (tableName, sFieldName, record, index, isColor) => { - handleViewChoose(tableName, sFieldName, record, index, isColor); - + const { mesTotalCount, mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {}; + const tableProps = { + ...baseProps, + tableBtnsConfig: btnsConfig, + // tableBtnsWidth: '100px', + // tableBtnsConfig: (params) => { + // console.log('=====params', params); + // return btnsConfig; + // }, + onTableBtnClick, + tableProps: { + onChange: () => { }, + rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" || baseProps?.config?.sName?.includes('/indexPage/commonList') ? 'sSlaveId' : 'sId', + mesTotalCount, + mesPageSize, + mesPageNum, + isPagination, + // AutoTableHeight: 200 + }, + onViewClick: (tableName, sFieldName, record, index, config) => { + // 异常事件提报-提报信息-事件类型字段点击事件 + if (tableName === "slave" && sFieldName === "sClassifyName") { + props.onTableBtnClick({ + name: tableName, + record, + config + }); } - }; + }, + onViewChoose: (tableName, sFieldName, record, index, isColor) => { + handleViewChoose(tableName, sFieldName, record, index, isColor); + + } + }; const handleViewChoose = (tableName, sFieldName, record, index, isColor) => { if (isColor) { const { sId } = record; /* 控制表主键 */ diff --git a/src/mes/common/commonOperationBarComponent/MesToolbar.js b/src/mes/common/commonOperationBarComponent/MesToolbar.js index 87e5fb4..a3d0ef9 100644 --- a/src/mes/common/commonOperationBarComponent/MesToolbar.js +++ b/src/mes/common/commonOperationBarComponent/MesToolbar.js @@ -19,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; @@ -326,6 +325,10 @@ const ToolbarFun = async (props) => { handleForceComplete(props, btnName); } } + } else if (btnName.includes('tmpinfobysql')) { + return false + } else if (btnName && btnName.includes('btncalc')) { + handleCalc(props, btnConfig) } @@ -856,7 +859,6 @@ const handleForceComplete = (props, name, createDate) => { } } } - console.log("singleRow:", singleRow); if (sIndex > -1) { if (target === "slaveInfo") { singleConfig = props.slaveInfoConfig.gdsconfigformslave[sIndex]; @@ -955,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; @@ -1059,9 +1149,9 @@ const handleScanFace = (props) => { proData.forEach(item => { const data = commonFunc.getAssignFieldValue(copyConfig?.sAssignField, item) const index = tableData.findIndex(x => x.sEmployeeNo === item.sEmployeeNo) - // if (index !== -1) { - // message.error('人员重复,请重新添加', 5) - // } else { + if (index !== -1) { + message.error('人员重复,请重新添加', 5) + } else { tableData.push({ ...item, ...data, @@ -1070,7 +1160,7 @@ const handleScanFace = (props) => { sParentId: props.masterData.sId, slaveId: props?.slaveData ? props?.slaveData[0].sId : '' }) - // } + } }); diff --git a/src/mes/common/commonOperationBarComponent/index.js b/src/mes/common/commonOperationBarComponent/index.js index e440d36..0cb4258 100644 --- a/src/mes/common/commonOperationBarComponent/index.js +++ b/src/mes/common/commonOperationBarComponent/index.js @@ -79,7 +79,7 @@ const useCommonOperationBarComponentEvent = props => { // 按钮点击事件 const clickRef = useRef(null); - const handleBtnClick = async (config, searchField) => { + const handleBtnClick = async (config, searchField, btnLeftConfig) => { // 限制半秒内只能点一次 if (clickRef.current) return; clickRef.current = true; @@ -92,10 +92,12 @@ const useCommonOperationBarComponentEvent = props => { const delayedOvertime = commonFunc.showLocalMessage(props, 'delayedOvertime', '延迟加班'); const cancelDelayedOvertime = commonFunc.showLocalMessage(props, 'cancelDelayedOvertime', '取消延迟加班'); + // 走工具栏功能逻辑 if (await MesToolbar({ ...props, btnConfig: config })) { return; } + // 自定义按钮事件 if ( costomPageFun({ @@ -305,8 +307,9 @@ const useCommonOperationBarComponentEvent = props => { } // 弹窗 + if (sActiveId) { - handleOpenCommonModal(config); + handleOpenCommonModal(config, btnLeftConfig); } if (["BtnLeft.setUpStart"].includes(sControlName)) { @@ -551,15 +554,17 @@ const useCommonOperationBarComponentEvent = props => { }; // 弹窗 - const handleOpenCommonModal = config => { + const handleOpenCommonModal = async (config, btnLeftConfig) => { const { sActiveId, sActiveName } = config; - const copyTo = handleGetCopyTo(config); - - // 获取sqlCondition值 + const copyTo = await handleGetCopyTo(config, btnLeftConfig); + // // 获取sqlCondition值 const sParentConditions = props.getSqlCondition(config); + 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') + // // 弹窗展示 props.onOpenCommonModal({ type: "commonModal", sActiveId, @@ -567,7 +572,7 @@ const useCommonOperationBarComponentEvent = props => { copyTo, sModelType: '/indexPage/commonBill', sParentConditions, - parentProps: props, + parentProps: { ...props, record }, onOk: data => { console.log("=====onOk", data); }, @@ -578,8 +583,90 @@ const useCommonOperationBarComponentEvent = props => { }; // 获取copyTo数据 - const handleGetCopyTo = config => { - const copyTo = {}; + const handleGetCopyTo = async (config, btnLeftConfig) => { + let copyTo = {}; + const { sModelsId, sName, token, app } = props + const name = config?.sControlName + const copyToConfig = btnLeftConfig.filter(x => x.sControlName.includes(config?.sControlName)) + const allReturnMap = {}; + let copyToData = props[sName + 'Data'] || [] + if (commonUtils.isNotEmptyObject(config?.sControlName) && config?.sControlName.toLowerCase().includes('btncopyto.tmpinfobysql')) { + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`; + const sConfigformId = commonUtils.isEmpty(copyToConfig) ? '' : copyToConfig[0]?.sParentId; + const sControlName = commonUtils.isNotEmptyObject(config?.sControlName) ? config?.sControlName : 'BtnCopyTo.TmpInfoBySql'; + const selectedRowKeys = props[sName + 'SelectedRowKeys']?.[0] || '' + const selectedRowKeysList = props[sName + 'SelectedRowKeys'] + const slaveSelectedData = props[sName + 'Data'] || [] + const sRowData = slaveSelectedData.map(item => { + const i = selectedRowKeysList.findIndex(x => x === item.id || x === item.sSlaveId) + if (i !== -1) { + return item + } else { + return null + } + }).filter(x => x !== null) + /* 塞原始数据 */ + if (commonUtils.isNotEmptyArr(slaveSelectedData)) { + 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 }; + const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data; + if (dataReturn.code === 1) { + const returnData = dataReturn.dataset.rows[0]; + if (commonUtils.isNotEmptyObject(returnData)) { + for (const key of Object.keys(returnData)) { + const sName = `${key}Data`; + const sDelName = `${key}DelData`; + const sAssignField = copyToConfig.find(x => x.sControlName.includes(key))?.sAssignField + const keyData = returnData[key]; + let newData = [] + if (commonUtils.isNotEmptyArr(keyData)) { + keyData.forEach(item => { + let tableRow = {}; + tableRow = { ...tableRow, ...commonFunc.getAssignFieldValue(sAssignField, item) }; // 取赋值字段 + tableRow.sId = commonUtils.createSid(); + tableRow.sParentId = copyTo.masterData.sId; + tableRow.handleType = 'add'; + tableRow.sSqlConditionOldId = tableRow.sSqlConditionId; + tableRow.sSqlConditionId = tableRow.sId + newData.push(tableRow); + }) + } + allReturnMap[sName] = newData; + + } + + if (commonUtils.isNotEmptyArr(copyTo.masterData) && Array.isArray(copyTo.masterData)) { + copyTo.masterData = copyTo.masterData[0]; + } + const configName = copyToConfig[0].sControlName.split(".").pop(); + copyTo = { + ...copyTo, + ...allReturnMap, + isTmpinfobysql: true + } + if (configName && allReturnMap[configName]) { + copyTo.masterData = allReturnMap[configName] + } + } + } else { + message.error(dataReturn.msg); + } + } + return copyTo; }; @@ -613,11 +700,11 @@ const useCommonOperationBarComponentEvent = props => { }; // 获取按钮配置 - const handleGetBtnPropps = (config, searchField) => { + const handleGetBtnPropps = (config, searchField, btnLeftConfig) => { const defaultProps = { type: "primary", size: "large", - onClick: handleBtnClick.bind(this, config, searchField) + onClick: handleBtnClick.bind(this, config, searchField, btnLeftConfig) }; const { sDefault, sControlName } = config; @@ -736,7 +823,7 @@ const useCommonOperationBarComponentEvent = props => { } catch (error) { console.log("=====err", { tempData, str: sDefault, strNew, error }); } - } else if (props.bMesBill) { + } else if (props.bMesBill || props.bMesSubBill) { const btnName = sControlName.replace('BtnLeft.', '').replace('BtnRight.', '').toLowerCase(); let enabled = props.enabled @@ -749,7 +836,9 @@ const useCommonOperationBarComponentEvent = props => { } } else { - if (["btnsave", "btnscanface"].includes(btnName)) { + + + if (["btnsave", "btnscanface"].includes(btnName) || btnName?.startsWith('btncalc')) { defaultProps.disabled = true; } if (!bSubmit) { @@ -955,9 +1044,17 @@ const CommonOperationBarComponent = basProps => { props.setExtraBtns(extraBtns); } - const btnLeftConfig = gdsconfigformslave.filter( + const originalData = gdsconfigformslave.filter( item => item.bVisible && item.sControlName.includes("BtnLeft.") ); + const btnLeftConfig = originalData.filter(item => { + const str = item.sControlName; + if (!str.includes("BtnCopyTo")) { + return true; + } + + return /BtnCopyTo\.[^.]*$/.test(str); + }); // 将扫码上料放到最后 const scanCodeToLoadMaterialsIndex = btnLeftConfig.findIndex( @@ -1408,7 +1505,7 @@ const CommonOperationBarComponent = basProps => {
} return ( - ); @@ -1503,58 +1600,63 @@ const BarcodeComponent = props => { item => item.sName === "sSearchProductName" ); - props.onExecInstructSet({ - btnConfig, - nextProps: { scanCodeData: [{ value: valueNew }] }, - // callback: () => { - // if (commonUtils.isNotEmptyArr(searchProductConfig)) { - // props.onSaveState({ - // refreshMachineDataFlag: new Date().getTime(), - // productionTableList: [sName] - // }); - // } - // }, - inscallback: nextProps => { - if (commonUtils.isNotEmptyArr(searchProductConfig)) { - props.onSaveState({ - refreshMachineDataFlag: new Date().getTime(), - productionTableList: [sName] - }, ()=>{ - props.onRefresh && props.onRefresh(); - }); + try { + props.onExecInstructSet({ + btnConfig, + nextProps: { scanCodeData: [{ value: valueNew }] }, + // callback: () => { + // if (commonUtils.isNotEmptyArr(searchProductConfig)) { + // props.onSaveState({ + // refreshMachineDataFlag: new Date().getTime(), + // productionTableList: [sName] + // }); + // } + // }, + inscallback: nextProps => { + if (commonUtils.isNotEmptyArr(searchProductConfig)) { + props.onSaveState({ + refreshMachineDataFlag: new Date().getTime(), + productionTableList: [sName] + }, () => { + // props.onRefresh && props.onRefresh(); + }); + } } - } - // inscallback: nextProps => { - // if (commonUtils.isNotEmptyArr(searchProductConfig)) { - // const { machinedataData } = nextProps; - // if (commonUtils.isNotEmptyArr(machinedataData)) { - // const { - // sProductId, - // sProductNo, - // sSearchProductId = sProductId, - // sSearchProductNo = sProductNo - // } = machinedataData[0]; - // nextProps.onSaveState( - // { - // workOrderInfoData: machinedataData, - // sSearchProductId: sSearchProductId - // }, - // nextPropsNew => { - // props.onSearchProductNameChange( - // "", - // "", - // { - // sSearchProductId, - // sSearchProductNo - // }, - // true - // ); - // } - // ); - // } - // } - // } - }); + // inscallback: nextProps => { + // if (commonUtils.isNotEmptyArr(searchProductConfig)) { + // const { machinedataData } = nextProps; + // if (commonUtils.isNotEmptyArr(machinedataData)) { + // const { + // sProductId, + // sProductNo, + // sSearchProductId = sProductId, + // sSearchProductNo = sProductNo + // } = machinedataData[0]; + // nextProps.onSaveState( + // { + // workOrderInfoData: machinedataData, + // sSearchProductId: sSearchProductId + // }, + // nextPropsNew => { + // props.onSearchProductNameChange( + // "", + // "", + // { + // sSearchProductId, + // sSearchProductNo + // }, + // true + // ); + // } + // ); + // } + // } + // } + }); + } finally { + console.log('finily-上料执行界面刷新:'); + props.onRefresh && props.onRefresh(); + } }; // 判断是否扫码枪输入 diff --git a/src/mes/productionExec/noticeModal/index.less b/src/mes/productionExec/noticeModal/index.less index 9382a44..0d2b27c 100644 --- a/src/mes/productionExec/noticeModal/index.less +++ b/src/mes/productionExec/noticeModal/index.less @@ -159,4 +159,4 @@ margin-left: initial; } } -} \ No newline at end of file +} diff --git a/src/mes/productionExec/productionExecMain/index.js b/src/mes/productionExec/productionExecMain/index.js index cb38532..a72beef 100644 --- a/src/mes/productionExec/productionExecMain/index.js +++ b/src/mes/productionExec/productionExecMain/index.js @@ -1102,7 +1102,7 @@ const ProductionExecContent0 = props => {
- +