| | |
| | | onVisibleChange = (visible) => { |
| | | const { element } = this.props |
| | | let val = this.props.form.getFieldValue('content') |
| | | let _url = this.props.form.getFieldValue('url') |
| | | |
| | | this.setState({ |
| | | visible: visible |
| | | }) |
| | | |
| | | if (val && element.content !== val) { |
| | | this.props.updateContent({...element, content: val}) |
| | | if (element.eleType === 'link') { |
| | | if ((val && element.content !== val) || (_url && element.url !== _url)) { |
| | | this.props.updateContent({...element, content: val, url: _url}) |
| | | } else { |
| | | this.props.form.setFieldsValue({content: element.content, url: element.url}) |
| | | } |
| | | } else { |
| | | this.props.form.setFieldsValue({content: element.content}) |
| | | if (val && element.content !== val) { |
| | | this.props.updateContent({...element, content: val}) |
| | | } else { |
| | | this.props.form.setFieldsValue({content: element.content}) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | {deletable !== false ? <Icon type="delete" onClick={this.deleteElement} /> : null} |
| | | <Popover content={ |
| | | <div> |
| | | {element.eleType === 'img' ? <FileUpload value={images} maxFile={1} fileType="text" onChange={this.imgChange}/> : null} |
| | | {element.eleType === 'img' ? <FileUpload accept=".jpg,.png,.gif,.svg" value={images} maxFile={1} fileType="text" onChange={this.imgChange}/> : null} |
| | | {getFieldDecorator('content', { |
| | | initialValue: element.content |
| | | })(element.eleType !== 'textarea' ? |
| | | <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> : |
| | | <TextArea autosize={{ minRows: 2, maxRows: 3 }} onPressEnter={this.handleSubmit} /> |
| | | <TextArea autoSize={{ minRows: 2, maxRows: 3 }} onPressEnter={this.handleSubmit} /> |
| | | )} |
| | | {element.eleType === 'link' ? <div className="link-url"> |
| | | <p>链接地址:</p> |
| | | {getFieldDecorator('url', { |
| | | initialValue: element.url |
| | | })( |
| | | <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} /> |
| | | )} |
| | | </div> : null} |
| | | </div> |
| | | } overlayClassName="mob-content-update-popover" placement="bottomRight" title="" visible={visible} trigger="click" onVisibleChange={this.onVisibleChange}> |
| | | <Icon type="edit" /> |