import { MyColumns, MyPageContainer, MyProTableProps } from '@/common';
import { Apis } from '@/gen/Apis';
import { ProTable } from '@ant-design/pro-components';

export default function Index({ title = '日志' }) {
  return (
    <MyPageContainer
      title={title}
      enableTabs={true}
      tabKey="workorders"
      tabLabel={title}
    >
      <ProTable<Record<any, any>>
        {...MyProTableProps.props}
        headerTitle="日志列表"
        request={async (params, sort) =>
          MyProTableProps.request(params, sort, Apis.Admin.AdminLogs.List)
        }
        columns={[
          MyColumns.ID({ search: false }),
          {
            title: '员工ID',
            dataIndex: 'company_employees_id',
            hidden: true,
          },
          {
            title: '操作人',
            dataIndex: 'employee_name',
          },
          {
            title: '操作时间',
            dataIndex: 'created_at',
            valueType: 'dateRange',
            hidden: true,
          },
          {
            title: '操作人电话',
            dataIndex: 'employee_phone',
          },
          {
            title: '操作',
            dataIndex: 'action',
            search: false,
            render: (_, item) => {
              return `${item.action}-${item.method_name}`;
            },
          },
          {
            title: '操作内容',
            dataIndex: 'description',
          },
          {
            title: '操作表',
            dataIndex: 'table_name',
            search: false,
          },
          {
            title: '操作路由',
            dataIndex: 'router_name',
          },
          {
            title: '操作电脑IP',
            dataIndex: 'ip_address',
            search: false,
          },
          MyColumns.CreatedAt({ title: '操作时间' }),
        ]}
      />
    </MyPageContainer>
  );
}
