king
2020-01-16 1a67732f77de8afd138b6e75235edcc4c0e9a166
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>
    )
  }
}
}
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)