mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-12-02 04:01:52 +08:00
feat: tenant
This commit is contained in:
parent
88cb5497c5
commit
407ac853cb
@ -27,7 +27,6 @@
|
|||||||
<mybatis-plus-generator.version>3.5.2</mybatis-plus-generator.version>
|
<mybatis-plus-generator.version>3.5.2</mybatis-plus-generator.version>
|
||||||
<dynamic-datasource.version>3.5.2</dynamic-datasource.version>
|
<dynamic-datasource.version>3.5.2</dynamic-datasource.version>
|
||||||
<redisson.version>3.18.0</redisson.version>
|
<redisson.version>3.18.0</redisson.version>
|
||||||
<!-- Config 配置中心相关 -->
|
|
||||||
<!-- 服务保障相关 -->
|
<!-- 服务保障相关 -->
|
||||||
<lock4j.version>2.2.2</lock4j.version>
|
<lock4j.version>2.2.2</lock4j.version>
|
||||||
<resilience4j.version>1.7.1</resilience4j.version>
|
<resilience4j.version>1.7.1</resilience4j.version>
|
||||||
|
@ -28,7 +28,7 @@ specifiers:
|
|||||||
dayjs: ^1.11.6
|
dayjs: ^1.11.6
|
||||||
echarts: ^5.4.0
|
echarts: ^5.4.0
|
||||||
echarts-wordcloud: ^2.0.0
|
echarts-wordcloud: ^2.0.0
|
||||||
element-plus: 2.2.22
|
element-plus: 2.2.21
|
||||||
eslint: ^8.27.0
|
eslint: ^8.27.0
|
||||||
eslint-config-prettier: ^8.5.0
|
eslint-config-prettier: ^8.5.0
|
||||||
eslint-define-config: ^1.12.0
|
eslint-define-config: ^1.12.0
|
||||||
@ -92,7 +92,7 @@ dependencies:
|
|||||||
dayjs: registry.npmmirror.com/dayjs/1.11.6
|
dayjs: registry.npmmirror.com/dayjs/1.11.6
|
||||||
echarts: registry.npmmirror.com/echarts/5.4.0
|
echarts: registry.npmmirror.com/echarts/5.4.0
|
||||||
echarts-wordcloud: registry.npmmirror.com/echarts-wordcloud/2.0.0_echarts@5.4.0
|
echarts-wordcloud: registry.npmmirror.com/echarts-wordcloud/2.0.0_echarts@5.4.0
|
||||||
element-plus: registry.npmmirror.com/element-plus/2.2.22_vue@3.2.45
|
element-plus: registry.npmmirror.com/element-plus/2.2.21_vue@3.2.45
|
||||||
intro.js: registry.npmmirror.com/intro.js/6.0.0
|
intro.js: registry.npmmirror.com/intro.js/6.0.0
|
||||||
js-cookie: registry.npmmirror.com/js-cookie/3.0.1
|
js-cookie: registry.npmmirror.com/js-cookie/3.0.1
|
||||||
jsencrypt: registry.npmmirror.com/jsencrypt/3.3.1
|
jsencrypt: registry.npmmirror.com/jsencrypt/3.3.1
|
||||||
@ -3645,11 +3645,11 @@ packages:
|
|||||||
version: 1.4.284
|
version: 1.4.284
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
registry.npmmirror.com/element-plus/2.2.22_vue@3.2.45:
|
registry.npmmirror.com/element-plus/2.2.21_vue@3.2.45:
|
||||||
resolution: {integrity: sha512-gg2g2WOMNpWf0wGesymUvTV0VZDF/4khQKroSNeCV/vWJ/cqssPYdtqfGxTiFRt/f+JpyFkV7O1mo0yzMCzrBg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/element-plus/-/element-plus-2.2.22.tgz}
|
resolution: {integrity: sha512-wZUePoXZ1zuCkzENK/8mn+mekuLJ9OoGYiudjUujzCf+T8HfOQl+TKQStwOkGBNk93fK8e9YdFIty4jH4AX6dg==, registry: https://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/element-plus/-/element-plus-2.2.21.tgz}
|
||||||
id: registry.npmmirror.com/element-plus/2.2.22
|
id: registry.npmmirror.com/element-plus/2.2.21
|
||||||
name: element-plus
|
name: element-plus
|
||||||
version: 2.2.22
|
version: 2.2.21
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
vue: ^3.2.0
|
vue: ^3.2.0
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -1,8 +1,36 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
import type { TenantVO } from './types'
|
|
||||||
|
export interface TenantVO {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
packageId: number
|
||||||
|
contactName: string
|
||||||
|
contactMobile: string
|
||||||
|
username: string
|
||||||
|
password: string
|
||||||
|
accountCount: number
|
||||||
|
expireTime: string
|
||||||
|
domain: string
|
||||||
|
status: number
|
||||||
|
createTime: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TenantPageReqVO extends PageParam {
|
||||||
|
name?: string
|
||||||
|
contactName?: string
|
||||||
|
contactMobile?: string
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TenantExportReqVO {
|
||||||
|
name?: string
|
||||||
|
contactName?: string
|
||||||
|
contactMobile?: string
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
// 查询租户列表
|
// 查询租户列表
|
||||||
export const getTenantPageApi = (params) => {
|
export const getTenantPageApi = (params: TenantPageReqVO) => {
|
||||||
return request.get({ url: '/system/tenant/page', params })
|
return request.get({ url: '/system/tenant/page', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,6 +55,6 @@ export const deleteTenantApi = (id: number) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 导出租户
|
// 导出租户
|
||||||
export const exportTenantApi = (params) => {
|
export const exportTenantApi = (params: TenantExportReqVO) => {
|
||||||
return request.download({ url: '/system/tenant/export-excel', params })
|
return request.download({ url: '/system/tenant/export-excel', params })
|
||||||
}
|
}
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
export type TenantVO = {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
packageId: number
|
|
||||||
contactName: string
|
|
||||||
contactMobile: string
|
|
||||||
username: string
|
|
||||||
password: string
|
|
||||||
accountCount: number
|
|
||||||
expireTime: string
|
|
||||||
domain: string
|
|
||||||
status: number
|
|
||||||
createTime: string
|
|
||||||
}
|
|
@ -1,8 +1,26 @@
|
|||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
import type { TenantPackageVO } from './types'
|
|
||||||
|
export interface TenantPackageVO {
|
||||||
|
id: number
|
||||||
|
name: string
|
||||||
|
status: number
|
||||||
|
remark: string
|
||||||
|
creator: string
|
||||||
|
createTime: string
|
||||||
|
updater: string
|
||||||
|
updateTime: string
|
||||||
|
menuIds: string[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TenantPackagePageReqVO extends PageParam {
|
||||||
|
name?: string
|
||||||
|
contactName?: string
|
||||||
|
contactMobile?: string
|
||||||
|
status?: number
|
||||||
|
}
|
||||||
|
|
||||||
// 查询租户套餐列表
|
// 查询租户套餐列表
|
||||||
export const getTenantPackageTypePageApi = (params) => {
|
export const getTenantPackageTypePageApi = (params: TenantPackagePageReqVO) => {
|
||||||
return request.get({ url: '/system/tenant-package/page', params })
|
return request.get({ url: '/system/tenant-package/page', params })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +43,7 @@ export const updateTenantPackageTypeApi = (data: TenantPackageVO) => {
|
|||||||
export const deleteTenantPackageTypeApi = (id: number) => {
|
export const deleteTenantPackageTypeApi = (id: number) => {
|
||||||
return request.delete({ url: '/system/tenant-package/delete?id=' + id })
|
return request.delete({ url: '/system/tenant-package/delete?id=' + id })
|
||||||
}
|
}
|
||||||
// // 获取租户套餐精简信息列表
|
// 获取租户套餐精简信息列表
|
||||||
export const getTenantPackageList = () => {
|
export const getTenantPackageList = () => {
|
||||||
return request.get({ url: '/system/tenant-package/get-simple-list' })
|
return request.get({ url: '/system/tenant-package/get-simple-list' })
|
||||||
}
|
}
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
export type TenantPackageVO = {
|
|
||||||
id: number
|
|
||||||
name: string
|
|
||||||
status: number
|
|
||||||
remark: string
|
|
||||||
creator: string
|
|
||||||
createTime: string
|
|
||||||
updater: string
|
|
||||||
updateTime: string
|
|
||||||
menuIds: string[]
|
|
||||||
}
|
|
@ -1,79 +1,55 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 搜索工作区 -->
|
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
|
|
||||||
</ContentWrap>
|
|
||||||
<ContentWrap>
|
|
||||||
<!-- 操作工具栏 -->
|
|
||||||
<div class="mb-10px">
|
|
||||||
<XButton
|
|
||||||
type="primary"
|
|
||||||
preIcon="ep:zoom-in"
|
|
||||||
:title="t('action.add')"
|
|
||||||
v-hasPermi="['system:tenant:create']"
|
|
||||||
@click="handleCreate()"
|
|
||||||
/>
|
|
||||||
<XButton
|
|
||||||
type="warning"
|
|
||||||
preIcon="ep:download"
|
|
||||||
:title="t('action.export')"
|
|
||||||
v-hasPermi="['system:tenant:export']"
|
|
||||||
@click="exportList('租户数据.xls')"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<Table
|
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
|
||||||
:columns="allSchemas.tableColumns"
|
<template #toolbar_buttons>
|
||||||
:selection="false"
|
<!-- 操作:新增 -->
|
||||||
:data="tableObject.tableList"
|
<XButton
|
||||||
:loading="tableObject.loading"
|
type="primary"
|
||||||
:pagination="{
|
preIcon="ep:zoom-in"
|
||||||
total: tableObject.total
|
:title="t('action.add')"
|
||||||
}"
|
v-hasPermi="['system:tenant:create']"
|
||||||
v-model:pageSize="tableObject.pageSize"
|
@click="handleCreate()"
|
||||||
v-model:currentPage="tableObject.currentPage"
|
/>
|
||||||
@register="register"
|
<XButton
|
||||||
>
|
type="warning"
|
||||||
|
preIcon="ep:download"
|
||||||
|
:title="t('action.export')"
|
||||||
|
v-hasPermi="['system:tenant:export']"
|
||||||
|
@click="handleExport()"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<template #accountCount="{ row }">
|
<template #accountCount="{ row }">
|
||||||
<el-tag> {{ row.accountCount }} </el-tag>
|
<el-tag> {{ row.accountCount }} </el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template #status="{ row }">
|
|
||||||
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
|
||||||
</template>
|
|
||||||
<template #packageId="{ row }">
|
<template #packageId="{ row }">
|
||||||
<el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag>
|
<el-tag v-if="row.packageId === 0" type="danger">系统租户</el-tag>
|
||||||
<el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag>
|
<el-tag v-else type="success"> {{ getPackageName(row.packageId) }} </el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template #expireTime="{ row }">
|
<template #actionbtns_default="{ row }">
|
||||||
<span>{{ dayjs(row.expireTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
|
||||||
</template>
|
|
||||||
<template #createTime="{ row }">
|
|
||||||
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
|
||||||
</template>
|
|
||||||
<template #action="{ row }">
|
|
||||||
<!-- 操作:修改 -->
|
<!-- 操作:修改 -->
|
||||||
<XTextButton
|
<XTextButton
|
||||||
preIcon="ep:edit"
|
preIcon="ep:edit"
|
||||||
:title="t('action.edit')"
|
:title="t('action.edit')"
|
||||||
v-hasPermi="['system:tenant:update']"
|
v-hasPermi="['system:tenant:update']"
|
||||||
@click="handleUpdate(row)"
|
@click="handleUpdate(row.id)"
|
||||||
/>
|
/>
|
||||||
<!-- 操作:详情 -->
|
<!-- 操作:详情 -->
|
||||||
<XTextButton
|
<XTextButton
|
||||||
preIcon="ep:view"
|
preIcon="ep:view"
|
||||||
:title="t('action.detail')"
|
:title="t('action.detail')"
|
||||||
v-hasPermi="['system:tenant:update']"
|
v-hasPermi="['system:tenant:update']"
|
||||||
@click="handleDetail(row)"
|
@click="handleDetail(row.id)"
|
||||||
/>
|
/>
|
||||||
<!-- 操作:删除 -->
|
<!-- 操作:删除 -->
|
||||||
<XTextButton
|
<XTextButton
|
||||||
preIcon="ep:delete"
|
preIcon="ep:delete"
|
||||||
:title="t('action.del')"
|
:title="t('action.del')"
|
||||||
v-hasPermi="['system:tenant:delete']"
|
v-hasPermi="['system:tenant:delete']"
|
||||||
@click="delList(row.id, false)"
|
@click="handleDelete(row.id)"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</Table>
|
</vxe-grid>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<XModal v-model="dialogVisible" :title="dialogTitle">
|
<XModal v-model="dialogVisible" :title="dialogTitle">
|
||||||
@ -124,27 +100,33 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, unref, onMounted } from 'vue'
|
import { ref, unref, onMounted } from 'vue'
|
||||||
import dayjs from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { ElMessage, ElTag, ElSelect, ElOption } from 'element-plus'
|
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
|
||||||
import { useTable } from '@/hooks/web/useTable'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||||
|
import { VxeGridInstance } from 'vxe-table'
|
||||||
|
import { ElTag, ElSelect, ElOption } from 'element-plus'
|
||||||
import { FormExpose } from '@/components/Form'
|
import { FormExpose } from '@/components/Form'
|
||||||
import type { TenantVO } from '@/api/system/tenant/types'
|
|
||||||
import { rules, allSchemas } from './tenant.data'
|
|
||||||
import * as TenantApi from '@/api/system/tenant'
|
import * as TenantApi from '@/api/system/tenant'
|
||||||
import { getTenantPackageList } from '@/api/system/tenantPackage'
|
import { rules, allSchemas } from './tenant.data'
|
||||||
import { TenantPackageVO } from '@/api/system/tenantPackage/types'
|
import { getTenantPackageList, TenantPackageVO } from '@/api/system/tenantPackage'
|
||||||
const { t } = useI18n() // 国际化
|
|
||||||
|
|
||||||
// ========== 列表相关 ==========
|
const { t } = useI18n() // 国际化
|
||||||
const { register, tableObject, methods } = useTable<TenantVO>({
|
const message = useMessage() // 消息弹窗
|
||||||
|
// 列表相关的变量
|
||||||
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
|
const { gridOptions, getList, deleteData, exportList } = useVxeGrid<TenantApi.TenantVO>({
|
||||||
|
allSchemas: allSchemas,
|
||||||
getListApi: TenantApi.getTenantPageApi,
|
getListApi: TenantApi.getTenantPageApi,
|
||||||
delListApi: TenantApi.deleteTenantApi,
|
deleteApi: TenantApi.deleteTenantApi,
|
||||||
exportListApi: TenantApi.exportTenantApi
|
exportListApi: TenantApi.exportTenantApi
|
||||||
})
|
})
|
||||||
const { getList, setSearchParams, delList, exportList } = methods
|
|
||||||
|
|
||||||
// ========== 套餐 ==========
|
const actionLoading = ref(false) // 遮罩层
|
||||||
|
const actionType = ref('') // 操作按钮的类型
|
||||||
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
|
const detailRef = ref() // 详情 Ref
|
||||||
const tenantPackageId = ref() // 套餐
|
const tenantPackageId = ref() // 套餐
|
||||||
const tenantPackageOptions = ref<TenantPackageVO[]>([]) //套餐列表
|
const tenantPackageOptions = ref<TenantPackageVO[]>([]) //套餐列表
|
||||||
|
|
||||||
@ -160,12 +142,6 @@ const getPackageName = (packageId: number) => {
|
|||||||
}
|
}
|
||||||
return '未知套餐'
|
return '未知套餐'
|
||||||
}
|
}
|
||||||
// ========== CRUD 相关 ==========
|
|
||||||
const actionLoading = ref(false) // 遮罩层
|
|
||||||
const actionType = ref('') // 操作按钮的类型
|
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
|
||||||
const dialogTitle = ref('edit') // 弹出层标题
|
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
|
||||||
|
|
||||||
// 设置标题
|
// 设置标题
|
||||||
const setDialogTile = (type: string) => {
|
const setDialogTile = (type: string) => {
|
||||||
@ -182,15 +158,34 @@ const handleCreate = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改操作
|
// 修改操作
|
||||||
const handleUpdate = async (row: any) => {
|
const handleUpdate = async (rowId: number) => {
|
||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await TenantApi.getTenantApi(row.id)
|
const res = await TenantApi.getTenantApi(rowId)
|
||||||
tenantPackageId.value = res.packageId
|
tenantPackageId.value = res.packageId
|
||||||
res.expireTime = dayjs(res.expireTime).format('YYYY-MM-DD HH:mm:ss')
|
res.expireTime = dayjs(res.expireTime).format('YYYY-MM-DD HH:mm:ss')
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 详情操作
|
||||||
|
const handleDetail = async (rowId: number) => {
|
||||||
|
// 设置数据
|
||||||
|
const res = await TenantApi.getTenantApi(rowId)
|
||||||
|
tenantPackageId.value = res.packageId
|
||||||
|
detailRef.value = res
|
||||||
|
setDialogTile('detail')
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleDelete = async (rowId: number) => {
|
||||||
|
await deleteData(xGrid, rowId)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出操作
|
||||||
|
const handleExport = async () => {
|
||||||
|
await exportList(xGrid, '租户列表.xls')
|
||||||
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
const elForm = unref(formRef)?.getElFormRef()
|
const elForm = unref(formRef)?.getElFormRef()
|
||||||
@ -200,40 +195,30 @@ const submitForm = async () => {
|
|||||||
actionLoading.value = true
|
actionLoading.value = true
|
||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as TenantVO
|
const data = unref(formRef)?.formModel as TenantApi.TenantVO
|
||||||
data.packageId = tenantPackageId.value
|
data.packageId = tenantPackageId.value
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
data.expireTime = dayjs(data.expireTime).valueOf().toString()
|
data.expireTime = dayjs(data.expireTime).valueOf().toString()
|
||||||
await TenantApi.createTenantApi(data)
|
await TenantApi.createTenantApi(data)
|
||||||
ElMessage.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
data.expireTime = dayjs(data.expireTime).valueOf().toString()
|
data.expireTime = dayjs(data.expireTime).valueOf().toString()
|
||||||
await TenantApi.updateTenantApi(data)
|
await TenantApi.updateTenantApi(data)
|
||||||
ElMessage.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
// 操作成功,重新加载列表
|
// 操作成功,重新加载列表
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
await getList()
|
|
||||||
} finally {
|
} finally {
|
||||||
actionLoading.value = false
|
actionLoading.value = false
|
||||||
|
// 刷新列表
|
||||||
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 详情相关 ==========
|
|
||||||
const detailRef = ref() // 详情 Ref
|
|
||||||
|
|
||||||
// 详情操作
|
|
||||||
const handleDetail = async (row: any) => {
|
|
||||||
// 设置数据
|
|
||||||
detailRef.value = row
|
|
||||||
setDialogTile('detail')
|
|
||||||
}
|
|
||||||
|
|
||||||
// ========== 初始化 ==========
|
// ========== 初始化 ==========
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getList()
|
|
||||||
await getTenantPackageOptions()
|
await getTenantPackageOptions()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@ -18,115 +18,82 @@ export const rules = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// CrudSchema.
|
// CrudSchema.
|
||||||
const crudSchemas = reactive<CrudSchema[]>([
|
const crudSchemas = reactive<VxeCrudSchema>({
|
||||||
{
|
primaryKey: 'id',
|
||||||
label: t('common.index'),
|
primaryType: 'seq',
|
||||||
field: 'id',
|
action: true,
|
||||||
type: 'index',
|
columns: [
|
||||||
form: {
|
{
|
||||||
show: false
|
title: '租户名称',
|
||||||
|
field: 'name',
|
||||||
|
isSearch: true
|
||||||
},
|
},
|
||||||
detail: {
|
{
|
||||||
show: false
|
title: '租户套餐',
|
||||||
}
|
field: 'packageId'
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '租户名称',
|
|
||||||
field: 'name',
|
|
||||||
search: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '租户套餐',
|
|
||||||
field: 'packageId'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '联系人',
|
|
||||||
field: 'contactName',
|
|
||||||
search: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '联系手机',
|
|
||||||
field: 'contactMobile',
|
|
||||||
search: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '用户名称',
|
|
||||||
field: 'username',
|
|
||||||
table: {
|
|
||||||
show: false
|
|
||||||
},
|
},
|
||||||
detail: {
|
{
|
||||||
show: false
|
title: '联系人',
|
||||||
}
|
field: 'contactName',
|
||||||
},
|
isSearch: true
|
||||||
{
|
|
||||||
label: '用户密码',
|
|
||||||
field: 'password',
|
|
||||||
table: {
|
|
||||||
show: false
|
|
||||||
},
|
},
|
||||||
detail: {
|
{
|
||||||
show: false
|
title: '联系手机',
|
||||||
|
field: 'contactMobile',
|
||||||
|
isSearch: true
|
||||||
},
|
},
|
||||||
form: {
|
{
|
||||||
component: 'InputPassword'
|
title: '用户名称',
|
||||||
}
|
field: 'username',
|
||||||
},
|
isTable: false,
|
||||||
{
|
isDetail: false
|
||||||
label: '账号额度',
|
},
|
||||||
field: 'accountCount',
|
{
|
||||||
form: {
|
title: '用户密码',
|
||||||
component: 'InputNumber'
|
field: 'password',
|
||||||
}
|
isTable: false,
|
||||||
},
|
isDetail: false,
|
||||||
{
|
form: {
|
||||||
label: '过期时间',
|
component: 'InputPassword'
|
||||||
field: 'expireTime',
|
|
||||||
form: {
|
|
||||||
show: true,
|
|
||||||
component: 'DatePicker',
|
|
||||||
componentProps: {
|
|
||||||
type: 'datetime',
|
|
||||||
valueFormat: 'x'
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '绑定域名',
|
|
||||||
field: 'domain'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: '租户状态',
|
|
||||||
field: 'status',
|
|
||||||
dictType: DICT_TYPE.COMMON_STATUS,
|
|
||||||
dictClass: 'number',
|
|
||||||
search: {
|
|
||||||
show: true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('table.createTime'),
|
|
||||||
field: 'createTime',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('table.action'),
|
|
||||||
field: 'action',
|
|
||||||
width: '240px',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
},
|
||||||
detail: {
|
{
|
||||||
show: false
|
title: '账号额度',
|
||||||
|
field: 'accountCount',
|
||||||
|
form: {
|
||||||
|
component: 'InputNumber'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '过期时间',
|
||||||
|
field: 'expireTime',
|
||||||
|
formatter: 'formatDate',
|
||||||
|
form: {
|
||||||
|
show: true,
|
||||||
|
component: 'DatePicker',
|
||||||
|
componentProps: {
|
||||||
|
type: 'datetime',
|
||||||
|
valueFormat: 'x'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '绑定域名',
|
||||||
|
field: 'domain'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '租户状态',
|
||||||
|
field: 'status',
|
||||||
|
dictType: DICT_TYPE.COMMON_STATUS,
|
||||||
|
dictClass: 'number',
|
||||||
|
isSearch: true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: t('table.createTime'),
|
||||||
|
field: 'createTime',
|
||||||
|
formatter: 'formatDate',
|
||||||
|
isForm: false
|
||||||
}
|
}
|
||||||
}
|
]
|
||||||
])
|
})
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
||||||
|
@ -1,42 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- 搜索工作区 -->
|
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams" />
|
|
||||||
</ContentWrap>
|
|
||||||
<ContentWrap>
|
|
||||||
<!-- 操作工具栏 -->
|
|
||||||
<div class="mb-10px">
|
|
||||||
<XButton
|
|
||||||
type="primary"
|
|
||||||
preIcon="ep:zoom-in"
|
|
||||||
:title="t('action.add')"
|
|
||||||
@click="handleCreate()"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<!-- 列表 -->
|
<!-- 列表 -->
|
||||||
<Table
|
<vxe-grid ref="xGrid" v-bind="gridOptions" class="xtable-scrollbar">
|
||||||
:columns="allSchemas.tableColumns"
|
<template #toolbar_buttons>
|
||||||
:selection="false"
|
<XButton
|
||||||
:data="tableObject.tableList"
|
type="primary"
|
||||||
:loading="tableObject.loading"
|
preIcon="ep:zoom-in"
|
||||||
:pagination="{
|
:title="t('action.add')"
|
||||||
total: tableObject.total
|
@click="handleCreate()"
|
||||||
}"
|
/>
|
||||||
v-model:pageSize="tableObject.pageSize"
|
|
||||||
v-model:currentPage="tableObject.currentPage"
|
|
||||||
@register="register"
|
|
||||||
>
|
|
||||||
<template #status="{ row }">
|
|
||||||
<DictTag :type="DICT_TYPE.COMMON_STATUS" :value="row.status" />
|
|
||||||
</template>
|
</template>
|
||||||
<template #createTime="{ row }">
|
<template #actionbtns_default="{ row }">
|
||||||
<span>{{ dayjs(row.createTime).format('YYYY-MM-DD HH:mm:ss') }}</span>
|
<XTextButton preIcon="ep:edit" :title="t('action.edit')" @click="handleUpdate(row.id)" />
|
||||||
|
<XTextButton preIcon="ep:delete" :title="t('action.del')" @click="handleDelete(row.id)" />
|
||||||
</template>
|
</template>
|
||||||
<template #action="{ row }">
|
</vxe-grid>
|
||||||
<XTextButton preIcon="ep:edit" :title="t('action.edit')" @click="handleUpdate(row)" />
|
|
||||||
<XTextButton preIcon="ep:delete" :title="t('action.del')" @click="delList(row.id, false)" />
|
|
||||||
</template>
|
|
||||||
</Table>
|
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
|
||||||
<XModal v-model="dialogVisible" :title="dialogTitle">
|
<XModal v-model="dialogVisible" :title="dialogTitle">
|
||||||
@ -89,28 +67,39 @@
|
|||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, ref, unref } from 'vue'
|
import { onMounted, ref, unref } from 'vue'
|
||||||
import dayjs from 'dayjs'
|
|
||||||
import { handleTree } from '@/utils/tree'
|
import { handleTree } from '@/utils/tree'
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
|
||||||
import { useTable } from '@/hooks/web/useTable'
|
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
|
import { useVxeGrid } from '@/hooks/web/useVxeGrid'
|
||||||
|
import { VxeGridInstance } from 'vxe-table'
|
||||||
import { FormExpose } from '@/components/Form'
|
import { FormExpose } from '@/components/Form'
|
||||||
import { TenantPackageVO } from '@/api/system/tenantPackage/types'
|
import { ElCard, ElSwitch, ElTree } from 'element-plus'
|
||||||
import { ElMessage, ElCard, ElSwitch, ElTree } from 'element-plus'
|
// 业务相关的 import
|
||||||
import { rules, allSchemas } from './tenantPackage.data'
|
import { rules, allSchemas } from './tenantPackage.data'
|
||||||
import * as TenantPackageApi from '@/api/system/tenantPackage'
|
import * as TenantPackageApi from '@/api/system/tenantPackage'
|
||||||
import { listSimpleMenusApi } from '@/api/system/menu'
|
import { listSimpleMenusApi } from '@/api/system/menu'
|
||||||
|
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const menuOptions = ref<any[]>([]) // 树形结构
|
||||||
|
const menuExpand = ref(false)
|
||||||
|
const menuNodeAll = ref(false)
|
||||||
|
const treeRef = ref<InstanceType<typeof ElTree>>()
|
||||||
|
const treeNodeAll = ref(false)
|
||||||
|
const xGrid = ref<VxeGridInstance>() // 列表 Grid Ref
|
||||||
|
const formRef = ref<FormExpose>() // 表单 Ref
|
||||||
|
const loading = ref(false) // 遮罩层
|
||||||
|
const actionType = ref('') // 操作按钮的类型
|
||||||
|
const dialogVisible = ref(false) // 是否显示弹出层
|
||||||
|
const dialogTitle = ref('edit') // 弹出层标题
|
||||||
|
|
||||||
const defaultProps = {
|
const defaultProps = {
|
||||||
children: 'children',
|
children: 'children',
|
||||||
label: 'name',
|
label: 'name',
|
||||||
value: 'id'
|
value: 'id'
|
||||||
}
|
}
|
||||||
// ========== 创建菜单树结构 ==========
|
|
||||||
const menuOptions = ref<any[]>([]) // 树形结构
|
|
||||||
const treeRef = ref<InstanceType<typeof ElTree>>()
|
|
||||||
const treeNodeAll = ref(false)
|
|
||||||
// 全选/全不选
|
// 全选/全不选
|
||||||
const handleCheckedTreeNodeAll = () => {
|
const handleCheckedTreeNodeAll = () => {
|
||||||
treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : [])
|
treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : [])
|
||||||
@ -119,22 +108,12 @@ const getTree = async () => {
|
|||||||
const res = await listSimpleMenusApi()
|
const res = await listSimpleMenusApi()
|
||||||
menuOptions.value = handleTree(res)
|
menuOptions.value = handleTree(res)
|
||||||
}
|
}
|
||||||
const menuExpand = ref(false)
|
|
||||||
const menuNodeAll = ref(false)
|
|
||||||
|
|
||||||
// ========== 列表相关 ==========
|
const { gridOptions, getList, deleteData } = useVxeGrid<TenantPackageApi.TenantPackageVO>({
|
||||||
const { register, tableObject, methods } = useTable<TenantPackageVO>({
|
allSchemas: allSchemas,
|
||||||
getListApi: TenantPackageApi.getTenantPackageTypePageApi,
|
getListApi: TenantPackageApi.getTenantPackageTypePageApi,
|
||||||
delListApi: TenantPackageApi.deleteTenantPackageTypeApi
|
deleteApi: TenantPackageApi.deleteTenantPackageTypeApi
|
||||||
})
|
})
|
||||||
const { getList, setSearchParams, delList } = methods
|
|
||||||
|
|
||||||
// ========== CRUD 相关 ==========
|
|
||||||
const loading = ref(false) // 遮罩层
|
|
||||||
const formRef = ref<FormExpose>() // 表单 Ref
|
|
||||||
const actionType = ref('') // 操作按钮的类型
|
|
||||||
const dialogVisible = ref(false) // 是否显示弹出层
|
|
||||||
const dialogTitle = ref('edit') // 弹出层标题
|
|
||||||
|
|
||||||
// 设置标题
|
// 设置标题
|
||||||
const setDialogTile = (type: string) => {
|
const setDialogTile = (type: string) => {
|
||||||
@ -153,14 +132,20 @@ const handleCreate = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 修改操作
|
// 修改操作
|
||||||
const handleUpdate = async (row: any) => {
|
const handleUpdate = async (rowId: number) => {
|
||||||
setDialogTile('update')
|
setDialogTile('update')
|
||||||
// 设置数据
|
// 设置数据
|
||||||
const res = await TenantPackageApi.getTenantPackageApi(row.id)
|
const res = await TenantPackageApi.getTenantPackageApi(rowId)
|
||||||
unref(formRef)?.setValues(res)
|
unref(formRef)?.setValues(res)
|
||||||
// 设置选中
|
// 设置选中
|
||||||
unref(treeRef)?.setCheckedKeys(res.menuIds)
|
unref(treeRef)?.setCheckedKeys(res.menuIds)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 删除操作
|
||||||
|
const handleDelete = async (rowId: number) => {
|
||||||
|
await deleteData(xGrid, rowId)
|
||||||
|
}
|
||||||
|
|
||||||
// 提交按钮
|
// 提交按钮
|
||||||
const submitForm = async () => {
|
const submitForm = async () => {
|
||||||
const elForm = unref(formRef)?.getElFormRef()
|
const elForm = unref(formRef)?.getElFormRef()
|
||||||
@ -170,20 +155,21 @@ const submitForm = async () => {
|
|||||||
loading.value = true
|
loading.value = true
|
||||||
// 提交请求
|
// 提交请求
|
||||||
try {
|
try {
|
||||||
const data = unref(formRef)?.formModel as TenantPackageVO
|
const data = unref(formRef)?.formModel as TenantPackageApi.TenantPackageVO
|
||||||
data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
|
data.menuIds = treeRef.value!.getCheckedKeys(false) as string[]
|
||||||
if (actionType.value === 'create') {
|
if (actionType.value === 'create') {
|
||||||
await TenantPackageApi.createTenantPackageTypeApi(data)
|
await TenantPackageApi.createTenantPackageTypeApi(data)
|
||||||
ElMessage.success(t('common.createSuccess'))
|
message.success(t('common.createSuccess'))
|
||||||
} else {
|
} else {
|
||||||
await TenantPackageApi.updateTenantPackageTypeApi(data)
|
await TenantPackageApi.updateTenantPackageTypeApi(data)
|
||||||
ElMessage.success(t('common.updateSuccess'))
|
message.success(t('common.updateSuccess'))
|
||||||
}
|
}
|
||||||
// 操作成功,重新加载列表
|
// 操作成功,重新加载列表
|
||||||
dialogVisible.value = false
|
dialogVisible.value = false
|
||||||
await getList()
|
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
// 刷新列表
|
||||||
|
await getList(xGrid)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -191,7 +177,6 @@ const submitForm = async () => {
|
|||||||
|
|
||||||
// ========== 初始化 ==========
|
// ========== 初始化 ==========
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
await getList()
|
|
||||||
await getTree()
|
await getTree()
|
||||||
})
|
})
|
||||||
// getList()
|
// getList()
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { reactive } from 'vue'
|
import { reactive } from 'vue'
|
||||||
import { required } from '@/utils/formRules'
|
import { required } from '@/utils/formRules'
|
||||||
import { useI18n } from '@/hooks/web/useI18n'
|
import { useI18n } from '@/hooks/web/useI18n'
|
||||||
import { CrudSchema, useCrudSchemas } from '@/hooks/web/useCrudSchemas'
|
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
|
||||||
const { t } = useI18n() // 国际化
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
// 表单校验
|
// 表单校验
|
||||||
@ -16,75 +16,49 @@ export const rules = reactive({
|
|||||||
})
|
})
|
||||||
|
|
||||||
// CrudSchema
|
// CrudSchema
|
||||||
const crudSchemas = reactive<CrudSchema[]>([
|
const crudSchemas = reactive<VxeCrudSchema>({
|
||||||
{
|
primaryKey: 'id',
|
||||||
label: t('common.index'),
|
primaryType: 'seq',
|
||||||
field: 'id',
|
action: true,
|
||||||
type: 'index',
|
columns: [
|
||||||
form: {
|
{
|
||||||
show: false
|
title: '套餐名称',
|
||||||
|
field: 'name',
|
||||||
|
isSearch: true
|
||||||
},
|
},
|
||||||
detail: {
|
{
|
||||||
show: false
|
title: t('common.status'),
|
||||||
}
|
field: 'status',
|
||||||
},
|
dictType: DICT_TYPE.COMMON_STATUS,
|
||||||
{
|
dictClass: 'number',
|
||||||
label: '套餐名称',
|
isSearch: true
|
||||||
field: 'name',
|
},
|
||||||
search: {
|
{
|
||||||
show: true
|
title: '菜单权限',
|
||||||
}
|
field: 'menuIds',
|
||||||
},
|
isTable: false
|
||||||
{
|
},
|
||||||
label: t('common.status'),
|
{
|
||||||
field: 'status',
|
title: t('form.remark'),
|
||||||
dictType: DICT_TYPE.COMMON_STATUS,
|
field: 'remark',
|
||||||
dictClass: 'number',
|
isTable: false,
|
||||||
search: {
|
form: {
|
||||||
show: true
|
component: 'Input',
|
||||||
}
|
componentProps: {
|
||||||
},
|
type: 'textarea',
|
||||||
{
|
rows: 4
|
||||||
label: '菜单权限',
|
},
|
||||||
field: 'menuIds',
|
colProps: {
|
||||||
table: {
|
span: 24
|
||||||
show: false
|
}
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('form.remark'),
|
|
||||||
field: 'remark',
|
|
||||||
form: {
|
|
||||||
component: 'Input',
|
|
||||||
componentProps: {
|
|
||||||
type: 'textarea',
|
|
||||||
rows: 4
|
|
||||||
},
|
|
||||||
colProps: {
|
|
||||||
span: 24
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
table: {
|
{
|
||||||
show: false
|
title: '创建时间',
|
||||||
|
field: 'createTime',
|
||||||
|
formatter: 'formatDate',
|
||||||
|
isForm: false
|
||||||
}
|
}
|
||||||
},
|
]
|
||||||
{
|
})
|
||||||
label: '创建时间',
|
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
||||||
field: 'createTime',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: t('table.action'),
|
|
||||||
field: 'action',
|
|
||||||
width: '240px',
|
|
||||||
form: {
|
|
||||||
show: false
|
|
||||||
},
|
|
||||||
detail: {
|
|
||||||
show: false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
])
|
|
||||||
export const { allSchemas } = useCrudSchemas(crudSchemas)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user