feat: 高级列表

This commit is contained in:
2025-09-13 17:56:13 +08:00
parent e42e1c01fb
commit 9d5a289929
18 changed files with 1301 additions and 6739 deletions

View File

@@ -1,5 +1,109 @@
import EnhancedProTable from "@/components/EnhancedProTable";
import {
getTenantPage,
deleteTenant,
type TenantPageReqVO,
type TenantVO,
} from "@/services/system/tenant/list";
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";
const TenantList = () => {
return <div>TenantList</div>;
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 onFetch = async (
params: TenantPageReqVO & {
pageSize?: number;
current?: number;
}
) => {
const data = await getTenantPage({
pageNo: params.current,
pageSize: params.pageSize,
});
console.log(data);
return {
data: data.list,
success: true,
total: data.total,
};
};
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 toolbarActions = createCommonToolbarActions({
onExport: actions.export,
});
return (
<div>
<EnhancedProTable<TenantVO>
columns={columns}
request={onFetch}
actions={tableActions}
toolbarActions={toolbarActions}
headerTitle="订单管理"
showIndex={false}
// showSelection
showActions
maxActionCount={3}
/>
</div>
);
};
export default TenantList;

View File

@@ -37,8 +37,8 @@ const Page = () => {
const navigate = useNavigate();
// 获取租户 ID
const getTenantId = async (name: string) => {
const res = await getTenantIdByName({ name });
authUtil.setTenantId(res.data);
const data = await getTenantIdByName({ name });
authUtil.setTenantId(data);
};
const fetchUserInfo = async () => {
@@ -69,19 +69,14 @@ const Page = () => {
}
// 调用登录接口
const res = await login(params);
if (res.code === 0) {
// 登录成功
messageApi.success("登录成功!");
// 跳转到首页
authUtil.setToken(res.data);
await fetchUserInfo();
const urlParams = new URL(window.location.href).searchParams;
navigate(urlParams.get("redirect") || "/");
} else {
// 登录失败
messageApi.error(res.msg || "登录失败,请重试!");
}
const data = await login(params);
// 登录成功
messageApi.success("登录成功!");
// 跳转到首页
authUtil.setToken(data);
await fetchUserInfo();
const urlParams = new URL(window.location.href).searchParams;
navigate(urlParams.get("redirect") || "/");
} catch (error) {
messageApi.error("登录失败,请检查网络或稍后重试!");
}