diff --git a/apps/web-antd/src/views/system/tenant/data.ts b/apps/web-antd/src/views/system/tenant/data.ts
index 208092c11..2ef061026 100644
--- a/apps/web-antd/src/views/system/tenant/data.ts
+++ b/apps/web-antd/src/views/system/tenant/data.ts
@@ -89,10 +89,10 @@ export function useFormSchema(): VbenFormSchema[] {
{
label: '绑定域名',
fieldName: 'websites',
- component: 'Textarea',
+ component: 'Select',
componentProps: {
- placeholder: '请输入绑定域名,多个域名请换行分隔',
- rows: 3,
+ placeholder: '请输入绑定域名',
+ mode: 'tags',
allowClear: true,
},
},
@@ -118,6 +118,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '租户名',
component: 'Input',
componentProps: {
+ placeholder: '请输入租户名',
allowClear: true,
},
},
@@ -126,6 +127,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '联系人',
component: 'Input',
componentProps: {
+ placeholder: '请输入联系人',
allowClear: true,
},
},
@@ -134,6 +136,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '联系手机',
component: 'Input',
componentProps: {
+ placeholder: '请输入联系手机',
allowClear: true,
},
},
@@ -142,6 +145,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '状态',
component: 'Select',
componentProps: {
+ placeholder: '请选择状态',
allowClear: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
@@ -167,14 +171,17 @@ export function useGridColumns(
{
field: 'id',
title: '租户编号',
+ minWidth: 100,
},
{
field: 'name',
title: '租户名',
+ minWidth: 180,
},
{
field: 'packageId',
title: '租户套餐',
+ minWidth: 180,
formatter: (row: { cellValue: number }) => {
return getPackageName?.(row.cellValue) || '-';
},
@@ -182,27 +189,33 @@ export function useGridColumns(
{
field: 'contactName',
title: '联系人',
+ minWidth: 100,
},
{
field: 'contactMobile',
title: '联系手机',
+ minWidth: 180,
},
{
field: 'accountCount',
title: '账号额度',
+ minWidth: 100,
},
{
field: 'expireTime',
title: '过期时间',
+ minWidth: 180,
formatter: 'formatDateTime',
},
{
field: 'websites',
title: '绑定域名',
+ minWidth: 180,
},
{
field: 'status',
title: '租户状态',
+ minWidth: 100,
cellRender: {
name: 'CellDict',
props: { type: DICT_TYPE.COMMON_STATUS },
@@ -211,6 +224,7 @@ export function useGridColumns(
{
field: 'createTime',
title: '创建时间',
+ minWidth: 180,
formatter: 'formatDateTime',
},
{
diff --git a/apps/web-antd/src/views/system/tenant/index.vue b/apps/web-antd/src/views/system/tenant/index.vue
index f7c3e4de8..cee574ac9 100644
--- a/apps/web-antd/src/views/system/tenant/index.vue
+++ b/apps/web-antd/src/views/system/tenant/index.vue
@@ -5,7 +5,7 @@ import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
import { onMounted, ref } from 'vue';
-import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
+import { confirm, DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
import { message } from 'ant-design-vue';
@@ -39,7 +39,7 @@ const [FormModal, formModalApi] = useVbenModal({
});
/** 刷新表格 */
-function onRefresh() {
+function handleRefresh() {
gridApi.query();
}
@@ -63,15 +63,29 @@ function handleEdit(row: SystemTenantApi.Tenant) {
async function handleDelete(row: SystemTenantApi.Tenant) {
const hideLoading = message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
- key: 'action_key_msg',
+ duration: 0,
});
try {
await deleteTenant(row.id as number);
- message.success({
- content: $t('ui.actionMessage.deleteSuccess', [row.name]),
- key: 'action_key_msg',
- });
- onRefresh();
+ message.success($t('ui.actionMessage.deleteSuccess', [row.name]));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 批量删除租户 */
+async function handleDeleteBatch() {
+ await confirm($t('ui.actionMessage.deleteBatchConfirm'));
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deletingBatch'),
+ duration: 0,
+ });
+ try {
+ await deleteTenantList(checkedIds.value);
+ checkedIds.value = [];
+ message.success($t('ui.actionMessage.deleteSuccess'));
+ handleRefresh();
} finally {
hideLoading();
}
@@ -86,23 +100,6 @@ function handleRowCheckboxChange({
checkedIds.value = records.map((item) => item.id!);
}
-/** 批量删除租户 */
-async function handleDeleteBatch() {
- const hideLoading = message.loading({
- content: $t('ui.actionMessage.deleting'),
- duration: 0,
- key: 'action_process_msg',
- });
- try {
- await deleteTenantList(checkedIds.value);
- checkedIds.value = [];
- message.success($t('ui.actionMessage.deleteSuccess'));
- onRefresh();
- } finally {
- hideLoading();
- }
-}
-
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
@@ -148,7 +145,7 @@ onMounted(async () => {
-
+
{
onClick: handleExport,
},
{
- label: '批量删除',
+ label: $t('ui.actionTitle.deleteBatch'),
type: 'primary',
danger: true,
- disabled: isEmpty(checkedIds),
icon: ACTION_ICON.DELETE,
+ disabled: isEmpty(checkedIds),
auth: ['system:tenant:delete'],
onClick: handleDeleteBatch,
},
diff --git a/apps/web-antd/src/views/system/tenant/modules/form.vue b/apps/web-antd/src/views/system/tenant/modules/form.vue
index c4f6f60db..82b5c0de2 100644
--- a/apps/web-antd/src/views/system/tenant/modules/form.vue
+++ b/apps/web-antd/src/views/system/tenant/modules/form.vue
@@ -27,7 +27,7 @@ const [Form, formApi] = useVbenForm({
class: 'w-full',
},
},
- wrapperClass: 'grid-cols-2',
+ wrapperClass: 'grid-cols-1',
layout: 'horizontal',
schema: useFormSchema(),
showDefaultActions: false,
@@ -41,16 +41,7 @@ const [Modal, modalApi] = useVbenModal({
}
modalApi.lock();
// 提交表单
- const formValues = (await formApi.getValues()) as SystemTenantApi.Tenant & {
- websites: string;
- };
- // 将换行符分隔的字符串转换为数组
- const data: SystemTenantApi.Tenant = {
- ...formValues,
- websites: formValues.websites
- ? formValues.websites.split('\n').filter((item) => item.trim())
- : [],
- };
+ const data = (await formApi.getValues()) as SystemTenantApi.Tenant;
try {
await (formData.value ? updateTenant(data) : createTenant(data));
// 关闭并提示
@@ -74,15 +65,8 @@ const [Modal, modalApi] = useVbenModal({
modalApi.lock();
try {
formData.value = await getTenant(data.id);
- // 将数组转换为换行符分隔的字符串
- const formValues = {
- ...formData.value,
- websites: Array.isArray(formData.value.websites)
- ? formData.value.websites.join('\n')
- : formData.value.websites || '',
- };
// 设置到 values
- await formApi.setValues(formValues);
+ await formApi.setValues(formData.value);
} finally {
modalApi.unlock();
}
@@ -90,7 +74,7 @@ const [Modal, modalApi] = useVbenModal({
});
-
+
diff --git a/apps/web-ele/src/views/system/tenant/data.ts b/apps/web-ele/src/views/system/tenant/data.ts
index 4075f901f..1a480662c 100644
--- a/apps/web-ele/src/views/system/tenant/data.ts
+++ b/apps/web-ele/src/views/system/tenant/data.ts
@@ -1,8 +1,6 @@
import type { VbenFormSchema } from '#/adapter/form';
-import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
-import type { SystemTenantApi } from '#/api/system/tenant';
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
-import { useAccess } from '@vben/access';
import { CommonStatusEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
@@ -10,8 +8,6 @@ import { z } from '#/adapter/form';
import { getTenantPackageList } from '#/api/system/tenant-package';
import { getRangePickerDefaultProps } from '#/utils';
-const { hasAccessByCodes } = useAccess();
-
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
return [
@@ -93,11 +89,9 @@ export function useFormSchema(): VbenFormSchema[] {
{
label: '绑定域名',
fieldName: 'websites',
- component: 'Textarea',
+ component: 'InputTag',
componentProps: {
- placeholder: '请输入绑定域名,多个域名请换行分隔',
- rows: 3,
- clearable: true,
+ placeholder: '请输入绑定域名',
},
},
{
@@ -122,6 +116,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '租户名',
component: 'Input',
componentProps: {
+ placeholder: '请输入租户名',
clearable: true,
},
},
@@ -130,6 +125,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '联系人',
component: 'Input',
componentProps: {
+ placeholder: '请输入联系人',
clearable: true,
},
},
@@ -138,6 +134,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '联系手机',
component: 'Input',
componentProps: {
+ placeholder: '请输入联系手机',
clearable: true,
},
},
@@ -146,6 +143,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: '状态',
component: 'Select',
componentProps: {
+ placeholder: '请选择状态',
clearable: true,
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
},
@@ -163,15 +161,11 @@ export function useGridFormSchema(): VbenFormSchema[] {
}
/** 列表的字段 */
-export function useGridColumns(
- onActionClick: OnActionClickFn,
+export function useGridColumns(
getPackageName?: (packageId: number) => string | undefined,
): VxeTableGridOptions['columns'] {
return [
- {
- type: 'checkbox',
- width: 40,
- },
+ { type: 'checkbox', width: 40 },
{
field: 'id',
title: '租户编号',
@@ -232,29 +226,10 @@ export function useGridColumns(
formatter: 'formatDateTime',
},
{
- field: 'operation',
title: '操作',
- minWidth: 130,
- align: 'center',
+ width: 130,
fixed: 'right',
- cellRender: {
- attrs: {
- nameField: 'name',
- nameTitle: '租户',
- onClick: onActionClick,
- },
- name: 'CellOperation',
- options: [
- {
- code: 'edit',
- show: hasAccessByCodes(['system:tenant:update']),
- },
- {
- code: 'delete',
- show: hasAccessByCodes(['system:tenant:delete']),
- },
- ],
- },
+ slots: { default: 'actions' },
},
];
}
diff --git a/apps/web-ele/src/views/system/tenant/index.vue b/apps/web-ele/src/views/system/tenant/index.vue
index 217badc4d..330d5c02b 100644
--- a/apps/web-ele/src/views/system/tenant/index.vue
+++ b/apps/web-ele/src/views/system/tenant/index.vue
@@ -1,8 +1,5 @@
-
+