feat: menu

This commit is contained in:
2025-09-17 10:41:00 +08:00
parent 9d5a289929
commit aada97ed22
27 changed files with 973 additions and 527 deletions

View File

@@ -0,0 +1,5 @@
const SyStemDept = () => {
return <>SyStemDept</>;
};
export default SyStemDept;

View File

@@ -0,0 +1,5 @@
const SyStemDict = () => {
return <>SyStemDict</>;
};
export default SyStemDict;

View File

@@ -0,0 +1,5 @@
const SyStemLogLogin = () => {
return <>SyStemLogLogin</>;
};
export default SyStemLogLogin;

View File

@@ -0,0 +1,5 @@
const SyStemLogOperate = () => {
return <>SyStemLogOperate</>;
};
export default SyStemLogOperate;

View File

@@ -0,0 +1,5 @@
const SyStemMenu = () => {
return <>SyStemMenu</>;
};
export default SyStemMenu;

View File

@@ -0,0 +1,5 @@
const SyStemPost = () => {
return <>SyStemPost</>;
};
export default SyStemPost;

View File

@@ -0,0 +1,5 @@
const SyStemRole = () => {
return <>SyStemRole</>;
};
export default SyStemRole;

View File

@@ -0,0 +1,223 @@
import { type TenantVO, deleteTenant } from "@/services/system/tenant/list";
import { ProColumns } from "@ant-design/pro-components";
import { DatePicker, Modal, Popconfirm } from "antd";
import { FormInstance } from "antd/lib";
import dayjs from "dayjs";
export const baseTenantColumns: ProColumns<TenantVO>[] = [
{
title: "租户编号",
dataIndex: "id",
tip: "租户编号",
width: 100,
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: "租户名",
dataIndex: "name",
tip: "租户名", // 提示信息
},
{
title: "租户套餐",
dataIndex: "packageId",
valueType: "select",
request: async () => {
return [
{
label: "默认套餐",
value: 1,
},
];
},
// valueEnum: {
// all: { text: "全部", status: "Default" },
// open: { text: "未解决", status: "Error" },
// closed: { text: "已解决", status: "Success" },
// },
},
{
title: "联系人",
dataIndex: "contactName",
},
{
title: "联系手机",
dataIndex: "contactMobile",
},
{
title: "账号额度",
dataIndex: "accountCount",
hideInSearch: true, // 在搜索表单中隐藏
},
{
title: "过期时间",
dataIndex: "expireTime",
valueType: "dateTime",
hideInSearch: true, // 在搜索表单中隐藏
},
{ title: "绑定域名", dataIndex: "website", width: 100 },
{
title: "租户状态",
dataIndex: "status",
valueType: "select",
valueEnum: {
all: { text: "全部", status: "Default" },
open: { text: "未解决", status: "Error" },
closed: { text: "已解决", status: "Success" },
},
},
{
title: "创建时间",
dataIndex: "createTime",
valueType: "dateRange",
search: {
transform: (value) => {
return [`${value[0]} 00:00:00`, `${value[1]} 00:00:00`];
},
},
render: (_, record: TenantVO) =>
dayjs(record.createTime).format("YYYY-MM-DD HH:mm:ss"),
},
];
export const formColumns: any = [
{
title: "租户名",
dataIndex: "name",
tip: "租户名", // 提示信息
formItemProps: {
rules: [
{
required: true,
message: "请输入用户名",
},
// {
// min: 2,
// max: 20,
// message: "用户名长度为2-20个字符",
// },
],
},
},
{
title: "租户套餐",
dataIndex: "packageId",
valueType: "select",
formItemProps: {
rules: [
{
required: true,
message: "请选择租户套餐",
},
],
},
fieldProps: {
placeholder: "请选择套餐类型",
options: [
{
label: "普通套餐",
value: 111,
},
],
},
},
{
title: "联系人",
dataIndex: "contactName",
},
{
title: "联系手机",
dataIndex: "contactMobile",
formItemProps: {
rules: [
{
required: true,
message: "请输入联系手机",
},
],
},
},
{
title: "用户名称",
dataIndex: "username",
hideInForm: true,
formItemProps: {
rules: [
{
required: true,
message: "请输入用户名称",
},
{
pattern: /^[a-zA-Z0-9]+$/,
message: "用户账号由 0-9、a-z、A-Z 组成",
},
// 用户账号由 数字、字母组成
],
},
},
{
title: "用户密码",
dataIndex: "password",
valueType: "password",
hideInForm: true,
fieldProps: {
placeholder: "请输入用户密码",
autoComplete: "new-password",
},
formItemProps: {
rules: [
{
required: true,
message: "请输入用户密码",
},
{
min: 4,
max: 16,
message: "密码长度为4-16个字符",
},
],
},
},
{
title: "账号额度",
dataIndex: "accountCount",
valueType: "digit",
},
{
title: "过期时间",
dataIndex: "expireTime",
valueType: "date",
fieldProps: {
placeholder: "请选择过期时间",
format: "YYYY-MM-DD",
},
},
{ title: "绑定域名", dataIndex: "website" },
{
title: "租户状态",
dataIndex: "status",
valueType: "radio",
formItemProps: {
rules: [
{
required: true,
message: "请选择租户状态",
},
],
},
fieldProps: {
placeholder: "请选择套餐类型",
options: [
{
label: "启用",
value: 1,
},
{
label: "禁用",
value: 0,
},
],
},
},
];

