REVIEW 租户套餐

This commit is contained in:
YunaiV 2023-03-29 23:43:22 +08:00
parent e30d32effb
commit 216ad84938
4 changed files with 68 additions and 87 deletions

View File

@ -12,15 +12,8 @@ export interface TenantPackageVO {
createTime: Date 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 }) 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 }) 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 }) 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 }) return request.delete({ url: '/system/tenant-package/delete?id=' + id })
} }
// 获取租户套餐精简信息列表 // 获取租户套餐精简信息列表

View File

@ -52,6 +52,7 @@ declare module '@vue/runtime-core' {
ElForm: typeof import('element-plus/es')['ElForm'] ElForm: typeof import('element-plus/es')['ElForm']
ElFormItem: typeof import('element-plus/es')['ElFormItem'] ElFormItem: typeof import('element-plus/es')['ElFormItem']
ElIcon: typeof import('element-plus/es')['ElIcon'] ElIcon: typeof import('element-plus/es')['ElIcon']
ElImage: typeof import('element-plus/es')['ElImage']
ElImageViewer: typeof import('element-plus/es')['ElImageViewer'] ElImageViewer: typeof import('element-plus/es')['ElImageViewer']
ElInput: typeof import('element-plus/es')['ElInput'] ElInput: typeof import('element-plus/es')['ElInput']
ElInputNumber: typeof import('element-plus/es')['ElInputNumber'] ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
@ -72,7 +73,10 @@ declare module '@vue/runtime-core' {
ElTabPane: typeof import('element-plus/es')['ElTabPane'] ElTabPane: typeof import('element-plus/es')['ElTabPane']
ElTabs: typeof import('element-plus/es')['ElTabs'] ElTabs: typeof import('element-plus/es')['ElTabs']
ElTag: typeof import('element-plus/es')['ElTag'] 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'] ElTooltip: typeof import('element-plus/es')['ElTooltip']
ElTransfer: typeof import('element-plus/es')['ElTransfer']
ElTree: typeof import('element-plus/es')['ElTree'] ElTree: typeof import('element-plus/es')['ElTree']
ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect'] ElTreeSelect: typeof import('element-plus/es')['ElTreeSelect']
ElUpload: typeof import('element-plus/es')['ElUpload'] ElUpload: typeof import('element-plus/es')['ElUpload']

View File

@ -1,5 +1,5 @@
<template> <template>
<Dialog :title="modelTitle" v-model="modelVisible" width="50%"> <Dialog :title="modelTitle" v-model="modelVisible">
<el-form <el-form
ref="formRef" ref="formRef"
:model="formData" :model="formData"
@ -13,13 +13,6 @@
<el-form-item label="菜单权限"> <el-form-item label="菜单权限">
<el-card class="cardHeight"> <el-card class="cardHeight">
<template #header> <template #header>
父子联动(选中父节点自动选择子节点):
<el-switch
v-model="menuCheckStrictly"
inline-prompt
active-text="是"
inactive-text="否"
/>
全选/全不选: 全选/全不选:
<el-switch <el-switch
v-model="treeNodeAll" v-model="treeNodeAll"
@ -43,7 +36,7 @@
:check-strictly="!menuCheckStrictly" :check-strictly="!menuCheckStrictly"
show-checkbox show-checkbox
:props="defaultProps" :props="defaultProps"
:data="menuOptions as any[]" :data="menuOptions"
empty-text="加载中,请稍候" empty-text="加载中,请稍候"
/> />
</el-card> </el-card>
@ -51,7 +44,7 @@
<el-form-item label="状态" prop="status"> <el-form-item label="状态" prop="status">
<el-radio-group v-model="formData.status"> <el-radio-group v-model="formData.status">
<el-radio <el-radio
v-for="dict in getDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :key="dict.value"
:label="parseInt(dict.value)" :label="parseInt(dict.value)"
> >
@ -70,30 +63,28 @@
</Dialog> </Dialog>
</template> </template>
<script setup lang="ts" name="TenantPackageForm"> <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 { CommonStatusEnum } from '@/utils/constants'
import type { FormRules } from 'element-plus'
import { defaultProps } from '@/utils/tree' import { defaultProps } from '@/utils/tree'
//
import * as TenantPackageApi from '@/api/system/tenantPackage' 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 { ElTree } from 'element-plus'
import { handleTree } from '@/utils/tree' import { handleTree } from '@/utils/tree'
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const modelVisible = ref(false) // const modelVisible = ref(false) //
const modelTitle = ref('') // const modelTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
const formData: Record<string, any> = ref<Record<string, any>>({ const formData = ref({
id: null, id: null,
name: null, name: null,
remark: null, remark: null,
menuIds: [], menuIds: [],
status: CommonStatusEnum.ENABLE status: CommonStatusEnum.ENABLE
}) })
const formRules: FormRules = ref<FormRules>({ const formRules = reactive({
name: [{ required: true, message: '套餐名不能为空', trigger: 'blur' }], name: [{ required: true, message: '套餐名不能为空', trigger: 'blur' }],
status: [{ required: true, message: '状态不能为空', trigger: 'blur' }], status: [{ required: true, message: '状态不能为空', trigger: 'blur' }],
menuIds: [{ 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 treeRef = ref<InstanceType<typeof ElTree>>() // Ref
const treeNodeAll = ref(false) // / 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) => { const open = async (type: string, id?: number) => {
modelVisible.value = true modelVisible.value = true
modelTitle.value = t('action.' + type) modelTitle.value = t('action.' + type)
formType.value = type formType.value = type
resetForm() resetForm()
// Menu
menuOptions.value = handleTree(await getSimpleMenusList())
// //
if (id) { if (id) {
formLoading.value = true formLoading.value = true
@ -140,6 +117,8 @@ const open = async (type: string, id?: number) => {
formLoading.value = false formLoading.value = false
} }
} }
// Menu
menuOptions.value = handleTree(await MenuApi.getSimpleMenusList())
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -159,10 +138,10 @@ const submitForm = async () => {
...(treeRef.value!.getHalfCheckedKeys() as unknown as Array<number>) ...(treeRef.value!.getHalfCheckedKeys() as unknown as Array<number>)
] ]
if (formType.value === 'create') { if (formType.value === 'create') {
await TenantPackageApi.createTenantPackageType(data) await TenantPackageApi.createTenantPackage(data)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
} else { } else {
await TenantPackageApi.updateTenantPackageType(data) await TenantPackageApi.updateTenantPackage(data)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
modelVisible.value = false modelVisible.value = false
@ -189,6 +168,18 @@ const resetForm = () => {
menuCheckStrictly.value = false menuCheckStrictly.value = false
formRef.value?.resetFields() 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> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.cardHeight { .cardHeight {

View File

@ -14,10 +14,11 @@
placeholder="请输入套餐名" placeholder="请输入套餐名"
clearable clearable
@keyup.enter="handleQuery" @keyup.enter="handleQuery"
class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item label="状态" prop="status"> <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 <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
:key="dict.value" :key="dict.value"
@ -29,7 +30,6 @@
<el-form-item label="创建时间" prop="createTime"> <el-form-item label="创建时间" prop="createTime">
<el-date-picker <el-date-picker
v-model="queryParams.createTime" v-model="queryParams.createTime"
style="width: 240px"
type="daterange" type="daterange"
value-format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss"
start-placeholder="开始日期" start-placeholder="开始日期"
@ -37,19 +37,12 @@
class="!w-240px" class="!w-240px"
/> />
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button @click="handleQuery"> <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<Icon icon="ep:search" class="mr-5px" /> <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
搜索
</el-button>
<el-button @click="resetQuery">
<Icon icon="ep:refresh" class="mr-5px" />
重置
</el-button>
<el-button <el-button
type="primary" type="primary"
@click="handleCreate('create')" @click="openForm('create')"
v-hasPermi="['system:tenant-package:create']" v-hasPermi="['system:tenant-package:create']"
> >
<Icon icon="ep:plus" class="mr-5px" /> <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="remark" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180"> <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template #default="scope"> <template #default="scope">
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ formatDate(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-button <el-button
size="mini" link
type="text" type="primary"
icon="el-icon-edit" @click="openForm('update', scope.row.id)"
@click="handleUpdate('update', scope.row.id)"
v-hasPermi="['system:tenant-package:update']" v-hasPermi="['system:tenant-package:update']"
>修改 >
修改
</el-button> </el-button>
<el-button <el-button
size="mini" link
type="text" type="danger"
icon="el-icon-delete"
@click="handleDelete(scope.row.id)" @click="handleDelete(scope.row.id)"
v-hasPermi="['system:tenant-package:delete']" v-hasPermi="['system:tenant-package:delete']"
>删除 >
删除
</el-button> </el-button>
</template> </template>
</el-table-column> </el-table-column>
@ -104,15 +97,15 @@
@pagination="getList" @pagination="getList"
/> />
</ContentWrap> </ContentWrap>
<!-- 表单弹窗添加/修改 -->
<TenantPackageForm ref="formRef" @success="getList" /> <TenantPackageForm ref="formRef" @success="getList" />
</template> </template>
<script setup lang="ts" name="TenantPackage"> <script setup lang="ts" name="TenantPackage">
import TenantPackageForm from './form.vue'
// import
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' 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 * as TenantPackageApi from '@/api/system/tenantPackage'
import TenantPackageForm from './TenantPackageForm.vue'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -128,17 +121,17 @@ const queryParams: Record<string, any> = ref<Record<string, any>>({
createTime: [] createTime: []
}) })
const queryFormRef = ref() // const queryFormRef = ref() //
const formRef = ref() // Ref
/** 查询列表 */ /** 查询列表 */
const getList = () => { const getList = async () => {
loading.value = true loading.value = true
// try {
TenantPackageApi.getTenantPackageTypePage(queryParams.value).then((response) => { const data = await TenantPackageApi.getTenantPackagePage(queryParams.value)
list.value = response.list list.value = data.list
total.value = response.total total.value = data.total
} finally {
loading.value = false loading.value = false
}) }
} }
/** 搜索按钮操作 */ /** 搜索按钮操作 */
@ -149,31 +142,31 @@ const handleQuery = () => {
/** 重置按钮操作 */ /** 重置按钮操作 */
const resetQuery = () => { const resetQuery = () => {
//
queryFormRef.value?.resetFields() queryFormRef.value?.resetFields()
getList() getList()
} }
// /** 添加/修改操作 */
const handleCreate = (type: string) => { const formRef = ref()
formRef.value.open(type) const openForm = (type: string, id?: number) => {
}
//
const handleUpdate = async (type: string, id?: number) => {
formRef.value.open(type, id) formRef.value.open(type, id)
} }
/** 删除按钮操作 */ /** 删除按钮操作 */
const handleDelete = async (id: number) => { const handleDelete = async (id: number) => {
try { try {
// //
await message.delConfirm() await message.delConfirm()
// //
await TenantPackageApi.deleteTenantPackageType(id) await TenantPackageApi.deleteTenantPackage(id)
message.success(t('common.delSuccess')) message.success(t('common.delSuccess'))
// //
await getList() await getList()
} catch {} } catch {}
} }
/** 初始化 **/
onMounted(() => {
getList() getList()
})
</script> </script>