import React from 'react'; import './index.scss'; import Input from '../../libs/Input'; // import Button from '../../libs/Button'; import { Button } from 'antd'; // import Default from '../../assets/scale_default.png' class QuestionnairContent extends React.PureComponent { state = { questionnairSign: false, questionnairTitle: '', questionnairDescription: '' }; componentDidMount() { const { title, content } = this.props.initData; console.log(title); this.setState({ questionnairTitle: title, questionnairDescription: content }); } //新增题目时内容页滚动到底部 componentDidUpdate() { if (this.scrollBottom) { const scrollHeight = this.content.scrollHeight; this.page.scrollTo(0, scrollHeight); } if (this.scrollTo) { this.page.scrollTo(0, this.scrollTo); } } componentWillReceiveProps(nextProps) { if (nextProps.isFirst) { this.scrollBottom = true; } else { this.scrollBottom = false; } if (nextProps.scrollTo !== this.props.scrollTo) { this.scrollTo = nextProps.scrollTo; } else { this.scrollTo = false; } this.setState({ questionnairSign: nextProps.questionnairSign // questionnairTitle: nextProps.questionnairTitle, // questionnairDescription: nextProps.questionnairDescription }); } handleSign = () => { const { onChangeSign } = this.props; this.setState( prevState => ({ questionnairSign: !prevState.questionnairSign }), () => { onChangeSign(this.state.questionnairSign); } ); }; handleChange = (e, key) => { this.setState({ [key]: e.target.value }); }; handleBlur = () => { // const { onBlurTitle } = this.props; // if (onBlurTitle) { // onBlurTitle(this.state.questionnairTitle); // } }; render() { const { questionnairSign, questionnairTitle, questionnairDescription } = this.state; const { submitQuestionTemp, editors, btnLoading } = this.props; const questionnairtitleEl = (
* { this.handleChange(e, 'questionnairTitle'); }} onBlur={this.handleBlur} style={{ height: 45, borderColor: 'transparent', textAlign: 'center', fontSize: 18, color: '#666', fontFamily: 'PingFangSC-Medium' }} className="title-input" />
); const questionnairDescriptionEl = (
{ this.handleChange(e, 'questionnairDescription'); }} onBlur={this.handleBlur} style={{ height: 25, borderColor: 'transparent', textAlign: 'left', fontSize: 16, color: '#666', fontFamily: 'PingFangSC-Medium' }} className="title-input" />
); return (
(this.page = el)}>
{/*
{questionnairSign ? '取消标记' : '标记'}
*/}
{questionnairtitleEl} {questionnairDescriptionEl}
(this.content = el)} > {/*如果组件没有子节点,this.props.children返回false*/} {this.props.children || (
{/* */}
您还没有添加题目哦,请点击左侧控件开始出题吧
)}
{this.props.children && (
)}
); } } export default QuestionnairContent;