优化小程序菜单管理功能

This commit is contained in:
gxwebsoft
2024-06-01 02:45:33 +08:00
parent 4bae8599e1
commit e3fb9ba283
36 changed files with 2161 additions and 430 deletions

View File

@@ -19,19 +19,16 @@
</a-tree-select>
</div>
<!-- 商户名称 -->
<template v-if="getMerchantName()">
<template v-if="merchants.length > 0">
<div class="ele-admin-header-tool-item">
<a-button @click="openUrl(`/booking/school`)">{{
getMerchantName()
}}</a-button>
<MerchantSelect
:merchants="merchants"
v-model:value="merchantName"
@done="onMerchant"
/>
</div>
</template>
<!-- <div-->
<!-- class="ele-admin-header-tool-item"-->
<!-- @click="openUrl('https://b.gxwebsoft.com')"-->
<!-- >-->
<!-- 旧版-->
<!-- </div>-->
<!-- 消息通知 -->
<div class="ele-admin-header-tool-item" @click="openUrl(`/user/notice`)">
<header-notice />
@@ -163,9 +160,6 @@
import {
DownOutlined,
CopyOutlined,
UserOutlined,
MoreOutlined,
LogoutOutlined,
ExclamationCircleOutlined,
FullscreenOutlined,
FullscreenExitOutlined,
@@ -183,6 +177,9 @@
import { listMenus } from '@/api/system/menu';
import { isExternalLink, toTreeData } from 'ele-admin-pro';
import { getMerchantName } from '@/utils/merchant';
import { Merchant } from '@/api/shop/merchant/model';
import { listMerchant } from '@/api/shop/merchant';
import MerchantSelect from './merchant-select.vue';
// 是否开启响应式布局
const themeStore = useThemeStore();
@@ -214,6 +211,8 @@
const menuTree = ref<Menu[]>([]);
const parentId = ref<number>();
const bordered = ref<boolean>(false);
const merchants = ref<Merchant[]>([]);
const merchantName = ref();
/* 用户信息下拉点击 */
const onUserDropClick = ({ key }) => {
@@ -261,7 +260,17 @@
if (item?.component) {
return push(item.path);
}
// bordered.value = true;
};
// 选择商户
const onMerchant = (id: number) => {
const item = merchants.value.find((d) => d.merchantId == id);
if (item) {
merchantName.value = item.merchantName;
localStorage.setItem('MerchantName', `${item.merchantName}`);
localStorage.setItem('MerchantId', `${item.merchantId}`);
window.location.reload();
}
};
/* 切换全屏 */
@@ -274,8 +283,9 @@
settingVisible.value = true;
};
const getMenus = () => {
if (!getMerchantName()) {
const reload = () => {
if (loginUser.value.username == 'admin') {
// 查询菜单列表
listMenus({ menuType: 0, hide: 0 }).then((data) => {
if (data) {
menuList.value = data;
@@ -289,9 +299,19 @@
}
});
}
merchantName.value = getMerchantName();
if (loginUser.value.merchants) {
listMerchant({ merchantIds: loginUser.value.merchants }).then((res) => {
merchants.value = res.map((d) => {
d.label = d.merchantName;
d.value = d.merchantId;
return d;
});
});
}
};
getMenus();
reload();
</script>
<script lang="ts">