import React from "react";
import { connect } from "dva";
import { initFilter, extendRule, extendOrder } from "../../../utils/common";
import { ChartPieShow, ChartBarShow } from "../../../utils/commonEcharsShow";
import { Table, Button, Row, Col, Modal, 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 BI009FormRunAnalysis extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
      noticeTitle: "",
      tmpData: {},
      tableKey: "1",
      timeType: 5,
      ordinaryCount: 0,
      crucialCount: 0,
      activityCount: 0,
      postCount: 0,
      postChangeCount: 0,
      taskCount: 0,
      weekColor: "black",
      monthColor: "orange",
      threeMonthColor: "black",
      sixMonthColor: "black",
      yearColor: "black",
      retData: [],
      groupData: [],
      detailData: [],
      newData: [],
      detailDataH: [],
      displayHr: "none",
      displaydetail: "none",
      columns: [
        {
          width: "80px",
          title: "序号",
          dataIndex: "Num",
          key: "Num",
          render: (text, record, index) => <span>{index + 1}</span>,
        },
        {
          width: "250px",
          title: "部门",
          dataIndex: "DEPARTMENT_NAME",
          key: "DEPARTMENT_NAME",
          // render: (text, record) => (
          //   <span>
          //     <a onClick={() => this.showEditModal(record.DEPARTMENT_ID,record.DEPARTMENT_NAME)}>{record.DEPARTMENT_NAME}</a>
          //   </span>
          // ),
        },
        {
          width: "250px",
          title: "班组",
          dataIndex: "TEAM_NAME",
          key: "TEAM_NAME",
          // render: (text, record) => (
          //   <span>
          //     <a onClick={() => this.showEditModal(record.DEPARTMENT_ID,record.DEPARTMENT_NAME)}>{record.DEPARTMENT_NAME}</a>
          //   </span>
          // ),
        },
        {
          title: "完成率",
          children: [
            {
              title: "班前会议",
              render: (text, record) => (
                <span>
                  {record.FO01_TOTAL == 0
                    ? "0%"
                    : (
                        ((record.FO01_FINISH + record.FO01_OVERTIME) /
                          record.FO01_TOTAL) *
                        100
                      ).toFixed(0) + "%"}
                </span>
              ),
            },
            {
              title: "岗位交接班",
              render: (text, record) => (
                <span>
                  {record.FO03_TOTAL == 0
                    ? "0%"
                    : (
                        ((record.FO03_FINISH + record.FO03_OVERTIME) /
                          record.FO03_TOTAL) *
                        100
                      ).toFixed(0) + "%"}
                </span>
              ),
            },
            {
              title: "岗位当班记录",
              render: (text, record) => (
                <span>
                  {record.FO02_TOTAL == 0
                    ? "0%"
                    : (
                        ((record.FO02_FINISH + record.FO02_OVERTIME) /
                          record.FO02_TOTAL) *
                        100
                      ).toFixed(0) + "%"}
                </span>
              ),
            },
          ],
        },
        // {
        //   title: '及时完成率',
        //   children: [
        //     {
        //       title: '班前会议',
        //       render: (text, record) => (<span>{record.FO01_TOTAL == 0?'0%':((record.FO01_FINISH/ record.FO01_TOTAL)*100).toFixed(0)+"%"}</span>)
        //     },
        //     {
        //       title: '岗位交接班',
        //       render: (text, record) => (<span>{record.FO03_TOTAL == 0?'0%':((record.FO03_FINISH / record.FO03_TOTAL)*100).toFixed(0)+"%"}</span>)
        //     },
        //     {
        //       title: '岗位当班记录',
        //       render: (text, record) => (<span>{record.FO02_TOTAL == 0?'0%':((record.FO02_FINISH / record.FO02_TOTAL)*100).toFixed(0)+"%"}</span>)
        //     },
        //   ],
        // },
      ],
      detailColumns: [
        {
          width: "60px",
          title: "班组",
          dataIndex: "DEPARTMENT_NAME",
          key: "DEPARTMENT_NAME",
          // render: (text, record) => (
          //   <span>
          //     <a onClick={() => this.showEditModal(record.DEPARTMENT_ID,record.DEPARTMENT_NAME)}>{record.DEPARTMENT_NAME}</a>
          //   </span>
          // ),
        },
        {
          width: "60px",
          title: "总任务数",
          dataIndex: "TOTAL_QTY",
          key: "TOTAL_QTY",
        },
        {
          width: "60px",
          title: "正常已办",
          dataIndex: "FINISH_QTY",
          key: "FINISH_QTY",
        },
        {
          width: "60px",
          title: "超时已办",
          dataIndex: "OVER_FINISH_QTY",
          key: "OVER_FINISH_QTY",
        },
        {
          width: "50px",
          title: "未完成",
          dataIndex: "UNFINISH_QTY",
          key: "UNFINISH_QTY",
        },
        {
          width: "100px",
          title: "完成率",
          dataIndex: "FINISH_RATE",
          key: "FINISH_RATE",
          render: (text, record) => (
            <Progress percent={record.FINISH_RATE.split("%")[0]} />
            // <span>
            //   <a onClick={() => this.showEditModal(record.DEPARTMENT_ID,record.DEPARTMENT_NAME)}>{record.DEPARTMENT_NAME}</a>
            // </span>
          ),
        },
        {
          width: "100px",
          title: "及时完成率",
          dataIndex: "NORMAL_FINISH_RATE",
          key: "NORMAL_FINISH_RATE",
          render: (text, record) => (
            <Progress
              percent={record.NORMAL_FINISH_RATE.split("%")[0]}
              strokeColor={{
                from: "rgba(82, 196, 26)",
                to: "rgba(82, 196, 26)",
              }}
            />
            // <span>
            //   <a onClick={() => this.showEditModal(record.DEPARTMENT_ID,record.DEPARTMENT_NAME)}>{record.DEPARTMENT_NAME}</a>
            // </span>
          ),
        },
      ],
    };
  }

  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 = (record) => {
    const { newData } = this.state;
    let newDataTemp = [];
    let temp = newData.filter(
      (t) =>
        t.DEPARTMENT_ID === record.departmentId &&
        t.SOURCE_FORMCODE === record.formCode
    );
    if (temp.length > 0) {
      let i = 1;
      temp.forEach((t) => {
        t.ROW_NO = i;
        t.formName = record.formName;
        newDataTemp.push(t);
        i++;
      });
    } else {
      newDataTemp = [];
    }
    this.setState({ displaydetail: "block", detailDataH: newDataTemp });
  };

  //加载数据赋值
  loadData = () => {
    this.getCount();
    this.workTicket();
    this.workTicket2();
    this.mainJobPie2();
    this.getBaseInfoData();
  };
  //获取数据
  getBaseInfoData = () => {
    let json = initFilter(this.props.login.OrgId, "", "DEPARTMENT_NAME", "asc");
    extendRule(json, "FILTER_TIME", 1, 0);
    extendRule(json, "DEPARTMENT_NAME", 2, "宁化行洛坑钨矿有限公司");
    extendRule(json, "DEPARTMENT_NAME", 2, "都昌金鼎钨钼矿业有限公司");
    extendRule(json, "DEPARTMENT_NAME", 2, "技术管理部");
    this.props.dispatch({
      type: "app/getDataByPost",
      url: "BI/SafetaskFinish/OrderEntities",
      payload: json,
      onlyData: false,
      onComplete: (ret) => {
        if (ret && ret.Data) {
          this.state.retData = ret.Data;
        }
      },
    });
  };
  getCount = () => {
    var orgId = this.props.login ? this.props.login.OrgId : "";
    const jsonTemp = initFilter(orgId);
    this.props.dispatch({
      type: "app/getDataByPost",
      payload: jsonTemp,
      url: "BI/BIStatiscialAnalysisController/GetTotalCount",
      onComplete: (ret) => {
        if (ret) {
          let riskLevels = document.getElementById("mainJobPie");
          if (riskLevels) {
            let myChart = echarts.init(riskLevels);
            myChart.setOption({
              backgroundColor: "#FFFFFF",
              title: [
                {
                  text: "班前会议完成率",
                  bottom: "12%",
                  x: "center",
                  // borderColor: "#1598FF",
                  // borderWidth: 1,
                  borderRadius: 15,
                  // backgroundColor: "#1598FF",
                  padding: [7, 14],
                  textStyle: {
                    // fontWeight: "bold",
                    fontSize: 14,
                    color: "#000",
                  },
                },
              ],
              angleAxis: {
                show: false,
                max: (100 * 360) / 270, //-45度到225度，二者偏移值是270度除360度
                type: "value",
                startAngle: 225, //极坐标初始角度
                splitLine: {
                  show: false,
                },
              },
              barMaxWidth: 10, //圆环宽度
              radiusAxis: {
                show: false,
                type: "category",
              },
              //圆环位置和大小
              polar: {
                center: ["50%", "50%"],
                radius: "120%",
              },
              series: [
                {
                  type: "bar",
                  data: [
                    {
                      //上层圆环，显示数据
                      value: 95,
                      itemStyle: {
                        color: "#1598FF",
                      },
                    },
                  ],
                  barGap: "-100%", //柱间距离,上下两层圆环重合
                  coordinateSystem: "polar",
                  roundCap: true, //顶端圆角
                  z: 3, //圆环层级，同zindex
                },
                {
                  //下层圆环，显示最大值
                  type: "bar",
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        color: "#1598FF",
                        opacity: 0.2,
                        borderWidth: 0,
                      },
                    },
                  ],
                  barGap: "-100%",
                  coordinateSystem: "polar",
                  roundCap: true,
                  z: 1,
                },
                //仪表盘
                {
                  type: "gauge",
                  startAngle: 225, //起始角度，同极坐标
                  endAngle: -45, //终止角度，同极坐标
                  axisLine: {
                    show: false,
                  },
                  splitLine: {
                    show: false,
                  },
                  axisTick: {
                    show: false,
                  },
                  axisLabel: {
                    show: false,
                  },
                  splitLabel: {
                    show: false,
                  },
                  pointer: {
                    // 分隔线
                    shadowColor: "auto", //默认透明
                    shadowBlur: 5,
                    length: "50%",
                    width: "1",
                  },
                  itemStyle: {
                    color: "#1598FF",
                    borderColor: "#1598FF",
                    borderWidth: 2,
                  },
                  detail: {
                    formatter: function (params) {
                      return 95 + "%";
                    },
                    color: "#1598FF",
                    fontSize: 20,
                    offsetCenter: [0, 80],
                  },
                  title: {
                    show: false,
                  },
                  data: [
                    {
                      value: 95,
                    },
                  ],
                },
                {
                  name: "外部刻度",
                  type: "gauge",
                  //  center: ['20%', '50%'],
                  radius: "73%",
                  min: 0, //最小刻度
                  max: 100, //最大刻度
                  splitNumber: 10, //刻度数量
                  startAngle: 225,
                  endAngle: -45,
                  axisLine: {
                    show: true,
                    lineStyle: {
                      width: 1,
                      color: [[1, "rgba(0,0,0,0)"]],
                    },
                  }, //仪表盘轴线
                  axisLabel: {
                    show: false,
                    color: "#4d5bd1",
                    distance: 25,
                  }, //刻度标签。
                  axisTick: {
                    show: true,
                    splitNumber: 7,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                      width: 2,
                    },
                    length: -8,
                  }, //刻度样式
                  splitLine: {
                    show: false,
                    length: -20,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                    },
                  }, //分隔线样式
                  detail: {
                    show: false,
                  },
                  pointer: {
                    show: false,
                  },
                },
                {
                  //指针外环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["10%", "13%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#1598FF",
                        },
                      },
                    },
                  ],
                },
                {
                  //指针内环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["0%", "10%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#FFFFFF",
                        },
                      },
                    },
                  ],
                },
              ],
            });
          }
          let riskLevel1s = document.getElementById("mainJobPie1");
          if (riskLevel1s) {
            let myChart1 = echarts.init(riskLevel1s);
            myChart1.setOption({
              backgroundColor: "#FFFFFF",
              title: [
                {
                  text: "岗位当班记录完成率",
                  bottom: "12%",
                  x: "center",
                  // borderColor: "#1598FF",
                  // borderWidth: 1,
                  borderRadius: 15,
                  // backgroundColor: "#1598FF",
                  padding: [7, 14],
                  textStyle: {
                    // fontWeight: "bold",
                    fontSize: 14,
                    color: "#000",
                  },
                },
              ],
              angleAxis: {
                show: false,
                max: (100 * 360) / 270, //-45度到225度，二者偏移值是270度除360度
                type: "value",
                startAngle: 225, //极坐标初始角度
                splitLine: {
                  show: false,
                },
              },
              barMaxWidth: 10, //圆环宽度
              radiusAxis: {
                show: false,
                type: "category",
              },
              //圆环位置和大小
              polar: {
                center: ["50%", "50%"],
                radius: "120%",
              },
              series: [
                {
                  type: "bar",
                  data: [
                    {
                      //上层圆环，显示数据
                      value: 97,
                      itemStyle: {
                        color: "#f8a035",
                      },
                    },
                  ],
                  barGap: "-100%", //柱间距离,上下两层圆环重合
                  coordinateSystem: "polar",
                  roundCap: true, //顶端圆角
                  z: 3, //圆环层级，同zindex
                },
                {
                  //下层圆环，显示最大值
                  type: "bar",
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        color: "#f8a035",
                        opacity: 0.2,
                        borderWidth: 0,
                      },
                    },
                  ],
                  barGap: "-100%",
                  coordinateSystem: "polar",
                  roundCap: true,
                  z: 1,
                },
                //仪表盘
                {
                  type: "gauge",
                  startAngle: 225, //起始角度，同极坐标
                  endAngle: -45, //终止角度，同极坐标
                  axisLine: {
                    show: false,
                  },
                  splitLine: {
                    show: false,
                  },
                  axisTick: {
                    show: false,
                  },
                  axisLabel: {
                    show: false,
                  },
                  splitLabel: {
                    show: false,
                  },
                  pointer: {
                    // 分隔线
                    shadowColor: "auto", //默认透明
                    shadowBlur: 5,
                    length: "50%",
                    width: "1",
                  },
                  itemStyle: {
                    color: "#f8a035",
                    borderColor: "#f8a035",
                    borderWidth: 2,
                  },
                  detail: {
                    formatter: function (params) {
                      return 97 + "%";
                    },
                    color: "#f8a035",
                    fontSize: 20,
                    offsetCenter: [0, 80],
                  },
                  title: {
                    show: false,
                  },
                  data: [
                    {
                      value: 97,
                    },
                  ],
                },
                {
                  name: "外部刻度",
                  type: "gauge",
                  //  center: ['20%', '50%'],
                  radius: "73%",
                  min: 0, //最小刻度
                  max: 100, //最大刻度
                  splitNumber: 10, //刻度数量
                  startAngle: 225,
                  endAngle: -45,
                  axisLine: {
                    show: true,
                    lineStyle: {
                      width: 1,
                      color: [[1, "rgba(0,0,0,0)"]],
                    },
                  }, //仪表盘轴线
                  axisLabel: {
                    show: false,
                    color: "#4d5bd1",
                    distance: 25,
                  }, //刻度标签。
                  axisTick: {
                    show: true,
                    splitNumber: 7,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                      width: 2,
                    },
                    length: -8,
                  }, //刻度样式
                  splitLine: {
                    show: false,
                    length: -20,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                    },
                  }, //分隔线样式
                  detail: {
                    show: false,
                  },
                  pointer: {
                    show: false,
                  },
                },
                {
                  //指针外环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["10%", "13%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#f8a035",
                        },
                      },
                    },
                  ],
                },
                {
                  //指针内环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["0%", "10%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#FFFFFF",
                        },
                      },
                    },
                  ],
                },
              ],
            });
          }
          let riskLevel3s = document.getElementById("mainJobPie3");
          if (riskLevel3s) {
            let myChart3 = echarts.init(riskLevel3s);
            myChart3.setOption({
              backgroundColor: "#FFFFFF",
              title: [
                {
                  text: "岗位交接班完成率",
                  bottom: "12%",
                  x: "center",
                  // borderColor: "#1598FF",
                  // borderWidth: 1,
                  borderRadius: 15,
                  // backgroundColor: "#1598FF",
                  padding: [7, 14],
                  textStyle: {
                    // fontWeight: "bold",
                    fontSize: 14,
                    color: "#000",
                  },
                },
              ],
              angleAxis: {
                show: false,
                max: (100 * 360) / 270, //-45度到225度，二者偏移值是270度除360度
                type: "value",
                startAngle: 225, //极坐标初始角度
                splitLine: {
                  show: false,
                },
              },
              barMaxWidth: 10, //圆环宽度
              radiusAxis: {
                show: false,
                type: "category",
              },
              //圆环位置和大小
              polar: {
                center: ["50%", "50%"],
                radius: "120%",
              },
              series: [
                {
                  type: "bar",
                  data: [
                    {
                      //上层圆环，显示数据
                      value: 99,
                      itemStyle: {
                        color: "#f1516d",
                      },
                    },
                  ],
                  barGap: "-100%", //柱间距离,上下两层圆环重合
                  coordinateSystem: "polar",
                  roundCap: true, //顶端圆角
                  z: 3, //圆环层级，同zindex
                },
                {
                  //下层圆环，显示最大值
                  type: "bar",
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        color: "#f1516d",
                        opacity: 0.2,
                        borderWidth: 0,
                      },
                    },
                  ],
                  barGap: "-100%",
                  coordinateSystem: "polar",
                  roundCap: true,
                  z: 1,
                },
                //仪表盘
                {
                  type: "gauge",
                  startAngle: 225, //起始角度，同极坐标
                  endAngle: -45, //终止角度，同极坐标
                  axisLine: {
                    show: false,
                  },
                  splitLine: {
                    show: false,
                  },
                  axisTick: {
                    show: false,
                  },
                  axisLabel: {
                    show: false,
                  },
                  splitLabel: {
                    show: false,
                  },
                  pointer: {
                    // 分隔线
                    shadowColor: "auto", //默认透明
                    shadowBlur: 5,
                    length: "50%",
                    width: "1",
                  },
                  itemStyle: {
                    color: "#f1516d",
                    borderColor: "#f1516d",
                    borderWidth: 2,
                  },
                  detail: {
                    formatter: function (params) {
                      return 99 + "%";
                    },
                    color: "#f1516d",
                    fontSize: 20,
                    offsetCenter: [0, 80],
                  },
                  title: {
                    show: false,
                  },
                  data: [
                    {
                      value: 99,
                    },
                  ],
                },
                {
                  name: "外部刻度",
                  type: "gauge",
                  //  center: ['20%', '50%'],
                  radius: "73%",
                  min: 0, //最小刻度
                  max: 100, //最大刻度
                  splitNumber: 10, //刻度数量
                  startAngle: 225,
                  endAngle: -45,
                  axisLine: {
                    show: true,
                    lineStyle: {
                      width: 1,
                      color: [[1, "rgba(0,0,0,0)"]],
                    },
                  }, //仪表盘轴线
                  axisLabel: {
                    show: false,
                    color: "#4d5bd1",
                    distance: 25,
                  }, //刻度标签。
                  axisTick: {
                    show: true,
                    splitNumber: 7,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                      width: 2,
                    },
                    length: -8,
                  }, //刻度样式
                  splitLine: {
                    show: false,
                    length: -20,
                    lineStyle: {
                      color: "#C7CBCF", //用颜色渐变函数不起作用
                    },
                  }, //分隔线样式
                  detail: {
                    show: false,
                  },
                  pointer: {
                    show: false,
                  },
                },
                {
                  //指针外环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["10%", "13%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#f1516d",
                        },
                      },
                    },
                  ],
                },
                {
                  //指针内环
                  type: "pie",
                  hoverAnimation: false,
                  legendHoverLink: false,
                  radius: ["0%", "10%"],
                  z: 10,
                  label: {
                    normal: {
                      show: false,
                    },
                  },
                  labelLine: {
                    normal: {
                      show: false,
                    },
                  },
                  data: [
                    {
                      value: 100,
                      itemStyle: {
                        normal: {
                          color: "#FFFFFF",
                        },
                      },
                    },
                  ],
                },
              ],
            });
          }
          this.setState({
            ordinaryCount: ret.ordinaryCount,
            crucialCount: ret.crucialCount,
            activityCount: ret.activityCount,
            postCount: ret.postCount,
            postChangeCount: ret.postChangeCount,
            taskCount: ret.taskCount,
          });
        }
      },
    });
  };
  //
  workTicket = () => {
    let json = initFilter(this.props.login.OrgId, "10", "NUM", "asc");
    // extendRule(json, "DEPARTMENT_NAME", 1,"选矿部");
    this.props.dispatch({
      type: "app/getDataByPost",
      url: "BI/BIStatiscialAnalysisController/GetDepartmentCompletionSort",
      payload: json,
      onlyData: false,
      onComplete: (data) => {
        if (data && data.IsSuccessful) {
          this.teamTop = data.Data.length;
          let teamName = [];
          let finishQty = [];
          data.Data.forEach((item) => {
            teamName.push(item.TEAM_NAME);
            let finishData = Number(item.CALC * 100).toFixed(2);
            finishQty.push(finishData);
          });
          let departmentCompletions = document.getElementById("workTicket");
          if (departmentCompletions) {
            let myChart = echarts.init(departmentCompletions);
            myChart.setOption(
              {
                tooltip: {
                  trigger: "axis",
                  axisPointer: {
                    // 坐标轴指示器，坐标轴触发有效
                    type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
                  },
                  formatter: function (param) {
                    return (
                      param[0].name +
                      "<br>" +
                      param[0].marker +
                      " " +
                      param[0].seriesName +
                      "：" +
                      param[0].value +
                      "%"
                    );
                  },
                },
                grid: {
                  top: "2%",
                  bottom: -15,
                  right: "10%",
                  left: "10%",
                  containLabel: true,
                },
                xAxis: {
                  show: false,
                },
                yAxis: [
                  {
                    triggerEvent: true,
                    show: true,
                    inverse: true,
                    data: teamName,
                    axisLine: {
                      show: false,
                    },
                    splitLine: {
                      show: false,
                    },
                    axisTick: {
                      show: false,
                    },
                    axisLabel: {
                      interval: 0,
                      color: "#666",
                      align: "right",
                      margin: 20,
                      fontSize: 13,

                      rich: {
                        idx0: {
                          color: "#FB375E",
                          backgroundColor: "#FFE8EC",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx1: {
                          color: "#FF9023",
                          backgroundColor: "#FFEACF",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx2: {
                          color: "#01B599",
                          backgroundColor: "#E1F7F3",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx: {
                          color: "#333",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        title: {
                          width: 165,
                        },
                      },
                    },
                  },
                  {
                    triggerEvent: true,
                    show: true,
                    inverse: true,
                    data: finishQty,
                    axisLine: {
                      show: false,
                    },
                    splitLine: {
                      show: false,
                    },
                    axisTick: {
                      show: false,
                    },
                    axisLabel: {
                      interval: 0,
                      color: "#666",
                      align: "left",
                      margin: 20,
                      fontSize: 12,
                      formatter: function (value) {
                        return value + "%";
                      },
                    },
                  },
                ],
                series: [
                  {
                    name: "完成率",
                    type: "bar",
                    yAxisIndex: 0,
                    data: finishQty,
                    barWidth: 10,
                    itemStyle: {
                      color: "#1990FF",
                      barBorderRadius: 30,
                    },
                    formatter: "{value}%",
                  },
                ],
              },
              true
            );
          }
        }
      },
    });
  };
  workTicket2 = () => {
    let json = initFilter(this.props.login.OrgId, "30", "NUM", "asc");
    // extendRule(json, "DEPARTMENT_NAME", 1,"选矿部");
    this.props.dispatch({
      type: "app/getDataByPost",
      url: "BI/BIStatiscialAnalysisController/GetDepartmentCompletionSort",
      payload: json,
      onlyData: false,
      onComplete: (data) => {
        if (data && data.IsSuccessful) {
          this.teamTop = data.Data.length;
          let teamName = [];
          let finishQty = [];
          data.Data.forEach((item) => {
            teamName.push(item.TEAM_NAME);
            let finishData = Number(item.CALC * 100).toFixed(2);
            finishQty.push(finishData);
          });
          let departmentCompletions = document.getElementById("workTicket2");
          if (departmentCompletions) {
            let myChart = echarts.init(departmentCompletions);
            myChart.setOption(
              {
                tooltip: {
                  trigger: "axis",
                  axisPointer: {
                    // 坐标轴指示器，坐标轴触发有效
                    type: "shadow", // 默认为直线，可选为：'line' | 'shadow'
                  },
                  formatter: function (param) {
                    return (
                      param[0].name +
                      "<br>" +
                      param[0].marker +
                      " " +
                      param[0].seriesName +
                      "：" +
                      param[0].value +
                      "%"
                    );
                  },
                },
                grid: {
                  top: "2%",
                  bottom: -15,
                  right: "10%",
                  left: "10%",
                  containLabel: true,
                },
                xAxis: {
                  show: false,
                },
                yAxis: [
                  {
                    triggerEvent: true,
                    show: true,
                    inverse: true,
                    data: teamName,
                    axisLine: {
                      show: false,
                    },
                    splitLine: {
                      show: false,
                    },
                    axisTick: {
                      show: false,
                    },
                    axisLabel: {
                      interval: 0,
                      color: "#666",
                      align: "right",
                      margin: 20,
                      fontSize: 13,

                      rich: {
                        idx0: {
                          color: "#FB375E",
                          backgroundColor: "#FFE8EC",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx1: {
                          color: "#FF9023",
                          backgroundColor: "#FFEACF",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx2: {
                          color: "#01B599",
                          backgroundColor: "#E1F7F3",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        idx: {
                          color: "#333",
                          borderRadius: 100,
                          padding: [5, 8],
                        },
                        title: {
                          width: 165,
                        },
                      },
                    },
                  },
                  {
                    triggerEvent: true,
                    show: true,
                    inverse: true,
                    data: finishQty,
                    axisLine: {
                      show: false,
                    },
                    splitLine: {
                      show: false,
                    },
                    axisTick: {
                      show: false,
                    },
                    axisLabel: {
                      interval: 0,
                      color: "#666",
                      align: "left",
                      margin: 20,
                      fontSize: 12,
                      formatter: function (value) {
                        return value + "%";
                      },
                    },
                  },
                ],
                series: [
                  {
                    name: "完成率",
                    type: "bar",
                    yAxisIndex: 0,
                    data: finishQty,
                    barWidth: 10,
                    itemStyle: {
                      color: "#1990FF",
                      barBorderRadius: 30,
                    },
                    formatter: "{value}%",
                  },
                ],
              },
              true
            );
          }
        }
      },
    });
  };

  //关键许可工作票（饼图）
  mainJobPie2 = () => {
    let json = initFilter(this.props.login.OrgId);
    this.props.dispatch({
      type: "app/getDataByPost",
      url: "BI/BIStatiscialAnalysisController/GetLicenseJob",
      payload: json,
      onlyData: false,
      onComplete: (data) => {
        if (data && data.IsSuccessful) {
          let riskLevel = [];
          let showData = [];
          let color = ["#C00000", "#FFC000", "#FFFF00", "#00B0F0", "#00B0C0"];
          data.Data.forEach((item) => {
            riskLevel.push(item.RISK_LEVEL);
            showData.push({ value: item.COUNT, name: item.RISK_LEVEL });
          });
          let riskLevels = document.getElementById("mainJobPie2");
          if (riskLevels) {
            let myChart = echarts.init(riskLevels);
            myChart.setOption({
              color: ["#c92a2a", "#ffa94d", "#ffe066", "#4285F4", "#fa8a89"],
              title: [
                {
                  text: "6270",
                  x: "24%",
                  y: "40%",
                  textStyle: {
                    fontSize: 26,
                    fontWeight: "normal",
                    color: ["#333"],
                  },
                },
                {
                  text: "关键作业/许可作业",
                  x: "20%",
                  y: "55%",
                  textStyle: {
                    color: "#666",
                    fontSize: 12,
                  },
                },
              ],
              tooltip: {
                trigger: "item",
                formatter: "{b}:({d}%)",
              },
              legend: {
                icon: "pin",
                orient: "vartical",
                // x: "right",
                // top: "18%",
                x: "60%",
                y: "center",
                // bottom: "20%",
                data: riskLevel,
                // itemWidth: 20,
                // itemHeight: 14,
                itemGap: 25,
                formatter: function (name) {
                  //通过name获取到数组对象中的单个对象
                  let singleData = showData.filter(function (item) {
                    return item.name == name;
                  });
                  let countAll = 0;
                  showData.map((item) => {
                    countAll = countAll + item.value;
                  });

                  return (
                    name +
                    "  |  " +
                    singleData[0].value +
                    "   |   " +
                    Number((singleData[0].value / countAll) * 100).toFixed(2) +
                    "%"
                  );
                },
              },
              grid: {
                left: 30,
                containLabel: true,
                bottom: 10,
                top: 10,
                right: 30,
              },
              series: [
                {
                  name: "访问来源",
                  type: "pie",
                  clockwise: false,
                  // minAngle: 20,
                  avoidLabelOverlap: false,
                  radius: ["50%", "65%"],
                  center: ["30%", "50%"],
                  itemStyle: {
                    //图形样式
                    normal: {
                      borderColor: "#ffffff",
                      borderWidth: 4,
                      padding: "0 20px",
                      borderRadius: 50,
                    },
                  },
                  label: {
                    show: false,
                  },
                  // color: color,
                  data: showData,
                },
              ],
            });
          }
        }
      },
    });
  };
  compare = (val1, val2) => {
    return val2.NUM - val1.NUM;
  };
  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();
  };
  render() {
    return (
      <div>
        {/* className='route-home' ,boxShadow:'inset 0 0 10px #ccc' */}
        <div
          style={{
            backgroundColor: "white",
            width: "1200px",
            top: "0",
            bottom: "0",
            left: "0",
            right: "0",
            margin: "auto",
            borderStyle: "solid",
            borderColor: "#ccc",
            borderWidth: "1px",
          }}
        >
          <Modal
            visible={this.state.visible}
            title={this.state.noticeTitle}
            maskClosable={false}
            onCancel={this.handleCancel}
            footer={null}
            className="antd-modal-fullscreen"
            closeModal={this.closeModal}
            // forceRender={true}
          >
            <FormPage {...this.state.tmpData} />
          </Modal>
          {/* {this.props.data.name} */}
          <h1
            style={{
              textAlign: "center",
              marginTop: "30px",
              fontWeight: "bold",
            }}
          >
            行洛坑钨矿-作业现场管理统计分析
          </h1>
          <br></br>
          <div
            style={{
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
              marginTop: "20px",
              //   marginBottom: "20px",
            }}
          >
            <div className={styles.menuPie}>
              <li>
                一般作业活动记录
                <br />
                <div className={styles.dataStyle}>
                  {this.state.ordinaryCount}
                </div>
              </li>
              <Divider
                type="vertical"
                style={{ width: "1px", height: "70px", margin: "9px 0px" }}
              />
              <li>
                许可作业活动记录
                <br />
                <div className={styles.dataStyle1}>
                  {this.state.crucialCount}
                </div>
              </li>
              <Divider
                type="vertical"
                style={{ width: "1px", height: "70px", margin: "9px 0px" }}
              />
              <li>
                班组安全活动
                <br />
                <div className={styles.dataStyle3}>
                  {this.state.activityCount}
                </div>
              </li>
              <Divider
                type="vertical"
                style={{ width: "1px", height: "70px", margin: "9px 0px" }}
              />
              <li>
                岗位当班记录
                <br />
                <div className={styles.dataStyle2}>{this.state.postCount}</div>
                {/* <a href="#" style={{ color: "red" }}> */}
                {/* </a> */}
              </li>
              <Divider
                type="vertical"
                style={{ width: "1px", height: "70px", margin: "9px 0px" }}
              />
              <li>
                岗位交接班记录
                <br />
                <div className={styles.dataStyle3}>
                  {this.state.postChangeCount}
                </div>
                {/* <a href="#" style={{ color: "red" }}> */}
                {/* </a> */}
              </li>
              <Divider
                type="vertical"
                style={{ width: "1px", height: "70px", margin: "9px 0px" }}
              />
              <li>
                作业任务库
                <br />
                <div className={styles.dataStyle3}>{this.state.taskCount}</div>
              </li>
            </div>
          </div>
          <hr
            style={{
              border: "1px dashed #ccc",
              marginBottom: "20px",
              marginTop: "20px",
            }}
          ></hr>
          <Row
            style={{
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <div
              style={{
                display: "flex",
                justifyContent: "space-around",
                alignItems: "center",
                width: "1100px",
              }}
            >
              <Col span={12}>
                <Col span={8}>
                  <div
                    id="mainJobPie"
                    style={{ width: "100%", height: "350px" }}
                  ></div>
                </Col>
                <Col span={8}>
                  <div
                    id="mainJobPie1"
                    style={{ width: "100%", height: "350px" }}
                  ></div>
                </Col>
                <Col span={8}>
                  <div
                    id="mainJobPie3"
                    style={{ width: "100%", height: "350px" }}
                  ></div>
                </Col>
              </Col>

              <Col span={12}>
                <div
                  id="mainJobPie2"
                  style={{ width: "100%", height: "350px" }}
                ></div>
              </Col>
            </div>
          </Row>
          <hr
            style={{
              border: "1px dashed #ccc",
              marginBottom: "20px",
              marginTop: "20px",
            }}
          ></hr>
          <Row
            style={{
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
            }}
          >
            <div
              style={{
                display: "flex",
                justifyContent: "space-around",
                alignItems: "center",
                width: "1100px",
              }}
            >
              <Col span={12} style={{ borderRight: "1px solid #e7e6e4" }}>
                <h3 style={{ textAlign: "center", fontWeight: "bold" }}>
                  矿山部-班组及时完成率排名(%)
                </h3>
                <div
                  id="workTicket2"
                  style={{
                    height: "350px",
                    // marginLeft: "40px",
                    // marginRight: "10px",
                    backgroundColor: "white",
                  }}
                ></div>
              </Col>
              <Col span={12}>
                <h3 style={{ textAlign: "center", fontWeight: "bold" }}>
                  选矿部-班组及时完成率排名(%)
                </h3>
                <div
                  id="workTicket"
                  style={{
                    height: "350px",
                    // marginLeft: "40px",
                    // marginRight: "10px",
                    backgroundColor: "white",
                  }}
                ></div>
              </Col>
            </div>
            {/* <Col span={11}>
              <h3 style={{ textAlign: "center", fontWeight: "bold" }}>
                关键作业/许可作业
              </h3>
              <div
                id="mainJobPie2"
                style={{
                  width: "560px",
                  height: "350px",
                  marginLeft: "20px",
                  backgroundColor: "white",
                  borderStyle: "solid",
                  borderColor: "#ccc",
                  borderWidth: "1px",
                }}
              ></div>
            </Col> */}
          </Row>
          <hr
            style={{
              border: "1px dashed #ccc",
              marginBottom: "20px",
              marginTop: "20px",
            }}
          ></hr>
          <Row
            style={{
              display: "flex",
              alignItems: "center",
              justifyContent: "center",
              margin: "10px 0px",
            }}
          >
            <div
              style={{
                display: "flex",
                justifyContent: "space-around",
                alignItems: "center",
                width: "1000px",
              }}
            >
              <Table
                style={{
                  width: "100%",
                  // marginLeft: "20px",
                  textAlign: "center",
                }}
                // scroll={{ y: 400 }}
                dataSource={this.state.retData}
                columns={this.state.columns}
                pagination={false}
                loading={false}
                size="small"
                bordered
              />
            </div>
          </Row>
        </div>
      </div>
    );
  }
}
export default connect(({ login, app }) => ({ login, app }))(
  BI009FormRunAnalysis
);
