import { useRef, useState } from "react"; import { Badge, Button, Modal, Space, Tag, Tabs, Descriptions } from "antd"; import { ProTable, type ProColumns, type ActionType } from "@ant-design/pro-components"; import { useTranslation } from "react-i18next"; import { getApprovalPage } from "@/api/mdm/coding-system"; import type { ApprovalVO } from "@/types/mdm/coding-system"; const ApprovalPage: React.FC = () => { const { t } = useTranslation("mdm/coding-system"); const { t: tc } = useTranslation("common"); const actionRef = useRef(null); const [tab, setTab] = useState("pending"); const [detailModal, setDetailModal] = useState(null); const getColumns = (): ProColumns[] => [ { title: t("approvalType"), dataIndex: "type", width: 80, render: (_, r) => { const colors: Record = { "准入": "blue", "变更": "orange", "注销": "red" }; return {r.type}; }, }, { title: t("applicant"), dataIndex: "applicant", width: 80, search: false, }, { title: t("ruleCode"), dataIndex: "ruleCode", width: 150, }, { title: t("ruleName"), dataIndex: "ruleName", ellipsis: true, width: 180, }, { title: t("submitTime"), dataIndex: "submitTime", width: 150, search: false, }, { title: t("status"), dataIndex: "status", width: 80, render: (_, r) => { const colors: Record = { "待审批": "warning", "已通过": "success", "已拒绝": "error" }; return {r.status}; }, }, { title: t("approver"), dataIndex: "approver", width: 80, search: false, }, { title: t("approveTime"), dataIndex: "approveTime", width: 150, search: false, }, { title: tc("operation"), key: "action", fixed: "right" as const, search: false, width: tab === "pending" ? 180 : 100, render: (_, record) => ( {tab === "pending" && ( <> )} ), }, ]; return ( <> {t("pendingApproval")}{" "} ), children: ( columns={getColumns()} actionRef={actionRef} rowKey="id" headerTitle={t("approvalList")} scroll={{ x: 1200 }} // eslint-disable-next-line @typescript-eslint/no-explicit-any request={async (params: any) => { const { current, pageSize } = params; const { data } = await getApprovalPage({ pageNo: current ?? 1, pageSize: pageSize ?? 10, tab: "pending", }); return { data: data.list, total: data.total, success: true }; }} pagination={{ defaultPageSize: 10 }} search={false} /> ), }, { key: "processed", label: t("processed"), children: ( columns={getColumns()} actionRef={actionRef} rowKey="id" headerTitle={t("approvalList")} scroll={{ x: 1200 }} // eslint-disable-next-line @typescript-eslint/no-explicit-any request={async (params: any) => { const { current, pageSize } = params; const { data } = await getApprovalPage({ pageNo: current ?? 1, pageSize: pageSize ?? 10, tab: "processed", }); return { data: data.list, total: data.total, success: true }; }} pagination={{ defaultPageSize: 10 }} search={false} /> ), }, { key: "submitted", label: t("submitted"), children: ( columns={getColumns()} actionRef={actionRef} rowKey="id" headerTitle={t("approvalList")} scroll={{ x: 1200 }} // eslint-disable-next-line @typescript-eslint/no-explicit-any request={async (params: any) => { const { current, pageSize } = params; const { data } = await getApprovalPage({ pageNo: current ?? 1, pageSize: pageSize ?? 10, tab: "submitted", }); return { data: data.list, total: data.total, success: true }; }} pagination={{ defaultPageSize: 10 }} search={false} /> ), }, ]} /> {detailModal && ( setDetailModal(null)} width={640} footer={} > {detailModal.type} {detailModal.applicant} {detailModal.ruleCode} {detailModal.ruleName} {detailModal.submitTime} {detailModal.status} {detailModal.status !== "待审批" && ( <> {detailModal.approver} {detailModal.approveTime} {detailModal.comment} )} )} ); }; export default ApprovalPage;