// 核心库 import React from 'react' import { connect } from 'dva' // 组件库 import { Empty, Row, Col, message, Timeline } from 'antd' import { Search, LayoutCard, ExportToExcel } from '@woowalker/feui' import ListPage from '../../Table/ListPage' import CommonChart from '../../Chart/CommonChart' //工具库 import { addRuleAndGroups } from '../../../utils/common' // 样式 import styles from './index.css' class EmStructurePage extends React.Component { constructor (props) { super(props) this.state = { searchRules: { rules: [] }, insertRows: [], order: 1, alarmHead: [], alarmSource: [], appName: '', rowSelectedKeys: [], chartData: {} } } componentDidMount () { this.getNodeAlarmLog() this.getRowSelectedKeys(this.state.searchRules) } getRowSelectedKeys = (searchRules) => { const json = { OrgId: this.props.login.OrgId, Parameter1: this.props.data.id, Parameter2: this.props.data.isNode, } searchRules.rules.push({ field: 'Parameter1', operator: 0, value: this.props.data.id, isCustom: true, isSysParam: false, }) searchRules.rules.push({ field: 'Parameter2', operator: 0, value: this.props.data.isNode, isCustom: true, isSysParam: false, }) this.props.dispatch({ type: 'app/getDataByPost', url: 'EM/Monitoring/GetRowSelectedKeys', payload: json }).then(res => { if (res) { this.setState({ rowSelectedKeys: res, },()=> this.child.loadData()) } }) } getNodeAlarmLog () { const json = { OrgId: this.props.login.OrgId, Parameter1: this.props.data.id, Parameter2: this.props.data.isNode, } this.props.dispatch({ type: 'app/getDataByPost', url: 'EM/Monitoring/GetNodeAlarmLog', payload: json }).then(res => { if (res) { this.setState({ alarmHead: res.alarmHead, alarmSource: res.alarmSource }) } }) } handleSearch = (value) => { value.rules.push({ field: 'Parameter1', operator: 0, value: this.props.data.id, isCustom: true, isSysParam: false, }) value.rules.push({ field: 'Parameter2', operator: 0, value: this.props.data.isNode, isCustom: true, isSysParam: false, }) this.setState({ searchRules: value, insertRows: value.rules.filter(rule => rule.field === 'Keyword').map(item => `查询时间:${item.value}`), order: 1 }, () => { this.getData(value) this.getNodeAlarmLog() this.child.loadData(value) }) } getData = (value) => { const json = { OrgId: this.props.login.OrgId, Parameter1: this.props.data.id, Parameter2: this.props.data.isNode, Parameter3:this.state.rowSelectedKeys.join(','), Order: this.state.order, } addRuleAndGroups(json, value) this.props.dispatch({ type: 'app/getDataByPost', url: 'EM/Monitoring/GetStructureLineData', payload: json }).then(res => { if (res && res.chartData && res.chartData.XAxis.length > 0) { const { chartData, appName } = res this.setState({ appName, chartData: { xAxis: chartData.XAxis[0].Data, yAxis: chartData.YAxis, data: chartData.Data } }) } }) } settingSave = (value) => { const json = { OrgId: this.props.login.OrgId, IdArry: value, Parameter1: this.props.data.id, Parameter2: this.props.data.isNode, } this.props.dispatch({ type: 'app/getDataByPost', url: 'EM/Monitoring/StructureSave', payload: json }).then(res => { if (res) { if (res.IsSucceed) { this.setState({ rowSelectedKeys: res.SelectRowKeys, },()=> this.getData(this.state.searchRules)) } else { message.error(res.Msg) } } }) } render () { const { formId, formCode } = this.props const { alarmHead, alarmSource, appName, rowSelectedKeys, chartData, insertRows } = this.state return (
{!alarmSource.length ? : null} { alarmSource.map((item, index) => { return {item.describe} }) }
this.child = ref} rowSelectedKeys={rowSelectedKeys} onRowSelectChange={this.settingSave} />
) } } export default connect(({ login, app, search }) => ({ login, app, search }))(EmStructurePage)