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

import { useMemo, useState } from 'react';

const AreaSynergyList = (props:any) => {
  const [fetchParams, setFetchParams] = useState<any>({
    pageNo: 0,
    pageSize: 10,
  });


  const { data ,loading} = useRequest(
    () =>
      services.DataBase.getSjdzInfoData({
        typeCode: 'zzcc-sqxt-fylb',
        params: {
          ...fetchParams,
          ...props?.searchTime,
          areaName:props?.areaName,
          caseTitle:props?.eventType,
          isOverdue:props?.isOverdue
        },
      }),
    {
      refreshDeps: [fetchParams],
    },
  );

  
  const { dispatch } = useGlobalModalServices();
  const columns = useMemo(() => {
    return [
      {
        title: '上报时间',
        dataIndex: 'reportTime',
        key: 'reportTime',
        width: 170,
        ellipsis: true,
        render: (text: string) => {
          return text?<span>{dayjs(text).format('YYYY-MM-DD HH:mm:ss')}</span>:'--';
        },
      },
      {
        title: '事件大类',
        dataIndex: 'eventType',
        key: 'eventType',
        width: 150,
        ellipsis: true,
      },
      // {
      //   title: '事件小类',
      //   dataIndex: 'ss',
      //   key: 'descgldw',
      //   width: 150,
      //   ellipsis: true,
      //   render:()=>{
      //     return '--'
      //   }
      // },
      {
        title: '交办部门',
        dataIndex: 'sjly',
        key: 'sjly',
        width: 350,
        ellipsis: true,
      },
      {
        title: '所属区域',
        dataIndex: 'areaName',
        key: 'areaName',
        width: 150,
        ellipsis: true,
      },
      {
        title: '操作',
        dataIndex: 'c',
        key: 'dictdldj_name',
        width: 100,
        ellipsis: true,
        render: (val: string, record: any) => {
          return (
            <div
              onClick={() => {
                dispatch.push('AreaSynergyDetails', {
              
                   props: {
                    dwId:record?.dwId ,
                   
                  },
                });
              }}
              style={{
                color: 'rgb(36, 164, 255)',
                fontSize: 20,
                fontWeight: 700,
                cursor: 'pointer',
              }}
            >
              详情
            </div>
          );
        },
      },
    ];
  }, []);
  return (
    <div>
    <BlueTable
     loading={loading}
      dataSource={data?.data?.data?.records?.[0]?.list || []}
      columns={columns}
      scroll={{ x: 1050, y: 600 }}
      rowKey={'id'}
      pagination={{
        total: data?.data?.data?.records?.[0]?.page?.total,
        pageSize: fetchParams?.pageSize,
        showQuickJumper: false,
        showSizeChanger: false,
        onChange: (page, pageSize) => {
          setFetchParams({
            ...fetchParams,

            pageNo: page - 1,
            pageSize: pageSize,
          });
        },
        //  hideOnSinglePage: true,
      }}
    />
  </div>
  );
};
export default AreaSynergyList;
