refactor:优化 tenantPackage 租户套餐的实现
parent
b119319381
commit
4870bff2a0
|
@ -2,7 +2,6 @@ import type { PageParam, PageResult } from '@vben/request';
|
||||||
|
|
||||||
import { requestClient } from '#/api/request';
|
import { requestClient } from '#/api/request';
|
||||||
|
|
||||||
// TODO @芋艿:
|
|
||||||
export namespace SystemTenantPackageApi {
|
export namespace SystemTenantPackageApi {
|
||||||
/** 租户套餐信息 */
|
/** 租户套餐信息 */
|
||||||
export interface SystemTenantPackage {
|
export interface SystemTenantPackage {
|
||||||
|
@ -20,7 +19,10 @@ export namespace SystemTenantPackageApi {
|
||||||
|
|
||||||
/** 租户套餐列表 */
|
/** 租户套餐列表 */
|
||||||
export function getTenantPackagePage(params: PageParam) {
|
export function getTenantPackagePage(params: PageParam) {
|
||||||
return requestClient.get<PageResult<SystemTenantPackageApi.SystemTenantPackage>>('/system/tenant-package/page', { params });
|
return requestClient.get<PageResult<SystemTenantPackageApi.SystemTenantPackage>>(
|
||||||
|
'/system/tenant-package/page',
|
||||||
|
{ params }
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询租户套餐详情 */
|
/** 查询租户套餐详情 */
|
|
@ -3,7 +3,7 @@ import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemTenantApi } from '#/api/system/tenant';
|
import type { SystemTenantApi } from '#/api/system/tenant';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { getTenantPackageList } from '#/api/system/tenantPackage';
|
import { getTenantPackageList } from '#/api/system/tenant-package';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
import { DICT_TYPE, getDictOptions } from '#/utils/dict';
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import type { VbenFormSchema } from '#/adapter/form';
|
import type { VbenFormSchema } from '#/adapter/form';
|
||||||
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickFn, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenantPackage';
|
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { z } from '#/adapter/form';
|
import { z } from '#/adapter/form';
|
||||||
import { CommonStatusEnum } from '#/utils/constants';
|
import { CommonStatusEnum } from '#/utils/constants';
|
||||||
|
@ -21,6 +21,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
fieldName: 'name',
|
fieldName: 'name',
|
||||||
label: '套餐名称',
|
label: '套餐名称',
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入套餐名称',
|
||||||
|
},
|
||||||
rules: 'required',
|
rules: 'required',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -44,6 +47,9 @@ export function useFormSchema(): VbenFormSchema[] {
|
||||||
fieldName: 'remark',
|
fieldName: 'remark',
|
||||||
label: '备注',
|
label: '备注',
|
||||||
component: 'Textarea',
|
component: 'Textarea',
|
||||||
|
componentProps: {
|
||||||
|
placeholder: '请输入备注',
|
||||||
|
}
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -57,6 +63,7 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
component: 'Input',
|
component: 'Input',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
allowClear: true,
|
||||||
|
placeholder: '请输入套餐名称',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -64,8 +71,9 @@ export function useGridFormSchema(): VbenFormSchema[] {
|
||||||
label: '状态',
|
label: '状态',
|
||||||
component: 'Select',
|
component: 'Select',
|
||||||
componentProps: {
|
componentProps: {
|
||||||
allowClear: true,
|
|
||||||
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
options: getDictOptions(DICT_TYPE.COMMON_STATUS, 'number'),
|
||||||
|
allowClear: true,
|
||||||
|
placeholder: '请选择状态',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,17 +1,16 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
import type { OnActionClickParams, VxeTableGridOptions } from '#/adapter/vxe-table';
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenantPackage';
|
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { Page, useVbenModal } from '@vben/common-ui';
|
import { Page, useVbenModal } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Button, message } from 'ant-design-vue';
|
import { Button, message } from 'ant-design-vue';
|
||||||
|
import Form from './modules/form.vue';
|
||||||
|
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
|
||||||
import { deleteTenantPackage, getTenantPackagePage } from '#/api/system/tenantPackage';
|
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
|
import { deleteTenantPackage, getTenantPackagePage } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { useGridColumns, useGridFormSchema } from './data';
|
import { useGridColumns, useGridFormSchema } from './data';
|
||||||
import Form from './modules/form.vue';
|
|
||||||
|
|
||||||
const [FormModal, formModalApi] = useVbenModal({
|
const [FormModal, formModalApi] = useVbenModal({
|
||||||
connectedComponent: Form,
|
connectedComponent: Form,
|
||||||
|
@ -55,14 +54,14 @@ async function onDelete(row: SystemTenantPackageApi.SystemTenantPackage) {
|
||||||
/** 表格操作按钮的回调函数 */
|
/** 表格操作按钮的回调函数 */
|
||||||
function onActionClick({ code, row }: OnActionClickParams<SystemTenantPackageApi.SystemTenantPackage>) {
|
function onActionClick({ code, row }: OnActionClickParams<SystemTenantPackageApi.SystemTenantPackage>) {
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case 'delete': {
|
|
||||||
onDelete(row);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case 'edit': {
|
case 'edit': {
|
||||||
onEdit(row);
|
onEdit(row);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'delete': {
|
||||||
|
onDelete(row);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,10 +95,11 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||||
} as VxeTableGridOptions<SystemTenantPackageApi.SystemTenantPackage>,
|
} as VxeTableGridOptions<SystemTenantPackageApi.SystemTenantPackage>,
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Page auto-content-height>
|
<Page auto-content-height>
|
||||||
<FormModal @success="onRefresh" />
|
<FormModal @success="onRefresh" />
|
||||||
<Grid table-title="套餐列表">
|
<Grid table-title="租户套餐列表">
|
||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<Button type="primary" @click="onCreate">
|
<Button type="primary" @click="onCreate">
|
||||||
<Plus class="size-5" />
|
<Plus class="size-5" />
|
||||||
|
|
|
@ -1,33 +1,30 @@
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import type { SystemDeptApi } from '#/api/system/dept';
|
import type { SystemDeptApi } from '#/api/system/dept';
|
||||||
import type { SystemTenantPackageApi } from '#/api/system/tenantPackage';
|
import type { SystemTenantPackageApi } from '#/api/system/tenant-package';
|
||||||
|
|
||||||
import { computed, ref } from 'vue';
|
|
||||||
|
|
||||||
import { useVbenModal, VbenTree } from '@vben/common-ui';
|
import { useVbenModal, VbenTree } from '@vben/common-ui';
|
||||||
|
|
||||||
import { Checkbox, message } from 'ant-design-vue';
|
import { Checkbox, message } from 'ant-design-vue';
|
||||||
|
|
||||||
|
import { computed, ref } from 'vue';
|
||||||
|
import { $t } from '#/locales';
|
||||||
import { useVbenForm } from '#/adapter/form';
|
import { useVbenForm } from '#/adapter/form';
|
||||||
import { getMenuList } from '#/api/system/menu';
|
import { getMenuList } from '#/api/system/menu';
|
||||||
import { createTenantPackage, getTenantPackage, updateTenantPackage } from '#/api/system/tenantPackage';
|
import { createTenantPackage, getTenantPackage, updateTenantPackage } from '#/api/system/tenant-package';
|
||||||
import { $t } from '#/locales';
|
|
||||||
import { handleTree } from '#/utils/tree';
|
import { handleTree } from '#/utils/tree';
|
||||||
|
|
||||||
import { useFormSchema } from '../data';
|
import { useFormSchema } from '../data';
|
||||||
|
|
||||||
const emit = defineEmits(['success']);
|
const emit = defineEmits(['success']);
|
||||||
const formData = ref<SystemTenantPackageApi.SystemTenantPackage>();
|
const formData = ref<SystemTenantPackageApi.SystemTenantPackage>();
|
||||||
|
const getTitle = computed(() => {
|
||||||
|
return formData.value ? $t('ui.actionTitle.edit', ['套餐']) : $t('ui.actionTitle.create', ['套餐']);
|
||||||
|
});
|
||||||
const menuTree = ref<SystemDeptApi.SystemDept[]>([]); // 菜单树
|
const menuTree = ref<SystemDeptApi.SystemDept[]>([]); // 菜单树
|
||||||
const menuLoading = ref(false); // 加载菜单列表
|
const menuLoading = ref(false); // 加载菜单列表
|
||||||
const isAllSelected = ref(false); // 全选状态
|
const isAllSelected = ref(false); // 全选状态
|
||||||
const isExpanded = ref(false); // 展开状态
|
const isExpanded = ref(false); // 展开状态
|
||||||
const expandedKeys = ref<number[]>([]); // 展开的节点
|
const expandedKeys = ref<number[]>([]); // 展开的节点
|
||||||
|
|
||||||
const getTitle = computed(() => {
|
|
||||||
return formData.value ? $t('ui.actionTitle.edit', ['套餐']) : $t('ui.actionTitle.create', ['套餐']);
|
|
||||||
});
|
|
||||||
|
|
||||||
const [Form, formApi] = useVbenForm({
|
const [Form, formApi] = useVbenForm({
|
||||||
layout: 'horizontal',
|
layout: 'horizontal',
|
||||||
schema: useFormSchema(),
|
schema: useFormSchema(),
|
||||||
|
@ -56,7 +53,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||||
modalApi.lock(false);
|
modalApi.lock(false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async onOpenChange(isOpen) {
|
async onOpenChange(isOpen: boolean) {
|
||||||
// 加载菜单列表
|
// 加载菜单列表
|
||||||
await loadMenuTree();
|
await loadMenuTree();
|
||||||
if (!isOpen) {
|
if (!isOpen) {
|
||||||
|
|
Loading…
Reference in New Issue