| | |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { value } = this.props |
| | | const { value, initialValue } = this.props |
| | | let val = '' |
| | | |
| | | if (value) { |
| | | val = value |
| | | } else if (initialValue) { |
| | | val = initialValue |
| | | } else if (this.props['data-__meta']) { |
| | | val = this.props['data-__meta'].initialValue || '' |
| | | } |
| | |
| | | } |
| | | |
| | | shouldComponentUpdate (nextProps, nextState) { |
| | | return !is(fromJS(this.state), fromJS(nextState)) |
| | | return !is(fromJS(this.state), fromJS(nextState)) || nextProps.type !== this.props.type |
| | | } |
| | | |
| | | deleteUrl = () => { |
| | |
| | | const { url, visible } = this.state |
| | | const { type } = this.props |
| | | let name = url ? url.slice(url.lastIndexOf('/') + 1) : '' |
| | | // url !== '@icon@' |
| | | |
| | | return ( |
| | | <div className="mk-source-wrap"> |
| | |
| | | <Radio.Button value="upload" size="small" onClick={() => this.handleChange('upload')}>上传</Radio.Button> |
| | | <Radio.Button value="system" size="small" onClick={() => this.handleChange('system')}>系统</Radio.Button> |
| | | </Radio.Group> : null} |
| | | {url ? <div className={'mk-source-item-info' + (type !== 'video' ? ' picture' : '')}> |
| | | {type === 'video' ? <PaperClipOutlined /> : <img src={url} alt="" />} |
| | | {url && type === 'video' ? <div className="mk-source-item-info"> |
| | | <PaperClipOutlined /> |
| | | <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> |
| | | <DeleteOutlined title="删除文件" onClick={this.deleteUrl}/> |
| | | </div> : null} |
| | | {url && type !== 'video' && url !== '@icon@' ? <div className="mk-source-item-info picture"> |
| | | <img src={url.replace(/@mywebsite@\//ig, window.GLOB.baseurl)} alt="" /> |
| | | <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> |
| | | <DeleteOutlined title="删除文件" onClick={this.deleteUrl}/> |
| | | </div> : null} |
| | | {url && type !== 'video' && url === '@icon@' ? <div className="mk-source-item-info avatar"> |
| | | <span className="mk-avatar">{name}</span> |
| | | <DeleteOutlined title="删除文件" onClick={this.deleteUrl}/> |
| | | </div> : null} |
| | | <Modal |
| | | visible={!!visible} |
| | | width={visible !== 'system' ? 600 : 1000} |
| | | width={visible !== 'system' ? 650 : 1000} |
| | | closable={false} |
| | | maskClosable={false} |
| | | okText="确定" |