|
|
@@ -1,281 +1,14 @@
|
|
|
-
|
|
|
<template>
|
|
|
-<div class="header">
|
|
|
- <a-menu style="flex:1" v-model:selectedKeys="current" mode="horizontal" @click="itemClick">
|
|
|
- <a-sub-menu v-for="item in mods" :key="item.systemmoduleid">
|
|
|
- <template #title>
|
|
|
- <div>
|
|
|
- <!-- <span class="menu-icon">{{item.systemmodulename.substr(0, 1)}}</span> -->
|
|
|
- <img width="15" style="margin-top:-2px;margin-right:5px" :src="item.iconurl" alt="">
|
|
|
- {{item.systemmodulename}}
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <a-menu-item v-for="app in item.apps" :key="app.systemappid" @click="routeChange(app)">{{app.meta.title}}</a-menu-item>
|
|
|
- </a-sub-menu>
|
|
|
- </a-menu>
|
|
|
- <a-space>
|
|
|
- <a-dropdown>
|
|
|
- <a class="ant-dropdown-link" @click.prevent>
|
|
|
- 切换主题
|
|
|
- <DownOutlined />
|
|
|
- </a>
|
|
|
- <template #overlay>
|
|
|
- <a-menu>
|
|
|
- <a-menu-item>
|
|
|
- <a @click="setTheme('normal')">默认主题</a>
|
|
|
- </a-menu-item>
|
|
|
- <a-menu-item>
|
|
|
- <a @click="setTheme('light')">明亮主题</a>
|
|
|
- </a-menu-item>
|
|
|
- <a-menu-item>
|
|
|
- <a @click="setTheme('caffairs')">商务主题</a>
|
|
|
- </a-menu-item>
|
|
|
- </a-menu>
|
|
|
- </template>
|
|
|
- </a-dropdown>
|
|
|
- <a-button type="text" @click="router.push('/shopCart')">
|
|
|
- 购物车
|
|
|
- <template #icon>
|
|
|
- <ShoppingCartOutlined/>
|
|
|
- </template>
|
|
|
- </a-button>
|
|
|
-
|
|
|
- <a-dropdown class="dropdown-link">
|
|
|
- <a class="ant-dropdown-link" @click.prevent>
|
|
|
- {{act_name}}
|
|
|
- <DownOutlined />
|
|
|
- </a>
|
|
|
- <template #overlay>
|
|
|
- <a-menu>
|
|
|
- <a-menu-item v-for="item in a_list" :key="item.index">
|
|
|
- <a @click="accountItemClick(item,false)">{{item.sitename + '-' + item.name}}</a>
|
|
|
- </a-menu-item>
|
|
|
- <a-menu-divider />
|
|
|
- <a-menu-item>
|
|
|
- <logout-outlined />
|
|
|
- <a class="color-red" @click="loginOut"> 退出登录</a>
|
|
|
- </a-menu-item>
|
|
|
- </a-menu>
|
|
|
- </template>
|
|
|
- </a-dropdown>
|
|
|
- </a-space>
|
|
|
-</div>
|
|
|
+ <div class="header">
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import Api from '@/api/api'
|
|
|
-import less from 'less'
|
|
|
-
|
|
|
-import { defineComponent,ref, reactive,onMounted,onBeforeMount,createVNode ,watch} from 'vue';
|
|
|
-
|
|
|
-import { useAuthStore } from '../../stores/modules/auth'
|
|
|
-import { storeToRefs } from 'pinia'
|
|
|
-
|
|
|
-import { DownOutlined,LogoutOutlined ,SettingOutlined,ExclamationCircleOutlined,ShoppingCartOutlined} from '@ant-design/icons-vue';
|
|
|
-import {ConfigProvider, Modal } from 'ant-design-vue';
|
|
|
-import { useRouter } from "vue-router";
|
|
|
-const router = useRouter()
|
|
|
-
|
|
|
-const actApp = ref({})
|
|
|
-const colorState = ref({})
|
|
|
-let current = ref([]);
|
|
|
-
|
|
|
-let a_list = ref([]);
|
|
|
-const at_account = ref({})
|
|
|
-const store = useAuthStore()
|
|
|
-
|
|
|
-let { system,mods,act_mods } = storeToRefs(store)
|
|
|
-
|
|
|
-const act_name = ref('')
|
|
|
-const count = ref('')
|
|
|
-const auth = async (data) => {
|
|
|
- store.systemAuthData(data)
|
|
|
-
|
|
|
- let app = sessionStorage.getItem('app')
|
|
|
-
|
|
|
- if (app)
|
|
|
- return false
|
|
|
- if (mods.value)
|
|
|
- return sessionStorage.setItem('app',JSON.stringify(mods.value[0].apps[0]))
|
|
|
- router.push({path:mods.value[0].apps[0].path})
|
|
|
-};
|
|
|
-
|
|
|
-const getAccountList = ()=>{
|
|
|
-
|
|
|
- a_list.value = JSON.parse(sessionStorage.getItem('a_list'))
|
|
|
-
|
|
|
- let hasActAccount = sessionStorage.getItem('active_account') ? true:false
|
|
|
-
|
|
|
- let act_account = JSON.parse(sessionStorage.getItem('active_account'))
|
|
|
-
|
|
|
- accountItemClick(hasActAccount ? act_account : a_list.value[0],true)
|
|
|
-
|
|
|
-};
|
|
|
-
|
|
|
-const accountItemClick = (account,bool)=>{
|
|
|
-
|
|
|
- setSessionStorage(account)
|
|
|
-
|
|
|
- at_account.value = account
|
|
|
-
|
|
|
- let data = {
|
|
|
- "classname": "sysmanage.develop.userauthforweb.userauth",
|
|
|
- "method": "query_userauth",
|
|
|
- "content": {
|
|
|
- "place": 1
|
|
|
- },
|
|
|
- "systemappid": ""
|
|
|
- }
|
|
|
- auth(data)
|
|
|
- if (!bool)
|
|
|
- return router.go(0)
|
|
|
-}
|
|
|
-const setSessionStorage = (account)=>{
|
|
|
- sessionStorage.setItem('active_account',JSON.stringify(account))
|
|
|
- sessionStorage.setItem('token',account.token)
|
|
|
- act_name.value = `${account.name}-${account.sitename}`
|
|
|
-}
|
|
|
-const routeChange = (app)=>{
|
|
|
- actApp.value = app
|
|
|
- sessionStorage.setItem('app',JSON.stringify(app))
|
|
|
- router.push({path:app.path,meta:{APP:app}})
|
|
|
-}
|
|
|
-
|
|
|
-const itemClick = (item, key, keyPath)=>{
|
|
|
- current.value = item.keyPath
|
|
|
-}
|
|
|
-const loginOut = ()=>{
|
|
|
- Modal.confirm({
|
|
|
- title: '注意',
|
|
|
- icon: createVNode(ExclamationCircleOutlined),
|
|
|
- content: '确定登出当前账号吗?',
|
|
|
- okText: '确认',
|
|
|
- cancelText: '取消',
|
|
|
- onOk () {
|
|
|
- Api.loginout({})
|
|
|
- router.push({path:'/'})
|
|
|
- }
|
|
|
- });
|
|
|
-}
|
|
|
-const setTheme = (themeName)=> {
|
|
|
- if (themeName === 'light') {
|
|
|
- colorState.value = {
|
|
|
- primaryColor: '#f23557',
|
|
|
- errorColor: '#eb586f',
|
|
|
- warningColor: '#ffde7d',
|
|
|
- successColor: '#4aa0d5',
|
|
|
- infoColor: '#d8e9f0',
|
|
|
- }
|
|
|
-
|
|
|
- ConfigProvider.config({
|
|
|
- theme: colorState.value
|
|
|
- });
|
|
|
-
|
|
|
- } else if (themeName === 'normal') {
|
|
|
- colorState.value = {
|
|
|
- primaryColor: '#4e71f7',
|
|
|
- errorColor: '#ff4d4f',
|
|
|
- warningColor: '#faad14',
|
|
|
- successColor: '#52c41a',
|
|
|
- infoColor: '#1890ff',
|
|
|
- }
|
|
|
- ConfigProvider.config({
|
|
|
- theme: colorState.value
|
|
|
- });
|
|
|
- } else if (themeName === 'caffairs') {
|
|
|
- colorState.value = {
|
|
|
- primaryColor: '#404b69',
|
|
|
- errorColor: '#ff5f5f',
|
|
|
- warningColor: '#ffc93c',
|
|
|
- successColor: '#1fab89',
|
|
|
- infoColor: '#dbedf3',
|
|
|
- }
|
|
|
- ConfigProvider.config({
|
|
|
- theme: colorState.value
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
-const shoppingCartCount = async ()=>{
|
|
|
- const res = await Api.optionstype('shoppingcartcount')
|
|
|
- count.value = res.data
|
|
|
-}
|
|
|
-const checkHasApp = (to)=>{
|
|
|
- let [arr, mode, app] = [[], [], []];
|
|
|
- system.value.forEach(e=>{
|
|
|
- mode = mode.concat(...e.modules)
|
|
|
- })
|
|
|
-
|
|
|
- mode.forEach(e=>{
|
|
|
- arr = arr.concat(...e.apps)
|
|
|
- })
|
|
|
- let hasApp = arr.some(e=>e.name == to.meta.name)
|
|
|
- if (!hasApp)
|
|
|
- return router.replace({name:'404'})
|
|
|
-}
|
|
|
-const getAppData = ()=> {
|
|
|
- let app = mods.value.map(e=>e.apps)
|
|
|
- app.forEach(e=>{
|
|
|
- e.forEach(a=>{
|
|
|
- if (router.currentRoute.value.meta.name == a.name) {
|
|
|
- sessionStorage.setItem('app',JSON.stringify(a))
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
-}
|
|
|
-onMounted(()=>{
|
|
|
- getAccountList()
|
|
|
- store.hideKeyWords(at_account.value)
|
|
|
- shoppingCartCount()
|
|
|
-
|
|
|
-})
|
|
|
-onBeforeMount(()=>{
|
|
|
- setTheme('normal')
|
|
|
-})
|
|
|
-watch(() => router.currentRoute.value,(to, from) => {
|
|
|
- // console.log(to)
|
|
|
- getAppData()
|
|
|
- checkHasApp(to)
|
|
|
-})
|
|
|
</script>
|
|
|
-<style>
|
|
|
-.header .ant-menu-horizontal {
|
|
|
- border-bottom: none;
|
|
|
-}
|
|
|
-</style>
|
|
|
<style scoped>
|
|
|
.header{
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- position: sticky;
|
|
|
- top:0px;
|
|
|
- padding-right: 60px;
|
|
|
- border-bottom: 1px solid #f0f0f0;
|
|
|
+ height: 50px;
|
|
|
background: #fff;
|
|
|
- z-index: 1000;
|
|
|
-}
|
|
|
-.dropdown-link{
|
|
|
- margin-top: -1px;
|
|
|
-}
|
|
|
-.color-red{
|
|
|
- color:red
|
|
|
-}
|
|
|
-.flex{
|
|
|
- display: flex;
|
|
|
- align-items: center;
|
|
|
- justify-content: space-around;
|
|
|
-}
|
|
|
-.menu-icon{
|
|
|
- display: inline-block;
|
|
|
- height: 20px;
|
|
|
- width: 20px;
|
|
|
- padding-top: -2px;
|
|
|
- font-size: 10px;
|
|
|
- text-align: center;
|
|
|
- line-height: 20px;
|
|
|
- color: #999;
|
|
|
- border-radius:100% ;
|
|
|
- border:1px solid #f1f2f3;
|
|
|
- background: #f1f2f3;
|
|
|
+ border-bottom:1px solid #f1f2f3
|
|
|
}
|
|
|
</style>
|