/* eslint-disable object-curly-newline */
import React, { Component } from 'react';
import { message, Progress } from 'antd';
import baseChar from '../Common/baseChar'; /* 获取图表配置及数据 */
import styles from './index.less';
import Bar from '../Charts/Bar';
import Columnar from '../Charts/Columnar';
import ColumnarGroup from '../Charts/ColumnarGroup';
import BrokenLine from '../Charts/BrokenLine';
import WaterWave from '../Charts/WaterWave';
import Gauge from '../Charts/Gauge';
import ColumnarStack from '../Charts/ColumnarStack';
import PieGroup from '../Charts/PieGroup';
import Pie from '../Charts/Pie';
import TimeLineGroup from '../Charts/TimeLineGroup';
import ColorBlock from '../Charts/ColorBlock';
import * as commonUtils from '../../utils/utils';
import CommonList from '../Common/CommonList';
import Gantt from '../Charts/Gantt';
import * as commonConfig from '../../utils/config';
const data = {
data: [
{
id: 1, text: 'Task #1', start_date: '15-04-2019', duration: 3, progress: 0.6,
},
{
id: 2, text: 'Task #2', start_date: '18-04-2019', duration: 3, progress: 0.4,
},
],
links: [
{
id: 1, source: 1, target: 2, type: '0',
},
],
};
const zoom = 'Hours';
class CommonAuto extends Component {
constructor(props) {
super(props);
this.state = {
};
}
componentWillMount() {
setTimeout(() => {
// console.log('初始时间:', new Date());
this.timer = setInterval(() => {
try {
console.log('定时时间:', new Date(), '设定间隔:', this.props.dRefreshTime);
const pageNum = commonUtils.isEmpty(this.props.pageNum) ? 2 : this.props.pageNum + 1;
this.props.onGetData({ ...this.props }, pageNum);
} catch (e) {
console.log('error', e.message);
}
}, commonUtils.isNotEmptyNumber(this.props.dRefreshTime) && this.props.dRefreshTime !== 0 ? this.props.dRefreshTime : 100000);
}, 8000);
/* 获取顶元素配置的刷新时间 */
}
componentWillReceiveProps(nextProps) {
this.setState({ ...nextProps });
}
handleInitLabelData = () => {
const tableData = [{ iOrder: 1,
sChinese: '8号模切机',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "flex": "1","borderLeft": "1px solid #fff", "backgroundColor": "#E17D31" }' }, { iOrder: 2,
sChinese: '9号模切机',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "flex": "1","borderLeft": "1px solid #fff", "backgroundColor": "#E17D31" }' }, { iOrder: 3,
sChinese: '10号模切机',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "flex": "1","borderLeft": "1px solid #fff", "backgroundColor": "#07A346" }' }, { iOrder: 4,
sChinese: '11号模切机',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "flex": "1","borderLeft": "1px solid #fff", "backgroundColor": "#E17D31" }' }];
return tableData;
}
handleInitLabelData5 = () => {
const tableData = [{ iOrder: 1,
sChinese: '工单',
sName: '工单',
sType: 'sLable',
sTypeValue: '{ "width": "20%" }' }, { iOrder: 2,
sChinese: 'DY19080045-1',
sName: 'DY',
sType: 'sLable',
sTypeValue: '{ "width": "50%" }' }, { iOrder: 3,
sChinese: '90',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "width": "30%", "color": "#ff0000" }' }];
return tableData;
}
handleInitLabelData61 = () => {
const tableData = [{ iOrder: 1,
sChinese: '班组数据',
sName: '班组数据',
sType: 'sLable',
sTypeValue: '{ "width": "20%" }' }];
return tableData;
}
handleInitLabelData62 = () => {
const tableData = [{ iOrder: 2,
sChinese: '今日数据',
sName: 'DY',
sType: 'sLable',
sTypeValue: '{ "textAlign": "center", "fontSize": "1em" }' }, { iOrder: 3,
sChinese: '合计 90',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "fontSize": "0.85em" }' }, { iOrder: 3,
sChinese: '计划达成 3/4',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "fontSize": "0.85em" }' }, { iOrder: 3,
sChinese: '设备稼动 60%',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "fontSize": "0.85em" }' }, { iOrder: 3,
sChinese: '速度稼动 100%',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "fontSize": "0.85em" }' }, { iOrder: 3,
sChinese: '生产异常 0起',
sName: 'title',
sType: 'sLable',
sTypeValue: '{ "fontSize": "0.85em" }' }];
return tableData;
}
/* 通用自定义模板1 初始化数据 */
handleInitLabelDataT1 = (props) => {
const tableData = [];
const { labelConfigData } = this.state;
const { childConfig } = props;
if (commonUtils.isNotEmptyArr(labelConfigData) && commonUtils.isNotEmptyArr(childConfig)) {
childConfig.forEach((child) => {
const addState = {};
addState.sType = 'sLable';
addState.sTypeValue = '';
const { sName, showName } = child;
if (sName === 'noQuery') {
addState.sChinese = showName;
} else {
const filterData = labelConfigData.filter(item => item.sName === sName);
if (commonUtils.isNotEmptyArr(filterData)) {
addState.sChinese = filterData[0].sValue;
}
}
tableData.push(addState);
});
}
return tableData;
}
handleChar = (props) => {
const { sCharType, child, iHeight, sStyle } = props;
let content = '';
if (commonUtils.isNotEmptyObject(child)) {
child.height = props.iHeight;
const style = {
color: '#ffffff',
fontSize: '12px',
textAlign: 'left',
};
let sStyleObject = {};
if (commonUtils.isNotEmptyObject(sStyle)) {
try {
sStyleObject = JSON.parse(sStyle);
if (commonUtils.isNotEmptyObject(sStyleObject.color)) {
style.color = sStyleObject.color;
} if (commonUtils.isNotEmptyNumber(sStyleObject.fontSize && commonUtils.isNum(sStyleObject.fontSize))) {
style.fontSize = sStyleObject.fontSize;
} if (commonUtils.isNotEmptyObject(sStyleObject.textAlign)) {
style.textAlign = sStyleObject.textAlign;
}
} catch (e) {
message.error(`JSON数据配置错误!${e.message}`);
}
}
child.style = style;
child.projectName = 'commonAuto';
if (sCharType === 'sBar') {
/* 横向条形图 */
content =