From fc6920985f8177f153e376fe7669c272d6b3d184 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 二月 2020 22:02:56 +0800
Subject: [PATCH] 2020-02-21

---
 src/tabviews/commontable/index.jsx |   86 ++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index 44b4dc8..47c50fa 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
-import { notification, Spin, Tabs, Icon, Switch, Modal, Button} from 'antd'
+import { notification, Spin, Tabs, Icon, Switch, Modal, Button, message, Tree, Typography } from 'antd'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -22,6 +22,8 @@
 const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable'))
 const FormTab = asyncComponent(() => import('@/tabviews/formtab'))
 const { TabPane } = Tabs
+const { TreeNode } = Tree
+const { Paragraph } = Typography
 
 class NormalTable extends Component {
   static propTpyes = {
@@ -58,6 +60,7 @@
     popAction: false,     // 寮规椤甸潰锛屾寜閽俊鎭�
     popData: false,       // 寮规椤甸潰锛屾墍閫夌殑琛ㄦ牸鏁版嵁
     visible: false,       // 寮规鏄剧ず闅愯棌鎺у埗
+    treevisible: false,   // 鑿滃崟缁撴瀯鏍戝脊妗嗘樉绀洪殣钘忔帶鍒�
     tabBtn: null,         // 琛ㄥ崟鏍囩鎸夐挳
     tabParam: null,       // 琛ㄥ崟鏍囩鍙傛暟
     refreshtabs: null     // 闇�瑕佸埛鏂扮殑鏍囩闆�
@@ -756,6 +759,65 @@
     this.refreshbyaction(this.state.popAction, 'pop')
   }
 
+  handleviewconfig = (e) => {
+    e.stopPropagation()
+
+    const { MenuNo } = this.props
+    const { config } = this.state
+
+    if (config && config.funcs && config.funcs.length > 0) {
+      this.setState({
+        treevisible: true
+      })
+    } else {
+      let oInput = document.createElement('input')
+      oInput.value = MenuNo || ''
+      document.body.appendChild(oInput)
+      oInput.select()
+      document.execCommand('Copy')
+      document.body.removeChild(oInput)
+      message.success(this.state.dict['main.copy.success'])
+    }
+  }
+
+  getTreeNode = (data) => {
+    let _type = {
+      view: '椤甸潰',
+      btn: '鎸夐挳',
+      tab: '鏍囩'
+    }
+
+    return data.map(item => {
+      let _title = _type[item.subtype]
+      let _others = []
+
+      _others.push(
+        (item.menuNo ? item.menuNo + '(鑿滃崟鍙傛暟)' : ''),
+        (item.tableName ? item.tableName + '(琛ㄥ悕) ' : ''),
+        (item.innerFunc ? item.innerFunc + '(鍐呴儴鍑芥暟) ' : ''),
+        (item.outerFunc ? item.outerFunc + '(澶栭儴鍑芥暟)' : '')
+      )
+      _others = _others.filter(Boolean)
+      _others = _others.join('銆�')
+
+      if (item.label) {
+        _title = _title + '(' + item.label + ')'
+      }
+      if (_others) {
+        _title = _title + ': ' + _others
+      }
+
+      if (item.subfuncs && item.subfuncs.length > 0) {
+        return (
+          <TreeNode title={_title} key={item.uuid} dataRef={item} selectable={false}>
+            {this.getTreeNode(item.subfuncs)}
+          </TreeNode>
+        )
+      }
+      return <TreeNode key={item.uuid} title={_title} isLeaf selectable={false} />
+    })
+  }
+
   UNSAFE_componentWillMount () {
     // 缁勪欢鍔犺浇鏃讹紝鑾峰彇鑿滃崟鏁版嵁
     this.loadconfig()
@@ -878,7 +940,7 @@
             icon="copy"
             shape="circle"
             className="common-table-copy"
-            onClick={this.copyMenuNo}
+            onClick={this.handleviewconfig}
           />
           <Modal
             className="popview-modal"
@@ -902,6 +964,26 @@
               refreshSupView={this.reloadtable}
             />}
           </Modal>
+          <Modal
+            className="menu-tree-modal"
+            title={'鑿滃崟缁撴瀯鏍�'}
+            width={'650px'}
+            maskClosable={false}
+            visible={this.state.treevisible}
+            onCancel={() => this.setState({treevisible: false})}
+            footer={[
+              <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button>
+            ]}
+            destroyOnClose
+          >
+            <div className="menu-header">
+              <span>鑿滃崟鍚嶇О锛歿this.props.MenuName}</span>
+              <span>鑿滃崟鍙傛暟锛歿<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span>
+            </div>
+            {this.state.treevisible ? <Tree defaultExpandAll showLine={true}>
+              {this.getTreeNode(config.funcs)}
+            </Tree> : null}
+          </Modal>
           {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
         </div> : null}
         {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null}

--
Gitblit v1.8.0