From 9a82bce9cf0ed4a51c1b0b0669eaa38cedbace07 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 16 七月 2020 16:35:58 +0800 Subject: [PATCH] 2020-07-16 --- src/tabviews/zshare/chartcomponent/index.jsx | 62 +++++++++++++++++++++++++++--- 1 files changed, 55 insertions(+), 7 deletions(-) diff --git a/src/tabviews/zshare/chartcomponent/index.jsx b/src/tabviews/zshare/chartcomponent/index.jsx index 9bea2d7..b9ab3d2 100644 --- a/src/tabviews/zshare/chartcomponent/index.jsx +++ b/src/tabviews/zshare/chartcomponent/index.jsx @@ -5,22 +5,30 @@ import DataSet from '@antv/data-set' import { Spin, Empty, Select } from 'antd' +import asyncComponent from './asyncButtonComponent' import Utils from '@/utils/utils.js' import zhCN from '@/locales/zh-CN/model.js' import enUS from '@/locales/en-US/model.js' import './index.scss' +const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton')) +const ExcelInButton = asyncComponent(() => import('@/tabviews/zshare/actionList/excelInbutton')) + class LineChart extends Component { static propTpyes = { + BID: PropTypes.any, + Tab: PropTypes.any, plot: PropTypes.object, data: PropTypes.array, loading: PropTypes.bool, - config: PropTypes.object + config: PropTypes.object, + getexceloutparam: PropTypes.func } state = { dict: localStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, empty: true, + actions: [], chartId: Utils.getuuid(), chartData: [], chartFields: [], @@ -28,20 +36,29 @@ } componentDidMount () { - const { plot, data } = this.props - + const { plot, data, config } = this.props let _state = {} + let actions = [] + config.action.forEach(item => { + if (!plot.actions || plot.actions.length === 0) return + if (!(item.OpenType === 'excelOut' || (item.OpenType === 'excelIn' && item.Ot === 'notRequired'))) return + if (plot.actions.includes(item.uuid)) { + actions.push(fromJS(item).toJS()) + } + }) if (plot.datatype === 'statistics' && (plot.chartType === 'line' || plot.chartType === 'bar')) { let result = this.getStaticMsg(data) _state.chartData = result.data _state.chartFields = result.chartFields _state.selectFields = result.selectFields + _state.actions = actions this.setState(_state, () => { this.viewrender() }) } else { + this.setState({ actions }) this.viewrender() } } @@ -74,7 +91,6 @@ getdata = () => { const { data, plot, config } = this.props - let vFields = plot.Yaxis && typeof(plot.Yaxis) === 'string' ? [plot.Yaxis] : plot.Yaxis let _columns = config.columns.filter(col => vFields.includes(col.field)) @@ -948,8 +964,8 @@ } render() { - const { plot, loading } = this.props - const { empty, chartFields, selectFields } = this.state + const { plot, loading, config, BID, Tab } = this.props + const { empty, chartFields, selectFields, actions } = this.state return ( <div className="line-chart-plot-box"> @@ -971,7 +987,39 @@ > {chartFields.map((item, i) => <Select.Option key={i} value={item}>{item}</Select.Option>)} </Select> : null} - <div className={'canvas' + (empty ? ' empty' : '')} style={{minHeight: plot.height ? plot.height : 400}} id={this.state.chartId}></div> + <div className="canvas-wrap"> + <div className={'chart-action ' + (plot.title ? 'with-title' : '')}> + {actions.map(item => { + if (item.OpenType === 'excelOut') { + return ( + <ExcelOutButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + show="icon" + setting={config.setting} + getexceloutparam={this.props.getexceloutparam} + updateStatus={() => {}} + /> + ) + } else { + return ( + <ExcelInButton + key={item.uuid} + BID={BID} + Tab={Tab} + btn={item} + show="icon" + setting={config.setting} + updateStatus={() => {}} + /> + ) + } + })} + </div> + <div className={'canvas' + (empty ? ' empty' : '')} style={{minHeight: plot.height ? plot.height : 400}} id={this.state.chartId}></div> + </div> {empty ? <Empty description={false}/> : null} </div> ) -- Gitblit v1.8.0