king
2020-11-26 89fb1308d92e10a27cf8f91f4dd766eb38976e12
src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -2,6 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Chart } from '@antv/g2'
import { connect } from 'react-redux'
import DataSet from '@antv/data-set'
import { Spin, Empty, Select, notification } from 'antd'
@@ -11,6 +12,7 @@
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UtilsDM from '@/utils/utils-datamanage.js'
import { modifyTabview } from '@/store/action'
import './index.scss'
const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton'))
@@ -1157,6 +1159,55 @@
      }
    }
    if (plot.linkmenu && plot.linkmenu.length > 0) {
      let menu_id = plot.linkmenu[plot.linkmenu.length - 1]
      let menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || ''
      chart.on('element:dblclick', (ev) => {
        if (!menu) {
          notification.warning({
            top: 92,
            message: '菜单已删除或没有访问权限!',
            duration: 5
          })
          return
        }
        try {
          let data = ev.data.data
          let primaryId = ''
          if (this.state.config.setting.primaryKey && data) {
            primaryId = data[this.state.config.setting.primaryKey] || ''
          }
          let newtab = {
            ...menu,
            selected: true,
            param: {
              BID: primaryId,
              data: data
            }
          }
          let tabs = this.props.tabviews.filter(tab => {
            tab.selected = false
            return tab.MenuID !== newtab.MenuID
          })
          if (this.props.tabviews.length !== tabs.length) {
            this.props.modifyTabview(fromJS(tabs).toJS())
          }
          this.setState({}, () => {
            tabs.push(newtab)
            this.props.modifyTabview(tabs)
          })
        } catch {
          console.warn('菜单打开失败!')
        }
      })
    }
    chart.render()
  }
@@ -1237,4 +1288,17 @@
  }
}
export default LineChart
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    permMenus: state.permMenus,
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
  }
}
export default connect(mapStateToProps, mapDispatchToProps)(LineChart)