king
2021-12-16 b5364600d98c8749caba625ec813d4fe670d0a19
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { fromJS } from 'immutable'
 
import Utils from '@/utils/utils.js'
import ColumnForm from './columnform'
import asyncComponent from '@/utils/asyncComponent'
import MenuUtils from '@/utils/utils-custom.js'
// import './index.scss'
 
const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
 
class SupNodes extends Component {
  static propTpyes = {
    card: PropTypes.object,
    supNodes: PropTypes.array,
    update: PropTypes.func
  }
 
  state = {
    modules: [],
    columns: [
      {
        title: '组件',
        dataIndex: 'label',
        editable: false,
        width: '60%'
      }
    ]
  }
 
  UNSAFE_componentWillMount() {
    const { supNodes, card } = this.props
 
    let modules = MenuUtils.getSupModules(window.GLOB.customMenu.components, card.uuid) || []
 
    this.setState({
      modules,
      supNodes: fromJS(supNodes).toJS()
    })
  }
 
  columnChange = (values) => {
    const { supNodes } = this.state
    values.uuid = Utils.getuuid()
    let _nodes = [...supNodes, values]
 
    this.setState({supNodes: _nodes})
    this.props.update(_nodes)
  }
 
  changeColumns = (columns) => {
    this.setState({supNodes: columns})
    this.props.update(columns)
  }
 
  render() {
    const { supNodes, columns, modules } = this.state
 
    return (
      <div style={{minHeight: '250px'}}>
        <ColumnForm supNodes={supNodes} modules={modules} columnChange={this.columnChange}/>
        <EditTable actions={['del']} data={supNodes} columns={columns} onChange={this.changeColumns}/>
      </div>
    )
  }
}
 
export default SupNodes