Zlpt_Portal/src/views/user/index.vue

247 lines
7.2 KiB
Vue
Raw Normal View History

2023-12-01 11:22:09 +08:00
<script setup lang="ts">
2024-11-27 15:16:53 +08:00
import Header from 'components/header/index.vue'
2024-11-27 09:08:48 +08:00
import { useRouter } from 'vue-router'
import { useStore } from '../../store/user'
import { useRoute } from 'vue-router'
2025-02-26 15:35:46 +08:00
const store: any = useStore()
2024-11-27 09:08:48 +08:00
const router = useRouter()
const route = useRoute()
2025-02-27 17:31:54 +08:00
const userInfo = JSON.parse(localStorage.getItem('main')).userInfo
// const isAdmin = ref(userInfo.admin)
2025-02-27 15:29:36 +08:00
// 临时管理员权限
2025-02-27 17:31:54 +08:00
// console.log('🚀 ~ userInfo:', userInfo)
2025-03-14 18:02:22 +08:00
// const isAdmin = ref(userInfo.userId == 226 || userInfo.userId == 225 || userInfo.admin)
const isAdmin = ref(true) // 临时放开权限
2025-02-27 17:31:54 +08:00
// console.log('🚀 ~ isAdmin:', isAdmin.value)
2024-11-27 09:08:48 +08:00
2024-11-29 13:57:59 +08:00
import imgSrc from '@/assets/img/logo.png'
2024-11-27 09:08:48 +08:00
const handleSelect = (name: any, path: any) => {
2025-02-26 15:35:46 +08:00
console.log('🚀 ~ handleSelect ~ name:', name)
if (name == 'admin') {
2025-02-26 17:09:25 +08:00
const token = localStorage.getItem('tokenNew')
const host = window.location.origin
2025-02-26 15:35:46 +08:00
2025-02-26 17:09:25 +08:00
if (host.indexOf('sgwpdm.ah.sgcc.com.cn') > -1) {
window.open(`${host}/iws/glweb/login?token=${token}`)
} else {
if (import.meta.env.VITE_ENV === 'production') {
window.open(`${host}/glweb/?token=${token}`)
} else {
window.open(`${host}/iws/glweb/?token=${token}`)
// window.open(`${'http://localhost:1024'}/iws/glweb/?token=${token}`)
}
}
2025-02-26 15:35:46 +08:00
} else {
store.editcurrentMenuItem(name)
router.push({
name,
})
}
2024-11-27 09:08:48 +08:00
}
2024-12-03 13:51:08 +08:00
const isType: any = computed(() => {
2024-12-02 14:06:16 +08:00
return localStorage.getItem('rolesType')
})
2025-02-24 16:06:02 +08:00
// 定义菜单项接口
interface MenuItem {
title: string
name: string
permission: string[]
}
// 按角色分组定义菜单---出租方
const lessorMenus: MenuItem[] = [
2024-12-02 14:06:16 +08:00
{ title: '装备管理', name: 'goodsManagement', permission: ['1'] },
2025-09-15 20:41:44 +08:00
{ title: '装备审核', name: 'goodsAuditing', permission: ['1'] },
2025-01-10 14:51:27 +08:00
{ title: '出租订单', name: 'orderManagementCz', permission: ['1'] },
2024-12-02 14:06:16 +08:00
{ title: '接单管理', name: 'accept-orders', permission: ['1'] },
2025-06-02 09:54:33 +08:00
{ title: '装备维保', name: 'quality-manage', permission: ['1'] },
2025-02-24 16:06:02 +08:00
{ title: '合同管理', name: 'contract-manage', permission: ['1'] },
2025-09-15 20:41:44 +08:00
/* { title: '自有装备管理', name: 'owned-manage', permission: ['1'] }, */
{ title: '外租装备管理', name: 'rent-manage', permission: ['1'] },
2025-07-03 21:48:14 +08:00
{ title: '机械化施工装备配置率', name: 'rent-facility', permission: ['1'] },
2025-09-15 20:41:44 +08:00
{ title: '后台管理', name: 'admin', permission: ['1'] },
2025-02-24 16:06:02 +08:00
]
// 按角色分组定义菜单---承租方
const lesseeMenus: MenuItem[] = [
2024-12-02 14:06:16 +08:00
{ title: '需求管理', name: 'sourcingNeed', permission: ['2'] },
2025-01-10 14:51:27 +08:00
{ title: '租赁订单', name: 'orderManagement', permission: ['2'] },
2024-12-16 13:06:54 +08:00
{ title: '收货地址管理', name: 'address-manage', permission: ['2'] },
2025-02-26 17:09:25 +08:00
{ title: '后台管理', name: 'admin', permission: ['2'] },
2024-12-02 14:06:16 +08:00
]
2025-01-09 15:36:06 +08:00
2025-02-24 16:06:02 +08:00
// 合并所有菜单项
const allList: MenuItem[] = [...lessorMenus, ...lesseeMenus]
2025-02-26 15:35:46 +08:00
const rolesType: any = ref('')
if (localStorage.getItem('rolesTypeName')) {
rolesType.value = localStorage.getItem('rolesTypeName')
} else {
rolesType.value = '承租方'
}
2024-11-27 15:16:53 +08:00
const menuList: any = computed(() => {
2025-02-26 15:35:46 +08:00
return rolesType.value == '承租方'
2025-02-26 17:09:25 +08:00
? allList.filter((e) => {
if (isAdmin.value) {
return e.permission.includes('2')
} else {
return e.permission.includes('2') && e.name != 'admin'
}
})
: allList.filter((e) => {
if (isAdmin.value) {
return e.permission.includes('1')
} else {
return e.permission.includes('1') && e.name != 'admin'
}
})
2024-12-02 14:06:16 +08:00
})
2024-12-02 15:33:53 +08:00
const activeItem = computed(() => {
2025-02-26 15:35:46 +08:00
if (rolesType.value == '出租方') {
return 'goodsManagement'
2025-01-10 09:25:09 +08:00
} else {
return 'sourcingNeed'
}
2024-12-02 15:33:53 +08:00
})
2024-12-02 14:06:16 +08:00
router.push({
2024-12-02 15:33:53 +08:00
name: activeItem.value,
2024-11-27 09:08:48 +08:00
})
2025-01-09 15:36:06 +08:00
const onChange = (val: any) => {
if (val == '承租方') {
2025-01-10 09:25:09 +08:00
store.editcurrentMenuItem('sourcingNeed')
2025-01-09 15:36:06 +08:00
router.push({
name: 'sourcingNeed',
})
2025-02-07 16:27:08 +08:00
localStorage.setItem('rolesTypeName', '承租方')
2025-01-09 15:36:06 +08:00
} else {
2025-01-10 09:25:09 +08:00
store.editcurrentMenuItem('goodsManagement')
2025-01-09 15:36:06 +08:00
router.push({
name: 'goodsManagement',
})
2025-02-07 16:27:08 +08:00
localStorage.setItem('rolesTypeName', '出租方')
2025-01-09 15:36:06 +08:00
}
}
2025-01-10 09:25:09 +08:00
onBeforeUnmount(() => {
store.editcurrentMenuItem(null)
})
2023-12-04 17:42:11 +08:00
</script>
2023-12-01 11:22:09 +08:00
<template>
<!-- 个人中心页面 -->
2024-12-13 10:20:22 +08:00
<div style="width: 100%; display: flex; background-color: #f5f5f5; justify-content: flex-end">
<Header style="margin-right: 20px" />
</div>
<div class="app-container" id="user-container">
2023-12-01 11:22:09 +08:00
<div class="left-menu">
2024-11-29 13:57:59 +08:00
<div class="logo-title" @click="$router.push({ name: 'home' })">
<el-image
style="width: 100%; height: 60px; cursor: pointer"
:src="imgSrc"
fit="contain"
/>
</div>
2025-01-09 15:36:06 +08:00
<div style="margin-top: 10px; width: 100%">
<el-radio-group v-model="rolesType" @change="onChange">
<el-radio-button label="承租方" value="承租方" />
<el-radio-button label="出租方" value="出租方" />
</el-radio-group>
</div>
2023-12-04 17:42:11 +08:00
<el-menu
2024-11-27 15:16:53 +08:00
class="el-menu-vertical-demo"
2024-11-27 09:08:48 +08:00
@select="handleSelect"
2025-02-07 16:27:08 +08:00
:default-active="route && route.name ? route.name : ''"
2024-11-27 09:08:48 +08:00
>
2024-12-02 14:06:16 +08:00
<template v-for="(item, index) in menuList" :key="index">
<el-menu-item :index="item.name">
{{ item.title }}
</el-menu-item>
</template>
2023-12-01 11:22:09 +08:00
</el-menu>
</div>
<div class="right-content">
<router-view />
</div>
</div>
</template>
2023-12-04 17:42:11 +08:00
<style lang="scss">
2024-11-27 09:08:48 +08:00
.app-container {
display: flex;
2024-12-13 10:20:22 +08:00
height: calc((100vh - 47px));
2024-11-27 15:16:53 +08:00
width: 100%;
2024-11-27 09:08:48 +08:00
.left-menu {
width: 260px;
background-color: #f7f9fa;
2024-11-27 15:16:53 +08:00
.logo-title {
cursor: pointer;
text-align: center;
padding: 15px;
color: #fff;
}
2024-11-27 09:08:48 +08:00
.pic-box {
2023-12-01 17:02:05 +08:00
width: 260px;
2024-11-27 09:08:48 +08:00
height: 180px;
text-align: center;
img {
margin: 30px 0 10px 0;
width: 90px;
height: 90px;
border-radius: 50%;
2023-12-01 11:22:09 +08:00
}
span {
2024-11-27 09:08:48 +08:00
display: block;
2023-12-01 11:22:09 +08:00
}
}
2024-11-27 09:08:48 +08:00
}
.btn-box {
height: 45px;
display: flex;
2023-12-01 11:22:09 +08:00
2024-11-27 09:08:48 +08:00
span {
2023-12-01 11:22:09 +08:00
height: 100%;
2024-11-27 09:08:48 +08:00
line-height: 45px;
flex: 1;
cursor: pointer;
text-align: center;
color: #82b8ff;
2023-12-01 11:22:09 +08:00
}
2024-11-27 09:08:48 +08:00
}
2023-12-01 17:02:05 +08:00
2024-11-27 09:08:48 +08:00
.right-content {
2024-11-27 15:16:53 +08:00
flex: 1;
padding: 15px;
2024-12-08 20:40:59 +08:00
background-color: #eeeff6;
2024-12-04 10:38:54 +08:00
overflow-y: auto;
2024-11-27 09:08:48 +08:00
}
.active {
color: #2282ff;
border-bottom: 2px solid #2282ff;
font-weight: bold;
2023-12-01 11:22:09 +08:00
}
2024-11-27 09:08:48 +08:00
}
2025-01-09 15:36:06 +08:00
.el-radio-group {
width: 100%;
}
.el-radio-button {
width: 50%;
box-sizing: border-box;
}
.el-radio-button__inner {
width: 100%;
box-sizing: border-box;
border-radius: 0 !important;
}
2023-12-04 17:42:11 +08:00
</style>