diff --git a/src/components/Common/CommonElementEvent.js b/src/components/Common/CommonElementEvent.js index 24f7bdc..e2f4b3b 100644 --- a/src/components/Common/CommonElementEvent.js +++ b/src/components/Common/CommonElementEvent.js @@ -3014,64 +3014,108 @@ export default (ChildComponent) => { /* 上一条、下一条、首条、末条 */ handleSearchData = async (handleType) => { const { - sModelsId, app, currentIndexFlag, currentPageNo, + sModelsId, app, currentIndexFlag, currentPageNo, masterData, masterConfig, slaveConfig, checkConfig, + sSrcModelsId, } = this.props; + let { sBillIdsArray = []} = this.props; + let { currentId } = this.props; + + const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条'); + const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条'); + const noSearhData = commonFunc.showLocalMessage(this.props, 'noSearhData', '非单据列表跳转,无上一条下一条'); const { currentPane, token } = app; const { pages, sFilterOrderBy, bFilter, sListFormmasterId, currentIndex, } = currentPane; - const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条'); - const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条'); + console.log('22page2222s2', pages); let currentPosition = currentIndexFlag ? currentPageNo : commonUtils.isEmptyObject(pages) ? 1 : (((pages.current - 1) * commonConfig.pageSize) + Number.parseInt(currentIndex, 10)) + 1; - if (commonUtils.isEmptyObject(pages) || commonUtils.isEmptyNumber(pages.total)) { - if (handleType === 'next' || handleType === 'end') { - message.warn(tipLast); - return; - } else { - message.warn(tipFirst); - return; - } - } if (currentIndex === undefined) { currentPosition = 1; - if (handleType === 'next') { - currentPosition = pages.total; - } } - if (handleType === 'first') { + if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加,就跳到第一条去 currentPosition = 1; - } else if (handleType === 'end') { - currentPosition = pages.total; } + let bExist = false; + /* 如果sBillIdsArray已存在 则不请求 */ + if(commonUtils.isNotEmptyArr(sBillIdsArray) && sBillIdsArray.length > 0) { + const index = sBillIdsArray.indexOf(currentId); + if(index > -1) { + if ("next".includes(handleType)) { + currentPosition = index + 1; + if(currentPosition > sBillIdsArray.length - 1 ){ + message.warn(tipLast); + return ; + } + } else if ("up".includes(handleType)) { + if(index === 0){ + message.warn(tipFirst); + return ; + } + currentPosition = index - 1; + } else if ("first".includes(handleType)) { + currentPosition = 0; + } else if ("end".includes(handleType)) { + currentPosition = sBillIdsArray.length - 1; + } + currentId = sBillIdsArray[currentPosition]; + currentPosition = currentPosition + 1; + bExist = true; + } else { + bExist = false; + } + } + /* 如果是第一次请求 */ + if(!bExist) { + const bFromList = commonUtils.isEmptyObject(pages) ? true: false; + if(bFromList) { + if(handleType ==='next' || handleType ==='end') { + message.warn(tipLast); + return ; + }else { + message.warn(tipFirst); + return ; + } + } + const value = { + sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total, + sUpId: masterData?.sId, sParentModelId :sSrcModelsId, + }; + const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`; + /* 接收返回值 */ + const { data } = await commonServices.postValueService(token, value, url); + /* 接收返回值 */ + /* 成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示 */ + if (data.code === 1) { + /* 数据查询成功 */ + const returnData = data.dataset.rows[0]; + if(commonUtils.isNotEmptyObject(returnData) && (commonUtils.isEmpty(returnData?.sId) || + returnData?.sId === "")) { + message.error(noSearhData); + return; + } + /* 拿到接口返回的sBillids */ + console.log('returnData', returnData); + const sBillIds = returnData?.sBillIds; + if(commonUtils.isNotEmptyArr(sBillIds)) { + sBillIdsArray = sBillIds; + } + currentId = returnData?.sId; + currentPosition = returnData?.currentPosition; + } else { /* 失败 */ + this.props.getServiceError(data); + return false; + } - const value = { - sClientType: '1', - sFilterOrderBy, - bFilter, - sListFormmasterId, - currentPosition, - handleType, - iCountSum: pages.total, - }; - const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`; - /* 接收返回值 */ - const { data } = await commonServices.postValueService(token, value, url); - /* 接收返回值 */ - /* 成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示 */ - if (data.code === 1) { - /* 数据查询成功 */ - const returnData = data.dataset.rows[0]; - this.props.onSaveState({ - currentIndexFlag: true, - currentPageNo: returnData.currentPosition, - currentId: returnData.sId, - searchUpDownData: {}, - slaveSelectedRowKeys: [], - }); - this.handleGetTableData(); - } else { /* 失败 */ - this.props.getServiceError(data); } + this.props.onSaveState({ + currentIndexFlag: true, + currentPageNo: currentPosition, + currentId, + searchUpDownData: {}, + slaveSelectedRowKeys: [], + sBillIdsArray, + }, () => this.handleGetTableData()); + return true; }; /* 切换作废状态 */ handleOkChangeInvaild = async (props) => {