king
2024-12-05 4a356e81b1a456f0cb16f61f548c46171c26c1b6
src/tabviews/custom/components/tree/antd-tree/index.jsx
@@ -36,6 +36,7 @@
  }
  loaded = false
  options = null
  UNSAFE_componentWillMount () {
    const { config } = this.props
@@ -364,11 +365,12 @@
      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] + ''
@@ -399,7 +401,7 @@
          $parentId: ''
        })
      } else if (pval) {
        _options.push({
        this.options.push({
          ...item,
          $$uuid: uuid,
          $title: item[config.wrap.labelField] || '',
@@ -408,7 +410,17 @@
        })
      }
    })
    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 = []
@@ -485,11 +497,11 @@
  /**
   * @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)
@@ -501,7 +513,7 @@
      if (parent.children.length === 0) {
        parent.children = null
      } else {
        parent.children = this.getTree(parent.children, options)
        parent.children = this.getTree(parent.children)
      }
    })
    return parents
@@ -519,7 +531,7 @@
          </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 />
    })
  }
@@ -528,7 +540,7 @@
      let title = null
      if (actShow === 'line') {
        title = <>
          {item.$title}
          {item.$$title || item.$title}
          <MainAction
            BID={this.state.BID}
            BData={this.state.BData}
@@ -540,7 +552,7 @@
        </>
      } else {
        title = <>
          {item.$title}
          {item.$$title || item.$title}
          <Dropdown overlay={
            <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}>
              <MainAction
@@ -661,6 +673,7 @@
          </Tree>
        </div> : null}
        {treeNodes && treeNodes.length === 0 ? <Empty description={false}/> : null}
        {!treeNodes ? <div style={{height: '100px'}}></div> : null}
      </div>
    )
  }