import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Spin } from "antd";
import { useEffect, useState } from "react";
import SeamlessScroll from "zy-react-library/components/SeamlessScroll";
import tableHeaderBackground from "~/assets/images/public/bigScreen/tablebg1.png";
import tableRowBackground from "~/assets/images/public/bigScreen/tablebg2.png";
import { NS_BI_STATISTICS } from "~/enumerate/namespace";
import Panel from "../../Panel";
import "./index.less";

/** 负责查询并展示各公司隐患整改统计。 */
function RectificationPanel(props) {
  const [list, setList] = useState([]);
  useEffect(() => {
    const loadList = async () => {
      const { data = [] } = await props.getHiddenStatisticsByCorp({
        pageIndex: 1,
        pageSize: 999,
      });
      setList(data);
    };

    loadList();
  }, []);
  return (
    <Panel
      title="当前各公司隐患整改情况"
      className="index-info-left-panel__rectification"
    >
      <Spin spinning={props.biStatistics.getHiddenStatisticsByCorpLoading}>
        <div className="index-info-rectification__table">
          <div
            className="index-info-rectification__header"
            style={{ backgroundImage: `url(${tableHeaderBackground})` }}
          >
            <div>公司名称</div>
            <div>发现隐患数</div>
            <div>整改隐患数</div>
            <div>待整改</div>
            <div>待验收</div>
          </div>
          <div className="index-info-rectification__body">
            <SeamlessScroll list={list} step={0.5}>
              {list.map((item, index) => (
                <div
                  className="index-info-rectification__row"
                  style={{ backgroundImage: `url(${tableRowBackground})` }}
                  key={index}
                >
                  <div>{item.corpName}</div>
                  <div>{item.findHiddenCount}</div>
                  <div>{item.rectifyHiddenCount}</div>
                  <div>{item.waitRectifyHiddenCount}</div>
                  <div>{item.waitAcceptHiddenCount}</div>
                </div>
              ))}
            </SeamlessScroll>
          </div>
        </div>
      </Spin>
    </Panel>
  );
}

export default Connect([NS_BI_STATISTICS], true)(RectificationPanel);
