king
2020-12-10 84804b405cb88f659d055b16eb3bd00b813ccb4a
src/tabviews/custom/components/chart/antv-bar-line/index.jsx
@@ -8,11 +8,12 @@
import asyncComponent from './asyncButtonComponent'
import { chartColors } from '@/utils/option.js'
// import searchLine from '../../share/searchLine'
import Api from '@/api'
import Utils from '@/utils/utils.js'
import UtilsDM from '@/utils/utils-datamanage.js'
import { modifyTabview } from '@/store/action'
// import searchLine from '../../share/searchLine'
import MKEmitter from '@/utils/events.js'
import './index.scss'
const ExcelOutButton = asyncComponent(() => import('@/tabviews/zshare/actionList/exceloutbutton'))
@@ -28,6 +29,7 @@
  }
  state = {
    BID: '',                   // 主表ID
    config: null,              // 图表配置信息
    empty: true,               // 图表数据为空
    loading: false,            // 数据加载状态
@@ -47,9 +49,8 @@
  }
  UNSAFE_componentWillMount () {
    const { config, data, initdata } = this.props
    const { config, data, initdata, BID } = this.props
    let _config = fromJS(config).toJS()
    let _data = null
    let _sync = config.setting.sync === 'true'
@@ -189,6 +190,7 @@
    this.setState({
      config: _config,
      data: _data,
      BID: BID || '',
      vFields: vFields,
      vstFields: vstFields,
      arr_field: _config.columns.map(col => col.field).join(','),
@@ -235,35 +237,46 @@
    return !is(fromJS(this.state), fromJS(nextState))
  }
  handleData = () => {
    const { data, plot } = this.state
  componentDidMount () {
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
  }
    if (plot.datatype === 'statistics') {
      let result = this.getStaticMsg(data)
      this.setState({
        chartData: result.data,
        chartFields: result.chartFields,
        selectFields: result.selectFields
      }, () => {
        let _element = document.getElementById(this.state.chartId)
        if (_element) {
          _element.innerHTML = ''
        }
        this.viewrender()
  /**
   * @description 组件销毁,清除state更新,清除快捷键设置
   */
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
  }
  resetParentParam = (MenuID, id) => {
    const { config } = this.state
    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
    if (id !== this.state.BID) {
      this.setState({ BID: id }, () => {
        this.loadData()
      })
    } else {
      let _element = document.getElementById(this.state.chartId)
      if (_element) {
        _element.innerHTML = ''
      }
      this.viewrender()
    }
  }
  /**
   * @description 数据加载
   */
  async loadData () {
    const { mainSearch, BID, menuType } = this.props
    const { config, arr_field, search } = this.state
    const { mainSearch, menuType } = this.props
    const { config, arr_field, BID, search } = this.state
    if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
      this.setState({
        data: []
      }, () => {
        this.handleData()
      })
      return
    }
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
@@ -299,6 +312,35 @@
        message: result.message,
        duration: 10
      })
    }
  }
  /**
   * @description 数据预处理,统计数据需要重置
   */
  handleData = () => {
    const { data, plot } = this.state
    if (plot.datatype === 'statistics') {
      let result = this.getStaticMsg(data)
      this.setState({
        chartData: result.data,
        chartFields: result.chartFields,
        selectFields: result.selectFields
      }, () => {
        let _element = document.getElementById(this.state.chartId)
        if (_element) {
          _element.innerHTML = ''
        }
        this.viewrender()
      })
    } else {
      let _element = document.getElementById(this.state.chartId)
      if (_element) {
        _element.innerHTML = ''
      }
      this.viewrender()
    }
  }
@@ -1224,8 +1266,7 @@
  }
  render() {
    const { BID } = this.props
    const { showHeader, config, loading, title, plot, empty, chartFields, selectFields } = this.state
    const { showHeader, config, loading, title, plot, empty, chartFields, selectFields, BID } = this.state
    return (
      <div className="custom-line-chart-plot-box" style={config.style}>