mirror of
				https://gitee.com/hhyykk/ipms-sjy-ui.git
				synced 2025-11-01 02:38:44 +08:00 
			
		
		
		
	REVIEW 租户套餐
This commit is contained in:
		| @@ -12,15 +12,8 @@ export interface TenantPackageVO { | ||||
|   createTime: Date | ||||
| } | ||||
|  | ||||
| export interface TenantPackagePageReqVO extends PageParam { | ||||
|   name?: string | ||||
|   status?: number | ||||
|   remark?: string | ||||
|   createTime?: Date[] | ||||
| } | ||||
|  | ||||
| // 查询租户套餐列表 | ||||
| export const getTenantPackageTypePage = (params: TenantPackagePageReqVO) => { | ||||
| export const getTenantPackagePage = (params: PageParam) => { | ||||
|   return request.get({ url: '/system/tenant-package/page', params }) | ||||
| } | ||||
|  | ||||
| @@ -30,17 +23,17 @@ export const getTenantPackage = (id: number) => { | ||||
| } | ||||
|  | ||||
| // 新增租户套餐 | ||||
| export const createTenantPackageType = (data: TenantPackageVO) => { | ||||
| export const createTenantPackage = (data: TenantPackageVO) => { | ||||
|   return request.post({ url: '/system/tenant-package/create', data }) | ||||
| } | ||||
|  | ||||
| // 修改租户套餐 | ||||
| export const updateTenantPackageType = (data: TenantPackageVO) => { | ||||
| export const updateTenantPackage = (data: TenantPackageVO) => { | ||||
|   return request.put({ url: '/system/tenant-package/update', data }) | ||||
| } | ||||
|  | ||||
| // 删除租户套餐 | ||||
| export const deleteTenantPackageType = (id: number) => { | ||||
| export const deleteTenantPackage = (id: number) => { | ||||
|   return request.delete({ url: '/system/tenant-package/delete?id=' + id }) | ||||
| } | ||||
| // 获取租户套餐精简信息列表 | ||||
|   | ||||
							
								
								
									
										4
									
								
								src/types/auto-components.d.ts
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								src/types/auto-components.d.ts
									
									
									
									
										vendored
									
									
								
							| @@ -52,6 +52,7 @@ declare module '@vue/runtime-core' { | ||||
|     ElForm: typeof import('element-plus/es')['ElForm'] | ||||
|     ElFormItem: typeof import('element-plus/es')['ElFormItem'] | ||||
|     ElIcon: typeof import('element-plus/es')['ElIcon'] | ||||
|     ElImage: typeof import('element-plus/es')['ElImage'] | ||||
|     ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] | ||||
|     ElInput: typeof import('element-plus/es')['ElInput'] | ||||
|     ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] | ||||
| @@ -72,7 +73,10 @@ declare module '@vue/runtime-core' { | ||||
|     ElTabPane: typeof import('element-plus/es')['ElTabPane'] | ||||
|     ElTabs: typeof import('element-plus/es')['ElTabs'] | ||||
|     ElTag: typeof import('element-plus/es')['ElTag'] | ||||
|     ElTimeline: typeof import('element-plus/es')['ElTimeline'] | ||||
|     ElTimelineItem: typeof import('element-plus/es')['ElTimelineItem'] | ||||
|     ElTooltip: typeof import('element-plus/es')['ElTooltip'] | ||||
|     ElTransfer: typeof import('element-plus/es')['ElTransfer'] | ||||
|     ElTree: typeof import('element-plus/es')['ElTree'] | ||||
|     ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect'] | ||||
|     ElUpload: typeof import('element-plus/es')['ElUpload'] | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| <template> | ||||
|   <Dialog :title="modelTitle" v-model="modelVisible" width="50%"> | ||||
|   <Dialog :title="modelTitle" v-model="modelVisible"> | ||||
|     <el-form | ||||
|       ref="formRef" | ||||
|       :model="formData" | ||||
| @@ -13,13 +13,6 @@ | ||||
|       <el-form-item label="菜单权限"> | ||||
|         <el-card class="cardHeight"> | ||||
|           <template #header> | ||||
|             父子联动(选中父节点,自动选择子节点): | ||||
|             <el-switch | ||||
|               v-model="menuCheckStrictly" | ||||
|               inline-prompt | ||||
|               active-text="是" | ||||
|               inactive-text="否" | ||||
|             /> | ||||
|             全选/全不选: | ||||
|             <el-switch | ||||
|               v-model="treeNodeAll" | ||||
| @@ -43,7 +36,7 @@ | ||||
|             :check-strictly="!menuCheckStrictly" | ||||
|             show-checkbox | ||||
|             :props="defaultProps" | ||||
|             :data="menuOptions as any[]" | ||||
|             :data="menuOptions" | ||||
|             empty-text="加载中,请稍候" | ||||
|           /> | ||||
|         </el-card> | ||||
| @@ -51,7 +44,7 @@ | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-radio-group v-model="formData.status"> | ||||
|           <el-radio | ||||
|             v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" | ||||
|             v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" | ||||
|             :key="dict.value" | ||||
|             :label="parseInt(dict.value)" | ||||
|           > | ||||
| @@ -70,30 +63,28 @@ | ||||
|   </Dialog> | ||||
| </template> | ||||
| <script setup lang="ts" name="TenantPackageForm"> | ||||
| import { DICT_TYPE, getDictOptions } from '@/utils/dict' | ||||
| import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | ||||
| import { CommonStatusEnum } from '@/utils/constants' | ||||
| import type { FormRules } from 'element-plus' | ||||
| import { defaultProps } from '@/utils/tree' | ||||
| // 业务相关 | ||||
| import * as TenantPackageApi from '@/api/system/tenantPackage' | ||||
| import { getSimpleMenusList } from '@/api/system/menu' | ||||
| import * as MenuApi from '@/api/system/menu' | ||||
| import { ElTree } from 'element-plus' | ||||
| import { handleTree } from '@/utils/tree' | ||||
| 
 | ||||
| const { t } = useI18n() // 国际化 | ||||
| const message = useMessage() // 消息弹窗 | ||||
| 
 | ||||
| const modelVisible = ref(false) // 弹窗的是否展示 | ||||
| const modelTitle = ref('') // 弹窗的标题 | ||||
| const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用 | ||||
| const formType = ref('') // 表单的类型:create - 新增;update - 修改 | ||||
| const formData: Record<string, any> = ref<Record<string, any>>({ | ||||
| const formData = ref({ | ||||
|   id: null, | ||||
|   name: null, | ||||
|   remark: null, | ||||
|   menuIds: [], | ||||
|   status: CommonStatusEnum.ENABLE | ||||
| }) | ||||
| const formRules: FormRules = ref<FormRules>({ | ||||
| const formRules = reactive({ | ||||
|   name: [{ required: true, message: '套餐名不能为空', trigger: 'blur' }], | ||||
|   status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], | ||||
|   menuIds: [{ required: true, message: '关联的菜单编号不能为空', trigger: 'blur' }] | ||||
| @@ -105,26 +96,12 @@ const menuExpand = ref(false) // 展开/折叠 | ||||
| const treeRef = ref<InstanceType<typeof ElTree>>() // 树组件Ref | ||||
| const treeNodeAll = ref(false) // 全选/全不选 | ||||
| 
 | ||||
| // 全选/全不选 | ||||
| const handleCheckedTreeNodeAll = () => { | ||||
|   treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : []) | ||||
| } | ||||
| // 全部(展开/折叠)TODO:for循环全部展开和折叠树组件数据 | ||||
| const handleCheckedTreeExpand = () => { | ||||
|   const nodes = treeRef.value?.store.nodesMap | ||||
|   for (let node in nodes) { | ||||
|     nodes[node].expanded = !nodes[node].expanded | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| /** 打开弹窗 */ | ||||
| const open = async (type: string, id?: number) => { | ||||
|   modelVisible.value = true | ||||
|   modelTitle.value = t('action.' + type) | ||||
|   formType.value = type | ||||
|   resetForm() | ||||
|   // 加载Menu列表 | ||||
|   menuOptions.value = handleTree(await getSimpleMenusList()) | ||||
|   // 修改时,设置数据 | ||||
|   if (id) { | ||||
|     formLoading.value = true | ||||
| @@ -140,6 +117,8 @@ const open = async (type: string, id?: number) => { | ||||
|       formLoading.value = false | ||||
|     } | ||||
|   } | ||||
|   // 加载Menu列表 | ||||
|   menuOptions.value = handleTree(await MenuApi.getSimpleMenusList()) | ||||
| } | ||||
| defineExpose({ open }) // 提供 open 方法,用于打开弹窗 | ||||
| 
 | ||||
| @@ -159,10 +138,10 @@ const submitForm = async () => { | ||||
|       ...(treeRef.value!.getHalfCheckedKeys() as unknown as Array<number>) | ||||
|     ] | ||||
|     if (formType.value === 'create') { | ||||
|       await TenantPackageApi.createTenantPackageType(data) | ||||
|       await TenantPackageApi.createTenantPackage(data) | ||||
|       message.success(t('common.createSuccess')) | ||||
|     } else { | ||||
|       await TenantPackageApi.updateTenantPackageType(data) | ||||
|       await TenantPackageApi.updateTenantPackage(data) | ||||
|       message.success(t('common.updateSuccess')) | ||||
|     } | ||||
|     modelVisible.value = false | ||||
| @@ -189,6 +168,18 @@ const resetForm = () => { | ||||
|   menuCheckStrictly.value = false | ||||
|   formRef.value?.resetFields() | ||||
| } | ||||
| 
 | ||||
| // 全选/全不选 | ||||
| const handleCheckedTreeNodeAll = () => { | ||||
|   treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : []) | ||||
| } | ||||
| // 全部(展开/折叠)TODO:for循环全部展开和折叠树组件数据 | ||||
| const handleCheckedTreeExpand = () => { | ||||
|   const nodes = treeRef.value?.store.nodesMap | ||||
|   for (let node in nodes) { | ||||
|     nodes[node].expanded = !nodes[node].expanded | ||||
|   } | ||||
| } | ||||
| </script> | ||||
| <style lang="scss" scoped> | ||||
| .cardHeight { | ||||
| @@ -14,10 +14,11 @@ | ||||
|           placeholder="请输入套餐名" | ||||
|           clearable | ||||
|           @keyup.enter="handleQuery" | ||||
|           class="!w-240px" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|       <el-form-item label="状态" prop="status"> | ||||
|         <el-select v-model="queryParams.status" placeholder="请选择状态" clearable> | ||||
|         <el-select v-model="queryParams.status" placeholder="请选择状态" clearable class="!w-240px"> | ||||
|           <el-option | ||||
|             v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" | ||||
|             :key="dict.value" | ||||
| @@ -29,7 +30,6 @@ | ||||
|       <el-form-item label="创建时间" prop="createTime"> | ||||
|         <el-date-picker | ||||
|           v-model="queryParams.createTime" | ||||
|           style="width: 240px" | ||||
|           type="daterange" | ||||
|           value-format="YYYY-MM-DD HH:mm:ss" | ||||
|           start-placeholder="开始日期" | ||||
| @@ -37,19 +37,12 @@ | ||||
|           class="!w-240px" | ||||
|         /> | ||||
|       </el-form-item> | ||||
|  | ||||
|       <el-form-item> | ||||
|         <el-button @click="handleQuery"> | ||||
|           <Icon icon="ep:search" class="mr-5px" /> | ||||
|           搜索 | ||||
|         </el-button> | ||||
|         <el-button @click="resetQuery"> | ||||
|           <Icon icon="ep:refresh" class="mr-5px" /> | ||||
|           重置 | ||||
|         </el-button> | ||||
|         <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> | ||||
|         <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> | ||||
|         <el-button | ||||
|           type="primary" | ||||
|           @click="handleCreate('create')" | ||||
|           @click="openForm('create')" | ||||
|           v-hasPermi="['system:tenant-package:create']" | ||||
|         > | ||||
|           <Icon icon="ep:plus" class="mr-5px" /> | ||||
| @@ -72,26 +65,26 @@ | ||||
|       <el-table-column label="备注" align="center" prop="remark" /> | ||||
|       <el-table-column label="创建时间" align="center" prop="createTime" width="180"> | ||||
|         <template #default="scope"> | ||||
|           <span>{{ parseTime(scope.row.createTime) }}</span> | ||||
|           <span>{{ formatDate(scope.row.createTime) }}</span> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
|       <el-table-column label="操作" align="center" class-name="small-padding fixed-width"> | ||||
|         <template #default="scope"> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-edit" | ||||
|             @click="handleUpdate('update', scope.row.id)" | ||||
|             link | ||||
|             type="primary" | ||||
|             @click="openForm('update', scope.row.id)" | ||||
|             v-hasPermi="['system:tenant-package:update']" | ||||
|             >修改 | ||||
|           > | ||||
|             修改 | ||||
|           </el-button> | ||||
|           <el-button | ||||
|             size="mini" | ||||
|             type="text" | ||||
|             icon="el-icon-delete" | ||||
|             link | ||||
|             type="danger" | ||||
|             @click="handleDelete(scope.row.id)" | ||||
|             v-hasPermi="['system:tenant-package:delete']" | ||||
|             >删除 | ||||
|           > | ||||
|             删除 | ||||
|           </el-button> | ||||
|         </template> | ||||
|       </el-table-column> | ||||
| @@ -104,15 +97,15 @@ | ||||
|       @pagination="getList" | ||||
|     /> | ||||
|   </ContentWrap> | ||||
|  | ||||
|   <!-- 表单弹窗:添加/修改 --> | ||||
|   <TenantPackageForm ref="formRef" @success="getList" /> | ||||
| </template> | ||||
| <script setup lang="ts" name="TenantPackage"> | ||||
| import TenantPackageForm from './form.vue' | ||||
| // 业务相关的 import | ||||
| import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' | ||||
| import { parseTime } from '@/utils/formatTime' | ||||
| import { formatDate } from '@/utils/formatTime' | ||||
| import * as TenantPackageApi from '@/api/system/tenantPackage' | ||||
|  | ||||
| import TenantPackageForm from './TenantPackageForm.vue' | ||||
| const message = useMessage() // 消息弹窗 | ||||
| const { t } = useI18n() // 国际化 | ||||
|  | ||||
| @@ -128,17 +121,17 @@ const queryParams: Record<string, any> = ref<Record<string, any>>({ | ||||
|   createTime: [] | ||||
| }) | ||||
| const queryFormRef = ref() // 搜索的表单 | ||||
| const formRef = ref() // 表单 Ref | ||||
|  | ||||
| /** 查询列表 */ | ||||
| const getList = () => { | ||||
| const getList = async () => { | ||||
|   loading.value = true | ||||
|   // 执行查询 | ||||
|   TenantPackageApi.getTenantPackageTypePage(queryParams.value).then((response) => { | ||||
|     list.value = response.list | ||||
|     total.value = response.total | ||||
|   try { | ||||
|     const data = await TenantPackageApi.getTenantPackagePage(queryParams.value) | ||||
|     list.value = data.list | ||||
|     total.value = data.total | ||||
|   } finally { | ||||
|     loading.value = false | ||||
|   }) | ||||
|   } | ||||
| } | ||||
|  | ||||
| /** 搜索按钮操作 */ | ||||
| @@ -149,31 +142,31 @@ const handleQuery = () => { | ||||
|  | ||||
| /** 重置按钮操作 */ | ||||
| const resetQuery = () => { | ||||
|   // 表单重置 | ||||
|   queryFormRef.value?.resetFields() | ||||
|   getList() | ||||
| } | ||||
|  | ||||
| // 新增操作 | ||||
| const handleCreate = (type: string) => { | ||||
|   formRef.value.open(type) | ||||
| } | ||||
|  | ||||
| // 修改操作 | ||||
| const handleUpdate = async (type: string, id?: number) => { | ||||
| /** 添加/修改操作 */ | ||||
| const formRef = ref() | ||||
| const openForm = (type: string, id?: number) => { | ||||
|   formRef.value.open(type, id) | ||||
| } | ||||
|  | ||||
| /** 删除按钮操作 */ | ||||
| const handleDelete = async (id: number) => { | ||||
|   try { | ||||
|     // 删除的二次确认 | ||||
|     await message.delConfirm() | ||||
|     // 发起删除 | ||||
|     await TenantPackageApi.deleteTenantPackageType(id) | ||||
|     await TenantPackageApi.deleteTenantPackage(id) | ||||
|     message.success(t('common.delSuccess')) | ||||
|     // 刷新列表 | ||||
|     await getList() | ||||
|   } catch {} | ||||
| } | ||||
| getList() | ||||
|  | ||||
| /** 初始化 **/ | ||||
| onMounted(() => { | ||||
|   getList() | ||||
| }) | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV