feat: 系统管理
Some checks failed
coverage CI / build (push) Has been cancelled

This commit is contained in:
2025-09-23 16:00:15 +08:00
parent 6d1db25c05
commit 9363dc0d6e
29 changed files with 3227 additions and 123 deletions

View File

@@ -1,25 +1,23 @@
import EnhancedProTable from "@/components/EnhancedProTable";
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { Popconfirm } from 'antd';
import dayjs from 'dayjs';
import React, { useCallback, useRef, useState } from 'react';
import ConfigurableDrawerForm, {
type ConfigurableDrawerFormRef,
} from '@/components/DrawerForm';
import EnhancedProTable from '@/components/EnhancedProTable';
import type { ToolbarAction } from '@/components/EnhancedProTable/types';
import { formStatusType } from '@/constants';
import {
getTenantPage,
createTenant,
deleteTenant,
getTenantPage,
type TenantPageReqVO,
type TenantVO,
deleteTenant,
updateTenant,
} from "@/services/system/tenant/list";
import React, { createContext, useCallback } from "react";
import ConfigurableDrawerForm, {
ConfigurableDrawerFormRef,
} from "@/components/DrawerForm";
import { useRef, useState } from "react";
import { formColumns, baseTenantColumns } from "./config";
import { PlusOutlined } from "@ant-design/icons";
import { ref } from "process";
import { ActionType, ProColumns } from "@ant-design/pro-components";
import { ToolbarAction } from "@/components/EnhancedProTable/types";
import { Modal, Popconfirm } from "antd";
import { formStatusType } from "@/constants";
import dayjs from "dayjs";
} from '@/services/system/tenant/list';
import { baseTenantColumns, formColumns } from './config';
export const waitTimePromise = async (time: number = 90) => {
return new Promise((resolve) => {
setTimeout(() => {
@@ -30,13 +28,13 @@ export const waitTimePromise = async (time: number = 90) => {
const TenantList = () => {
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const tableRef = useRef<ActionType>(null);
const [type, setType] = useState<"create" | "update">("create");
const [type, setType] = useState<'create' | 'update'>('create');
const [id, setId] = useState<number>(0);
const onFetch = async (
params: TenantPageReqVO & {
pageSize?: number;
current?: number;
}
},
) => {
await waitTimePromise();
const data = await getTenantPage({
@@ -53,7 +51,7 @@ const TenantList = () => {
const handleSubmit = useCallback(
async (values: TenantVO) => {
if (type === "create") {
if (type === 'create') {
await createTenant(values);
} else {
await updateTenant({
@@ -65,36 +63,36 @@ const TenantList = () => {
tableRef.current?.reload();
return true;
},
[type]
[type],
);
const handleAdd = () => {
setType("create");
setType('create');
configurableDrawerRef.current?.open({});
};
const handleEdit = (record: TenantVO) => {
setType("update");
setType('update');
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const toolbarActions: ToolbarAction[] = [
{
key: "add",
label: "新建",
type: "primary",
key: 'add',
label: '新建',
type: 'primary',
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<TenantVO> = {
title: "操作",
dataIndex: "option",
valueType: "option",
fixed: "right",
title: '操作',
dataIndex: 'option',
valueType: 'option',
fixed: 'right',
width: 120,
render: (text: React.ReactNode, record: TenantVO, _: any, action: any) => [
render: (_text: React.ReactNode, record: TenantVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
@@ -123,8 +121,6 @@ const TenantList = () => {
headerTitle="租户列表"
showIndex={false}
showSelection={false}
showActions
maxActionCount={3}
/>
<ConfigurableDrawerForm