import BlueTable from '@/components/BlueTable';
import { useGlobalModalServices } from '@/pages/GlobalModalServices/provider';
import services from '@/services';
import { useRequest } from 'ahooks';

import { useMemo, useState } from 'react';

const DyaPatrolList = (props: any) => {
  const [fetchParams, setFetchParams] = useState<any>({
    data: {
      pageNo: 1,
      pageSize: 10,
    },
  });
  const { dispatch } = useGlobalModalServices();

  const { data, loading } = useRequest(
    () =>
      services.DataBase.getSjdzInfoData({
        typeCode: 'zzcc-rcxc-fylb',
        params: {
          ...fetchParams,
          ...props?.search,
          ssqy: props?.ssqy,
          bm: props?.bm,
          ...props?.searchTime,
          sbr: props?.sbr,
        },
      }),
    {
      refreshDeps: [fetchParams],
    },
  );
  console.log(data);

  const columns = useMemo(() => {
    return [
      {
        title: '完结时间',
        dataIndex: 'wjsj',
        key: 'wjsj',
        width: 150,
        ellipsis: true,
      },
      {
        title: '问题大类',
        dataIndex: 'wtdl',
        key: 'wtdl',
        width: 150,
        ellipsis: true,
      },
      {
        title: '问题小类',
        dataIndex: 'wtxl',
        key: 'wtxl',
        width: 350,
        ellipsis: true,
      },
      {
        title: '上报部门',
        dataIndex: 'sbbm',
        key: 'sbbm',
        width: 350,
        ellipsis: true,
      },
      {
        title: '所属区域',
        dataIndex: 'ssqy',
        key: 'ssqy',
        width: 150,
        ellipsis: true,
      },
      {
        title: '操作',
        dataIndex: 'c',
        key: 'dictdldj_name',
        width: 100,
        ellipsis: true,
        render: (val: string, record: any) => {
          return (
            <div
              onClick={() => {
                dispatch.push('DyaPatrolDetails', {
                  // title:'行政处罚详情'
                  props: {
                    id: record.zj,
                  },
                });
              }}
              style={{
                color: 'rgb(36, 164, 255)',
                fontSize: 20,
                fontWeight: 700,
                cursor: 'pointer',
              }}
            >
              详情
            </div>
          );
        },
      },
    ];
  }, [data]);
  return (
    <div>
      <BlueTable
        loading={loading}
        dataSource={data?.data?.data?.records?.[0]?.list || []}
        columns={columns}
        scroll={{ x: 1050, y: 600 }}
        pagination={{
          // total: tableData?.data?.data?.page?.total,
          total: data?.data?.data?.records?.[0]?.page?.total,
          showQuickJumper: false,
          showSizeChanger: false,
          onChange: (page, pageSize) => {
            setFetchParams({
              ...fetchParams,
              data: {
                pageNo: page - 1,
                pageSize: pageSize,
              },
            });
          },
          //  hideOnSinglePage: true,
        }}
      />
    </div>
  );
};
export default DyaPatrolList;
