From fa301bf59537cdf9db4c94b9c58592416e8f5310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=98=8E?= <775174143@qq.com> Date: Thu, 5 Sep 2019 19:00:20 +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 --- public/react/config/webpack.config.dev.js | 2 +- .../courses/coursesPublic/AppraiseModal.js | 23 ++++++++---- .../shixunHomework/ShixunWorkReport.js | 37 +++++++++++++++---- .../src/modules/modals/WordNumberTextarea.js | 2 +- 4 files changed, 47 insertions(+), 17 deletions(-) diff --git a/public/react/config/webpack.config.dev.js b/public/react/config/webpack.config.dev.js index 1adf3aef9..de3bffa48 100644 --- a/public/react/config/webpack.config.dev.js +++ b/public/react/config/webpack.config.dev.js @@ -32,7 +32,7 @@ module.exports = { // See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.s // devtool: "cheap-module-eval-source-map", // 开启调试 - // devtool: "source-map", // 开启调试 + devtool: "source-map", // 开启调试 // These are the "entry points" to our application. // This means they will be the "root" imports that are included in JS bundle. // The first two entry points enable "hot" CSS and auto-refreshes for JS. diff --git a/public/react/src/modules/courses/coursesPublic/AppraiseModal.js b/public/react/src/modules/courses/coursesPublic/AppraiseModal.js index 63d854ad6..14f29acbe 100644 --- a/public/react/src/modules/courses/coursesPublic/AppraiseModal.js +++ b/public/react/src/modules/courses/coursesPublic/AppraiseModal.js @@ -11,11 +11,20 @@ class AppraiseModal extends Component{ fileList:[], textareaval:undefined, Inputsval:undefined, - valuetype:1, + valuetype:0, textareavaltype:false } } + componentDidMount() { + + this.setState({ + valuetype:this.props.work_type===undefined?0:this.props.work_type, + textareaval:this.props.work_comment, + }) + + } + onChanges=(e)=>{ this.setState({ valuetype:e.target.value @@ -30,7 +39,6 @@ class AppraiseModal extends Component{ Saves=()=>{ let{textareaval,valuetype}=this.state; - let newvaluetype=valuetype===1?false:true; if(textareaval===undefined||textareaval===null||textareaval===""){ this.setState({ @@ -42,11 +50,11 @@ class AppraiseModal extends Component{ let url=`/student_works/${this.props.match.params.homeworkid}/shixun_work_comment.json` axios.post(url, { comment:textareaval, - is_hidden:newvaluetype + is_hidden:valuetype }).then((response) => { if(response.data.status===0){ this.props.showNotification(response.data.message) - this.props.Cancel() + this.props.showCancel(textareaval,valuetype) }else{ this.props.showNotification(response.data.message) } @@ -62,6 +70,7 @@ class AppraiseModal extends Component{ height: '30px', lineHeight: '30px', }; + return(
- 可见 (学生查看老师的评阅内容) - 不可见 (仅对课堂老师可见) + 可见 (学生查看老师的评阅内容) + 不可见 (仅对课堂老师可见)

@@ -125,7 +134,7 @@ class AppraiseModal extends Component{

- {this.props.Cancelname || '取消'} + this.props.Cancel()}>{this.props.Cancelname || '取消'} {this.props.Savesname || '确定'}
diff --git a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js index 87f4f9555..309a0b755 100644 --- a/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js +++ b/public/react/src/modules/courses/shixunHomework/ShixunWorkReport.js @@ -32,7 +32,9 @@ class ShixunWorkReport extends Component { DownloadMessageval:undefined, isspinning:false, showAppraiseModaltype:false, - work_comment_hidden:false + work_comment_hidden:false, + showAppraiseModalsshow:true, + work_comment:null } } @@ -104,6 +106,7 @@ class ShixunWorkReport extends Component { this.setState({ data:result.data, work_comment_hidden:result.data.work_comment_hidden, + work_comment:result.data.work_comment, spinning:false }) } @@ -151,25 +154,40 @@ class ShixunWorkReport extends Component { } showAppraiseModal=()=>{ + debugger this.setState({ showAppraiseModaltype:true }) } hideAppraiseModal=()=>{ - let{data}=this.state; + let{data,work_comment}=this.state; this.setState({ showAppraiseModaltype:false, - work_comment_hidden:data&&data.work_comment_hidden===true?true:data&&data.work_description!=null?true:false, + work_comment_hidden:data&&data.work_comment_hidden===true?true:work_comment!=null?true:false, + }) + } + showAppraiseModals=(list,type)=>{ + let{data,work_comment}=this.state; + this.setState({ + showAppraiseModaltype:false, + work_comment_hidden:data&&data.work_comment_hidden===true?true:work_comment!=null?true:false, + work_comment:list, + work_type:type, + showAppraiseModals:true, + showAppraiseModalsshow:true }) } - isdeleteModal=()=>{ let url =`/student_works/${this.props.match.params.homeworkid}/destroy_work_comment.json` axios.delete(url).then((response) => { // const { status } = response.data; if(response.data.status===0){ this.props.showNotification(response.data.message) + this.setState({ + showAppraiseModalsshow:false, + work_comment_hidden:false + }) }else{ this.props.showNotification(response.data.message) } @@ -179,14 +197,14 @@ class ShixunWorkReport extends Component { }); } render() { - let{data,showAppraiseModaltype,work_comment_hidden} =this.state; + let{data,showAppraiseModaltype,work_comment_hidden,showAppraiseModalsshow,work_comment} =this.state; let category_id=data===undefined?"":data.category===null?"":data.category.category_id; let homework_common_id=data===undefined?"":data.homework_common_id; let homeworkid=this.props.match.params.homeworkid; const antIcon = ; - let showAppraiseModals=this.props&&this.props.isAdminOrTeacher()===true?work_comment_hidden===true?true:false:data&&data.work_description===null?false:true; + let showAppraiseModals=this.props&&this.props.isAdminOrTeacher()===true?work_comment_hidden===true?true:false:work_comment===null?false:true; return ( @@ -197,6 +215,9 @@ class ShixunWorkReport extends Component { {...this.state} visible={showAppraiseModaltype} Cancel={()=>this.hideAppraiseModal()} + showCancel={(list,type)=>this.showAppraiseModals(list,type)} + work_comment={this.state.work_comment} + work_type={this.state.work_type} />:""}
@@ -395,7 +416,7 @@ class ShixunWorkReport extends Component {
- {showAppraiseModals===true?
+ {showAppraiseModals===true&&showAppraiseModalsshow===true?
@@ -415,7 +436,7 @@ class ShixunWorkReport extends Component {
+ dangerouslySetInnerHTML={{__html: markdownToHTML(work_comment).replace(/▁/g, "▁▁▁")}}>
diff --git a/public/react/src/modules/modals/WordNumberTextarea.js b/public/react/src/modules/modals/WordNumberTextarea.js index 52711de2c..f93dff978 100644 --- a/public/react/src/modules/modals/WordNumberTextarea.js +++ b/public/react/src/modules/modals/WordNumberTextarea.js @@ -14,7 +14,7 @@ render() { onInput={(e)=>this.props.onInput(e)} maxlength={this.props.maxlength} /> -
{this.props.value===undefined?0:this.props.value.length}/{this.props.maxlength}
+
{this.props.value===undefined||this.props.value===null?0:this.props.value.length}/{this.props.maxlength}
) }