| | |
| | | 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, notification } from 'antd' |
| | | |
| | | // import searchLine from '../../share/searchLine' |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | | import { modifyTabview } from '@/store/action' |
| | | import { chartColors } from '@/utils/option.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import './index.scss' |
| | | |
| | | class LineChart extends Component { |
| | | class PieChart extends Component { |
| | | static propTpyes = { |
| | | BID: PropTypes.any, // 父级Id |
| | | data: PropTypes.array, // 统一查询数据 |
| | |
| | | chart.legend(X_axis, { |
| | | position: plot.legend, |
| | | itemName: { |
| | | style: { |
| | | fill: color, |
| | | } |
| | | style: { fill: color } |
| | | } |
| | | }) |
| | | } else { |
| | | chart.legend({ |
| | | position: plot.legend, |
| | | itemName: { |
| | | style: { |
| | | fill: color, |
| | | } |
| | | style: { fill: color } |
| | | } |
| | | }) |
| | | } |
| | |
| | | }) |
| | | } |
| | | } |
| | | |
| | | 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() |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | 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)(PieChart) |