Commit c5a43a950d7490e3b1a3276d560cd24a765ae9ce

Authored by zhangzzzz
1 parent a79b625f

上一页下一页数据请求期间新增loading;

src/components/Common/CommonBase.js
... ... @@ -4,7 +4,7 @@
4 4 * Created by mar105 on 2019-02-15.
5 5 */
6 6  
7   -import React, { Component } from 'react';
  7 +import React, { Component, useEffect } from 'react';
8 8 import { message } from '@/utils/common/message';
9 9 import moment from 'moment';
10 10 import lodash from 'lodash';
... ... @@ -592,6 +592,9 @@ export default (ChildComponent) => {
592 592  
593 593 /** 获取sql下拉数据 */
594 594 getServiceError = async (returnData) => {
  595 + if (this.state.loading) {
  596 + this.handleSaveState({ loading: false });
  597 + }
595 598 if (location.pathname.indexOf('/indexOee/') > -1) {
596 599 this.props.dispatch({ type: 'app/throwErrorOee', payload: returnData });
597 600 } else {
... ... @@ -3458,8 +3461,28 @@ export default (ChildComponent) => {
3458 3461 onExecInstructSet={this.handleExecInstructSet} // 调用指令集
3459 3462 showCacheData={this.showCacheData}
3460 3463 />
  3464 + <div style={{ display: 'none' }} >
  3465 + <CommonChangePageEvent {...this.props} {...this.state} onSaveState={this.handleSaveState}/>
  3466 + </div>
3461 3467 </div>
3462 3468 );
3463 3469 }
3464 3470 };
3465 3471 };
  3472 +
  3473 +const CommonChangePageEvent = (props) => {
  3474 +
  3475 + const { currentPageNo, currentId, masterData = {}, loading } = props;
  3476 + const { sId } = masterData;
  3477 +
  3478 + // 上一页下一页loading加载完成后,取消loading
  3479 + useEffect(() => {
  3480 + if (loading && currentPageNo && currentId && sId) {
  3481 + if (currentId === sId) {
  3482 + props.onSaveState({ loading: false });
  3483 + }
  3484 + }
  3485 + }, [currentPageNo, sId]);
  3486 +
  3487 + return null;
  3488 +}
... ...
src/components/Common/CommonBillDeliverEvent.js
... ... @@ -2108,7 +2108,7 @@ export default (ChildComponent) =&gt; {
2108 2108 if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加,就跳到第一条去
2109 2109 currentPosition = 1;
2110 2110 }
2111   -
  2111 + this.props.onSaveState({ loading: true });
2112 2112 const value = {
2113 2113 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
2114 2114 };
... ...
src/components/Common/CommonBillEvent.js
... ... @@ -2903,6 +2903,7 @@ export default (ChildComponent) =&gt; {
2903 2903 return ;
2904 2904 }
2905 2905 }
  2906 + this.props.onSaveState({ loading: true });
2906 2907 const value = {
2907 2908 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total,
2908 2909 sUpId: masterData?.sId, sParentModelId :sSrcModelsId,
... ... @@ -2937,6 +2938,7 @@ export default (ChildComponent) =&gt; {
2937 2938 searchUpDownData: {},
2938 2939 slaveSelectedRowKeys: [],
2939 2940 sBillIdsArray,
  2941 + loading: true,
2940 2942 }, () => this.handleGetData(masterConfig, slaveConfig, checkConfig));
2941 2943 return true;
2942 2944 };
... ...
src/components/Common/CommonCheckBillEvent.js
... ... @@ -2367,6 +2367,7 @@ export default (ChildComponent) =&gt; {
2367 2367 const value = {
2368 2368 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
2369 2369 };
  2370 + this.props.onSaveState({ loading: true });
2370 2371 const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
2371 2372 /* 接收返回值 */
2372 2373 const { data } = await commonServices.postValueService(token, value, url);
... ...
src/components/Common/CommonElementEvent.js
... ... @@ -3081,6 +3081,7 @@ export default (ChildComponent) =&gt; {
3081 3081 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages?.total,
3082 3082 sUpId: masterData?.sId, sParentModelId :sSrcModelsId,
3083 3083 };
  3084 + this.props.onSaveState({ loading: true });
3084 3085 const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
3085 3086 /* 接收返回值 */
3086 3087 const { data } = await commonServices.postValueService(token, value, url);
... ... @@ -3115,6 +3116,7 @@ export default (ChildComponent) =&gt; {
3115 3116 searchUpDownData: {},
3116 3117 slaveSelectedRowKeys: [],
3117 3118 sBillIdsArray,
  3119 + loading: true,
3118 3120 }, () => this.handleGetTableData());
3119 3121 return true;
3120 3122 };
... ...
src/components/Common/CommonGroupBillEvent.js
... ... @@ -1742,6 +1742,7 @@ export default (ChildComponent) =&gt; {
1742 1742 const value = {
1743 1743 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
1744 1744 };
  1745 + this.props.onSaveState({ loading: true });
1745 1746 const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
1746 1747 /* 接收返回值 */
1747 1748 const { data } = await commonServices.postValueService(token, value, url);
... ...
src/components/Common/CommonNewBillEvent.js
... ... @@ -2265,6 +2265,7 @@ export default ChildComponent =&gt; {
2265 2265 sUpId: masterData?.sId,
2266 2266 sParentModelId: sSrcModelsId,
2267 2267 };
  2268 + this.props.onSaveState({ loading: true });
2268 2269 const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
2269 2270 /* 接收返回值 */
2270 2271 const { data } = await commonServices.postValueService(token, value, url);
... ... @@ -2296,6 +2297,7 @@ export default ChildComponent =&gt; {
2296 2297 searchUpDownData: {},
2297 2298 slaveSelectedRowKeys: [],
2298 2299 sBillIdsArray,
  2300 + loading: true
2299 2301 },
2300 2302 () => {
2301 2303 this.handleGetData(masterConfig, slaveConfig, slave0Config, slave1Config, slave2Config, slave3Config, slave4Config);
... ...
src/components/Common/CommonNewTabBillEvent.js
... ... @@ -2261,7 +2261,7 @@ export default (ChildComponent) =&gt; {
2261 2261 if (!commonUtils.isNum(currentPosition)) { // 如果是列表直接点增加,就跳到第一条去
2262 2262 currentPosition = 1;
2263 2263 }
2264   -
  2264 + this.props.onSaveState({ loading: true });
2265 2265 const value = {
2266 2266 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
2267 2267 };
... ...
src/components/Common/CommonSubBillEvent.js
... ... @@ -2882,6 +2882,7 @@ export default (ChildComponent) =&gt; {
2882 2882 sClientType: '1', sFilterOrderBy, bFilter, sListFormmasterId, currentPosition, handleType, iCountSum: pages.total,
2883 2883 sUpId: masterData?.sId, sParentModelId :sSrcModelsId,
2884 2884 };
  2885 + this.props.onSaveState({ loading: true });
2885 2886 const url = `${commonConfig.server_host}business/getBusinessDataByIndex?sModelsId=${sModelsId}`;
2886 2887 /* 接收返回值 */
2887 2888 const { data } = await commonServices.postValueService(token, value, url);
... ... @@ -2912,6 +2913,7 @@ export default (ChildComponent) =&gt; {
2912 2913 searchUpDownData: {},
2913 2914 slaveSelectedRowKeys: [],
2914 2915 sBillIdsArray,
  2916 + loading: true,
2915 2917 },
2916 2918 () => {
2917 2919 this.handleGetData(masterConfig, slaveConfig, checkConfig);
... ...