From a6428c0b532ba41ca6633fc9dfff11b4ceb03845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Mon, 16 Dec 2019 14:41:11 +0800 Subject: [PATCH 01/14] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../react/src/modules/courses/poll/PollNew.js | 58 ++++++++++++++----- 1 file changed, 44 insertions(+), 14 deletions(-) diff --git a/public/react/src/modules/courses/poll/PollNew.js b/public/react/src/modules/courses/poll/PollNew.js index 7384c7f6e..8740a9bbf 100644 --- a/public/react/src/modules/courses/poll/PollNew.js +++ b/public/react/src/modules/courses/poll/PollNew.js @@ -893,7 +893,6 @@ class PollNew extends Component { //保存并继续 //保存并继续,即提交本题的新建并继续创建一个相同的题(该新题处于编辑模式,题目和选项不要清空) Deleteadddomtwo = (indexo, object,bool) => { - debugger var thiss = this; @@ -1038,7 +1037,7 @@ class PollNew extends Component { if(object.question.max_choices){ if(object.question.max_choices>0){ if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); + this.props.showNotification(`可选的最大限制不能小于最小限制`); return; } } @@ -1258,7 +1257,7 @@ class PollNew extends Component { if(object.question.max_choices){ if(object.question.max_choices>0){ if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); + this.props.showNotification(`可选的最大限制不能小于最小限制`); return; } } @@ -1449,9 +1448,7 @@ class PollNew extends Component { // indexo 第几个数组 //object 单个数组数据 Deleteadddomthree = (indexo, object,bool) => { - this.setState({ - newoption: false, - }) + // console.log("deleteadddom 349") var thiss = this; let arr = this.state.adddom; @@ -1477,9 +1474,14 @@ class PollNew extends Component { } if (newarr[indexo].question.question_title === "") { this.props.showNotification('题目不能为空!'); + return + } + if (newarr[indexo].question.question_title.match(/^[ ]*$/)) { + this.props.showNotification('题目不能为空!'); return } + if (max > 0) { if (object.question.question_type === 1) { this.props.showNotification('选项内容不能为空!'); @@ -1579,7 +1581,7 @@ class PollNew extends Component { if(object.question.max_choices){ if(object.question.max_choices>0){ if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); + this.props.showNotification(`可选的最大限制不能小于最小限制`); return; } } @@ -1790,7 +1792,7 @@ class PollNew extends Component { if(object.question.max_choices){ if(object.question.max_choices>0){ if (object.question.max_choices < object.question.min_choices) { - this.props.showNotification(`可选:最小和最大限制须同时为数值或者“--"`); + this.props.showNotification(`可选的最大限制不能小于最小限制`); return; } } @@ -1867,7 +1869,6 @@ class PollNew extends Component { }; question = {"question": questiontwo}; //插入多选题 - if (uuk !== -1) { // console.log("修改") this.edittotheserver(object, 2, arrc, null, object.question.max_choices, object.question.min_choices,object.question.answers.length); @@ -2016,10 +2017,11 @@ class PollNew extends Component { if (result !== undefined) { if (result.data.status === 0) { this.props.showNotification(`已完成`); - thiss.thisinitializationdatanew(); this.setState({ Newdisplay:false, + newoption: false, + }) // console.log("确认创建问题") // console.log(result) @@ -2032,11 +2034,24 @@ class PollNew extends Component { // // } } + }else{ + this.setState({ + Newdisplay:true, + newoption: false, + + }) } // } catch (e) { // // } + }).catch((error) => { + console.log(error) + this.setState({ + Newdisplay:true, + newoption: false, + + }) }) @@ -2096,11 +2111,24 @@ class PollNew extends Component { if (result.data.status === 0) { this.props.showNotification(`编辑题目成功`); thiss.thisinitializationdatanew(); + this.setState({ + Newdisplay:false, + newoption: false, + }) } } catch (e) { // console.log("调用了edittotheserver") - console.log(e) + this.setState({ + Newdisplay:true, + newoption: false, + }) } + }).catch((error) => { + console.log(error) + this.setState({ + Newdisplay:true, + newoption: false, + }) }) } @@ -2685,7 +2713,8 @@ class PollNew extends Component { // console.log("2301"); // console.log(newr); // window.history.pushState('','',newUrl+'?tab='+e); - window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; + + // window.location.href = `/courses/${coursesId}/polls/${result.data.data.id}/edit`; }) } else { @@ -2773,6 +2802,7 @@ class PollNew extends Component { height: '30px', lineHeight: '30px', }; + const hejiine=this.state.mysingles + this.state.mydoubles + this.state.mymainsint; // console.log(this.state.projects===undefined?"":this.state.projects.poll_questions) var displaymysave = (mysave === true) ? "" : "display:none;"; @@ -2942,7 +2972,7 @@ class PollNew extends Component { { - this.state.mysingles + this.state.mydoubles + this.state.mymainsint === 0 ? "" : + hejiine=== 0 ? "" :