From 84804b405cb88f659d055b16eb3bd00b813ccb4a Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 10 十二月 2020 10:58:38 +0800 Subject: [PATCH] 2020-12-10 --- src/tabviews/custom/components/chart/antv-bar-line/index.jsx | 97 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 69 insertions(+), 28 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 5cd4c24..f45ba50 100644 --- a/src/tabviews/custom/components/chart/antv-bar-line/index.jsx +++ b/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}> -- Gitblit v1.8.0