From abee25b58b44df1e3976bb45736c9f5835803666 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 16:39:28 +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 --- .../question/component/ChoquesEditor.js | 72 +++++-------------- .../question/component/JudquestionEditor.js | 33 +-------- .../question/component/SingleEditor.js | 37 +++++----- 3 files changed, 37 insertions(+), 105 deletions(-) diff --git a/public/react/src/modules/question/component/ChoquesEditor.js b/public/react/src/modules/question/component/ChoquesEditor.js index ef1a07d9b..36ef4c61f 100644 --- a/public/react/src/modules/question/component/ChoquesEditor.js +++ b/public/react/src/modules/question/component/ChoquesEditor.js @@ -236,24 +236,23 @@ class ChoquesEditor extends Component{ texts=""; } } else { - // if(_text.length>=500){ - // var result = _text.substring(0,450); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else { - // // 提交到后台的内容需要处理一下; - // value = JSON.stringify(value); - // if(value.length>=500){ - // let a=value.length-500; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } - texts = JSON.stringify(value); + if(_text.length>=500){ + var result = _text.substring(0,450); + texts={"ops":[{"insert":result}]}; + texts=JSON.stringify(texts); + }else { + // 提交到后台的内容需要处理一下; + value = JSON.stringify(value); + if(value.length>=500){ + let a=value.length-500; + let b=_text.length-a; + var result = _text.substring(0,b); + texts={"ops":[{"insert":result}]}; + texts=JSON.stringify(texts); + }else{ + texts=value; + } + } } let question_choices = this.state.question_choices.slice(0); question_choices[index] = texts; @@ -295,24 +294,6 @@ class ChoquesEditor extends Component{ } else { // 提交到后台的内容需要处理一下; let texts=""; - // if(_text.length>=979){ - // var result = _text.substring(0,975); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // console.log("111111111"); - // console.log(texts.length); - // }else { - // value = JSON.stringify(value); - // if(value.length>=1000){ - // let a=value.length-1000; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } texts = JSON.stringify(value); this.setState({ question_titleysl:texts @@ -336,24 +317,7 @@ class ChoquesEditor extends Component{ } else { // 提交到后台的内容需要处理一下; let texts=""; - // if(_text.length>=979){ - // var result = _text.substring(0,975); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // console.log("2222222"); - // console.log(texts.length); - // }else { - // value = JSON.stringify(value); - // if(value.length>=1000){ - // let a=value.length-1000; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } + 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 b628d1012..09cf1094f 100644 --- a/public/react/src/modules/question/component/JudquestionEditor.js +++ b/public/react/src/modules/question/component/JudquestionEditor.js @@ -314,22 +314,6 @@ class JudquestionEditor extends Component{ // 提交到后台的内容需要处理一下; let texts=""; - // if(_text.length>=979){ - // var result = _text.substring(0,975); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else { - // value = JSON.stringify(value); - // if(value.length>=1000){ - // let a=value.length-1000; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } texts = JSON.stringify(value); this.setState({ question_titleysl:texts @@ -354,22 +338,7 @@ class JudquestionEditor extends Component{ } else { // 提交到后台的内容需要处理一下; let texts=""; - // if(_text.length>=979){ - // var result = _text.substring(0,975); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else { - // value = JSON.stringify(value); - // if(value.length>=1000){ - // let a=value.length-1000; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } + texts = JSON.stringify(value); this.setState({ question_titlesysl:texts diff --git a/public/react/src/modules/question/component/SingleEditor.js b/public/react/src/modules/question/component/SingleEditor.js index 50681c576..c1255c83a 100644 --- a/public/react/src/modules/question/component/SingleEditor.js +++ b/public/react/src/modules/question/component/SingleEditor.js @@ -258,26 +258,24 @@ class SingleEditor extends Component{ texts=""; } } else { - // if(_text.length>=500){ - // var result = _text.substring(0,450); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else { - // // 提交到后台的内容需要处理一下; - // - // if(value.length>=500){ - // let a=value.length-500; - // let b=_text.length-a; - // var result = _text.substring(0,b); - // texts={"ops":[{"insert":result}]}; - // texts=JSON.stringify(texts); - // }else{ - // texts=value; - // } - // } - texts = JSON.stringify(value); + if(_text.length>=500){ + var result = _text.substring(0,450); + texts={"ops":[{"insert":result}]}; + texts=JSON.stringify(texts); + }else { + // 提交到后台的内容需要处理一下; + value = JSON.stringify(value); + if(value.length>=500){ + let a=value.length-500; + let b=_text.length-a; + var result = _text.substring(0,b); + texts={"ops":[{"insert":result}]}; + texts=JSON.stringify(texts); + }else{ + texts=value; + } + } } - let question_choices = this.state.question_choices.slice(0); question_choices[index] = texts; this.setState({ question_choices }); @@ -336,6 +334,7 @@ class SingleEditor extends Component{ }) } } else { + let texts = JSON.stringify(value); this.setState({ question_titlesysl:texts