import React from "react"; import { connect } from "dva"; import { initFilter, extendRule, extendOrder } from "../../../utils/common"; import { ChartPieShow, ChartBarShow } from "../../../utils/commonEcharsShow"; import DropDownPagination from '../../common/DropDownPaginationEx' import { Table, Button, Input, Row, Col, Modal, DatePicker, Icon, Progress, Divider, } from "antd"; import echarts from "echarts"; import styles from "../HI/StepForm1.css"; import moment from "moment"; import { T } from "antd/lib/upload/utils"; import FormPage from "../../FormPage"; class BI012FormRunAnalysis extends React.Component { constructor(props) { super(props); this.state = { selectStartTime: moment(this.getStartDate(), "YYYY-MM-DD"), selectEndTime: moment(this.getEndDate(), "YYYY-MM-DD"), visible: false, loading: false, noticeTitle: "", tmpData: {}, tableKey: "1", startTime: moment(new Date().setDate(1)) .subtract(6, "months") .format("YYYY-MM-DD"), endTime: moment(new Date()).format("YYYY-MM-DD"), timeType: 5, totalCount: 0, finishCount: 0, overtimeCount: 0, unfinishCount: 0, dtotalCount: 0, dfinishCount: 0, dovertimeCount: 0, dunfinishCount: 0, inputText: this.props.login.user.NAME, drate: "0%", dnormalRate: "0%", weekColor: "black", monthColor: "orange", threeMonthColor: "black", sixMonthColor: "black", yearColor: "black", retData: [], departData:[], DEPARTMENT_ID:null, displayHr: "none", displaydetail: "none", columns: [ { width: "150px", title: "月份", dataIndex: "MONTHStr", key: "MONTHStr", }, { width: "100px", title: "任务数", dataIndex: "TOTAL_QTY", key: "TOTAL_QTY", }, { width: "150px", title: "完成率", dataIndex: "FINISH_RATE", key: "FINISH_RATE", render: (text, record) => ( ), }, { width: "150px", title: "及时完成率", dataIndex: "NORMAL_FINISH_RATE", key: "NORMAL_FINISH_RATE", render: (text, record) => ( ), }, ], detailcolumns: [ { width: "150px", title: "组织名称", dataIndex: "DEPARTMENT_NAME", key: "DEPARTMENT_NAME", }, { width: "100px", title: "待办人", dataIndex: "USER_NAME", key: "USER_NAME", }, { title: "待办名称", dataIndex: "NOTICE_TITLE", key: "NOTICE_TITLE", }, { width: "150px", title: "开始时间", dataIndex: "TASK_STARTDT", key: "TASK_STARTDT", }, { width: "150px", title: "结束时间", dataIndex: "TASK_ENDDT", key: "TASK_ENDDT", }, { width: "150px", title: "预警状态", dataIndex: "NOTICE_TYPE", key: "NOTICE_TYPE", render: (text, record) => this.ShowState(record), }, ], }; this.text="组织/个人"; this.text2=""; } ShowState(obj) { var thisResult = (Date.parse(obj.TASK_ENDDT) - Date.parse(Date())) / 3600 / 1000; if (thisResult > 0) { return "正常"; } else { return 超期; } } getStartDate = () => { let date = new Date(); let y = date.getFullYear(); let m = date.getMonth() + 1; let d = date.getDate(); // 当前日期 let nowDate = y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d); let pastDate = moment(nowDate).add(-180, "d").format("YYYY-MM-DD"); return pastDate; }; getEndDate = () => { let date = new Date(); let y = date.getFullYear(); let m = date.getMonth() + 1; let d = date.getDate(); // 当前日期 let nowDate = y + "-" + (m < 10 ? "0" + m : m) + "-" + (d < 10 ? "0" + d : d); let pastDate = moment(nowDate).format("YYYY-MM-DD"); return pastDate; }; componentDidMount() { this.loadData(); } showEditModal = (departmentId, departmentName) => { const newtmpData = { data: { id: departmentId, name: departmentName, onCancel: this.handleCancel, tableKey: this.state.tableKey, homeReload: true, }, formCode: "BI007_RUNANALYSIS", }; this.setState( { id: departmentId, name: departmentName, noticeTitle: departmentName + "安全生产标准化运行情况", tmpData: newtmpData, currActivatedMenu: "", }, () => this.setState({ visible: true, }) ); }; showFormModal = (mouldName) => { const newtmpData = { data: { name: mouldName, onCancel: this.handleCancel, tableKey: this.state.tableKey, homeReload: true, }, formCode: "BI008_RUNANALYSIS", }; this.setState( { name: mouldName, noticeTitle: mouldName + "安全生产标准化运行情况", tmpData: newtmpData, currActivatedMenu: "", }, () => this.setState({ visible: true, }) ); }; //加载数据赋值 loadData = () => { this.getMould(this.props.login.user.NAME); }; onSelectDepartment=(departData,record)=>{ if (departData && departData.data && departData.data.length > 0) { this.setState({ departData: { ...this.state.departData, // DEPARTMENT_ID: departData.data[0], Nav_Department: { NAME: departData.record.NAME } }, DEPARTMENT_ID: departData.data[0], }) if(!this.state.inputText) { this.text =departData.record.NAME; this.text2 = departData.record.NAME; } } else { this.setState({ departData: { ...this.state.departData, Nav_Department: { NAME: null }, }, DEPARTMENT_ID: null, }) }; } //矿山 ksRun = (data) => { if (data) { let month = []; let company = []; let department = []; let totalCount = []; data.forEach((item) => { month.push(item.MONTHStr); company.push(item.FINISH_RATE); department.push(item.NORMAL_FINISH_RATE); totalCount.push(item.TOTAL_QTY); }); let myChart = echarts.init(document.getElementById("ksRun")); myChart.setOption({ tooltip: { trigger: "axis", axisPointer: { // 坐标轴指示器,坐标轴触发有效 type: "shadow", // 默认为直线,可选为:'line' | 'shadow' }, transitionDuration: 0, formatter: function (params) { return ( params[0].marker + params[0].seriesName + " : " + params[0].value + "" + params[1].marker + params[1].seriesName + " : " + params[1].value + "%" + "" + params[2].marker + params[2].seriesName + " : " + params[2].value + "%" ); }, }, title: { text: this.text+"任务完成情况分析", left: "center", top: "5%", }, legend: { data: ["完成数", "完成率", "及时完成率"], left: "center", align: "left", top: "15%", textStyle: { color: "#000", }, itemWidth: 10, itemHeight: 10, // itemGap: 35, }, grid: { left: "3%", right: "4%", top: "27%", bottom: "5%", containLabel: true, }, xAxis: { type: "category", data: month, axisLabel: { showMaxLabel: true, }, }, yAxis: [ { type: "value", position: "left", splitLine: { show: true, lineStyle: { color: ["#f2f2f2"], // opacity:0.2 // zlevel: -1, }, }, axisLine: { lineStyle: { color: "#0c3b71", }, }, axisLabel: { color: "rgb(170,170,170)", formatter: "{value} ", }, }, { type: "value", position: "right", splitLine: { show: false, lineStyle: { color: ["#f2f2f2"], }, }, axisLine: { lineStyle: { color: "#f2f2f2", }, }, axisLabel: { color: "rgb(170,170,170)", formatter: "{value} %", }, }, ], series: [ { name: "完成数", type: "bar", color: "#72b85b", data: totalCount, barWidth: "20%", barGap: "10%", stack: null, }, { name: "完成率", type: "line", color: "#4b9bf3", data: company, yAxisIndex: 1, smooth: true, // zlevel:100, }, { name: "及时完成率", type: "line", color: "#FCD149", data: department, yAxisIndex: 1, smooth: true, // zlevel:100, }, ], }); } }; getMould = (inputText,DEPARTMENT_ID) => { this.setState({ loading: true }); var orgId = this.props.login ? this.props.login.OrgId : ""; let startTime = this.state.selectStartTime.format("YYYY-MM-DD"); let endTime = this.state.selectEndTime.format("YYYY-MM-DD"); let json = initFilter(orgId, inputText, "", "", "", startTime, endTime,DEPARTMENT_ID); this.props.dispatch({ type: "app/getDataByPost", payload: json, url: "BI/BIStatiscialAnalysisController/GetPersonAnalyzeD", onComplete: (ret) => { if (ret) { this.setState({ retData: ret.waitData,//ret.groupData, totalCount: ret.TotalCount, finishCount: ret.doneCount, overtimeCount: ret.timeOverCount, unfinishCount: ret.unfinishCount, dovertimeCount: ret.timeOverWaitCount, loading: false, }); this.ksRun(ret.groupDataLine); } else { this.setState({ retData: [], totalCount: 0, finishCount: 0, overtimeCount: 0, unfinishCount: 0, dovertimeCount: 0, loading: false, }); } }, }); }; closeModal = () => { // 退出弹窗 this.clearData(); }; clearData = () => { let newtmpData = { ...this.state.tmpData }; newtmpData["data"].id = ""; newtmpData["data"].homeReload = false; newtmpData.formCode = ""; this.setState({ visible: false, tmpData: newtmpData, }); }; handleCancel = () => { // 退出弹窗 this.clearData(); }; handleSearch = (evt) => { const { value } = evt.target; this.setState({ inputText: value}); if(value) { this.text=value; } else if(this.text2) { this.text=this.text2; } else { this.text=''; } // this.setState({ inputText: value ? value : this.props.login.user.NAME }); }; startChange = (value) => { this.setState({ selectStartTime: value, startTime: value.format("YYYY-MM-DD"), }); }; endChange = (value) => { this.setState({ selectEndTime: value, endTime: value.format("YYYY-MM-DD"), }); }; render() { const { startTime, endTime, finishCount, overtimeCount, totalCount, unfinishCount, inputText, DEPARTMENT_ID, weekColor, monthColor, threeMonthColor, sixMonthColor, yearColor, dovertimeCount, } = this.state; let allFinishRate = totalCount === 0 || totalCount == undefined ? 0 : (((finishCount + overtimeCount) / totalCount) * 100).toFixed(1); let finishRate = totalCount === 0 || totalCount == undefined ? 0 : ((finishCount / totalCount) * 100).toFixed(1); return (