import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { Modal, Icon } from 'antd'
|
|
import MenusForm from './menus'
|
import './index.scss'
|
|
class NodesWrap extends Component {
|
static propTpyes = {
|
card: PropTypes.object,
|
updateMenus: PropTypes.func
|
}
|
|
state = {
|
visible: false,
|
nodes: [],
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
trigger = () => {
|
const { card } = this.props
|
|
this.setState({
|
visible: true,
|
nodes: card.nodes || []
|
})
|
}
|
|
submit = () => {
|
this.setState({
|
visible: false
|
})
|
this.props.updateMenus(this.state.nodes)
|
}
|
|
update = (nodes) => {
|
this.setState({nodes})
|
}
|
|
render() {
|
const { visible, nodes, appType } = this.state
|
|
return (
|
<>
|
<Icon type="more" style={{color: '#1890ff'}} title="节点组" onClick={this.trigger}/>
|
<Modal
|
title="节点组"
|
wrapClassName="nodes-field-modal"
|
visible={visible}
|
width={900}
|
maskClosable={false}
|
onOk={this.submit}
|
onCancel={() => { this.setState({ visible: false })}}
|
destroyOnClose
|
>
|
<MenusForm menus={nodes} appType={appType} update={this.update}/>
|
</Modal>
|
</>
|
)
|
}
|
}
|
|
export default NodesWrap
|