import DescriptionItem from '@/components/DescriptionItem';
import BaseCard from '@/pages/GlobalModalServices/components/BaseCard';
import { ChildrenModalMethods } from '@/pages/GlobalModalServices/type';
import services from '@/services';
import { useRequest } from 'ahooks';
import { Flex } from 'antd';
import React from 'react';
import styles from './index.less';

/** @name 基本信息 */
const Info: React.FC<{
  modalDispatch: ChildrenModalMethods;
  searchTime: any;
}> = (props) => {
  const { modalDispatch, searchTime } = props;

  //总体统计
  const { data } = useRequest(
    () =>
      services.DataBase.getSjdzInfoData({
        typeCode: 'zzcc-xzcf-fkjezs',
        params: {
          ...searchTime,
        },
      }).then((res) => {
        if (res.code === 200) {
          return res.data.data.records[0];
        }
        throw new Error('获取数据失败');
      }),
    {
      refreshDeps: [searchTime],
    },
  );

  return (
    <BaseCard w={457} h={271} title="总体情况">
      <Flex
        className={styles.item}
        align="center"
        gap={10}
        onClick={() => {
          modalDispatch.push('AdministPunishList', {
            props: {
              searchTime,
            },
          });
        }}
      >
        <img
          src={require('@/assets/images/administPunish/cfIcon.png')}
          alt=""
          className={styles.icon}
        />

        <div className={styles.desc}>
          <DescriptionItem
            direction="horizontal"
            name="行政处罚件数"
            value={data?.cfsl}
            unit="件"
          ></DescriptionItem>
        </div>
      </Flex>
      <Flex
        className={styles.item}
        onClick={() => {
          modalDispatch.push('AdministPunishList', {
            props: {
              searchTime,
            },
          });
        }}
        gap={10}
        align="center"
      >
        <img
          src={require('@/assets/images/administPunish/fkIcon.png')}
          alt=""
          className={styles.icon}
        />
        <div className={styles.desc}>
          <DescriptionItem
            direction="horizontal"
            name="罚款金额"
            value={data?.fkze / 1000}
            unit="万元"
            decimals={2}
          ></DescriptionItem>
        </div>
      </Flex>
    </BaseCard>
  );
};

export default Info;
