REVIEW 租户套餐
This commit is contained in:
parent
e30d32effb
commit
216ad84938
@ -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 })
|
||||||
}
|
}
|
||||||
// 获取租户套餐精简信息列表
|
// 获取租户套餐精简信息列表
|
||||||
|
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']
|
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']
|
||||||
|
@ -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) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
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 {
|
@ -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 {}
|
||||||
}
|
}
|
||||||
getList()
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
getList()
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
Reference in New Issue
Block a user