From 1a67732f77de8afd138b6e75235edcc4c0e9a166 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 16 一月 2020 23:29:57 +0800
Subject: [PATCH] 2020-01-16

---
 src/tabviews/commontable/index.jsx |   89 ++++++++++++++++++++++++++++++++++++++------
 1 files changed, 77 insertions(+), 12 deletions(-)

diff --git a/src/tabviews/commontable/index.jsx b/src/tabviews/commontable/index.jsx
index b7e8f63..d099e40 100644
--- a/src/tabviews/commontable/index.jsx
+++ b/src/tabviews/commontable/index.jsx
@@ -1,5 +1,6 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
+import {connect} from 'react-redux'
 import { is, fromJS } from 'immutable'
 import { BackTop, notification, Spin, Tabs, Icon, Switch, Modal, Button} from 'antd'
 import moment from 'moment'
@@ -10,6 +11,7 @@
 import SubTable from '@/tabviews/subtable'
 import NotFount from '@/components/404'
 import asyncComponent from '@/utils/asyncLoadComponent'
+import {refreshTabView, modifyTabview} from '@/store/action'
 import zhCN from '@/locales/zh-CN/main.js'
 import enUS from '@/locales/en-US/main.js'
 import Utils from '@/utils/utils.js'
@@ -18,7 +20,7 @@
 const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable'))
 const { TabPane } = Tabs
 
-export default class NormalTable extends Component {
+class NormalTable extends Component {
   static propTpyes = {
     MenuNo: PropTypes.string,    // 鑿滃崟鍙傛暟
     MenuName: PropTypes.string,  // 鑿滃崟鍙傛暟
@@ -58,6 +60,8 @@
    * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅
    */
   async loadconfig () {
+    const { permAction } = this.props
+
     let param = {
       func: 'sPC_Get_LongParam',
       MenuID: this.props.MenuID
@@ -97,6 +101,13 @@
       let _hideCol = []      // 闅愯棌鍙婂悎骞跺垪涓瓧娈电殑uuid闆�
       let colMap = new Map()
 
+      // 鏉冮檺杩囨护
+      config.action = config.action.filter(item => permAction[item.uuid])
+      // config.tabgroups.forEach(group => {
+      //   if (!config[group]) return
+      //   config[group] = config[group].filter(tab => permAction[tab.uuid])
+      // })
+
       // 1銆佺瓫閫夊瓧娈甸泦锛�2銆佽繃婊ら殣钘忓垪鍙婂悎骞跺垪涓殑瀛楁uuid
       config.columns.forEach(col => {
         if (col.field) {
@@ -129,16 +140,18 @@
         }
       })
 
-      // 娣诲姞鎿嶄綔鍒楋紙瀛樺湪鏃讹級锛堟湭缁忚繃鏉冮檺杩囨护锛�
-      if (config.gridBtn && config.gridBtn.display) {
+      let _actions = config.action.filter(item => item.position === 'toolbar') // 杩囨护宸ュ叿鏍忔寜閽�
+      let _operations = config.action.filter(item => item.position === 'grid') // 娣诲姞鎿嶄綔鍒楋紙瀛樺湪鏃讹級
+
+      if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
         _columns.push({
           ...config.gridBtn,
-          operations: config.action.filter(item => item.position === 'grid')
+          operations: _operations
         })
       }
 
-      let _actions = config.action.filter(item => item.position === 'toolbar') // 杩囨护宸ュ叿鏍忔寜閽紙鏈粡杩囨潈闄愯繃婊わ級
-      let _isLinkMain = false        // 妫�鏌ユ槸鍚︽湁涓庝富琛ㄥ叧鑱旂殑瀛愯〃
+      
+      let _isLinkMain = false // 妫�鏌ユ槸鍚︽湁涓庝富琛ㄥ叧鑱旂殑瀛愯〃
       let supmenus = {}
       config.tabgroups.forEach(group => {
         if (config[group] && config[group].length > 0) {
@@ -209,6 +222,11 @@
 
       if (item.resourceType === '1' && item.dataSource) {
         let arrfield = item.valueField + ',' + item.valueText
+
+        if (item.valueField === item.valueText) { // value 涓� text 瀛楁鐩稿悓鏃�
+          arrfield = item.valueField
+        }
+
         if (item.type === 'link') {
           arrfield = arrfield + ',' + item.linkField
         }
@@ -630,11 +648,41 @@
    * @description 瑙﹀彂鎸夐挳寮圭獥锛堟爣绛鹃〉锛�
    */
   triggerPopview = (btn, data) => {
-    this.setState({
-      popAction: btn,
-      popData: data[0] ? data[0] : null,
-      visible: true
-    })
+    console.log(btn)
+    if (btn.OpenType === 'popview') {
+      this.setState({
+        popAction: btn,
+        popData: data[0] ? data[0] : null,
+        visible: true
+      })
+    } else if (btn.OpenType === 'tab') {
+      // const { tabviews, MenuNo, MenuID } = this.props
+      // let newtab = {
+      //   MenuNo: MenuNo,
+      //   MenuID: btn.uuid,
+      //   MenuName: btn.label,
+      //   type: btn.tabTemplate,
+      //   selected: true,
+      //   param: {
+      //     btn: btn,
+      //     data: data
+      //   }
+      // }
+
+      // let index = 0
+      // let tabs = tabviews.map((tab, i) => {
+      //   if (tab.MenuID === MenuID) {
+      //     index = i
+      //   }
+      //   tab.selected = false
+
+      //   return tab
+      // })
+
+      // tabs.splice(index + 1, 0, newtab)
+      
+      // this.props.modifyTabview(tabs)
+    }
   }
 
   popclose = () => {
@@ -770,4 +818,21 @@
       </div>
     )
   }
-}
\ No newline at end of file
+}
+
+const mapStateToProps = (state) => {
+  return {
+    tabviews: state.tabviews,
+    refreshTab: state.refreshTab,
+    permAction: state.permAction
+  }
+}
+
+const mapDispatchToProps = (dispatch) => {
+  return {
+    refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)),
+    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
+  }
+}
+
+export default connect(mapStateToProps, mapDispatchToProps)(NormalTable)
\ No newline at end of file

--
Gitblit v1.8.0