| | |
| | | } |
| | | |
| | | loaded = false |
| | | options = null |
| | | |
| | | UNSAFE_componentWillMount () { |
| | | const { config } = this.props |
| | |
| | | return |
| | | } |
| | | let parentNodes = [] |
| | | let _options = [] |
| | | let logMap = new Map() |
| | | let selectKey = selectedKeys[0] || '' |
| | | let selectData = '' |
| | | let hasSelectKey = false |
| | | |
| | | this.options = [] |
| | | |
| | | data.forEach(item => { |
| | | let pval = item[config.wrap.parentField] + '' |
| | |
| | | $parentId: '' |
| | | }) |
| | | } else if (pval) { |
| | | _options.push({ |
| | | this.options.push({ |
| | | ...item, |
| | | $$uuid: uuid, |
| | | $title: item[config.wrap.labelField] || '', |
| | |
| | | }) |
| | | } |
| | | }) |
| | | let _treedata = this.getTree(parentNodes, _options) |
| | | let _treedata = this.getTree(parentNodes) |
| | | |
| | | if (this.options.length) { |
| | | this.options.forEach(item => { |
| | | _treedata.push({ |
| | | ...item, |
| | | mk_floor: 1, |
| | | $$title: <span style={{color: '#f5222d'}}>{item.$title}</span> |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | let _treeNodes = [] |
| | | |
| | |
| | | /** |
| | | * @description 获取结构树信息 |
| | | */ |
| | | getTree = (parents, options) => { |
| | | getTree = (parents) => { |
| | | parents.forEach(parent => { |
| | | parent.children = [] |
| | | // 添加菜单的子元素 |
| | | options = options.filter(option => { |
| | | this.options = this.options.filter(option => { |
| | | if (option.$parentId === parent.$key) { |
| | | option.mk_floor = parent.mk_floor + 1 |
| | | parent.children.push(option) |
| | |
| | | if (parent.children.length === 0) { |
| | | parent.children = null |
| | | } else { |
| | | parent.children = this.getTree(parent.children, options) |
| | | parent.children = this.getTree(parent.children) |
| | | } |
| | | }) |
| | | return parents |
| | |
| | | </TreeNode> |
| | | ) |
| | | } |
| | | return <TreeNode icon={<FileOutlined />} key={item.$key} title={item.$title} dataRef={item} isLeaf /> |
| | | return <TreeNode icon={<FileOutlined />} key={item.$key} title={item.$$title || item.$title} dataRef={item} isLeaf /> |
| | | }) |
| | | } |
| | | |
| | |
| | | let title = null |
| | | if (actShow === 'line') { |
| | | title = <> |
| | | {item.$title} |
| | | {item.$$title || item.$title} |
| | | <MainAction |
| | | BID={this.state.BID} |
| | | BData={this.state.BData} |
| | |
| | | </> |
| | | } else { |
| | | title = <> |
| | | {item.$title} |
| | | {item.$$title || item.$title} |
| | | <Dropdown overlay={ |
| | | <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}> |
| | | <MainAction |
| | |
| | | </Tree> |
| | | </div> : null} |
| | | {treeNodes && treeNodes.length === 0 ? <Empty description={false}/> : null} |
| | | {!treeNodes ? <div style={{height: '100px'}}></div> : null} |
| | | </div> |
| | | ) |
| | | } |