import BlueTable from '@/components/BlueTable';
import { useGlobalModalServices } from '@/pages/GlobalModalServices/provider';
import services from '@/services';
import { useRequest } from 'ahooks';
import { useMemo, useState } from 'react';
import Loading from '../../components/Loading';

const AiPatrol = (props: any) => {
  const [fetchParams, setFetchParams] = useState<any>({
    page: 1,
    count: 10,
  });
  const { dispatch } = useGlobalModalServices();

  const { data, loading } = useRequest(
    () => services.DealQuery.getMovementSensorEventList(fetchParams),
    {
      refreshDeps: [fetchParams],
    },
  );

  const columns = useMemo(() => {
    return [
      {
        title: '事件大类',
        dataIndex: 'largeCategoryName',
        key: 'largeCategoryName',
        width: 180,
        ellipsis: true,
      },
      {
        title: '事件大类Code',
        dataIndex: 'largeCategoryCode',
        key: 'largeCategoryCode',
        width: 150,
        ellipsis: true,
      },
      {
        title: '事件小类',
        dataIndex: 'smallCategoryName',
        key: 'smallCategoryName',
        width: 180,
        ellipsis: true,
      },
      {
        title: '事件小类Code',
        dataIndex: 'smallCategoryCode',
        key: 'smallCategoryCode',
        width: 150,
        ellipsis: true,
      },
      {
        title: '上报时间',
        dataIndex: 'reportTime',
        key: 'reportTime',
        width: 180,
        ellipsis: true,
      },
      {
        title: '事件地址',
        dataIndex: 'address',
        key: 'address',
        width: 250,
        ellipsis: true,
      },
      {
        title: '描述',
        dataIndex: 'description',
        key: 'description',
        width: 350,
        ellipsis: true,
      },
      // {
      //   title: '处罚决定日期',
      //   dataIndex: 'cfjdrq',
      //   key: 'cfjdrq',
      //   width: 150,
      //   ellipsis: true,
      // },
      {
        title: '操作',
        dataIndex: 'c',
        key: 'dictdldj_name',
        width: 100,
        ellipsis: true,
        render: (val: string, record: any) => {
          return (
            <div
              onClick={() => {
                dispatch.push('AiPatrolDetail', {
                  props: {
                    data: record,
                  },
                });
              }}
              style={{
                color: 'rgb(36, 164, 255)',
                fontSize: 20,
                fontWeight: 700,
                cursor: 'pointer',
              }}
            >
              详情
            </div>
          );
        },
      },
    ];
  }, [data]);
  return (
    <div>
      <Loading loading={loading}>
        <BlueTable
          //   dataSource={tableData?.data?.data?.records}
          dataSource={data?.data?.items || []}
          columns={columns}
          scroll={{ x: 1150, y: 600 }}
          rowKey={'2025021200001990'}
          pagination={{
            total: data?.data?.total,
            current: data?.data.page,
            // pageSize: fetchParams?.count,
            showQuickJumper: false,
            showSizeChanger: false,
            onChange: (page, pageSize) => {
              setFetchParams({
                ...fetchParams,

                page: page,
                count: pageSize,
              });
            },
            //  hideOnSinglePage: true,
          }}
        />
      </Loading>
    </div>
  );
};
export default AiPatrol;
