84726a22 by lihua

登录角色选择,数据提供方首页

1 parent 1129f998

2.44 MB | W: | H:

514 KB | W: | H:

src/assets/images/login-bg.png
src/assets/images/login-bg.png
src/assets/images/login-bg.png
src/assets/images/login-bg.png
  • 2-up
  • Swipe
  • Onion skin
import type { RouteRecordRaw } from 'vue-router'
function Layout() {
return import('@/layouts/index.vue')
}
const routes: RouteRecordRaw[] = [
{
path: '/data-home-index',
component: Layout,
meta: {
title: '首页',
icon: 'sidebar-videos',
},
children: [{
path: '',
name: 'homeIndex',
component: () => import('@/views/homeIndex.vue'),
meta: {
title: '首页',
sidebar: false,
breadcrumb: false,
cache: true
},
}]
},
]
export default routes
......@@ -5,6 +5,7 @@ import DataAssess from './modules/dataAsset';
import DataService from './modules/dataService';
import DataSmartContract from './modules/dataSmartContract';
import DataFacilitator from './modules/dataFacilitator';
import HomeIndex from './modules/homeIndex';
import useSettingsStore from '@/store/modules/settings'
......@@ -95,6 +96,7 @@ const asyncRoutes: RouteRecordRaw[] = [
...DataService,
...DataSmartContract,
...DataFacilitator,
...HomeIndex,
// ...DataAssetRegistry,
]
......
......@@ -30,6 +30,7 @@ const useUserStore = defineStore(
/* idass的登录页面url,退出登录需要跳转到登录页。*/
const idassLoginUrl = import.meta.env.VITE_IDASS_BASEURL;
const timer: any = ref(null);
const isGetCurrUserInfo = ref(false); //记录登录时是否已经获取登录用户的信息,根据用户信息展示角色选择对话框。
//获取token.
function getToken(data, state) {
data.platformGuid = "7f16f697aec111ef8656fa163e60becd";
......@@ -71,26 +72,50 @@ const useUserStore = defineStore(
localStorage.setItem('userName', res.data?.staffName);
localStorage.setItem('userData', JSON.stringify(res.data));
userData.value = localStorage.getItem('userData');
return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
if (info.code == '00000') {
localStorage.setItem('userInfoData', JSON.stringify(info.data));
userInfoData.value = info.data;
// window.location.href = location.origin + info.data[0].menuList[0].path
} else {
ElMessage.error(info.msg)
}
})
isGetCurrUserInfo.value = true
// return getSystemMenu({ tenantGuid: currentTenantGuid.value }, res.data?.isAdmin == 'Y' && (!res.data?.superTubeFlag || res.data?.superTubeFlag == 'Y')).then((info: any) => { //解决页面调用流程接口传递staffGuid,为空的问题
// if (info.code == '00000') {
// localStorage.setItem('userInfoData', JSON.stringify(info.data));
// userInfoData.value = info.data;
// // window.location.href = location.origin + info.data[0].menuList[0].path
// } else {
// ElMessage.error(info.msg)
// }
// })
} else {
ElMessage.error(res.msg)
}
})
} else {
isLogin.value = false;
isGetCurrUserInfo.value = false;
// ElMessage.error(res.msg);//授权码被重复使用,不抛出异常。
}
});
}
/** 根据选择的角色获取用户菜单 */
function getUserSystemMenuByRole(role) {
let data = localStorage.getItem('userData');
let userData = data && JSON.parse(data);
return getSystemMenu(
{ tenantGuid: localStorage.getItem('currentTenantGuid') },
userData?.isAdmin == "Y" &&
(!userData?.superTubeFlag ||
userData?.superTubeFlag == "Y")
).then((info: any) => {
//解决页面调用流程接口传递staffGuid,为空的问题
if (info.code == "00000") {
localStorage.setItem("userInfoData", JSON.stringify(info.data));
userInfoData.value = info.data;
// window.location.href = location.origin + info.data[0].menuList[0].path
return true;
} else {
ElMessage.error(info.msg);
}
});
}
async function refreshUserToken(isExec = true) {
let expiresIn = localStorage.getItem('expiresIn');
if (!expiresIn || (parseInt(expiresIn) - Date.now()) < 0) {
......@@ -182,6 +207,7 @@ const useUserStore = defineStore(
token.value = '';
timer.value && clearInterval(timer.value);
isLogin.value = false;
isGetCurrUserInfo.value = false;
userInfoData.value = [];
routeStore.removeRoutes()
menuStore.setActived(0)
......@@ -200,6 +226,7 @@ const useUserStore = defineStore(
token.value = '';
timer.value && clearInterval(timer.value);
isLogin.value = false;
isGetCurrUserInfo.value = false;
userInfoData.value = [];
routeStore.removeRoutes()
menuStore.setActived(0)
......@@ -323,9 +350,11 @@ const useUserStore = defineStore(
currentTime,
permissions,
isLogin,
isGetCurrUserInfo,
isLoginOut,
getTokenPromise,
getToken,
getUserSystemMenuByRole,
login,
logout,
getPermissions,
......
......@@ -8,48 +8,98 @@ meta:
<script lang="ts" setup>
import useUserStore from '@/store/modules/user';
import { ElMessage } from 'element-plus';
const userStore = useUserStore()
const router = useRouter()
const route = useRoute()
const data = ref({
inter: NaN,
countdown: 5,
})
/** 对话框显示隐藏 */
const dialogVisible = computed(() => {
return route.query.code && userStore.isGetCurrUserInfo;
});
const loading = ref(false);
/** 记录用户选择的角色 */
const selectRole = ref('use');
onBeforeRouteLeave(() => {
data.value.inter && clearInterval(data.value.inter)
})
onMounted(() => {
// data.value.inter = setInterval(() => {
// data.value.countdown--
// if (data.value.countdown === 0) {
// data.value.inter && clearInterval(data.value.inter)
// goBack()
// }
// }, 1000)
goBack()
})
function goBack() {
}
const beforeLogin = () => {
if (userStore.getTokenPromise) {
userStore.getTokenPromise.then(() => {
userStore.getUserSystemMenuByRole(selectRole.value).then((res) => {
if (res === true) {
userStore.isGetCurrUserInfo = false;
}
router.push('/')
})
});
} else {
userStore.getUserSystemMenuByRole(selectRole.value).then((res) => {
if (res === true) {
userStore.isGetCurrUserInfo = false;
}
router.push('/')
})
}
}
</script>
<template>
<div class="notfound">
<div class="full-page">
<div class="notfound" v-show="!dialogVisible">
<img style="width: 480px; height: 110px;" src="../../public/swzl_logo.gif">
</div>
<div class="bg-banner" v-if="dialogVisible">
<div id="login-box">
<div class="login_form login-size">
<div class="login-title">选择角色</div>
<div class="row-main">
<div class="per" :class="selectRole == 'use' ? 'selected' : ''" @click="selectRole = 'use'">
<div class="img-use"></div>
<div class="title">数据使用方</div>
</div>
<div class="per" :class="selectRole == 'provider' ? 'selected' : ''" @click="selectRole = 'provider'">
<div class="img-provider"></div>
<div class="title">数据提供方</div>
</div>
<div class="per" :class="selectRole == 'operation' ? 'selected' : ''" @click="selectRole = 'operation'">
<div class="img-operation"></div>
<div class="title">平台运营方</div>
</div>
</div>
<div class="login-footer">
<el-button :loading="loading" ref="loginButton" type="primary" size="large" style="width: 100%;"
@click.prevent="beforeLogin">确认</el-button>
</div>
</div>
</div>
<div class="copyright_text">
<span>Copyright © 2015-2024</span>
<a style="color: #4FA1A4;margin: 0 8px;" href="https://beian.miit.gov.cn" target="_blank">京ICP备2024044205号</a>
<span>北京传世博润科技有限公司</span>
</div>
</div>
</div>
</template>
<style lang="scss" scoped>
.full-page {
height: 100%;
width: 100%;
}
.notfound {
display: flex;
align-items: center;
......@@ -77,4 +127,166 @@ function goBack() {
}
}
}
.bg-banner {
// position: fixed;
// z-index: 1001;
width: 100%;
height: 100%;
background-image: url('@/assets/images/login-bg.png');
background-size: cover;
/* 背景图覆盖整个元素 */
background-position: center;
/* 背景图居中 */
background-repeat: no-repeat;
/* 防止背景图重复 */
}
#login-box {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
.login-form {
display: flex;
flex-direction: column;
justify-content: center;
min-height: 500px;
width: 368px;
overflow: hidden;
.title-container {
position: relative;
.title {
font-size: 28px;
color: #212121;
letter-spacing: 0;
text-align: center;
line-height: 42px;
font-weight: 600;
margin-bottom: 32px;
}
}
}
}
.login-title {
font-family: PingFangSC-Semibold;
font-size: 24px;
color: #212121;
letter-spacing: 0;
line-height: 36px;
font-weight: 600;
margin-bottom: 33px;
}
.login_form {
position: relative;
background: #FFFFFF;
box-shadow: 0px 4px 10px 0px rgba(0, 0, 0, 0.2);
border-radius: 2px;
.row-main {
display: flex;
flex-direction: row;
column-gap: 40px;
.per {
cursor: pointer;
&.selected {
.img-use {
background-image: url('@/assets/images/dataUser-select.png');
}
.img-provider {
background-image: url('@/assets/images/dataProvider-select.png');
}
.img-operation {
background-image: url('@/assets/images/dataOperation-select.png');
}
.title {
color: #1478E9;
}
}
.img-use {
width: 100px;
height: 100px;
background-image: url('@/assets/images/dataUser-default.png');
background-size: cover;
/* 背景图覆盖整个元素 */
background-position: center;
/* 背景图居中 */
background-repeat: no-repeat;
}
.img-provider {
width: 100px;
height: 100px;
background-image: url('@/assets/images/dataProvider-default.png');
background-size: cover;
/* 背景图覆盖整个元素 */
background-position: center;
/* 背景图居中 */
background-repeat: no-repeat;
}
.img-operation {
width: 100px;
height: 100px;
background-image: url('@/assets/images/dataOperation-default.png');
background-size: cover;
/* 背景图覆盖整个元素 */
background-position: center;
/* 背景图居中 */
background-repeat: no-repeat;
}
.title {
margin-top: 8px;
font-family: PingFangSC-Regular;
font-size: 14px;
color: #666666;
line-height: 21px;
font-weight: 400;
text-align: center;
}
}
}
}
.login-size {
padding: 40px 32px;
width: 444px;
height: 420px;
}
.login-footer {
display: flex;
flex-direction: column;
margin-top: 54px;
}
:deep(.el-button--primary) {
background-image: linear-gradient(116deg, #0C48F5 0%, #23D6D1 95%);
}
.copyright_text {
width: 100%;
font-size: 12px;
color: #2c3e50;
line-height: 18px;
text-align: center;
font-weight: 400;
position: absolute;
bottom: 2px;
left: 50%;
transform: translateX(-50%);
}
</style>
......
......@@ -21,7 +21,7 @@ import {
getRegisterCatalogTableList,
checkDamTableChange,
getTenantList,
getDamTypesList
getDamTypesList,//获取数据目录分类。
} from "@/api/modules/dataAsset";
import {
getValidApi,
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!