Files
iot-device-management-frontend/apps/web-antd/src/views/system/tenantPackage/index.vue

133 lines
3.4 KiB
Vue
Raw Normal View History

<script lang="ts" setup>
2025-05-15 14:47:19 +08:00
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
import { Page, useVbenModal } from '@vben/common-ui';
2025-04-22 11:25:11 +08:00
2025-05-19 16:31:07 +08:00
import { message } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
2025-04-22 11:25:11 +08:00
import {
deleteTenantPackage,
getTenantPackagePage,
} from '#/api/system/tenant-package';
import { DocAlert } from '#/components/doc-alert';
import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data';
2025-04-22 11:25:11 +08:00
import Form from './modules/form.vue';
const [FormModal, formModalApi] = useVbenModal({
connectedComponent: Form,
destroyOnClose: true,
});
/** 刷新表格 */
function onRefresh() {
gridApi.query();
}
/** 创建租户套餐 */
function onCreate() {
formModalApi.setData(null).open();
}
/** 编辑租户套餐 */
2025-04-22 22:10:33 +08:00
function onEdit(row: SystemTenantPackageApi.TenantPackage) {
formModalApi.setData(row).open();
}
/** 删除租户套餐 */
2025-04-22 22:10:33 +08:00
async function onDelete(row: SystemTenantPackageApi.TenantPackage) {
2025-05-19 11:10:38 +08:00
message.loading({
content: $t('ui.actionMessage.deleting', [row.name]),
2025-05-19 16:31:07 +08:00
key: 'action_key_msg',
});
2025-05-19 11:10:38 +08:00
await deleteTenantPackage(row.id as number);
message.success({
content: $t('ui.actionMessage.deleteSuccess', [row.name]),
2025-05-19 16:31:07 +08:00
key: 'action_key_msg',
2025-05-19 11:10:38 +08:00
});
onRefresh();
}
const [Grid, gridApi] = useVbenVxeGrid({
formOptions: {
schema: useGridFormSchema(),
// TODO @芋艿:时间筛选,后续处理;
},
gridOptions: {
2025-05-15 14:47:19 +08:00
columns: useGridColumns(),
height: 'auto',
keepSource: true,
proxyConfig: {
ajax: {
query: async ({ page }, formValues) => {
return await getTenantPackagePage({
pageNo: page.currentPage,
pageSize: page.pageSize,
...formValues,
});
},
},
},
rowConfig: {
keyField: 'id',
},
toolbarConfig: {
refresh: { code: 'query' },
search: true,
},
2025-04-22 22:10:33 +08:00
} as VxeTableGridOptions<SystemTenantPackageApi.TenantPackage>,
});
</script>
<template>
<Page auto-content-height>
<template #doc>
<DocAlert title="SaaS 多租户" url="https://doc.iocoder.cn/saas-tenant/" />
</template>
2025-04-05 17:09:16 +08:00
<FormModal @success="onRefresh" />
<Grid table-title="租户套餐列表">
<template #toolbar-tools>
2025-05-19 16:31:07 +08:00
<TableAction
:actions="[
{
label: $t('ui.actionTitle.create', ['套餐']),
type: 'primary',
icon: ACTION_ICON.ADD,
auth: ['system:tenant-package:create'],
onClick: onCreate,
},
]"
/>
</template>
2025-05-15 14:47:19 +08:00
<template #actions="{ row }">
<TableAction
:actions="[
{
label: $t('common.edit'),
type: 'link',
2025-05-19 16:31:07 +08:00
icon: ACTION_ICON.EDIT,
2025-05-15 14:47:19 +08:00
auth: ['system:role:update'],
onClick: onEdit.bind(null, row),
},
{
label: $t('common.delete'),
type: 'link',
danger: true,
2025-05-19 16:31:07 +08:00
icon: ACTION_ICON.DELETE,
2025-05-15 14:47:19 +08:00
auth: ['system:role:delete'],
popConfirm: {
title: $t('ui.actionMessage.deleteConfirm', [row.name]),
confirm: onDelete.bind(null, row),
},
},
]"
/>
</template>
</Grid>
</Page>
</template>