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