修改登录展示菜单
This commit is contained in:
parent
ab8b5a26f2
commit
9cd6f5ab07
@ -65,12 +65,12 @@ const getTimeOut = () => {
|
||||
}
|
||||
|
||||
// 创建axios实例
|
||||
const time = getTimeOut()
|
||||
window._de_get_time_out = time
|
||||
// const time = getTimeOut()
|
||||
// window._de_get_time_out = time
|
||||
console.log('timeout', PATH_URL)
|
||||
const service: AxiosInstanceWithLoading = axios.create({
|
||||
baseURL: PATH_URL, // api 的 base_url
|
||||
timeout: time ? time * 1000 : config.request_timeout // 请求超时时间
|
||||
// timeout: time ? time * 1000 : config.request_timeout // 请求超时时间
|
||||
})
|
||||
const mapping = {
|
||||
'zh-CN': 'zh-CN',
|
||||
@ -152,14 +152,15 @@ service.interceptors.response.use(
|
||||
} else {
|
||||
if (
|
||||
!response?.config?.url.startsWith('/xpackComponent/content') &&
|
||||
response?.data?.code !== 60003
|
||||
response?.data?.code !== 60003
|
||||
) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: response.data.msg,
|
||||
showClose: true
|
||||
})
|
||||
|
||||
if(response?.data?.code != '1'){
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
message: response.data.msg,
|
||||
showClose: true
|
||||
})
|
||||
}
|
||||
if (response.data.code === 80001) {
|
||||
localStorage.clear()
|
||||
let queryRedirectPath = '/application/index'
|
||||
|
@ -5,7 +5,7 @@ import { useUserStore } from '@/store/user'
|
||||
const routes:any = [
|
||||
{
|
||||
path: '/',
|
||||
redirect: '/dashboard'
|
||||
redirect: '/UserNavbar'
|
||||
},
|
||||
// 登录页面路由配置
|
||||
{
|
||||
@ -86,7 +86,7 @@ const routes:any = [
|
||||
name: 'visualization',
|
||||
component: () => import('@/data-visualization/index.vue'),
|
||||
meta: {
|
||||
title: '字典管理',
|
||||
title: '数据大屏',
|
||||
requiresAuth: true
|
||||
}
|
||||
},
|
||||
@ -136,11 +136,9 @@ const router = createRouter({
|
||||
// 路由守卫
|
||||
router.beforeEach((to, from, next) => {
|
||||
const userStore = useUserStore()
|
||||
|
||||
// 设置页面标题
|
||||
document.title = to.meta.title ? `${to.meta.title} - StdProject` : 'StdProject'
|
||||
const token = localStorage.getItem('token') || ''
|
||||
console.log(userStore.isAuthenticated)
|
||||
// 检查是否需要认证
|
||||
if (to.meta.requiresAuth) {
|
||||
if (!!token) {
|
||||
@ -151,7 +149,7 @@ router.beforeEach((to, from, next) => {
|
||||
} else {
|
||||
// 如果已登录且访问登录页,重定向到仪表板
|
||||
if (to.path === '/UserLogin' && userStore.isAuthenticated) {
|
||||
next('/dashboard')
|
||||
next('/UserNavbar')
|
||||
} else {
|
||||
next()
|
||||
}
|
||||
|
@ -11,26 +11,22 @@ const route = useRoute()
|
||||
const router = useRouter()
|
||||
const applicationId:any =ref("")
|
||||
const curmenu = ref('')
|
||||
onMounted(() => {
|
||||
if (route.query.id) {
|
||||
applicationId.value = route.query.id
|
||||
curmenu.value = '组织机构配置'
|
||||
// findApplicationById(applicationId.value).then(res => {
|
||||
// res.data.data.typename = '权限设置'
|
||||
// projectInfo.value = res.data.data
|
||||
// })
|
||||
}else{
|
||||
|
||||
}
|
||||
const props = defineProps({
|
||||
isshowheader: Boolean
|
||||
})
|
||||
function menuclick(name){
|
||||
onMounted(() => {
|
||||
const userInfo:any = JSON.parse(localStorage.getItem('userInfo'))
|
||||
applicationId.value = userInfo.appid
|
||||
curmenu.value = '组织机构配置'
|
||||
})
|
||||
function menuclick(name:any){
|
||||
curmenu.value = name
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div>
|
||||
<Header v-if="!route.query.name" :projectInfo="projectInfo"/>
|
||||
<Header v-if="!props.isshowheader" :projectInfo="projectInfo"/>
|
||||
<div class="permission-box">
|
||||
<div class="permission-leftbox">
|
||||
<div class="permission-leftbox-menu" :class="curmenu == '组织机构配置' ? 'permission-leftbox-menu-active' : ''" @click="menuclick('组织机构配置')">组织机构配置</div>
|
||||
|
@ -11,7 +11,6 @@ import { Delete } from '@element-plus/icons-vue'
|
||||
import { ElTable,ElTree } from 'element-plus'
|
||||
import { getOrganizations,addOrganization,setIsValid,updateOrganizationById,
|
||||
deleteById,getOrganizationById } from '@/api/data-visualization/manage/organization'
|
||||
import { re } from 'mathjs'
|
||||
const props = defineProps({
|
||||
applicationId:String
|
||||
})
|
||||
|
@ -4,7 +4,7 @@
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref, onMounted, onUnmounted } from 'vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { loadModule } from 'vue3-sfc-loader'
|
||||
import * as Vue from 'vue/dist/vue.esm-bundler.js'
|
||||
import * as ElementPlus from 'element-plus'
|
||||
@ -14,16 +14,12 @@ import * as VueRouter from 'vue-router'
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import { i18n } from '@/data-visualization/plugins/vue-i18n'
|
||||
import defaultTemplate from '@/views/system/userlogin/frame.vue?raw'
|
||||
// import { moduleUpdate, moduleById } from '@/api/application/module'
|
||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||
import { getMenuTree } from '@/api/data-visualization/manage/menu'
|
||||
import { moduleList } from '@/api/data-visualization/module'
|
||||
import { any } from 'vue-types'
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
|
||||
const sfcCode = ref(defaultTemplate)
|
||||
const previewContainer = ref(null)
|
||||
const previewContainer:any = ref(null)
|
||||
let prevApp:any = null
|
||||
const projectName:any = ref('')
|
||||
const applicationId:any = ref('')
|
||||
@ -55,15 +51,18 @@ const runCode = async () => {
|
||||
prevApp = null
|
||||
await Vue.nextTick()
|
||||
}
|
||||
const options = {
|
||||
const options:any = {
|
||||
moduleCache: {
|
||||
vue: Vue,
|
||||
'element-plus': ElementPlus,
|
||||
'vue/dist/vue.esm-bundler.js': Vue,
|
||||
'vue-router': VueRouter,
|
||||
// '@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue': Vue.defineAsyncComponent(() =>
|
||||
// import('@/viewsnew/application/SfcEditor/NavbarEditor/assocPage.vue')
|
||||
// ),
|
||||
'@/data-visualization/index.vue': Vue.defineAsyncComponent(() =>
|
||||
import('@/data-visualization/index.vue')
|
||||
),
|
||||
'@/views/BuiltInPage/FormCreate.vue': Vue.defineAsyncComponent(() =>
|
||||
import('@/views/BuiltInPage/FormCreate.vue')
|
||||
),
|
||||
'@/views/system/manage/index.vue': Vue.defineAsyncComponent(() =>
|
||||
import('@/views/system/manage/index.vue')
|
||||
),
|
||||
@ -109,7 +108,7 @@ const runCode = async () => {
|
||||
return ''
|
||||
},
|
||||
//样式
|
||||
addStyle: (css) => {
|
||||
addStyle: (css:any) => {
|
||||
const style = document.createElement('style')
|
||||
style.textContent = css
|
||||
document.head.appendChild(style)
|
||||
@ -117,14 +116,12 @@ const runCode = async () => {
|
||||
compiledCache: new Map(),
|
||||
compileTemplate: true
|
||||
}
|
||||
const componentModule = await loadModule('dynamic.vue', options)
|
||||
const componentModule:any = await loadModule('dynamic.vue', options)
|
||||
const component = componentModule.default || componentModule
|
||||
const dynamicProps = Vue.reactive({
|
||||
menuList: menuList.value,
|
||||
isFixed: true,
|
||||
projectName: '测试',
|
||||
applicationId: applicationId.value,
|
||||
isExecuteEvent: false
|
||||
})
|
||||
// 修改createApp方式
|
||||
prevApp = Vue.createApp({
|
||||
@ -140,8 +137,8 @@ const runCode = async () => {
|
||||
prevApp.use(ElementPlus)
|
||||
prevApp.mount(previewContainer.value)
|
||||
|
||||
} catch (error) {
|
||||
console.error('运行时错误:', error)
|
||||
} catch (error:any) {
|
||||
// console.error('运行时错误:', error)
|
||||
previewContainer.value.innerHTML = `
|
||||
<div class="error">
|
||||
<h3>错误</h3>
|
||||
@ -150,48 +147,41 @@ const runCode = async () => {
|
||||
`
|
||||
}
|
||||
}
|
||||
const processMenuTree = (menuNodes: any[], moduleData: any[]) => {
|
||||
const typeMap = new Map(
|
||||
moduleData.map(({ id, type }) => [id, type])
|
||||
);
|
||||
const traverseMenu = (nodes: any[]) => {
|
||||
for (const node of nodes) {
|
||||
if (node.module_id && typeMap.has(node.module_id)) {
|
||||
node.module_type = typeMap.get(node.module_id);
|
||||
}
|
||||
if (node.children?.length) {
|
||||
traverseMenu(node.children);
|
||||
}
|
||||
}
|
||||
};
|
||||
traverseMenu(menuNodes);
|
||||
return menuNodes;
|
||||
};
|
||||
onMounted(() => {
|
||||
if (route.query.id) {
|
||||
applicationId.value = route.query.id
|
||||
projectName.value = route.query.name
|
||||
const appInfo:any = JSON.parse(localStorage.getItem('userInfo'))
|
||||
if (appInfo.id) {
|
||||
applicationId.value = appInfo.id
|
||||
projectName.value = '测试'
|
||||
getmenuinfo()
|
||||
}
|
||||
})
|
||||
function getmenuinfo() {
|
||||
const params = {
|
||||
appId: applicationId.value,
|
||||
name: '',
|
||||
isdisplay: ''
|
||||
function gettreeData(orglist:any) {
|
||||
const res:any = {};
|
||||
for (const row of orglist) {
|
||||
// 处理 parentid 并解构需要字段
|
||||
const parentid = row.parentid || "0";
|
||||
const { id, name,code, isdisplay, appId, type,module_id,module_type } = row;
|
||||
// 统一节点数据对象
|
||||
const nodeData = { parentid, id, name,code, isdisplay, appId, type,module_id,module_type }
|
||||
// 更新或创建节点
|
||||
if (res[id]) {
|
||||
Object.assign(res[id], nodeData);
|
||||
} else {
|
||||
res[id] = { ...nodeData, children: [] };
|
||||
}
|
||||
getMenuTree(params).then((res:any) => {
|
||||
menuList.value = res.data
|
||||
const paramss = { appId: applicationId.value }
|
||||
moduleList(paramss).then((ress:any) => {
|
||||
var arr = ress.data
|
||||
if(ress.data.length>0){
|
||||
menuList.value = processMenuTree(menuList.value, arr)
|
||||
}
|
||||
runCode()
|
||||
})
|
||||
})
|
||||
|
||||
// 处理父子关系
|
||||
if (res[parentid]) {
|
||||
res[parentid].children.push(res[id]);
|
||||
} else {
|
||||
res[parentid] = { children: [res[id]] };
|
||||
}
|
||||
}
|
||||
return res[0].children;
|
||||
}
|
||||
function getmenuinfo() {
|
||||
const permissions:any = JSON.parse(localStorage.getItem('permissions'))
|
||||
menuList.value = gettreeData(permissions)
|
||||
runCode()
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
|
@ -6,6 +6,8 @@ import PermissionSet from '@/views/system/manage/index.vue'
|
||||
import UserInfoSet from '@/views/system/manage/user/userinfo.vue'
|
||||
import {useRoute, useRouter } from 'vue-router'
|
||||
import { useCache } from '@/data-visualization/hooks/web/useCache'
|
||||
import dataVisualization from '@/data-visualization/index.vue'
|
||||
import FormCreate from '@/views/BuiltInPage/FormCreate.vue'
|
||||
const { wsCache } = useCache()
|
||||
const router = useRouter()
|
||||
const route = useRoute()
|
||||
@ -18,18 +20,16 @@ const props = defineProps({
|
||||
isFixed: Boolean,
|
||||
projectName: String,
|
||||
applicationId: String,
|
||||
isExecuteEvent: Boolean
|
||||
})
|
||||
const navtitle:any = ref('')
|
||||
const navmenulist: any = ref([
|
||||
])
|
||||
const checkindex = ref(null)
|
||||
const showmodule = ref(false)
|
||||
const currentMoudleId = ref('')
|
||||
const showermission = ref(false)
|
||||
const showUserInfo = ref(false)
|
||||
const currentrow = ref({})
|
||||
const currentMoudleType = ref('')
|
||||
const currentrow:any = ref({})
|
||||
const userList:any = ref({})
|
||||
const showcontent = ref('')
|
||||
watch(
|
||||
() => props.menuList,
|
||||
(newVal) => {
|
||||
@ -40,34 +40,37 @@ watch(
|
||||
{ immediate: true } // 立即执行一次
|
||||
)
|
||||
function menuclick(index: any) {
|
||||
showcontent.value = ''
|
||||
if (navmenulist.value[index].children.length == 0 || navmenulist.value[index].children == undefined) {
|
||||
checkindex.value = index
|
||||
if (props.isExecuteEvent) {
|
||||
return
|
||||
}
|
||||
currentMoudleId.value = navmenulist.value[index].module_id
|
||||
if (navmenulist.value[index].module_id && navmenulist.value[index].module_id !== '') {
|
||||
currentMoudleId.value = navmenulist.value[index].module_id
|
||||
currentrow.value = navmenulist.value[index]
|
||||
showmodule.value = true
|
||||
showermission.value = false
|
||||
showUserInfo.value = false
|
||||
if(currentrow.value.module_type == '03'){
|
||||
currentMoudleType.value = 'dataV'
|
||||
showcontent.value = 'dataVisualization'
|
||||
}else if(currentrow.value.module_type == '0301'){
|
||||
currentMoudleType.value = 'dashboard'
|
||||
showcontent.value = 'dataVisualization'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function childmenuclick(item: any) {
|
||||
if (props.isExecuteEvent) {
|
||||
return
|
||||
}
|
||||
showermission.value = false
|
||||
showmodule.value = false
|
||||
showUserInfo.value = false
|
||||
showcontent.value = ''
|
||||
if (item.module_id && item.module_id !== '') {
|
||||
currentrow.value = item
|
||||
currentMoudleId.value = item.module_id
|
||||
showmodule.value = true
|
||||
} else {
|
||||
showmodule.value = false
|
||||
if(currentrow.value.module_type == '03'){
|
||||
currentMoudleType.value = 'dataV'
|
||||
showcontent.value = 'dataVisualization'
|
||||
}else if(currentrow.value.module_type == '0301'){
|
||||
currentMoudleType.value = 'dashboard'
|
||||
showcontent.value = 'dataVisualization'
|
||||
}else if(currentrow.value.module_type == '05'){
|
||||
showcontent.value = 'FormCreate'
|
||||
}
|
||||
}
|
||||
}
|
||||
// 时间相关逻辑移动到独立组件中
|
||||
@ -112,18 +115,13 @@ const TimeDisplay = {
|
||||
onMounted(() => {
|
||||
navmenulist.value = props.menuList
|
||||
navtitle.value = props.projectName
|
||||
userList.value = wsCache.get('Permission-userinfo')
|
||||
userList.value = JSON.parse(localStorage.getItem('userInfo'))
|
||||
})
|
||||
onBeforeUnmount(() => {
|
||||
|
||||
});
|
||||
function permissionClick() {
|
||||
if (props.isExecuteEvent) {
|
||||
return
|
||||
}
|
||||
showmodule.value = false
|
||||
showUserInfo.value = false
|
||||
showermission.value = true
|
||||
showcontent.value = 'PermissionSet'
|
||||
}
|
||||
function logout(){
|
||||
ElMessageBox.confirm(
|
||||
@ -136,18 +134,17 @@ function logout(){
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
wsCache.delete('Permission-userinfo')
|
||||
localStorage.removeItem('token')
|
||||
localStorage.removeItem('userInfo')
|
||||
localStorage.removeItem('permissions')
|
||||
router.push({
|
||||
path: '/UserLogin',
|
||||
query: { id: props.applicationId, name: props.projectName }
|
||||
})
|
||||
})
|
||||
.catch(() => {})
|
||||
}
|
||||
function userdetails(){
|
||||
showmodule.value = false
|
||||
showermission.value = false
|
||||
showUserInfo.value = true
|
||||
showcontent.value = 'UserInfoSet'
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
@ -180,18 +177,17 @@ function userdetails(){
|
||||
<div style="margin-right: 10px;cursor: pointer;" @click="permissionClick"><img
|
||||
src="@/assets/system/navpermission.png" alt=""></div>
|
||||
<div style="margin-right: 10px;cursor: pointer;" @click="userdetails"><img src="@/assets/system/nav1.png" alt=""></div>
|
||||
<div style="margin-right: 15px;min-width: 45px;cursor: pointer;" @click="userdetails">{{ props.isExecuteEvent == false?userList.nickname:'admin' }}</div>
|
||||
<div style="margin-right: 15px;min-width: 45px;cursor: pointer;" @click="userdetails">{{ userList.nickname }}</div>
|
||||
<div style="margin-right: 15px;cursor: pointer;"><img src="@/assets/system/nav3.png" alt=""></div>
|
||||
<div @click="logout" style="cursor: pointer;"><img src="@/assets/system/nav4.png" alt=""></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="!props.isExecuteEvent" class="system-box-content"
|
||||
:style="{ height: props.isFixed ? 'calc(100vh - 65px)' : 'calc(100vh - 125px)' }">
|
||||
<!-- <Assocmodule v-if="showmodule" :applicationId="props.applicationId"
|
||||
:moduleinfo="currentrow" /> -->
|
||||
<PermissionSet v-if="showermission" />
|
||||
<UserInfoSet v-if="showUserInfo" :userList="userList" :applicationId="props.applicationId" />
|
||||
<div class="system-box-content" style="height: calc(100vh - 65px);">
|
||||
<dataVisualization v-if="showcontent == 'dataVisualization'" :appId="currentrow.module_id" :busiFlag="currentMoudleType" />
|
||||
<FormCreate v-if="showcontent == 'FormCreate'" :appId="currentrow.module_id" />
|
||||
<PermissionSet v-if="showcontent == 'PermissionSet'" :isshowheader="true" />
|
||||
<UserInfoSet v-if="showcontent == 'UserInfoSet'" :userList="userList" :applicationId="props.applicationId" />
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -30,6 +30,7 @@ const loginRules = ref({
|
||||
})
|
||||
const ruleFormRef = ref<FormInstance>()
|
||||
const loginTitle: any = ref('')
|
||||
const errormsg = ref('')
|
||||
const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
if (props.isExecuteEvent) {
|
||||
return
|
||||
@ -39,36 +40,31 @@ const submitForm = async (formEl: FormInstance | undefined) => {
|
||||
if (valid) {
|
||||
var password = encrypt(form.value.password)
|
||||
const params = {
|
||||
appid:props.id,
|
||||
username: form.value.username,
|
||||
password: password
|
||||
}
|
||||
userLogin(params).then((res:any) => {
|
||||
if(res.code == '0'){
|
||||
let userInfo = {
|
||||
errormsg.value = ''
|
||||
let userInfo:any = {
|
||||
nickname: res.data.nickname,
|
||||
username: res.data.username,
|
||||
id: res.data.userid
|
||||
id: res.data.userid,
|
||||
appid:res.data.appid
|
||||
}
|
||||
wsCache.set('Permission-userinfo', userInfo)
|
||||
|
||||
ElMessage.success('登录成功')
|
||||
userStore.isAuthenticated = true
|
||||
localStorage.setItem('userInfo',JSON.stringify(userInfo))
|
||||
localStorage.setItem('token', res.data.token)
|
||||
setTimeout(() => {
|
||||
router.push({
|
||||
localStorage.setItem('permissions', JSON.stringify(res.data.permissions))
|
||||
ElMessage.success('登录成功')
|
||||
router.push({
|
||||
path: '/UserNavbar',
|
||||
query: { id: props.id, name: props.name }
|
||||
})
|
||||
}, 500)
|
||||
|
||||
}else{
|
||||
console.log(res,'信息')
|
||||
ElMessage.error(res.msg)
|
||||
errormsg.value = res.msg
|
||||
return
|
||||
}
|
||||
}).catch((err:any) => {
|
||||
ElMessage.error(err.msg)
|
||||
errormsg.value = err
|
||||
})
|
||||
} else {
|
||||
|
||||
@ -115,6 +111,7 @@ onBeforeUnmount(() => {
|
||||
style="width:100%;height: 1px;" alt="">
|
||||
</div>
|
||||
</el-form-item>
|
||||
<div style="color:red;margin-top:10px">{{errormsg}}</div>
|
||||
<div class="login-button" @click="submitForm(ruleFormRef)">登录</div>
|
||||
</el-form>
|
||||
</div>
|
||||
@ -203,7 +200,7 @@ onBeforeUnmount(() => {
|
||||
color: #fff;
|
||||
background: url(/images/loginbtn.png) no-repeat;
|
||||
background-size: 100% 100%;
|
||||
margin-top: 40px;
|
||||
margin-top: 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user