Please enter the commit message for your changes. Lines starting

with '#' will be ignored, and an empty message aborts the commit.

On branch develop
Your branch is ahead of 'goflyapp/develop' by 1 commit.
  (use "git push" to publish your local commits)

Changes to be committed:
	new file:   zlt-business/user-center/src/main/java/com/central/user/config/TenantConfiguration.java
	new file:   zlt-business/user-center/src/main/java/com/central/user/controller/SysTenantController.java
	modified:   zlt-business/user-center/src/main/java/com/central/user/mapper/SysTenantMapper.java
	modified:   zlt-business/user-center/src/main/java/com/central/user/model/SysTenant.java
	new file:   zlt-business/user-center/src/main/java/com/central/user/service/ISysTenantService.java
	new file:   zlt-business/user-center/src/main/java/com/central/user/service/impl/SysTenantServiceImpl.java
	new file:   zlt-business/user-center/src/main/java/com/central/user/service/impl/TenantInitServiceImpl.java
	modified:   zlt-business/user-center/src/main/resources/application.yml
	new file:   zlt-business/user-center/src/main/resources/mapper/SysTenantMapper.xml
	modified:   zlt-commons/zlt-common-core/src/main/java/com/central/common/properties/TenantProperties.java
	modified:   zlt-web/react-web/src/main/frontend/config/routes.ts
	new file:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/components/UpdateForm.less
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/components/UpdateForm.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/constants.ts
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.less
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/types.ts
	new file:   zlt-web/react-web/src/main/frontend/src/pages/system/Tenant/components/CreateForm.tsx
	new file:   zlt-web/react-web/src/main/frontend/src/pages/system/Tenant/components/UpdateForm.tsx
	new file:   zlt-web/react-web/src/main/frontend/src/pages/system/Tenant/index.tsx
	modified:   zlt-web/react-web/src/main/frontend/src/services/system/api.ts
	modified:   zlt-web/react-web/src/main/frontend/src/services/system/typings.d.ts
