Commit c89d44fdc2420ad76a70937e3d1f33709a3fbcc3
1 parent
48c13d56
1.处理基础信息上一页,下一页报错
Showing
1 changed file
with
89 additions
and
45 deletions
src/components/Common/CommonElementEvent.js
| ... | ... | @@ -3014,64 +3014,108 @@ export default (ChildComponent) => { |
| 3014 | 3014 | /* 上一条、下一条、首条、末条 */ |
| 3015 | 3015 | handleSearchData = async (handleType) => { |
| 3016 | 3016 | const { |
| 3017 | - sModelsId, app, currentIndexFlag, currentPageNo, | |
| 3017 | + sModelsId, app, currentIndexFlag, currentPageNo, masterData, masterConfig, slaveConfig, checkConfig, | |
| 3018 | + sSrcModelsId, | |
| 3018 | 3019 | } = this.props; |
| 3020 | + let { sBillIdsArray = []} = this.props; | |
| 3021 | + let { currentId } = this.props; | |
| 3022 | + | |
| 3023 | + const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条'); | |
| 3024 | + const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条'); | |
| 3025 | + const noSearhData = commonFunc.showLocalMessage(this.props, 'noSearhData', '非单据列表跳转,无上一条下一条'); | |
| 3019 | 3026 | const { currentPane, token } = app; |
| 3020 | 3027 | const { |
| 3021 | 3028 | pages, sFilterOrderBy, bFilter, sListFormmasterId, currentIndex, |
| 3022 | 3029 | } = currentPane; |
| 3023 | - const tipLast = commonFunc.showLocalMessage(this.props, 'tipLast', '当前已经是最后一条'); | |
| 3024 | - const tipFirst = commonFunc.showLocalMessage(this.props, 'tipFirst', '当前已经是第一条'); | |
| 3030 | + console.log('22page2222s2', pages); | |
| 3025 | 3031 | let currentPosition = currentIndexFlag ? currentPageNo : commonUtils.isEmptyObject(pages) ? 1 : (((pages.current - 1) * commonConfig.pageSize) + Number.parseInt(currentIndex, 10)) + 1; |
| 3026 | - if (commonUtils.isEmptyObject(pages) || commonUtils.isEmptyNumber(pages.total)) { | |
| 3027 | - if (handleType === 'next' || handleType === 'end') { | |
| 3028 | - message.warn(tipLast); | |
| 3029 | - return; | |
| 3030 | - } else { | |
| 3031 | - message.warn(tipFirst); | |
| 3032 | - return; | |
| 3033 | - } | |
| 3034 | - } | |
| 3035 | 3032 | if (currentIndex === undefined) { |
| 3036 | 3033 | currentPosition = 1; |
| 3037 | - if (handleType === 'next') { | |
| 3038 | - currentPosition = pages.total; | |
| 3039 | - } | |
| 3040 | 3034 | } |
| 3041 | - if (handleType === 'first') { | |
| 3035 | + if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加,就跳到第一条去 | |
| 3042 | 3036 | currentPosition = 1; |
| 3043 | - } else if (handleType === 'end') { | |
| 3044 | - currentPosition = pages.total; | |
| 3045 | 3037 | } |
| 3038 | + let bExist = false; | |
| 3039 | + /* 如果sBillIdsArray已存在 则不请求 */ | |
| 3040 | + if(commonUtils.isNotEmptyArr(sBillIdsArray) && sBillIdsArray.length > 0) { | |
| 3041 | + const index = sBillIdsArray.indexOf(currentId); | |
| 3042 | + if(index > -1) { | |
| 3043 | + if ("next".includes(handleType)) { | |
| 3044 | + currentPosition = index + 1; | |
| 3045 | + if(currentPosition > sBillIdsArray.length - 1 ){ | |
| 3046 | + message.warn(tipLast); | |
| 3047 | + return ; | |
| 3048 | + } | |
| 3049 | + } else if ("up".includes(handleType)) { | |
| 3050 | + if(index === 0){ | |
| 3051 | + message.warn(tipFirst); | |
| 3052 | + return ; | |
| 3053 | + } | |
| 3054 | + currentPosition = index - 1; | |
| 3055 | + } else if ("first".includes(handleType)) { | |
| 3056 | + currentPosition = 0; | |
| 3057 | + } else if ("end".includes(handleType)) { | |
| 3058 | + currentPosition = sBillIdsArray.length - 1; | |
| 3059 | + } | |
| 3060 | + currentId = sBillIdsArray[currentPosition]; | |
| 3061 | + currentPosition = currentPosition + 1; | |
| 3062 | + bExist = true; | |
| 3063 | + } else { | |
| 3064 | + bExist = false; | |
| 3065 | + } | |
| 3066 | + } | |
| 3067 | + /* 如果是第一次请求 */ | |
| 3068 | + if(!bExist) { | |
| 3069 | + const bFromList = commonUtils.isEmptyObject(pages) ? true: false; | |
| 3070 | + if(bFromList) { | |
| 3071 | + if(handleType ==='next' || handleType ==='end') { | |
| 3072 | + message.warn(tipLast); | |
| 3073 | + return ; | |
| 3074 | + }else { | |
| 3075 | + message.warn(tipFirst); | |
| 3076 | + return ; | |
| 3077 | + } | |
| 3078 | + } | |
| 3079 | + const value = { | |
| 3080 | + sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total, | |
| 3081 | + sUpId: masterData?.sId, sParentModelId :sSrcModelsId, | |
| 3082 | + }; | |
| 3083 | + const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`; | |
| 3084 | + /* 接收返回值 */ | |
| 3085 | + const { data } = await commonServices.postValueService(token, value, url); | |
| 3086 | + /* 接收返回值 */ | |
| 3087 | + /* 成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示 */ | |
| 3088 | + if (data.code === 1) { | |
| 3089 | + /* 数据查询成功 */ | |
| 3090 | + const returnData = data.dataset.rows[0]; | |
| 3091 | + if(commonUtils.isNotEmptyObject(returnData) && (commonUtils.isEmpty(returnData?.sId) || | |
| 3092 | + returnData?.sId === "")) { | |
| 3093 | + message.error(noSearhData); | |
| 3094 | + return; | |
| 3095 | + } | |
| 3096 | + /* 拿到接口返回的sBillids */ | |
| 3097 | + console.log('returnData', returnData); | |
| 3098 | + const sBillIds = returnData?.sBillIds; | |
| 3099 | + if(commonUtils.isNotEmptyArr(sBillIds)) { | |
| 3100 | + sBillIdsArray = sBillIds; | |
| 3101 | + } | |
| 3102 | + currentId = returnData?.sId; | |
| 3103 | + currentPosition = returnData?.currentPosition; | |
| 3104 | + } else { /* 失败 */ | |
| 3105 | + this.props.getServiceError(data); | |
| 3106 | + return false; | |
| 3107 | + } | |
| 3046 | 3108 | |
| 3047 | - const value = { | |
| 3048 | - sClientType: '1', | |
| 3049 | - sFilterOrderBy, | |
| 3050 | - bFilter, | |
| 3051 | - sListFormmasterId, | |
| 3052 | - currentPosition, | |
| 3053 | - handleType, | |
| 3054 | - iCountSum: pages.total, | |
| 3055 | - }; | |
| 3056 | - const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`; | |
| 3057 | - /* 接收返回值 */ | |
| 3058 | - const { data } = await commonServices.postValueService(token, value, url); | |
| 3059 | - /* 接收返回值 */ | |
| 3060 | - /* 成功的话刷新页面(同步主表和从表数据),不成功就弹出错误提示 */ | |
| 3061 | - if (data.code === 1) { | |
| 3062 | - /* 数据查询成功 */ | |
| 3063 | - const returnData = data.dataset.rows[0]; | |
| 3064 | - this.props.onSaveState({ | |
| 3065 | - currentIndexFlag: true, | |
| 3066 | - currentPageNo: returnData.currentPosition, | |
| 3067 | - currentId: returnData.sId, | |
| 3068 | - searchUpDownData: {}, | |
| 3069 | - slaveSelectedRowKeys: [], | |
| 3070 | - }); | |
| 3071 | - this.handleGetTableData(); | |
| 3072 | - } else { /* 失败 */ | |
| 3073 | - this.props.getServiceError(data); | |
| 3074 | 3109 | } |
| 3110 | + this.props.onSaveState({ | |
| 3111 | + currentIndexFlag: true, | |
| 3112 | + currentPageNo: currentPosition, | |
| 3113 | + currentId, | |
| 3114 | + searchUpDownData: {}, | |
| 3115 | + slaveSelectedRowKeys: [], | |
| 3116 | + sBillIdsArray, | |
| 3117 | + }, () => this.handleGetTableData()); | |
| 3118 | + return true; | |
| 3075 | 3119 | }; |
| 3076 | 3120 | /* 切换作废状态 */ |
| 3077 | 3121 | handleOkChangeInvaild = async (props) => { | ... | ... |