diff --git a/src/components/gird/main.js b/src/components/gird/main.js index 92c6468a..7e5875a9 100644 --- a/src/components/gird/main.js +++ b/src/components/gird/main.js @@ -199,6 +199,15 @@ export default class menu extends React.Component { this.setState({ tableData: tabledata }) } + gridPageLoads() { + let clr = null + if (clr) clearTimeout(clr) + this.setState({ pageLoading: true }) + clr = setTimeout(() => { + this.setState({ pageLoading: false }) + }, 800) + } + checkChange(index, e) { this.state.tableData[index].checked = e.target.checked this.setState({ @@ -264,11 +273,12 @@ export default class menu extends React.Component { componentWillReceiveProps(nextProps) { if (this.state.tableData != nextProps.tableData) { - this.setState({ tableData: nextProps.tableData ,pageLoading:false}) + this.setState({ tableData: nextProps.tableData }) this.setState({ page: nextProps.page }) this.setState({ page: nextProps.page, emptyText: nextProps.emptyText }) this.setState({ dataCount: nextProps.dataCount }) this.scrollPosition() + this.gridPageLoads() } } @@ -306,7 +316,7 @@ export default class menu extends React.Component { this.setState({ pageCount: e }) } gridPageLoad(flag) { - this.setState({ pageLoading: flag }) + this.setState({ pageLoading: flag }) } pageShow(e) {} gridEditChange(e) {} @@ -319,7 +329,6 @@ export default class menu extends React.Component { } rowItemClick(index) { console.log(index) - this.setState({ curIndex: index }) } diff --git a/src/pages/plan/keyList/index.jsx b/src/pages/plan/keyList/index.jsx index 3d0d7d62..0ad21d1e 100644 --- a/src/pages/plan/keyList/index.jsx +++ b/src/pages/plan/keyList/index.jsx @@ -1,4 +1,4 @@ -import React, { useRef,useEffect } from 'react' +import React, { useRef, useEffect } from 'react' import { useUpdateEffect, useSetState } from 'ahooks' import { getNowTime } from '@/utils.js' @@ -188,7 +188,7 @@ const UseKeyList = () => { * 获取表格 */ const getTable = () => { - plan_list_el.current.gridPageLoad(true); + plan_list_el.current.gridPageLoad(true) const param = getParam() getKeysList(param).then((res) => { handelResponse( @@ -213,12 +213,9 @@ const UseKeyList = () => { getTable() }, [state.isQuery]) - useEffect(()=>{ - plan_list_el.current.gridPageLoad(false); - return ()=>{//在函数组件卸载前执行 - - } - }, []); + useEffect(() => { + plan_list_el.current.gridPageLoad(false) + }, []) /** * 获取查询值 */ @@ -250,7 +247,8 @@ const UseKeyList = () => { limit: 10, hash: '', tableData: [], - lodgingTable: false + lodgingTable: false, + dataCount: 0 }) } @@ -259,7 +257,7 @@ const UseKeyList = () => { */ const clearSelectTableBtn = () => { plan_list_el.current.allChecked(false) - plan_list_el.current.gridPageLoad(false); + plan_list_el.current.gridPageLoad(false) setState({ selectTable: [] }) }