|
|
@@ -1,17 +1,39 @@
|
|
|
<script setup>
|
|
|
+import { computed, ref } from 'vue'
|
|
|
import { onShow } from '@dcloudio/uni-app'
|
|
|
import { useUserStore } from '@/stores/user'
|
|
|
import { WORKBENCH_MODULES } from '@/config/workbench-menus'
|
|
|
import { PAGE_PATHS, WORKBENCH_ROUTE_MAP } from '@/config/api'
|
|
|
+import { filterWorkbenchModules } from '@/utils/workbenchMenuFilter'
|
|
|
|
|
|
const userStore = useUserStore()
|
|
|
-const modules = WORKBENCH_MODULES
|
|
|
+const modules = computed(() =>
|
|
|
+ filterWorkbenchModules(WORKBENCH_MODULES, {
|
|
|
+ menuAll: userStore.menuAll,
|
|
|
+ menuCodes: userStore.menuCodes
|
|
|
+ })
|
|
|
+)
|
|
|
+const loggingOut = ref(false)
|
|
|
+
|
|
|
+const displayName = computed(() => {
|
|
|
+ const info = userStore.userInfo
|
|
|
+ if (!info) return '未登录'
|
|
|
+ return info.realName || info.username || '用户'
|
|
|
+})
|
|
|
|
|
|
-onShow(() => {
|
|
|
+/** 三列宫格补齐空白格,避免末行空位露出网格底色 */
|
|
|
+const menuPadCount = (len) => {
|
|
|
+ const rem = Number(len) % 3
|
|
|
+ return rem === 0 ? 0 : 3 - rem
|
|
|
+}
|
|
|
+
|
|
|
+onShow(async () => {
|
|
|
userStore.checkLoginStatus()
|
|
|
if (!userStore.isLoggedIn) {
|
|
|
uni.reLaunch({ url: PAGE_PATHS.login })
|
|
|
+ return
|
|
|
}
|
|
|
+ await userStore.fetchMenuCodes()
|
|
|
})
|
|
|
|
|
|
const openMenu = (module, menu) => {
|
|
|
@@ -31,13 +53,37 @@ const openMenu = (module, menu) => {
|
|
|
url: `${PAGE_PATHS.bizPlaceholder}?title=${title}&module=${moduleTitle}&code=${code}`
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+const handleLogout = async () => {
|
|
|
+ if (loggingOut.value) return
|
|
|
+ loggingOut.value = true
|
|
|
+ try {
|
|
|
+ await userStore.logout()
|
|
|
+ } finally {
|
|
|
+ loggingOut.value = false
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
<view class="mp-page mp-page--tab">
|
|
|
- <view class="mp-header">
|
|
|
- <text class="mp-header__title">工作台</text>
|
|
|
- <text class="mp-header__meta">选择业务模块,进入对应功能办理</text>
|
|
|
+ <view class="mp-header mp-header--workbench">
|
|
|
+ <view class="mp-header__row">
|
|
|
+ <view class="mp-header__main">
|
|
|
+ <text class="mp-header__title">工作台</text>
|
|
|
+ <text class="mp-header__meta">选择业务模块,进入对应功能办理</text>
|
|
|
+ </view>
|
|
|
+ <view class="mp-header__user-stack">
|
|
|
+ <text class="mp-header__user-name">{{ displayName }}</text>
|
|
|
+ <text
|
|
|
+ class="mp-header__logout"
|
|
|
+ :class="{ 'mp-header__logout--disabled': loggingOut }"
|
|
|
+ @click="handleLogout"
|
|
|
+ >
|
|
|
+ {{ loggingOut ? '退出中…' : '退出登录' }}
|
|
|
+ </text>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
|
|
|
<view class="mp-section">
|
|
|
@@ -62,9 +108,14 @@ const openMenu = (module, menu) => {
|
|
|
:class="{ 'mp-menu-card--disabled': !menu.enabled }"
|
|
|
@click="openMenu(mod, menu)"
|
|
|
>
|
|
|
- <view class="mp-menu-card__icon" />
|
|
|
+ <view class="mp-menu-card__icon">{{ menu.icon || '' }}</view>
|
|
|
<text class="mp-menu-card__name">{{ menu.name }}</text>
|
|
|
</view>
|
|
|
+ <view
|
|
|
+ v-for="i in menuPadCount(mod.menus.length)"
|
|
|
+ :key="'pad-' + mod.key + '-' + i"
|
|
|
+ class="mp-menu-card mp-menu-card--pad"
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|