From d4ffbc52fcf22e57f7f070920dac75d38d8b145e Mon Sep 17 00:00:00 2001 From: hjm <63528605@qq.com> Date: Wed, 3 Jul 2019 15:25:58 +0800 Subject: [PATCH] 23 --- .../modules/tpm/challengesnew/TPMMDEditor.js | 7 +++++++ .../modules/tpm/challengesnew/TPManswer2.js | 18 +++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js index 46f3a4128..445d7b759 100644 --- a/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js +++ b/public/react/src/modules/tpm/challengesnew/TPMMDEditor.js @@ -209,6 +209,13 @@ export default class TPMMDEditor extends Component { initValue: '' } } + componentDidUpdate(prevProps, prevState) { + // 不能加,影响了试卷填空题 + // if (this.props.initValue != prevProps.initValue) { + // this.answers_editormd.setValue(this.props.initValue) + // } + } + // react_mdEditor_ componentDidMount = () => { const { mdID, initValue, placeholder, showNullButton} = this.props; diff --git a/public/react/src/modules/tpm/challengesnew/TPManswer2.js b/public/react/src/modules/tpm/challengesnew/TPManswer2.js index f379ccf53..67b0e7fe9 100644 --- a/public/react/src/modules/tpm/challengesnew/TPManswer2.js +++ b/public/react/src/modules/tpm/challengesnew/TPManswer2.js @@ -194,6 +194,17 @@ export default class TPManswer extends Component { newAnswers[index] = newAnswer this.setState({ answers: newAnswers}) } + answerOnChange = (val, index) => { + // if (!this.state.answers[index]) { + // // 1、2、3删除2会走到这里 + // return; + // } + const newAnswer = Object.assign({}, this.state.answers[index]) + newAnswer.contents = val + const newAnswers = this.state.answers.slice(0) + newAnswers[index] = newAnswer + this.setState({ answers: newAnswers}) + } addAnswer = () => { const newAnswers = this.state.answers.slice(0) newAnswers.push({ @@ -210,6 +221,10 @@ export default class TPManswer extends Component { newanswers.splice(index,1) this.setState({ answers:newanswers + }, () => { + for(let i = index; i < newanswers.length; i ++) { + this.refs[`md${i}`].setValue(newanswers[i].contents) + } }) } render() { @@ -316,7 +331,8 @@ export default class TPManswer extends Component {
参考答案: - + this.answerOnChange(val, index)}>