功能变化: 支持租户插件
parent
a2f3f5ff2b
commit
44243889d4
|
@ -114,7 +114,7 @@ class MenuInitSerializer(CustomModelSerializer):
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Menu
|
model = Menu
|
||||||
fields = ['name', 'icon', 'sort', 'is_link', 'is_catalog', 'web_path', 'component', 'component_name', 'status',
|
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 = {
|
extra_kwargs = {
|
||||||
'creator': {'write_only': True},
|
'creator': {'write_only': True},
|
||||||
'dept_belong_id': {'write_only': True}
|
'dept_belong_id': {'write_only': True}
|
||||||
|
@ -137,7 +137,8 @@ class WebRouterSerializer(CustomModelSerializer):
|
||||||
else:
|
else:
|
||||||
# 根据当前角色获取权限按钮id集合
|
# 根据当前角色获取权限按钮id集合
|
||||||
permissionIds = self.request.user.role.values_list('permission', flat=True)
|
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:
|
if queryset:
|
||||||
return queryset
|
return queryset
|
||||||
else:
|
else:
|
||||||
|
@ -145,7 +146,8 @@ class WebRouterSerializer(CustomModelSerializer):
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Menu
|
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')
|
'component_name', 'cache', 'visible', 'menuPermission', 'frame_out')
|
||||||
read_only_fields = ["id"]
|
read_only_fields = ["id"]
|
||||||
|
|
||||||
|
@ -165,6 +167,7 @@ class MenuViewSet(CustomModelViewSet):
|
||||||
update_serializer_class = MenuCreateSerializer
|
update_serializer_class = MenuCreateSerializer
|
||||||
search_fields = ['name', 'status']
|
search_fields = ['name', 'status']
|
||||||
filter_fields = ['parent', 'name', 'status', 'is_link', 'visible', 'cache', 'is_catalog']
|
filter_fields = ['parent', 'name', 'status', 'is_link', 'visible', 'cache', 'is_catalog']
|
||||||
|
|
||||||
# extra_filter_backends = []
|
# extra_filter_backends = []
|
||||||
|
|
||||||
@action(methods=['GET'], detail=False, permission_classes=[])
|
@action(methods=['GET'], detail=False, permission_classes=[])
|
||||||
|
@ -179,7 +182,7 @@ class MenuViewSet(CustomModelViewSet):
|
||||||
data = serializer.data
|
data = serializer.data
|
||||||
return SuccessResponse(data=data, total=len(data), msg="获取成功")
|
return SuccessResponse(data=data, total=len(data), msg="获取成功")
|
||||||
|
|
||||||
def list(self,request):
|
def list(self, request):
|
||||||
"""懒加载"""
|
"""懒加载"""
|
||||||
params = request.query_params
|
params = request.query_params
|
||||||
parent = params.get('parent', None)
|
parent = params.get('parent', None)
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
@Remark: 系统配置
|
@Remark: 系统配置
|
||||||
"""
|
"""
|
||||||
import django_filters
|
import django_filters
|
||||||
|
from django.db import connection
|
||||||
from django.db.models import Q
|
from django.db.models import Q
|
||||||
from django_filters.rest_framework import BooleanFilter
|
from django_filters.rest_framework import BooleanFilter
|
||||||
from rest_framework import serializers
|
from rest_framework import serializers
|
||||||
|
@ -277,4 +278,5 @@ class InitSettingsViewSet(APIView):
|
||||||
'key')]
|
'key')]
|
||||||
data = dict(filter(lambda x: x[0] not in backend_config, data.items()))
|
data = dict(filter(lambda x: x[0] not in backend_config, data.items()))
|
||||||
data = self.filter_system_config_values(data=data)
|
data = self.filter_system_config_values(data=data)
|
||||||
|
data['schema_name'] = connection.tenant.schema_name
|
||||||
return DetailResponse(data=data)
|
return DetailResponse(data=data)
|
||||||
|
|
|
@ -1,11 +1,3 @@
|
||||||
<!--
|
|
||||||
* @创建文件时间: 2021-06-01 22:41:20
|
|
||||||
* @Auther: 猿小天
|
|
||||||
* @最后修改人: 猿小天
|
|
||||||
* @最后修改时间: 2021-07-27 00:18:52
|
|
||||||
* 联系Qq:1638245306
|
|
||||||
* @文件介绍:
|
|
||||||
-->
|
|
||||||
<template>
|
<template>
|
||||||
<el-dropdown size="small" class="d2-mr">
|
<el-dropdown size="small" class="d2-mr">
|
||||||
<el-link
|
<el-link
|
||||||
|
@ -28,6 +20,9 @@
|
||||||
<el-dropdown-item @click.native="userInfo">
|
<el-dropdown-item @click.native="userInfo">
|
||||||
<d2-icon name="cog" class="d2-mr-5" />个人信息
|
<d2-icon name="cog" class="d2-mr-5" />个人信息
|
||||||
</el-dropdown-item>
|
</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>
|
<el-dropdown-item @click.native="logOff" divided>
|
||||||
<d2-icon name="power-off" class="d2-mr-5" />
|
<d2-icon name="power-off" class="d2-mr-5" />
|
||||||
注销
|
注销
|
||||||
|
@ -61,6 +56,10 @@ export default {
|
||||||
/** 个人信息 */
|
/** 个人信息 */
|
||||||
userInfo () {
|
userInfo () {
|
||||||
this.$router.push({ path: 'userInfo' })
|
this.$router.push({ path: 'userInfo' })
|
||||||
|
},
|
||||||
|
/** 租户信息 */
|
||||||
|
clientInfo () {
|
||||||
|
this.$router.push({ path: 'myClientInfo' })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
import { mapActions, mapState } from 'vuex'
|
import { mapActions, mapState } from 'vuex'
|
||||||
import localeMixin from '@/locales/mixin.js'
|
import localeMixin from '@/locales/mixin.js'
|
||||||
import * as api from '@/views/system/login/api'
|
import * as api from '@/views/system/login/api'
|
||||||
|
import { checkPlugins } from '@/views/plugins'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [localeMixin],
|
mixins: [localeMixin],
|
||||||
|
@ -55,7 +56,8 @@ export default {
|
||||||
username: 'admin',
|
username: 'admin',
|
||||||
password: 'admin123456'
|
password: 'admin123456'
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
isTenant: checkPlugins('dvadmin-tenants-web')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -68,7 +70,8 @@ export default {
|
||||||
helpUrl: state => state.settings.data['login.help_url'], // 帮助
|
helpUrl: state => state.settings.data['login.help_url'], // 帮助
|
||||||
privacyUrl: state => state.settings.data['login.privacy_url'], // 隐私
|
privacyUrl: state => state.settings.data['login.privacy_url'], // 隐私
|
||||||
clauseUrl: state => state.settings.data['login.clause_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 () {
|
mounted () {
|
||||||
|
@ -78,8 +81,8 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
...mapActions('d2admin/account', ['login']),
|
...mapActions('d2admin/account', ['login']),
|
||||||
/**
|
/**
|
||||||
* 获取验证码
|
* 获取验证码
|
||||||
*/
|
*/
|
||||||
getCaptcha () {
|
getCaptcha () {
|
||||||
if (this.captchaState !== undefined && !this.captchaState) return
|
if (this.captchaState !== undefined && !this.captchaState) return
|
||||||
api.getCaptcha().then((ret) => {
|
api.getCaptcha().then((ret) => {
|
||||||
|
@ -89,8 +92,8 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @description 提交表单
|
* @description 提交表单
|
||||||
*/
|
*/
|
||||||
// 提交登录信息
|
// 提交登录信息
|
||||||
submit () {
|
submit () {
|
||||||
const that = this
|
const that = this
|
||||||
|
@ -138,106 +141,106 @@ export default {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
// ----
|
// ----
|
||||||
.page-login {
|
.page-login {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
background-position: center 0;
|
background-position: center 0;
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
background-attachment: fixed;
|
background-attachment: fixed;
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
-webkit-background-size: cover; /* 兼容Webkit内核浏览器如Chrome和Safari */
|
-webkit-background-size: cover; /* 兼容Webkit内核浏览器如Chrome和Safari */
|
||||||
-o-background-size: cover; /* 兼容Opera */
|
-o-background-size: cover; /* 兼容Opera */
|
||||||
zoom: 1;
|
zoom: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
::v-deep .el-card__body {
|
::v-deep .el-card__body {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
border-radius: 30px;
|
border-radius: 30px;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-top: 12%;
|
margin-top: 12%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-card {
|
.right-card {
|
||||||
float: right;
|
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;
|
text-align: center;
|
||||||
width: 50%;
|
color: $color-text-normal;
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.right-card h1 {
|
a {
|
||||||
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;
|
|
||||||
color: $color-text-normal;
|
color: $color-text-normal;
|
||||||
|
margin: 0 0.5em;
|
||||||
|
|
||||||
a {
|
&:hover {
|
||||||
color: $color-text-normal;
|
color: $color-text-main;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.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>
|
</style>
|
||||||
|
|
|
@ -69,9 +69,20 @@
|
||||||
</el-input>
|
</el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<button class="btn btn-primary btn-block" style="padding: 10px 10px;" @click="submit">
|
<el-row v-if="isTenant && isPublic">
|
||||||
登录
|
<el-col :span="11">
|
||||||
</button>
|
<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>
|
<component v-if="componentTag" :is="componentTag"></component>
|
||||||
</el-tab-pane>
|
</el-tab-pane>
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
|
|
Loading…
Reference in New Issue