From 545f9f5bc101e98625f2bf92af7f70a6d3fa6ccc Mon Sep 17 00:00:00 2001 From: smthhy Date: Thu, 3 Apr 2025 18:55:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Etenant=20=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/web-antd/src/api/system/tenant/index.ts | 63 +++++ .../src/api/system/tenantPackage/index.ts | 63 +++++ apps/web-antd/src/views/system/tenant/data.ts | 234 ++++++++++++++++++ .../src/views/system/tenant/index.vue | 127 ++++++++++ .../src/views/system/tenant/modules/form.vue | 76 ++++++ 5 files changed, 563 insertions(+) create mode 100644 apps/web-antd/src/api/system/tenant/index.ts create mode 100644 apps/web-antd/src/api/system/tenantPackage/index.ts create mode 100644 apps/web-antd/src/views/system/tenant/data.ts create mode 100644 apps/web-antd/src/views/system/tenant/index.vue create mode 100644 apps/web-antd/src/views/system/tenant/modules/form.vue diff --git a/apps/web-antd/src/api/system/tenant/index.ts b/apps/web-antd/src/api/system/tenant/index.ts new file mode 100644 index 000000000..9c81f9184 --- /dev/null +++ b/apps/web-antd/src/api/system/tenant/index.ts @@ -0,0 +1,63 @@ +import type { PageParam } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace SystemTenantApi { + /** + * 租户信息 + */ + export interface SystemTenant { + id?: number; + name: string; + packageId: number; + contactName: string; + contactMobile: string; + accountCount: number; + expireTime: Date; + website: string; + status: number; + } +} + +/** + * 租户列表 + */ +export function getTenantPage(params: PageParam) { + return requestClient.get('/system/tenant/page', { params }); +} + +/** 获取租户精简信息列表 */ +export function getSimpleTenantList() { + return requestClient.get( + '/system/tenant/simple-list', + ); +} + +/** 查询租户详情 */ +export function getTenant(id: number) { + return requestClient.get( + `/system/tenant/get?id=${id}`, + ); +} + +/** 新增租户 */ +export function createTenant(data: SystemTenantApi.SystemTenant) { + return requestClient.post('/system/tenant/create', data); +} + +/** 修改租户 */ +export function updateTenant(data: SystemTenantApi.SystemTenant) { + return requestClient.put('/system/tenant/update', data); +} + +/** 删除租户 */ +export function deleteTenant(id: number) { + return requestClient.delete(`/system/tenant/delete?id=${id}`); +} + +/** 导出租户 */ +export function exportTenant(params: any) { + return requestClient.download('/system/tenant/export-excel', { + params, + }); +} diff --git a/apps/web-antd/src/api/system/tenantPackage/index.ts b/apps/web-antd/src/api/system/tenantPackage/index.ts new file mode 100644 index 000000000..4787b87b5 --- /dev/null +++ b/apps/web-antd/src/api/system/tenantPackage/index.ts @@ -0,0 +1,63 @@ +import type { PageParam, PageResult } from '@vben/request'; + +import { requestClient } from '#/api/request'; + +export namespace SystemTenantPackageApi { + /** + * 租户套餐信息 + */ + export interface SystemTenantPackage { + id: number; + name: string; + status: number; + remark: string; + creator: string; + updater: string; + updateTime: string; + menuIds: number[]; + createTime: Date; + } +} + +/** + * 租户套餐列表 + */ +export function getTenantPackagePage(params: PageParam) { + return requestClient.get< + PageResult + >('/system/tenant-package/page', params); +} + +/** 查询租户套餐详情 */ +export function getTenantPackage(id: number) { + return requestClient.get(`/system/TenantPackage/get?id=${id}`); +} + +/** 新增租户套餐 */ +export function createTenantPackage( + data: SystemTenantPackageApi.SystemTenantPackage, +) { + return requestClient.post('/system/TenantPackage/create', data); +} + +/** 修改租户套餐 */ +export function updateTenantPackage( + data: SystemTenantPackageApi.SystemTenantPackage, +) { + return requestClient.put('/system/TenantPackage/update', data); +} + +/** 删除租户套餐 */ +export function deleteTenantPackage(id: number) { + return requestClient.delete(`/system/TenantPackage/delete?id=${id}`); +} + +// 获取租户套餐精简信息列表 +export function getTenantPackageList() { + return requestClient.get('/system/tenant-package/get-simple-list'); +} + +/** 导出租户套餐 */ +export function exportTenantPackage(params: any) { + return requestClient.download('/system/TenantPackage/export', params); +} diff --git a/apps/web-antd/src/views/system/tenant/data.ts b/apps/web-antd/src/views/system/tenant/data.ts new file mode 100644 index 000000000..462f7bb9f --- /dev/null +++ b/apps/web-antd/src/views/system/tenant/data.ts @@ -0,0 +1,234 @@ +import type { VbenFormSchema } from '#/adapter/form'; +import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table'; +import type { SystemTenantApi } from '#/api/system/tenant'; + +import { z } from '#/adapter/form'; +import { getTenantPackageList } from '#/api/system/tenantPackage'; +import { CommonStatusEnum } from '#/utils/constants'; +import { DICT_TYPE, getDictOptions } from '#/utils/dict'; + +/** 新增、修改表单 */ +export function useFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'id', + component: 'Input', + dependencies: { + triggerFields: [''], + show: () => false, + }, + }, + { + component: 'Input', + fieldName: 'name', + label: '租户名称', + rules: 'required', + }, + { + component: 'ApiSelect', + fieldName: 'packageId', + label: '租户套餐', + rules: 'required', + componentProps: { + api: () => getTenantPackageList(), + class: 'w-full', + labelField: 'name', + valueField: 'id', + placeholder: '请选择租户套餐', + }, + }, + { + component: 'Input', + fieldName: 'contactName', + label: '联系人', + rules: 'required', + }, + { + component: 'Input', + fieldName: 'contactMobile', + label: '联系手机', + }, + { + component: 'Input', + label: '用户名称', + fieldName: 'username', + rules: 'required', + dependencies: { + triggerFields: ['id'], + show: (values) => !values.id, + }, + }, + { + label: '用户密码', + fieldName: 'password', + component: 'InputPassword', + rules: 'required', + dependencies: { + triggerFields: ['id'], + show: (values) => !values.id, + }, + }, + { + component: 'InputNumber', + label: '账号额度', + fieldName: 'accountCount', + rules: 'required', + defaultValue: 0, + componentProps: { + class: 'w-full', + }, + }, + { + component: 'DatePicker', + label: '过期时间', + fieldName: 'expireTime', + rules: 'required', + componentProps: { + showTime: true, + format: 'YYYY-MM-DD HH:mm:ss', + valueFormat: 'x', + class: 'w-full', + }, + }, + { + component: 'Input', + label: '绑定域名', + fieldName: 'website', + rules: 'required', + }, + { + fieldName: 'status', + label: '租户状态', + component: 'RadioGroup', + componentProps: { + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + buttonStyle: 'solid', + optionType: 'button', + }, + rules: z.number().default(CommonStatusEnum.ENABLE), + }, + ]; +} + +/** 列表的搜索表单 */ +export function useGridFormSchema(): VbenFormSchema[] { + return [ + { + fieldName: 'name', + label: '租户名', + component: 'Input', + componentProps: { + allowClear: true, + }, + }, + { + fieldName: 'contactName', + label: '联系人', + component: 'Input', + componentProps: { + allowClear: true, + }, + }, + { + fieldName: 'contactMobile', + label: '联系手机', + component: 'Input', + componentProps: { + allowClear: true, + }, + }, + { + fieldName: 'status', + label: '状态', + component: 'Select', + componentProps: { + allowClear: true, + options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'), + }, + }, + { + fieldName: 'createTime', + label: '创建时间', + component: 'RangePicker', + }, + ]; +} + +/** 列表的字段 */ +export function useGridColumns( + onActionClick: OnActionClickFn, +): VxeTableGridOptions['columns'] { + return [ + { + field: 'id', + title: '租户编号', + minWidth: 200, + }, + { + field: 'name', + title: '租户名', + minWidth: 200, + }, + { + field: 'packageId', + title: '租户套餐', + minWidth: 200, + }, + { + field: 'contactName', + title: '联系人', + minWidth: 100, + }, + { + field: 'contactMobile', + title: '联系手机', + minWidth: 200, + }, + { + field: 'accountCount', + title: '账号额度', + minWidth: 100, + }, + { + field: 'expireTime', + title: '过期时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'website', + title: '绑定域名', + minWidth: 180, + }, + { + field: 'status', + title: '租户状态', + minWidth: 100, + cellRender: { + name: 'CellDict', + props: { type: DICT_TYPE.COMMON_STATUS }, + }, + }, + { + field: 'createTime', + title: '创建时间', + minWidth: 180, + formatter: 'formatDateTime', + }, + { + field: 'operation', + title: '操作', + minWidth: 130, + align: 'center', + fixed: 'right', + cellRender: { + attrs: { + nameField: 'name', + nameTitle: '租户', + onClick: onActionClick, + }, + name: 'CellOperation', + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/system/tenant/index.vue b/apps/web-antd/src/views/system/tenant/index.vue new file mode 100644 index 000000000..c40971b13 --- /dev/null +++ b/apps/web-antd/src/views/system/tenant/index.vue @@ -0,0 +1,127 @@ + + diff --git a/apps/web-antd/src/views/system/tenant/modules/form.vue b/apps/web-antd/src/views/system/tenant/modules/form.vue new file mode 100644 index 000000000..4493d6a8b --- /dev/null +++ b/apps/web-antd/src/views/system/tenant/modules/form.vue @@ -0,0 +1,76 @@ + +