From 2a256ee057be91752278df0e622c4e6c4c5d89f6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Wed, 25 Dec 2019 15:53:56 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=A2=98=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/question/Questionitem_banks.js | 43 +++++++++++++++++-- .../question/component/Itembankstop.js | 36 +++++++++++++--- .../modules/question/component/Listjihe.js | 5 ++- 3 files changed, 73 insertions(+), 11 deletions(-) diff --git a/public/react/src/modules/question/Questionitem_banks.js b/public/react/src/modules/question/Questionitem_banks.js index 63ffa6095..c2c0d2a07 100644 --- a/public/react/src/modules/question/Questionitem_banks.js +++ b/public/react/src/modules/question/Questionitem_banks.js @@ -32,8 +32,8 @@ class Questionitem_banks extends Component { this.Choques= React.createRef(); this.Judquestio= React.createRef(); this.state = { - item_type:null - + item_type:null, + item_banksedit:[] } } @@ -60,6 +60,39 @@ class Questionitem_banks extends Component { // } // } // }); + const params= this.props&&this.props.match&&this.props.match.params; + if(JSON.stringify(params)==="{}"){ + //新增 + }else{ + //编辑 + + const url=`/item_banks/${this.props.match.params.id}/edit.json`; + axios.get((url)).then((response) => { + if(response===null||response===undefined){ + + return + } + if (response.data.status === 403||response.data.status === 401||response.data.status === 500) { + + }else{ + + } + ////console.log("item_banks"); + console.log("Questionitem_banks"); + console.log(response.data); + this.setState({ + item_banksedit:response.data, + }) + }).catch((error) => { + ////console.log(error) + + }); + + } + + + + } @@ -289,6 +322,8 @@ class Questionitem_banks extends Component { ////console.log("塞选的数据"); ////console.log(item_type); + const params= this.props&&this.props.match&&this.props.match.params; + // console.log(params); return (
- 试题库 - 新增试题 + 试题库 + {JSON.stringify(params)==="{}"?"新增":"编辑"}试题
diff --git a/public/react/src/modules/question/component/Itembankstop.js b/public/react/src/modules/question/component/Itembankstop.js index 6b0d59d29..f0400986a 100644 --- a/public/react/src/modules/question/component/Itembankstop.js +++ b/public/react/src/modules/question/component/Itembankstop.js @@ -59,6 +59,7 @@ class Itembankstop extends Component { this.state = { page:1, Knowpoints:[], + rbtx:"", } } //初始化 @@ -79,8 +80,23 @@ class Itembankstop extends Component { // } // }).catch((error) => { // //console.log(error) - // }); + // });() + // 题型 + + + + } + componentDidUpdate(prevProps) { + console.log("componentDidUpdate"); + console.log(prevProps); + console.log(this.props.item_banksedit); + + if(prevProps.item_banksedit !== this.props.item_banksedit){ + debugger + this.handleFormtixing(this.props.item_banksedit.item_type); + this.handleFormLayoutChange(this.props.item_banksedit.difficulty); + } } onChange=(e)=> { //console.log(`checked = ${e.target.checked}`); @@ -122,6 +138,9 @@ class Itembankstop extends Component { this.props.form.setFieldsValue({ rbnd:value, }); + this.setState({ + rbnd:value, + }) } handleFormkechen=(value)=>{ @@ -148,11 +167,14 @@ class Itembankstop extends Component { handleFormtixing=(value)=>{ //题型 - //console.log("题型"); - //console.log(value); + console.log("题型"); + console.log(value); this.props.form.setFieldsValue({ rbtx:value, }); + this.setState({ + rbtx:value, + }) this.props.setitem_type(value); } preventDefault=(e)=> { @@ -188,7 +210,8 @@ class Itembankstop extends Component { render() { let {page}=this.state; const { getFieldDecorator } = this.props.form; - + console.log("renderrenderrender"); + console.log(this.props.item_banksedit); return (
@@ -234,6 +257,7 @@ class Itembankstop extends Component { @@ -286,7 +310,7 @@ class Itembankstop extends Component { } )( - @@ -357,7 +381,7 @@ class Itembankstop extends Component { } )( - + 简单 适中 困难 diff --git a/public/react/src/modules/question/component/Listjihe.js b/public/react/src/modules/question/component/Listjihe.js index bf734db1e..0352b3194 100644 --- a/public/react/src/modules/question/component/Listjihe.js +++ b/public/react/src/modules/question/component/Listjihe.js @@ -45,6 +45,7 @@ class Listjihe extends Component { } + render() { let {page,name,nd,chakanjiexibool}=this.state; let {defaultActiveKey,items}=this.props; @@ -112,10 +113,12 @@ class Listjihe extends Component { 删除

-

+ +

编辑

+

this.props.showmodels(items.id)}> 公开