From 17ef1d3a2af2425c6f73e2428384ffef63cdffb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=A0=91=E6=9E=97?= <904079904@qq.com> Date: Fri, 6 Mar 2020 21:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=98=E5=BA=93=E5=8F=AF?= =?UTF-8?q?=E4=BB=A5=E8=BE=93=E5=85=A5=E7=A9=BA=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/component/ChoquesEditor.js | 73 +++++-------------- .../question/component/JudquestionEditor.js | 60 +++++---------- .../question/component/SingleEditor.js | 64 ++++++---------- public/react/src/modules/tpm/NewHeader.js | 30 ++++---- 4 files changed, 78 insertions(+), 149 deletions(-) diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index 725817d17..d2a0b231b 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -229,22 +229,9 @@ class ChoquesEditor extends Component{ var texts; const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - - - - if(this.isNull(_text)===true){ - - return - } - if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - texts=JSON.stringify(value); - }catch (e) { texts=""; - } } else { if(_text.length>=500){ var result = _text.substring(0,450); @@ -298,66 +285,46 @@ class ChoquesEditor extends Component{ // debugger const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - if(this.isNull(_text)===true){ - this.setState({ - question_titleysl:"" - }) - return - } - - if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - this.setState({ - question_titleysl: JSON.stringify(value) - }) - }catch (e) { this.setState({ question_titleysl:"" }) - } } else { // 提交到后台的内容需要处理一下; - let texts=""; - texts = JSON.stringify(value); - this.setState({ - question_titleysl:texts - }) + try { + let texts = JSON.stringify(value); + this.setState({ + question_titleysl:texts + }) + }catch (e) { + this.setState({ + question_titleysl:"" + }) + } } } onContentChanges=(value,quill)=>{ const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - - if(this.isNull(_text)===true){ - this.setState({ - question_titlesysl:"" - }) - return - } - if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - this.setState({ - question_titlesysl: JSON.stringify(value) - }) - }catch (e) { this.setState({ question_titlesysl:"" }) - } } else { // 提交到后台的内容需要处理一下; - let texts=""; + try { + let texts = JSON.stringify(value); + this.setState({ + question_titlesysl:texts + }) + }catch (e) { + this.setState({ + question_titlesysl:"" + }) + } - texts = JSON.stringify(value); - this.setState({ - question_titlesysl:texts - }) } } diff --git a/public/react/src/modules/question/component/JudquestionEditor.js b/public/react/src/modules/question/component/JudquestionEditor.js index 603fbd6e7..868700c6b 100644 --- a/public/react/src/modules/question/component/JudquestionEditor.js +++ b/public/react/src/modules/question/component/JudquestionEditor.js @@ -303,72 +303,50 @@ class JudquestionEditor extends Component{ // console.log(quill); const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - // console.log(_text); - // console.log(_text.length); - if(this.isNull(_text)===true){ - this.setState({ - question_titleysl:"" - }) - return - } - if (!reg.test(_text)) { // 处理编辑器内容为空 - try { this.setState({ - question_titleysl:JSON.stringify(value) + question_titleysl:"" + }) + // console.log("空"); + } else { + // 提交到后台的内容需要处理一下; + try { + let texts = JSON.stringify(value); + this.setState({ + question_titleysl:texts }) }catch (e) { this.setState({ question_titleysl:"" }) } - - // console.log("空"); - } else { - // console.log("有"); - - // 提交到后台的内容需要处理一下; - let texts=""; - texts = JSON.stringify(value); - this.setState({ - question_titleysl:texts - }) } } onContentChanges=(value,quill)=>{ const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - if(this.isNull(_text)===true){ - this.setState({ - question_titlesysl:"" - }) - return - } if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - this.setState({ - question_titlesysl:JSON.stringify(value) - }) - }catch (e) { this.setState({ question_titlesysl:"" }) - } - } else { // 提交到后台的内容需要处理一下; - let texts=""; + try { - texts = JSON.stringify(value); - this.setState({ - question_titlesysl:texts - }) + let texts = JSON.stringify(value); + this.setState({ + question_titlesysl:texts + }) + }catch (e) { + this.setState({ + question_titlesysl:"" + }) + } } } render() { diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index 464eb19e0..fab9170b8 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -140,7 +140,13 @@ class SingleEditor extends Component{ // this.refs['titleEditor'].showError() this.props.showNotification('请您输入题干'); return editordata; + }else{ + console.log("question_titleysl"); + console.log(question_titleysl); } + + + for(let i = 0; i < question_choices.length; i++) { if (!question_choices[i]) { // this.refs[`optionEditor${i}`].showError() @@ -244,6 +250,7 @@ class SingleEditor extends Component{ this.setState({ standard_answers }) } onOptionContentChange = (value,quill,index) => { + debugger if (index >= this.state.question_choices.length) { // TODO 新建,然后删除CD选项,再输入题干,会调用到这里,且index是3 return; @@ -251,18 +258,9 @@ class SingleEditor extends Component{ var texts; const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - - if(this.isNull(_text)===true){ - return - } if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - texts= JSON.stringify(value) - }catch (e) { texts=""; - } } else { if(_text.length>=500){ var result = _text.substring(0,450); @@ -315,61 +313,47 @@ class SingleEditor extends Component{ const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - - if(this.isNull(_text)===true){ - this.setState({ - question_titleysl:"" - }) - return - } - - - if (!reg.test(_text)) { // 处理编辑器内容为空 - try { - this.setState({ - question_titleysl: JSON.stringify(value) - }) - }catch (e) { this.setState({ question_titleysl:"" }) - } } else { + try { let texts = JSON.stringify(value); - this.setState({ - question_titleysl:texts - }) + this.setState({ + question_titleysl:texts===undefined|| null?"":texts + }) + }catch (e) { + this.setState({ + question_titleysl:"" + }) + } } } onContentChanges=(value,quill)=>{ const _text = quill.getText(); const reg = /^[\s\S]*.*[^\s][\s\S]*$/; - if(this.isNull(_text)===true){ - this.setState({ - question_titlesysl:"" - }) - return - } + if (!reg.test(_text)) { // 处理编辑器内容为空 + this.setState({ + question_titlesysl:"" + }) + } else { try { + let texts = JSON.stringify(value); this.setState({ - question_titlesysl:JSON.stringify(value) + question_titlesysl:texts===undefined|| null?"":texts }) }catch (e) { this.setState({ question_titlesysl:"" }) } - } else { - let texts = JSON.stringify(value); - this.setState({ - question_titlesysl:texts - }) + } } handleShowImage = (url) => { diff --git a/public/react/src/modules/tpm/NewHeader.js b/public/react/src/modules/tpm/NewHeader.js index 8d3c85378..dccdbc5a7 100644 --- a/public/react/src/modules/tpm/NewHeader.js +++ b/public/react/src/modules/tpm/NewHeader.js @@ -1075,21 +1075,21 @@ submittojoinclass=(value)=>{ ` } - {/*{*/} - {/* Periofters===true?*/} - {/*
  • */} - {/* */} - {/*
    */} - {/*
    */} - {/* 题库*/} - {/*
    */} - {/*
    */} - {/*
    */} - {/*
  • */} - {/* :""*/} - {/*}*/} + { + Periofters===true? +
  • + +
    +
    + 题库 +
    +
    +
    +
  • + :"" + }