From 89fb1308d92e10a27cf8f91f4dd766eb38976e12 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 26 十一月 2020 21:56:42 +0800
Subject: [PATCH] 2020-11-26

---
 src/tabviews/custom/components/chart/antv-bar-line/index.jsx |   66 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 1 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx b/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
index 70cbff2..23f1f6a 100644
--- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx
+++ b/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
\ No newline at end of file
+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)
\ No newline at end of file

--
Gitblit v1.8.0