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 PartnerPanel(props) {
  const [list, setList] = useState([]);
  useEffect(() => {
    const loadList = async () => {
      const { data = [] } = await props.getXgfStatisticsListCorpStatistics();
      setList(data);
    };

    loadList();
  }, []);
  return (
    <Panel
      title="相关方单位情况统计"
      className="index-info-right-panel__partner"
    >
      <Spin spinning={props.biStatistics.getXgfStatisticsListCorpStatisticsLoading}>
        <div className="index-info-partner__table">
          <div
            className="index-info-partner__header"
            style={{ backgroundImage: `url(${tableHeaderBackground})` }}
          >
            <div>相关方单位名称</div>
            <div>资质申请情况</div>
            <div>项目执行情况</div>
            <div>执行人员情况</div>
          </div>
          <div className="index-info-partner__body">
            <SeamlessScroll list={list} step={0.5}>
              {list.map((item, index) => (
                <div
                  className="index-info-partner__row"
                  style={{ backgroundImage: `url(${tableRowBackground})` }}
                  key={index}
                >
                  <div>{item.corpName}</div>
                  <div>{`${item.qualificationsPassedCount}/${item.qualificationsApplyCount}`}</div>
                  <div>{`${item.executingProjectCount}/${item.applyProjectCount}`}</div>
                  <div>{`${item.trainingPassedCount}/${item.projectUserCount}`}</div>
                </div>
              ))}
            </SeamlessScroll>
          </div>
        </div>
      </Spin>
    </Panel>
  );
}

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