From 9c1df0debff737505ff8c3f0fb6c43903c5cf7de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Tue, 18 Feb 2020 17:59:54 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/modules/testpaper/Testpaperlibrary.js | 25 ++++++++----- .../testpaper/component/Contentpart.js | 37 ++++++++++++------- 2 files changed, 39 insertions(+), 23 deletions(-) diff --git a/public/react/src/modules/testpaper/Testpaperlibrary.js b/public/react/src/modules/testpaper/Testpaperlibrary.js index e58cfb3e8..45b08cd80 100644 --- a/public/react/src/modules/testpaper/Testpaperlibrary.js +++ b/public/react/src/modules/testpaper/Testpaperlibrary.js @@ -33,6 +33,7 @@ class Testpaperlibrary extends Component { modalsType:false, timuid:0, modalsTypeInaudit:false, + defaultActiveKeybool:false, } } getContainer = () => { @@ -115,12 +116,21 @@ class Testpaperlibrary extends Component { } this.getdata(data); } - callback = (key) => { + callback = (key,bool) => { + try { + var currenturl = window.location.href; + var newUrl = (currenturl.split("?"))[0]; + window.history.pushState('','',newUrl+'?defaultActiveKey='+key); + }catch (e) { + + } + this.setState({ defaultActiveKey: key, - difficulty: null, - keyword: null, - page: 1, + difficulty:null, + keyword:null, + page:1, + defaultActiveKeybool:bool, }) var data = { page: 1, @@ -335,13 +345,8 @@ class Testpaperlibrary extends Component { }) }; -<<<<<<< HEAD - Testpapereditor = (id) => { - this.props.history.push(`/paperlibrary/edit/${id}`); -======= Testpapereditor=(id)=>{ this.props.history.push(`/paperlibrary/edit/${id}?defaultActiveKey=${this.state.defaultActiveKey}`); ->>>>>>> ae8378b... 调整 } @@ -475,7 +480,7 @@ class Testpaperlibrary extends Component { showmodels={(e)=>this.showmodels(e)} showmodelysl={(e)=>this.showmodelysl(e)} setdatafuns={(key)=>this.setdatafuns(key)} - callback={(key)=>this.callback(key)} + callback={(key,bool)=>this.callback(key,bool)} setdatafunsval={(key)=>this.setdatafunsval(key)} setdifficulty={(bool)=>this.setdifficulty(bool)} showmodelsInaudit={(e)=>this.showmodelsInaudit(e)} diff --git a/public/react/src/modules/testpaper/component/Contentpart.js b/public/react/src/modules/testpaper/component/Contentpart.js index ad65211a2..8a3d57414 100644 --- a/public/react/src/modules/testpaper/component/Contentpart.js +++ b/public/react/src/modules/testpaper/component/Contentpart.js @@ -64,24 +64,32 @@ class Contentpart extends Component { const is_teacher=this.props&&this.props.current_user&&this.props.current_user.is_teacher?this.props.current_user.is_teacher:false; const professional_certification=this.props&&this.props.current_user&&this.props.current_user.professional_certification?this.props.current_user.professional_certification:false; let {defaultActiveKey} = this.props; - var defaultActiveKeys=defaultActiveKey; + let defaultActiveKeys=defaultActiveKey; if(isysladmins===true||(is_teacher===true&&professional_certification===true)){ defaultActiveKeys="0" }else{ defaultActiveKeys="1" } - if (this.state.defaultActiveKeyss==="0"){ - defaultActiveKeys="0" - } else { - defaultActiveKeys="1" + try { + if(this.props.defaultActiveKeybool===false){ + if (this.state.defaultActiveKeyss==="0"){ + defaultActiveKeys="0" + } else { + defaultActiveKeys="1" + } + } + }catch (e) { + } - this.props.callback(defaultActiveKeys); + + + this.props.callback(defaultActiveKeys,false); } } render() { let {page,defaultActiveKeyss}=this.state; - let {defaultActiveKey}=this.props; + let {defaultActiveKey,defaultActiveKeybool}=this.props; let defaultActiveKeys=defaultActiveKey+''; const isysladmins=this.props&&this.props.current_user&&this.props.current_user.admin?this.props.current_user.admin:false; @@ -104,13 +112,16 @@ class Contentpart extends Component { ); - if(defaultActiveKeyss==="0"){ - defaultActiveKeys="0"; - }else { - defaultActiveKeys="1"; + if(defaultActiveKeybool===false){ + if(defaultActiveKeyss==="0"){ + defaultActiveKeys="0"; + }else { + defaultActiveKeys="1"; + } } + return (