解决表格页码tab切换bug

This commit is contained in:
red-deng-deng 2021-11-25 13:42:15 +08:00
parent b693366f8d
commit 70dd51d1cd
4 changed files with 35 additions and 13 deletions

View File

@ -28,6 +28,7 @@ export default class menu extends React.Component {
isShowPageBar:true, //是否显示页码 isShowPageBar:true, //是否显示页码
isMultiple: true, isMultiple: true,
isSwitch: true, isSwitch: true,
page:'',
headBackgroud: "", headBackgroud: "",
spliteColor: "#f9fafc", spliteColor: "#f9fafc",
countbarVisible:true, countbarVisible:true,
@ -255,10 +256,8 @@ export default class menu extends React.Component {
} }
componentWillReceiveProps(nextProps) { componentWillReceiveProps(nextProps) {
this.setState({tableData: nextProps.tableData}); this.setState({tableData: nextProps.tableData});
this.setState({page: nextProps.page});
this.setState( {dataCount:nextProps.dataCount}) this.setState( {dataCount:nextProps.dataCount})
} }
@ -302,6 +301,9 @@ export default class menu extends React.Component {
this.setState({pageLoading:false}) this.setState({pageLoading:false})
},500) },500)
} }
pageShow(e){
console.log('page',e);
}
gridEditChange(e){ gridEditChange(e){
} }
@ -567,6 +569,8 @@ export default class menu extends React.Component {
this.props.pageChange(e); this.props.pageChange(e);
} }
} }
page={this.props.page}
pageFn={(e)=>this.setState({page:e})}
onNextClick = { onNextClick = {
(e) => { (e) => {
console.log("下一页页码",e) console.log("下一页页码",e)

View File

@ -10,13 +10,14 @@ import _ from "lodash";
super(props); super(props);
this.state = { this.state = {
count:10, count:10,
page:1, //当前页 page:props.page|1, //当前页
visible:false, visible:false,
jump_page:"", jump_page:"",
page_num:"", page_num:"",
dataCount:this.props.data dataCount:this.props.data
} }
} }
getPageArr(pages, current, viewsize){ getPageArr(pages, current, viewsize){
@ -89,6 +90,7 @@ import _ from "lodash";
} }
this.setState({page:e}) this.setState({page:e})
this.props.pageFn(e);
this.props.onJumpPage(e) this.props.onJumpPage(e)
} }
onInputChange(e,page_num){ onInputChange(e,page_num){
@ -131,6 +133,12 @@ import _ from "lodash";
} }
this.setState({ visible: false }) this.setState({ visible: false })
} }
componentWillMount(){
}
componentWillReceiveProps(nextProps) {
this.setState({page: nextProps.page});
}
render() { render() {
const { data} = this.props; const { data} = this.props;
let page_num =Math.ceil( data.count / this.state.count); let page_num =Math.ceil( data.count / this.state.count);

View File

@ -171,7 +171,11 @@ export default class acclist extends React.Component{
} }
tabFn(index){ tabFn(index){
this.setState({tabIndex:index}) this.setState({tabIndex:index})
this.getCodeListFn({},index); this.setState({page:1})
setTimeout(() => {
this.getCodeListFn({},index);
}, 10);
} }
//page //page
pageChange(e){ pageChange(e){
@ -344,10 +348,10 @@ componentDidUpdate(prevProps,prevState){
maxheight={this.state.tableHeight} maxheight={this.state.tableHeight}
countbarVisible={false} countbarVisible={false}
isSwitch={false} isSwitch={false}
page={this.state.page}
dataCount={this.state.total} dataCount={this.state.total}
isMultiple={false} isMultiple={false}
pageChange={(e)=>{ pageChange={(e)=>{
this.pageChange(e) this.pageChange(e)
}} }}
countChange={ countChange={

View File

@ -135,7 +135,9 @@ export default class edittemplate extends React.Component{
putMyTheme(this.state.model.id,formdata).then((res)=>{ putMyTheme(this.state.model.id,formdata).then((res)=>{
handelResponse(res,(req,msg)=>{ handelResponse(res,(req,msg)=>{
Notify.success("保存成功") Notify.success("保存成功")
},(err)=>{ },(err)=>{
Notify.error(err) Notify.error(err)
}) })
@ -150,7 +152,11 @@ export default class edittemplate extends React.Component{
addTheme(formdata).then((res)=>{ addTheme(formdata).then((res)=>{
handelResponse(res,(req,msg)=>{ handelResponse(res,(req,msg)=>{
Notify.success("保存成功") Notify.success("保存213213成功")
setTimeout(() => {
let link = window.location.href.replace(window.location.hash,"#/home/myexchangetemplate");
window.open(link, "_blank")
}, 2000);
},(err)=>{ },(err)=>{
Notify.error(err) Notify.error(err)