From 8d66ff34fae5b048a6b7923cc75d34f13a08be9d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 八月 2022 11:42:43 +0800 Subject: [PATCH] Merge branch 'develop' --- src/components/mkIcon/index.jsx | 36 +++++++++++++++++++++++++++--------- 1 files changed, 27 insertions(+), 9 deletions(-) diff --git a/src/components/mkIcon/index.jsx b/src/components/mkIcon/index.jsx index ba860be..dcb0684 100644 --- a/src/components/mkIcon/index.jsx +++ b/src/components/mkIcon/index.jsx @@ -1,28 +1,45 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Modal, Icon, Row, Col, Button } from 'antd' +import { Modal, Row, Col, Button } from 'antd' +import { CloseCircleFilled } from '@ant-design/icons' import { minkeIconSystem } from '@/utils/option.js' +import MkIcon from '@/components/mk-icon' import './index.scss' -class MkIcon extends Component { +// ['direction', 'edit', 'normal', 'data', 'hint'] + +class MkEditIcon extends Component { static propTpyes = { onChange: PropTypes.func } state = { selectIcon: '', - icons: [...minkeIconSystem.normal, ...minkeIconSystem.trademark, ...minkeIconSystem.data, ...minkeIconSystem.edit, ...minkeIconSystem.hint, ...minkeIconSystem.direction], + allowClear: false, + icons: [], visible: false } UNSAFE_componentWillMount () { + const { options } = this.props let val = '' if (this.props['data-__meta']) { val = this.props['data-__meta'].initialValue || '' } - this.setState({selectIcon: val}) + + let icons = [] + + if (options) { + options.forEach(item => { + icons.push(...minkeIconSystem[item]) + }) + } else { + icons = [...minkeIconSystem.direction, ...minkeIconSystem.edit, ...minkeIconSystem.normal, ...minkeIconSystem.data, ...minkeIconSystem.hint] + } + + this.setState({selectIcon: val, allowClear: this.props.allowClear === true, icons}) } shouldComponentUpdate (nextProps, nextState) { @@ -35,12 +52,13 @@ } render() { - const { selectIcon, visible, icons } = this.state + const { selectIcon, visible, icons, allowClear } = this.state return ( <div className="mk-icon-box"> - {selectIcon ? <Icon type={selectIcon}/> : null} - <Icon onClick={() => this.setState({visible: true})} type="appstore"/> + {selectIcon ? <MkIcon type={selectIcon}/> : <span style={{color: '#bcbcbc'}}>璇烽�夋嫨</span>} + <MkIcon className="trigger" onClick={() => this.setState({visible: true})} type="swap"/> + {allowClear && selectIcon ? <CloseCircleFilled className="close" onClick={() => this.checkIcon('')}/> : null} <Modal wrapClassName="popview-modal mk-icon-wrap" title={'鍥炬爣閫夋嫨'} @@ -55,7 +73,7 @@ > <Row> {icons.map(icon => <Col className={icon === selectIcon ? 'active' : ''} key={icon} span={4}> - <Icon onClick={() => this.checkIcon(icon)} type={icon} /> + <MkIcon onClick={() => this.checkIcon(icon)} type={icon} /> </Col>)} </Row> </Modal> @@ -64,4 +82,4 @@ } } -export default MkIcon \ No newline at end of file +export default MkEditIcon \ No newline at end of file -- Gitblit v1.8.0