From b23db4e1b9e8bc813b4b3b95d35552e5e2e980c6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期一, 01 二月 2021 18:51:00 +0800 Subject: [PATCH] 2021-02-01 --- src/menu/components/share/sourcecomponent/index.jsx | 47 +++++++++++++++++++++++++++++++++-------------- 1 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/menu/components/share/sourcecomponent/index.jsx b/src/menu/components/share/sourcecomponent/index.jsx index 8f1f40c..a5ed3e6 100644 --- a/src/menu/components/share/sourcecomponent/index.jsx +++ b/src/menu/components/share/sourcecomponent/index.jsx @@ -1,9 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Popover, Button, Icon } from 'antd' +import { Radio, Icon, Modal } from 'antd' -import PopSource from './popsource' +import InputForm from './inputform' import './index.scss' class CopyComponent extends Component { @@ -14,7 +14,8 @@ } state = { - url: this.props.value + url: this.props.value, + visible: '' } UNSAFE_componentWillMount () { @@ -30,30 +31,48 @@ this.props.onChange('') } - changePopover = (visible) => { - if (!visible && this.SourceWrap.state.url) { - this.setState({url: this.SourceWrap.state.url}) - this.props.onChange(this.SourceWrap.state.url) - } else if (visible && this.SourceWrap) { - this.SourceWrap.init() + handleChange = (key) => { + this.setState({visible: key}) + } + + popSubmit = () => { + let url = '' + if (this.inputWrap && this.inputWrap.state.url) { + url = this.inputWrap.state.url } + + this.setState({visible: '', url}) + this.props.onChange(url) } render () { - const { url } = this.state - const { type, placement } = this.props + const { url, visible } = this.state + const { type } = this.props let name = url ? url.slice(url.lastIndexOf('/') + 1) : '' return ( <div className="mk-source-wrap"> - {!url ? <Popover overlayClassName="mk-source-manage" placement={placement || 'top'} content={<PopSource type={type} ref={dom => { this.SourceWrap = dom }} />} trigger="click" onVisibleChange={this.changePopover}> - <Button icon="upload">鐐瑰嚮娣诲姞</Button> - </Popover> : null} + {!url ? <Radio.Group> + <Radio.Button value="input" size="small" onClick={() => this.handleChange('input')}>杈撳叆</Radio.Button> + <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"> <Icon type="paper-clip" /> <a target="_blank" rel="noopener noreferrer" href={url}>{name}</a> <Icon title="鍒犻櫎鏂囦欢" type="delete" onClick={this.deleteUrl}/> </div> : null} + <Modal + visible={!!visible} + width={visible !== 'system' ? 600 : 1000} + closable={false} + maskClosable={false} + onOk={this.popSubmit} + onCancel={() => {this.setState({visible: ''})}} + destroyOnClose + > + <InputForm type={type === 'picture' ? 'image' : type} keyword={visible} ref={dom => { this.inputWrap = dom }} /> + </Modal> </div> ) } -- Gitblit v1.8.0