View File

@@ -1,68 +1,49 @@
import EnhancedProTable from "@/components/EnhancedProTable";
import {
getTenantPage,
deleteTenant,
createTenant,
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 {
ProCoreActionType,
ProTable,
TableDropdown,
type ProColumns,
} from "@ant-design/pro-components";
import { Button, Space } from "antd";
import {
createOrderTableConfig,
createCommonActions,
createCommonToolbarActions,
} from "@/utils/antd/tableConfigFactory";
import { useEnhancedTable } from "@/hooks/antd/useEnhancedTable";
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";
export const waitTimePromise = async (time: number = 90) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true);
}, time);
});
};
const TenantList = () => {
const columns: ProColumns<TenantVO>[] = [
{
title: "租户编号",
dataIndex: "id",
tip: "租户编号",
},
{
title: "租户名",
dataIndex: "name",
ellipsis: true, // 超长省略
tip: "租户名", // 提示信息
},
{
title: "状态",
dataIndex: "status",
valueType: "select",
valueEnum: {
all: { text: "全部", status: "Default" },
open: { text: "未解决", status: "Error" },
closed: { text: "已解决", status: "Success" },
},
},
{
title: "创建时间",
dataIndex: "created_at",
valueType: "dateTime",
hideInSearch: true, // 在搜索表单中隐藏
},
];
const configurableDrawerRef = useRef<ConfigurableDrawerFormRef>(null);
const tableRef = useRef<ActionType>(null);
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({
...params,
pageNo: params.current,
pageSize: params.pageSize,
});
console.log(data);
return {
data: data.list,
success: true,
@@ -70,39 +51,89 @@ const TenantList = () => {
};
};
const { actionRef, selectedRowKeys, selectedRows, actions } =
useEnhancedTable<TenantVO>({
onEdit: (record) => {
console.log("编辑订单:", record);
},
onDelete: async (record) => {
await deleteTenant(record.id);
return true;
},
});
const tableActions = createCommonActions<TenantVO>({
onView: actions.view,
onEdit: actions.edit,
onDelete: actions.delete,
});
const handleSubmit = useCallback(
async (values: TenantVO) => {
if (type === "create") {
await createTenant(values);
} else {
await updateTenant({
...values,
id,
expireTime: dayjs(values.expireTime).valueOf(),
});
}
tableRef.current?.reload();
return true;
},
[type]
);
const toolbarActions = createCommonToolbarActions({
onExport: actions.export,
});
const handleAdd = () => {
setType("create");
configurableDrawerRef.current?.open({});
};
const handleEdit = (record: TenantVO) => {
setType("update");
setId(record.id);
configurableDrawerRef.current?.open(record);
};
const toolbarActions: ToolbarAction[] = [
{
key: "add",
label: "新建",
type: "primary",
icon: <PlusOutlined />,
onClick: handleAdd,
},
];
const actionColumns: ProColumns<TenantVO> = {
title: "操作",
dataIndex: "option",
valueType: "option",
fixed: "right",
width: 120,
render: (text: React.ReactNode, record: TenantVO, _: any, action: any) => [
<a key="editable" onClick={() => handleEdit(record)}>
</a>,
<Popconfirm
title="是否删除?"
key="delete"
onConfirm={async () => {
await deleteTenant(record.id);
action?.reload();
}}
okText="是"
cancelText="否"
>
<a></a>
</Popconfirm>,
],
};
const columns = [...baseTenantColumns, actionColumns];
return (
<div>
<>
<EnhancedProTable<TenantVO>
ref={tableRef}
columns={columns}
request={onFetch}
actions={tableActions}
toolbarActions={toolbarActions}
headerTitle="订单管理"
headerTitle="租户列表"
showIndex={false}
// showSelection
showSelection={false}
showActions
maxActionCount={3}
/>
</div>
<ConfigurableDrawerForm
ref={configurableDrawerRef}
title={formStatusType[type]}
columns={formColumns}
onSubmit={handleSubmit}
/>
</>
);
};

View File

@@ -0,0 +1,5 @@
const SyStemUser = () => {
return <>SyStemUser</>;
};
export default SyStemUser;