功能变化: 支持租户插件

pull/102/head
李强 2023-07-07 08:59:06 +08:00
parent a2f3f5ff2b
commit 44243889d4
5 changed files with 131 additions and 113 deletions

View File

@ -114,7 +114,7 @@ class MenuInitSerializer(CustomModelSerializer):
class Meta:
model = Menu
fields = ['name', 'icon', 'sort', 'is_link', 'is_catalog', 'web_path', 'component', 'component_name', 'status',
'cache', 'visible', 'parent', 'children', 'menu_button', 'creator', 'dept_belong_id']
'cache', 'visible', 'parent', 'children', 'menu_button', 'frame_out', 'creator', 'dept_belong_id']
extra_kwargs = {
'creator': {'write_only': True},
'dept_belong_id': {'write_only': True}
@ -137,7 +137,8 @@ class WebRouterSerializer(CustomModelSerializer):
else:
# 根据当前角色获取权限按钮id集合
permissionIds = self.request.user.role.values_list('permission', flat=True)
queryset = instance.menuPermission.filter(id__in=permissionIds, menu=instance.id).values_list('value', flat=True)
queryset = instance.menuPermission.filter(id__in=permissionIds, menu=instance.id).values_list('value',
flat=True)
if queryset:
return queryset
else:
@ -145,7 +146,8 @@ class WebRouterSerializer(CustomModelSerializer):
class Meta:
model = Menu
fields = ('id', 'parent', 'icon', 'sort', 'path', 'name', 'title', 'is_link', 'is_catalog', 'web_path', 'component',
fields = (
'id', 'parent', 'icon', 'sort', 'path', 'name', 'title', 'is_link', 'is_catalog', 'web_path', 'component',
'component_name', 'cache', 'visible', 'menuPermission', 'frame_out')
read_only_fields = ["id"]
@ -165,6 +167,7 @@ class MenuViewSet(CustomModelViewSet):
update_serializer_class = MenuCreateSerializer
search_fields = ['name', 'status']
filter_fields = ['parent', 'name', 'status', 'is_link', 'visible', 'cache', 'is_catalog']
# extra_filter_backends = []
@action(methods=['GET'], detail=False, permission_classes=[])
@ -179,7 +182,7 @@ class MenuViewSet(CustomModelViewSet):
data = serializer.data
return SuccessResponse(data=data, total=len(data), msg="获取成功")
def list(self,request):
def list(self, request):
"""懒加载"""
params = request.query_params
parent = params.get('parent', None)

View File

@ -7,6 +7,7 @@
@Remark: 系统配置
"""
import django_filters
from django.db import connection
from django.db.models import Q
from django_filters.rest_framework import BooleanFilter
from rest_framework import serializers
@ -277,4 +278,5 @@ class InitSettingsViewSet(APIView):
'key')]
data = dict(filter(lambda x: x[0] not in backend_config, data.items()))
data = self.filter_system_config_values(data=data)
data['schema_name'] = connection.tenant.schema_name
return DetailResponse(data=data)

View File

@ -1,11 +1,3 @@
<!--
* @创建文件时间: 2021-06-01 22:41:20
* @Auther: 猿小天
* @最后修改人: 猿小天
* @最后修改时间: 2021-07-27 00:18:52
* 联系Qq:1638245306
* @文件介绍:
-->
<template>
<el-dropdown size="small" class="d2-mr">
<el-link
@ -28,6 +20,9 @@
<el-dropdown-item @click.native="userInfo">
<d2-icon name="cog" class="d2-mr-5" />个人信息
</el-dropdown-item>
<el-dropdown-item @click.native="clientInfo" v-if="info.tenant_id === 100000">
<d2-icon name="cog" class="d2-mr-5" />租户信息
</el-dropdown-item>
<el-dropdown-item @click.native="logOff" divided>
<d2-icon name="power-off" class="d2-mr-5" />
注销
@ -61,6 +56,10 @@ export default {
/** 个人信息 */
userInfo () {
this.$router.push({ path: 'userInfo' })
},
/** 租户信息 */
clientInfo () {
this.$router.push({ path: 'myClientInfo' })
}
}
}

View File

@ -6,6 +6,7 @@
import { mapActions, mapState } from 'vuex'
import localeMixin from '@/locales/mixin.js'
import * as api from '@/views/system/login/api'
import { checkPlugins } from '@/views/plugins'
export default {
mixins: [localeMixin],
@ -55,7 +56,8 @@ export default {
username: 'admin',
password: 'admin123456'
}
]
],
isTenant: checkPlugins('dvadmin-tenants-web')
}
},
computed: {
@ -68,7 +70,8 @@ export default {
helpUrl: state => state.settings.data['login.help_url'], //
privacyUrl: state => state.settings.data['login.privacy_url'], //
clauseUrl: state => state.settings.data['login.clause_url'], //
captchaState: state => state.settings.data['base.captcha_state'] !== undefined ? state.settings.data['base.captcha_state'] : true //
captchaState: state => state.settings.data['base.captcha_state'] !== undefined ? state.settings.data['base.captcha_state'] : true, //
isPublic: state => state.settings.data.schema_name === 'public' //
})
},
mounted () {
@ -78,8 +81,8 @@ export default {
methods: {
...mapActions('d2admin/account', ['login']),
/**
* 获取验证码
*/
* 获取验证码
*/
getCaptcha () {
if (this.captchaState !== undefined && !this.captchaState) return
api.getCaptcha().then((ret) => {
@ -89,8 +92,8 @@ export default {
})
},
/**
* @description 提交表单
*/
* @description 提交表单
*/
//
submit () {
const that = this
@ -138,106 +141,106 @@ export default {
</script>
<style lang="scss" scoped>
// ----
.page-login {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-position: center 0;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
-webkit-background-size: cover; /* 兼容Webkit内核浏览器如Chrome和Safari */
-o-background-size: cover; /* 兼容Opera */
zoom: 1;
}
// ----
.page-login {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-position: center 0;
background-repeat: no-repeat;
background-attachment: fixed;
background-size: cover;
-webkit-background-size: cover; /* 兼容Webkit内核浏览器如Chrome和Safari */
-o-background-size: cover; /* 兼容Opera */
zoom: 1;
}
::v-deep .el-card__body {
height: 100%;
padding: 0;
}
::v-deep .el-card__body {
height: 100%;
padding: 0;
}
.card {
height: 100%;
width: 100%;
border-radius: 30px;
padding: 0;
margin-top: 12%;
}
.card {
height: 100%;
width: 100%;
border-radius: 30px;
padding: 0;
margin-top: 12%;
}
.right-card {
float: right;
.right-card {
float: right;
text-align: center;
width: 50%;
height: 100%;
}
.right-card h1 {
color: #098dee;
margin-bottom: 40px;
margin-top: 40px;
}
.button-login {
width: 100%;
margin-top: 30px;
}
::v-deep .el-input-group__append {
padding: 0;
}
// footer
.page-login--content-footer {
margin-top: 10%;
padding: 1em 0;
.page-login--content-footer-locales {
padding: 0px;
margin: 0px;
margin-bottom: 15px;
font-size: 12px;
line-height: 12px;
text-align: center;
width: 50%;
height: 100%;
}
color: $color-text-normal;
.right-card h1 {
color: #098dee;
margin-bottom: 40px;
margin-top: 40px;
}
.button-login {
width: 100%;
margin-top: 30px;
}
::v-deep .el-input-group__append {
padding: 0;
}
// footer
.page-login--content-footer {
margin-top: 10%;
padding: 1em 0;
.page-login--content-footer-locales {
padding: 0px;
margin: 0px;
margin-bottom: 15px;
font-size: 12px;
line-height: 12px;
text-align: center;
a {
color: $color-text-normal;
margin: 0 0.5em;
a {
color: $color-text-normal;
margin: 0 0.5em;
&:hover {
color: $color-text-main;
}
}
}
.page-login--content-footer-copyright {
padding: 0px;
margin: 0px;
margin-bottom: 10px;
font-size: 12px;
line-height: 12px;
text-align: center;
color: $color-text-normal;
a {
color: $color-text-normal;
}
}
.page-login--content-footer-options {
padding: 0px;
margin: 0px;
font-size: 12px;
line-height: 12px;
text-align: center;
a {
color: $color-text-normal;
margin: 0 1em;
&:hover {
color: $color-text-main;
}
}
}
.page-login--content-footer-copyright {
padding: 0px;
margin: 0px;
margin-bottom: 10px;
font-size: 12px;
line-height: 12px;
text-align: center;
color: $color-text-normal;
a {
color: $color-text-normal;
}
}
.page-login--content-footer-options {
padding: 0px;
margin: 0px;
font-size: 12px;
line-height: 12px;
text-align: center;
a {
color: $color-text-normal;
margin: 0 1em;
}
}
}
</style>

View File

@ -69,9 +69,20 @@
</el-input>
</el-form-item>
</el-form>
<button class="btn btn-primary btn-block" style="padding: 10px 10px;" @click="submit">
登录
</button>
<el-row v-if="isTenant && isPublic">
<el-col :span="11">
<button class="btn btn-primary btn-block" style="padding: 10px 10px;" @click="submit"></button>
</el-col>
<el-col :span="11" :offset="2">
<button
class="btn btn-primary btn-block"
style="padding: 10px 10px;background-color: #409eff;color: #fff;"
@click="$router.push('/register')">
免费试用
</button>
</el-col>
</el-row>
<button v-else class="btn btn-primary btn-block" style="padding: 10px 10px;" @click="submit"></button>
<component v-if="componentTag" :is="componentTag"></component>
</el-tab-pane>
</el-tabs>