import { useRef } from "react"; import { Button, Tag } from "antd"; import { DownloadOutlined } from "@ant-design/icons"; import { ProTable, type ProColumns, type ActionType } from "@ant-design/pro-components"; import { useTranslation } from "react-i18next"; import { getCodeLogPage } from "@/api/mdm/coding-system"; import type { CodeLogVO } from "@/types/mdm/coding-system"; import { CODING_SCOPE_OPTIONS } from "@/types/mdm/coding-system"; const TRIGGER_COLORS: Record = { "手动": "blue", "业务模块": "cyan", "事件驱动": "purple", }; const CodeLogPage: React.FC = () => { const { t } = useTranslation("mdm/coding-system"); const actionRef = useRef(null); const columns: ProColumns[] = [ { title: t("codeValue"), dataIndex: "code", ellipsis: true, width: 220, }, { title: t("scope"), dataIndex: "scope", valueType: "select", valueEnum: Object.fromEntries(CODING_SCOPE_OPTIONS.map((s) => [s, { text: s }])), width: 110, }, { title: t("trigger"), dataIndex: "trigger", valueType: "select", valueEnum: { "手动": { text: t("triggerType.手动") }, "业务模块": { text: t("triggerType.业务模块") }, "事件驱动": { text: t("triggerType.事件驱动") } }, width: 100, render: (_, record) => ( {t(`triggerType.${record.trigger}` as Parameters[0])} ), }, { title: t("caller"), dataIndex: "caller", width: 200, search: false, ellipsis: true, }, { title: t("rule"), dataIndex: "ruleCode", width: 160, search: false, }, { title: t("seq"), dataIndex: "seq", width: 80, search: false, render: (_, r) => #{r.seq}, }, { title: t("generateTime"), dataIndex: "time", width: 160, search: { transform: (value) => { if (!Array.isArray(value)) return {}; return { startTime: value[0], endTime: value[1] }; } }, valueType: "dateRange" as const, }, ]; return ( columns={columns} actionRef={actionRef} rowKey="id" headerTitle={t("codeLog")} scroll={{ x: 1100 }} // eslint-disable-next-line @typescript-eslint/no-explicit-any request={async (params: any) => { const { current, pageSize, ...rest } = params; const { data } = await getCodeLogPage({ pageNo: current ?? 1, pageSize: pageSize ?? 10, ...rest, }); return { data: data.list, total: data.total, success: true }; }} pagination={{ defaultPageSize: 10, showSizeChanger: true }} search={{ labelWidth: "auto" }} toolBarRender={() => [ , ]} /> ); }; export default CodeLogPage;