This commit is contained in:
2025-04-10 17:16:01 +08:00
parent 4859929595
commit 946e033545
22 changed files with 1179 additions and 182 deletions
@@ -24,6 +24,10 @@
path: '/system/role.html',
component: './system/Role',
},
{
path: '/system/tenant.html',
component: './system/Tenant',
},
{
path: '/system/tokens.html',
component: './system/Token',
@@ -0,0 +1,68 @@
.auditModal {
:global {
.ant-modal-body {
padding: 24px;
}
}
}
.orderInfo {
margin-bottom: 24px;
:global {
.ant-descriptions {
background: #fafafa;
border-radius: 4px;
}
.ant-descriptions-item-label {
width: 100px;
background: #f5f5f5;
font-weight: 500;
}
.ant-descriptions-item-content {
background: #fff;
}
}
}
.formContent {
padding: 16px 0;
:global {
.ant-form-item-label {
font-weight: 500;
}
}
}
.codeText {
font-family: 'Roboto Mono', monospace;
color: #1890ff;
}
.amount {
font-family: 'Roboto Mono', monospace;
color: #262626;
font-weight: 500;
}
.selectField {
width: 100%;
:global {
.ant-select-selector {
border-radius: 4px !important;
}
}
}
.textArea {
border-radius: 4px;
resize: none;
&:hover, &:focus {
border-color: #1890ff;
}
}
@@ -2,80 +2,97 @@ import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import { useEffect } from 'react';
import { Typography, Descriptions, Space, Tag } from 'antd';
import React from 'react';
import { ORDER_STATUS, REFUND_STATUS } from '../constants';
import styles from './UpdateForm.less';
export type FormValueType = Partial<ORDERS.Refund>;
const { Text } = Typography;
export type UpdateFormProps = {
onVisibleChange: (flag: boolean) => void;
onSubmit: (values: FormValueType) => Promise<void>;
interface UpdateFormProps {
onSubmit: (values: any) => Promise<void>;
onVisibleChange: (visible: boolean) => void;
updateModalVisible: boolean;
values?: ORDERS.Refund;
values?: any;
}
// 金额转换:分转元
const formatAmount = (amount?: string | number | null) => {
if (!amount && amount !== 0) return '-';
return `¥ ${(Number(amount) / 100).toFixed(2)}`;
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const [form] = Form.useForm();
const { values } = props;
useEffect(() => {
form.setFieldsValue(values);
}, [form, values]);
return (
<ModalForm
title="退款审核"
form={form}
width={600}
visible={props.updateModalVisible}
onFinish={props.onSubmit}
onVisibleChange={props.onVisibleChange}
onFinish={props.onSubmit}
modalProps={{
destroyOnClose: true,
className: styles.auditModal
}}
>
<ProForm.Group>
<ProFormText
readonly = {true}
width="md"
name="orderNo"
label="订单编号"
/>
<ProFormText
readonly={true}
width="md"
name="refundNo"
label="退款编号"
/>
<ProFormText
rules={[
{
required: true,
message: '审核理由不为空',
},
]}
width="md"
name="approveReason"
label="审核理由"
placeholder="输入审核理由"
/>
<div className={styles.orderInfo}>
<Descriptions column={2} bordered size="small">
<Descriptions.Item label="退款单号" span={2}>
<Text copyable className={styles.codeText}>{values?.refundNo}</Text>
</Descriptions.Item>
<Descriptions.Item label="订单编号" span={2}>
<Text copyable className={styles.codeText}>{values?.orderNo}</Text>
</Descriptions.Item>
<Descriptions.Item label="订单金额">
<span className={styles.amount}>{formatAmount(values?.orderAmount)}</span>
</Descriptions.Item>
<Descriptions.Item label="退款金额">
<span className={styles.amount}>{formatAmount(values?.refundAmount)}</span>
</Descriptions.Item>
<Descriptions.Item label="订单状态">
<Tag color={ORDER_STATUS[values?.status]?.color}>
{ORDER_STATUS[values?.status]?.text || '未知状态'}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="退款状态">
<Tag color={REFUND_STATUS[values?.state]?.color}>
{REFUND_STATUS[values?.state]?.text || '未知状态'}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="申请时间" span={2}>
{values?.createTime}
</Descriptions.Item>
</Descriptions>
</div>
<div className={styles.formContent}>
<ProFormSelect
rules={[
{
required: true,
message: '审核状态不为空',
},
]}
width="md"
name="state"
label="状态"
placeholder="请选择审核状态"
options={[
{ label: '审核中', value: 0 },
{ label: '已通过', value: 1 },
{ label: '已拒绝', value: 2 },
// 添加更多选项...
]}
/>
</ProForm.Group>
name="state"
label="审核结果"
rules={[{ required: true, message: '请选择审核结果' }]}
options={[
{ label: '同意退款', value: 1 },
{ label: '拒绝退款', value: 2 },
]}
fieldProps={{
className: styles.selectField,
}}
/>
<ProFormTextArea
name="approveReason"
label="审核意见"
placeholder="请输入审核意见"
rules={[{ required: true, message: '请输入审核意见' }]}
fieldProps={{
rows: 4,
className: styles.textArea,
}}
/>
</div>
</ModalForm>
);
};
@@ -1,12 +1,27 @@
// 将常量配置提取到单独文件
export const STATUS_CONFIG = {
7: { color: 'yellow', text: '退款申请中' },
8: { color: 'green', text: '已退款' },
9: { color: 'red', text: '退款失败' },
// 订单状态配置(与后端 OrderStatus 枚举保持一致)
export const ORDER_STATUS = {
0: { text: '待支付', color: 'default' },
1: { text: '已支付排队中', color: 'processing' },
2: { text: '已取消', color: 'default' },
3: { text: '设备执行完成', color: 'success' },
4: { text: '正在服务中', color: 'processing' },
5: { text: '素材上传中', color: 'processing' },
6: { text: '素材上传完成', color: 'success' },
7: { text: '退款中', color: 'warning' },
8: { text: '已退款', color: 'success' },
9: { text: '退款失败', color: 'error' },
} as const;
export const STATE_CONFIG = {
0: { color: 'yellow', text: '待审核' },
1: { color: 'green', text: '已通过' },
2: { color: 'red', text: '已拒绝' },
} as const;
// 退款状态配置(与订单状态保持一致)
export const REFUND_STATUS = {
0: { text: '待审核', color: 'default' },
1: { text: '已同意', color: 'success' },
2: { text: '已拒绝', color: 'error' },
} as const;
// 退款相关状态(用于筛选)
export const REFUND_ORDER_STATUS = {
7: ORDER_STATUS[7],
8: ORDER_STATUS[8],
9: ORDER_STATUS[9],
} as const;
@@ -1 +1,76 @@
@import (reference) '~antd/es/style/themes/index';
.queryCard {
margin-bottom: 16px;
:global {
.ant-card-body {
padding: 16px 24px;
}
}
}
.tableCard {
:global {
.ant-card-body {
padding: 0;
}
}
}
.customTable {
:global {
.ant-table-thead > tr > th {
background: #fafafa;
font-weight: 500;
}
.ant-table-row:hover {
background-color: #f5f5f5;
}
}
}
.statusTag {
min-width: 72px;
text-align: center;
font-size: 13px;
}
.amount {
font-family: 'Roboto Mono', monospace;
color: #262626;
font-weight: 500;
}
.codeText {
font-family: 'Roboto Mono', monospace;
color: #1890ff;
&:hover {
text-decoration: underline;
}
}
.actionLink {
&:hover {
color: #1890ff;
text-decoration: underline;
}
}
.queryFilter {
:global {
.ant-form-item {
margin-bottom: 16px;
}
.ant-select-selector {
border-radius: 4px !important;
}
.ant-input {
border-radius: 4px;
}
}
}
@@ -3,149 +3,236 @@ import type { ActionType, ProColumns } from '@ant-design/pro-components';
import {
PageContainer,
ProFormText,
ProFormSelect,
ProTable,
QueryFilter,
} from '@ant-design/pro-components';
import { Typography, Tag, Space, message } from 'antd';
import React, { useRef, useState, useCallback } from 'react';
import { STATUS_CONFIG, STATE_CONFIG } from './constants';
import { Typography, Tag, Space, message, Card } from 'antd';
import React, { useRef, useState } from 'react';
import { ORDER_STATUS, REFUND_STATUS, REFUND_ORDER_STATUS } from './constants';
import UpdateForm from './components/UpdateForm';
import type { RefundItem } from './types';
import styles from './index.less';
const { Link } = Typography;
// 将渲染标签的函数移到组件外部
const renderTag = (value: number, config: typeof STATUS_CONFIG | typeof STATE_CONFIG) => {
const info = config[value] || { color: 'gray', text: '未知状态' };
return <Tag color={info.color}>{info.text}</Tag>;
// 金额转换:分转元,处理字符串或数字类型的金额
const formatAmount = (amount?: string | number | null) => {
if (!amount && amount !== 0) return '-';
return `¥ ${(Number(amount) / 100).toFixed(2)}`;
};
// 状态标签渲染函数
const renderStatusTag = (value: any, statusConfig: Record<number, { text: string; color: string }>) => {
const statusValue = typeof value === 'string' ? parseInt(value, 10) : value;
if (statusValue === undefined || statusValue === null || isNaN(statusValue)) {
return <Tag color="default">未知状态</Tag>;
}
const status = statusConfig[statusValue] || { text: `未知状态(${statusValue})`, color: 'default' };
return (
<Tag color={status.color} className={styles.statusTag}>
{status.text}
</Tag>
);
};
const TableList: React.FC = () => {
// 1. 所有 hooks 放在组件最顶部
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, string | number>>({});
const [updateModalVisible, setUpdateModalVisible] = useState<boolean>(false);
const [currentRow, setCurrentRow] = useState<RefundItem>();
// 2. 处理编辑的回调函数
const handleEdit = useCallback(async (fields: RefundItem) => {
const hide = message.loading('正在更新');
try {
const result = await updateRefund({ ...fields });
hide();
if (result.resp_code === 0) {
message.success('审核成功');
return true;
}
message.error(result.resp_msg);
return false;
} catch (error) {
hide();
message.error('审核失败');
return false;
}
}, []);
// 3. 处理表单提交的回调函数
const handleSubmit = useCallback(async (values: Partial<RefundItem>) => {
if (!currentRow) return;
const success = await handleEdit({ ...currentRow, ...values });
if (success) {
setUpdateModalVisible(false);
actionRef.current?.reload();
setCurrentRow(undefined);
}
}, [currentRow, handleEdit]);
// 4. 定义表格列
const columns: ProColumns<RefundItem>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
align: 'center',
},
{
title: '订单ID',
dataIndex: 'id',
},
{
title: '退款订单编号',
title: '退款单号',
dataIndex: 'refundNo',
copyable: true,
width: 200,
ellipsis: true,
render: (text) => (
<span className={styles.codeText}>{text}</span>
),
},
{
title: '订单编号',
dataIndex: 'orderNo',
copyable: true,
width: 200,
ellipsis: true,
render: (text) => (
<span className={styles.codeText}>{text}</span>
),
},
{
title: '订单金额',
dataIndex: 'orderAmount',
valueType: 'money',
width: 120,
align: 'right',
render: (_, record) => (
<span className={styles.amount}>{formatAmount(record.orderAmount)}</span>
),
},
{
title: '退款金额',
dataIndex: 'refundAmount',
valueType: 'money',
width: 120,
align: 'right',
render: (_, record) => (
<span className={styles.amount}>{formatAmount(record.refundAmount)}</span>
),
},
{
title: '订单状态',
dataIndex: 'status',
render: (status) => renderTag(status as number, STATUS_CONFIG),
width: 120,
align: 'center',
render: (status) => renderStatusTag(status, ORDER_STATUS),
},
{
title: '退款状态',
dataIndex: 'state',
render: (state) => renderTag(state as number, STATE_CONFIG),
width: 100,
align: 'center',
render: (state) => renderStatusTag(state, REFUND_STATUS),
},
{
title: '退款时间',
dataIndex: 'refundTime',
valueType: 'dateTime',
width: 180,
align: 'center',
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
width: 180,
align: 'center',
sorter: true,
},
{
title: '操作',
key: 'action',
render: (_, entity) => (
<Space>
<Link
onClick={() => {
setCurrentRow(entity);
setUpdateModalVisible(true);
}}
>
修改
</Link>
fixed: 'right',
width: 120,
align: 'center',
render: (_, record) => (
<Space size="middle">
{record.state === 0 && (
<Link
className={styles.actionLink}
onClick={() => {
setCurrentRow(record);
setUpdateModalVisible(true);
}}
>
审核
</Link>
)}
</Space>
),
},
];
return (
<PageContainer header={{ subTitle: '退款管理' }}>
<QueryFilter
defaultCollapsed
split
span={6}
className="query-filter"
onFinish={async (values) => setParams(values)}
>
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
</QueryFilter>
<ProTable<RefundItem>
rowKey="id"
headerTitle="退款列表"
request={refund}
actionRef={actionRef}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
}}
/>
<PageContainer
header={{
title: '退款管理',
subTitle: '管理订单退款申请及审核',
}}
>
<Card bordered={false} className={styles.queryCard}>
<QueryFilter
defaultCollapsed={false}
split
span={6}
className={styles.queryFilter}
onFinish={async (values) => setParams(values)}
>
<ProFormText
name="refundNo"
label="退款单号"
placeholder="请输入退款单号"
/>
<ProFormText
name="orderNo"
label="订单编号"
placeholder="请输入订单编号"
/>
<ProFormSelect
name="status"
label="订单状态"
placeholder="请选择订单状态"
options={Object.entries(REFUND_ORDER_STATUS).map(([key, value]) => ({
label: value.text,
value: Number(key),
}))}
fieldProps={{
allowClear: true,
}}
/>
<ProFormSelect
name="state"
label="退款状态"
placeholder="请选择退款状态"
options={Object.entries(REFUND_STATUS).map(([key, value]) => ({
label: value.text,
value: Number(key),
}))}
fieldProps={{
allowClear: true,
}}
/>
</QueryFilter>
</Card>
<Card bordered={false} className={styles.tableCard}>
<ProTable<RefundItem>
rowKey="id"
headerTitle="退款列表"
actionRef={actionRef}
request={refund}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
defaultPageSize: 10,
showTotal: (total) => `共 ${total} 条记录`,
}}
scroll={{ x: 'max-content' }}
dateFormatter="string"
className={styles.customTable}
/>
</Card>
<UpdateForm
onSubmit={handleSubmit}
onSubmit={async (values) => {
if (!currentRow) return false;
const success = await updateRefund({ ...currentRow, ...values });
if (success) {
setUpdateModalVisible(false);
actionRef.current?.reload();
setCurrentRow(undefined);
}
return success;
}}
onVisibleChange={setUpdateModalVisible}
updateModalVisible={updateModalVisible}
values={currentRow}
refundStatusOptions={Object.entries(REFUND_STATUS).map(([key, value]) => ({
label: value.text,
value: Number(key),
}))}
/>
</PageContainer>
);
@@ -3,8 +3,10 @@ export interface RefundItem {
refundNo: string;
orderAmount: number;
refundAmount: number;
status: number;
state: number;
status: string;
state: string;
reason?: string;
createTime: string;
remark?: string;
[key: string]: any;
}
@@ -0,0 +1,59 @@
import {
ModalForm,
ProForm,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-components';
import React from 'react';
interface CreateFormProps {
visible: boolean;
onVisibleChange: (visible: boolean) => void;
onSubmit: (values: SYSTEM.Tenant) => Promise<void>;
}
const CreateForm: React.FC<CreateFormProps> = (props) => {
return (
<ModalForm
title="新增租户"
visible={props.visible}
onVisibleChange={props.onVisibleChange}
onFinish={props.onSubmit}
modalProps={{ destroyOnClose: true }}
>
<ProForm.Group>
<ProFormText
name="name"
label="租户名称"
rules={[{ required: true, message: '请输入租户名称' }]}
width="md"
/>
<ProFormText
name="code"
label="租户编码"
rules={[{ required: true, message: '请输入租户编码' }]}
width="md"
/>
<ProFormText
name="contactPerson"
label="联系人"
rules={[{ required: true, message: '请输入联系人' }]}
width="md"
/>
<ProFormText
name="contactPhone"
label="联系电话"
rules={[{ required: true, message: '请输入联系电话' }]}
width="md"
/>
<ProFormTextArea
name="address"
label="地址"
width="md"
/>
</ProForm.Group>
</ModalForm>
);
};
export default CreateForm;
@@ -0,0 +1,61 @@
import {
ModalForm,
ProForm,
ProFormText,
ProFormTextArea,
} from '@ant-design/pro-components';
import React from 'react';
interface UpdateFormProps {
visible: boolean;
onVisibleChange: (visible: boolean) => void;
onSubmit: (values: SYSTEM.Tenant) => Promise<void>;
values?: SYSTEM.Tenant;
}
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
return (
<ModalForm
title="修改租户"
visible={props.visible}
onVisibleChange={props.onVisibleChange}
onFinish={props.onSubmit}
initialValues={props.values}
modalProps={{ destroyOnClose: true }}
>
<ProForm.Group>
<ProFormText
name="name"
label="租户名称"
rules={[{ required: true, message: '请输入租户名称' }]}
width="md"
/>
<ProFormText
name="code"
label="租户编码"
rules={[{ required: true, message: '请输入租户编码' }]}
width="md"
/>
<ProFormText
name="contactPerson"
label="联系人"
rules={[{ required: true, message: '请输入联系人' }]}
width="md"
/>
<ProFormText
name="contactPhone"
label="联系电话"
rules={[{ required: true, message: '请输入联系电话' }]}
width="md"
/>
<ProFormTextArea
name="address"
label="地址"
width="md"
/>
</ProForm.Group>
</ModalForm>
);
};
export default UpdateForm;
@@ -0,0 +1,213 @@
import {
getTenantList,
saveOrUpdateTenant,
deleteTenant,
updateTenantStatus
} from '@/services/system/api';
import { PlusOutlined } from '@ant-design/icons';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import { PageContainer, ProFormText, ProTable, QueryFilter } from '@ant-design/pro-components';
import { Typography, message, Popconfirm, Button, Space, Switch } from 'antd';
import React, { useRef, useState } from 'react';
import CreateForm from './components/CreateForm';
import UpdateForm from './components/UpdateForm';
const { Link } = Typography;
// 统一的错误处理
const handleApiRequest = async (
apiCall: () => Promise<any>,
loadingMessage: string,
successMessage: string,
) => {
const hide = message.loading(loadingMessage);
try {
const result = await apiCall();
hide();
if (result.code === 0) {
message.success(successMessage);
return true;
}
message.error(result.message || '操作失败');
return false;
} catch (error) {
hide();
message.error('操作失败');
return false;
}
};
const TenantList: React.FC = () => {
const [params, setParams] = useState<Record<string, string | number>>({});
const actionRef = useRef<ActionType>();
const [createModalVisible, handleCreateModalVisible] = useState<boolean>(false);
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [currentRow, setCurrentRow] = useState<any>();
// 处理状态切换
const handleStatusChange = async (checked: boolean, record: SYSTEM.Tenant) => {
const success = await handleApiRequest(
() => updateTenantStatus(record.id!, checked ? 1 : 0),
'正在更新状态',
'状态更新成功'
);
if (success && actionRef.current) {
actionRef.current.reload();
}
};
const columns: ProColumns<SYSTEM.Tenant>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
width: 48,
},
{
title: '租户名称',
dataIndex: 'name',
ellipsis: true,
},
{
title: '租户编码',
dataIndex: 'code',
ellipsis: true,
},
{
title: '联系人',
dataIndex: 'contactPerson',
},
{
title: '联系电话',
dataIndex: 'contactPhone',
},
{
title: '地址',
dataIndex: 'address',
ellipsis: true,
},
{
title: '状态',
dataIndex: 'status',
width: 100,
render: (_, record) => (
<Switch
checked={record.status === 1}
onChange={(checked) => handleStatusChange(checked, record)}
/>
),
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
width: 180,
},
{
title: '操作',
key: 'action',
fixed: 'right',
width: 180,
render: (_, record) => (
<Space>
<Link
onClick={() => {
setCurrentRow(record);
handleUpdateModalVisible(true);
}}
>
修改
</Link>
<Popconfirm
title={`确认删除租户[${record.name}]?`}
onConfirm={async () => {
const success = await handleApiRequest(
() => deleteTenant(record.id!),
'正在删除',
'删除成功'
);
if (success && actionRef.current) {
actionRef.current.reload();
}
}}
>
<Link>删除</Link>
</Popconfirm>
</Space>
),
},
];
return (
<PageContainer header={{ title: '租户管理' }}>
<QueryFilter
defaultCollapsed
split
span={6}
className="query-filter"
onFinish={async (values) => setParams(values)}
>
<ProFormText name="name" label="租户名称" placeholder="请输入租户名称" />
<ProFormText name="code" label="租户编码" placeholder="请输入租户编码" />
</QueryFilter>
<ProTable
rowKey="id"
headerTitle="租户列表"
actionRef={actionRef}
request={getTenantList}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
}}
toolBarRender={() => [
<Button
key="add"
type="primary"
onClick={() => handleCreateModalVisible(true)}
>
<PlusOutlined /> 新增租户
</Button>,
]}
/>
<CreateForm
visible={createModalVisible}
onVisibleChange={handleCreateModalVisible}
onSubmit={async (values) => {
const success = await handleApiRequest(
() => saveOrUpdateTenant(values),
'正在添加',
'添加成功'
);
if (success) {
handleCreateModalVisible(false);
actionRef.current?.reload();
}
}}
/>
<UpdateForm
visible={updateModalVisible}
onVisibleChange={handleUpdateModalVisible}
values={currentRow}
onSubmit={async (values) => {
const success = await handleApiRequest(
() => saveOrUpdateTenant({ ...currentRow, ...values }),
'正在更新',
'更新成功'
);
if (success) {
handleUpdateModalVisible(false);
setCurrentRow(undefined);
actionRef.current?.reload();
}
}}
/>
</PageContainer>
);
};
export default TenantList;
@@ -247,3 +247,42 @@ export async function deleteToken(token: string) {
});
return result;
}
// 获取租户列表
export async function getTenantList(params?: { [key: string]: string | number }) {
const { current, pageSize, ...rest } = params ?? {};
const result = await request<SYSTEM.Page<SYSTEM.Tenant>>('/api-user/tenant/list', {
method: 'GET',
params: { page: current, limit: pageSize, ...rest },
});
return { data: result.data, total: result.count };
}
// 获取租户详情
export async function getTenantDetail(id: string) {
return request<API.Result<SYSTEM.Tenant>>(`/api-user/tenant/${id}`, {
method: 'GET',
});
}
// 保存或更新租户
export async function saveOrUpdateTenant(data: SYSTEM.Tenant): Promise<API.Result<SYSTEM.Tenant>> {
return request<API.Result<SYSTEM.Tenant>>('/api-user/tenant/save', {
method: 'POST',
data,
});
}
// 删除租户
export async function deleteTenant(id: string) {
return request<API.Result<void>>(`/api-user/tenant/${id}`, {
method: 'DELETE',
});
}
// 更新租户状态
export async function updateTenantStatus(id: string, status: number) {
return request<API.Result<void>>(`/api-user/tenant/status/${id}/${status}`, {
method: 'PUT',
});
}
@@ -101,4 +101,16 @@ declare namespace SYSTEM {
tenantId?: string;
updateTime?: string;
}
type Tenant = {
id?: number;
name: string; // 租户名称
code: string; // 租户编码
contactPerson: string; // 联系人
contactPhone: string; // 联系电话
address?: string; // 地址
status: number; // 状态:0-禁用,1-启用
createTime?: Date; // 创建时间
updateTime?: Date; // 更新时间
};
}