From 328be53b4461397cd96da79c7e40c892bdb94e2a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 15 六月 2025 21:00:39 +0800
Subject: [PATCH] 2025-06-15

---
 src/tabviews/custom/components/tree/antd-tree/index.jsx |  122 +++++++++++++++++++++++++++++-----------
 1 files changed, 87 insertions(+), 35 deletions(-)

diff --git a/src/tabviews/custom/components/tree/antd-tree/index.jsx b/src/tabviews/custom/components/tree/antd-tree/index.jsx
index 1009ba9..0f4a527 100644
--- a/src/tabviews/custom/components/tree/antd-tree/index.jsx
+++ b/src/tabviews/custom/components/tree/antd-tree/index.jsx
@@ -31,10 +31,12 @@
     treeNodes: null,           // 鍒楄〃鏁版嵁闆�
     expandedKeys: [],          // 灞曞紑鐨勬爲鑺傜偣
     selectedKeys: [],          // 閫変腑鐨勬爲鑺傜偣
+    lineActions: [],
     selected: false            // 閫変腑棣栬
   }
 
   loaded = false
+  options = null
 
   UNSAFE_componentWillMount () {
     const { config } = this.props
@@ -69,15 +71,32 @@
   
         window.GLOB.SyncData.delete(_config.dataName)
       }
+    } else if (_config.setting.supModule && !BID) {
+      _config.setting.onload = 'false'
     }
 
+    let lineActions = []
+    _config.action = _config.action || []
+    _config.action = _config.action.filter(item => {
+      if (item.Ot === 'requiredSgl') {
+        lineActions.push(item)
+        return false
+      }
+      return true
+    })
+
     _config.wrap.contentHeight = config.wrap.title || config.wrap.searchable === 'true' ? 'calc(100% - 45px)' : '100%'
+
+    if (_config.wrap.lineHeight) {
+      _config.style['--mk-tree-line-height'] = _config.wrap.lineHeight + 'px'
+    }
 
     this.setState({
       selected: _config.wrap.selected === 'true',
       config: _config,
       data: _data,
-      BID: BID || ''
+      BID: BID || '',
+      lineActions
     })
   }
 
@@ -254,13 +273,13 @@
    * @param {*} position   // 鍒锋柊浣嶇疆
    * @param {*} btn        // 鎵ц鐨勬寜閽�
    */
-  refreshByButtonResult = (menuId, position, btn) => {
+  refreshByButtonResult = (menuId, position) => {
     const { config, BID } = this.state
 
     if (config.uuid !== menuId) return
 
-    if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 鍒锋柊婧愮粍浠舵椂锛岄檮甯﹀埛鏂颁笂绾ц涓庡綋鍓嶇粍浠�
-      MKEmitter.emit('reloadData', config.setting.supModule, BID)
+    if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) {
+      MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID)
     } else {
       this.loadData()
     }
@@ -346,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] + ''
@@ -381,7 +401,7 @@
           $parentId: ''
         })
       } else if (pval) {
-        _options.push({
+        this.options.push({
           ...item,
           $$uuid: uuid,
           $title: item[config.wrap.labelField] || '',
@@ -390,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 = []
 
@@ -467,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)
@@ -483,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
@@ -501,34 +531,49 @@
           </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 />
     })
   }
 
-  renderActionTreeNodes = (nodes) => {
+  renderActionTreeNodes = (nodes, actShow) => {
     return nodes.map(item => {
-      let title = <>
-        {item.$title}
-        <Dropdown overlay={
-          <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}>
-            <MainAction
-              BID={this.state.BID}
-              BData={this.state.BData}
-              setting={this.state.config.setting}
-              actions={this.state.config.action}
-              columns={this.state.config.columns}
-              selectedData={[{...item, children: ''}]}
-            />
-          </div>
-        } placement="bottomCenter" trigger={['hover']}>
-          <MoreOutlined onClick={(e) => e.stopPropagation()}/>
-        </Dropdown>
-      </>
+      let title = null
+      if (actShow === 'line') {
+        title = <>
+          {item.$$title || item.$title}
+          <MainAction
+            BID={this.state.BID}
+            BData={this.state.BData}
+            setting={this.state.config.setting}
+            actions={this.state.lineActions}
+            columns={this.state.config.columns}
+            selectedData={[{...item, children: ''}]}
+          />
+        </>
+      } else {
+        title = <>
+          {item.$$title || item.$title}
+          <Dropdown overlay={
+            <div className="mk-tree-dropdown-wrap" onClick={(e) => e.stopPropagation()}>
+              <MainAction
+                BID={this.state.BID}
+                BData={this.state.BData}
+                setting={this.state.config.setting}
+                actions={this.state.lineActions}
+                columns={this.state.config.columns}
+                selectedData={[{...item, children: ''}]}
+              />
+            </div>
+          } placement="bottomCenter" trigger={['hover']}>
+            <MoreOutlined onClick={(e) => e.stopPropagation()}/>
+          </Dropdown>
+        </>
+      }
 
       if (item.children) {
         return (
           <TreeNode icon={<span><FolderOpenOutlined /><FolderOutlined /></span>} title={title} key={item.$key} dataRef={item}>
-            {this.renderActionTreeNodes(item.children)}
+            {this.renderActionTreeNodes(item.children, actShow)}
           </TreeNode>
         )
       }
@@ -591,9 +636,7 @@
   }
 
   render() {
-    const { config, loading, treeNodes, expandedKeys, selectedKeys } = this.state
-
-    let extra = config.action && config.action.length > 0
+    const { BID, BData, config, loading, treeNodes, expandedKeys, selectedKeys, lineActions } = this.state
 
     return (
       <div className="custom-tree-box" id={'anchor' + config.uuid} style={config.style}>
@@ -607,21 +650,30 @@
           <span className={'title ' + (config.wrap.searchable !== 'true' ? 'search-unable' : '')}>{config.wrap.title}</span>
           {config.wrap.searchable === 'true' ? <Search allowClear onSearch={this.treeFilter} /> : null}
         </div> : null}
+        {config.action.length ? <MainAction
+          BID={BID}
+          setting={config.setting}
+          actions={config.action}
+          BData={BData}
+          columns={config.columns}
+          selectedData={[]}
+        /> : null}
         {treeNodes && treeNodes.length > 0 ? <div className="tree-box" style={{height: config.wrap.contentHeight}}>
           <Tree
             blockNode
             onSelect={this.selectTreeNode}
             expandedKeys={expandedKeys}
             selectedKeys={selectedKeys}
-            onRightClick={!extra ? this.changeExpandedAllKeys : null}
+            onRightClick={!lineActions.length ? this.changeExpandedAllKeys : null}
             onExpand={this.changeExpandedKeys}
             showIcon={config.wrap.showIcon === 'true'}
             showLine={config.wrap.showLine === 'true'}
           >
-            {!extra ? this.renderTreeNodes(treeNodes) : this.renderActionTreeNodes(treeNodes)}
+            {!lineActions.length ? this.renderTreeNodes(treeNodes) : this.renderActionTreeNodes(treeNodes, config.wrap.actShow)}
           </Tree>
         </div> : null}
         {treeNodes && treeNodes.length === 0 ? <Empty description={false}/> : null}
+        {!treeNodes ? <div style={{height: '100px'}}></div> : null}
       </div>
     )
   }

--
Gitblit v1.8.0