| | |
| | | <template>
|
| | | <div class="navbar">
|
| | | <div>
|
| | | <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container" @toggleClick="toggleSideBar" />
|
| | | <hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container"
|
| | | @toggleClick="toggleSideBar" />
|
| | | <breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container" />
|
| | | </div>
|
| | | <!-- <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />-->
|
| | | <!-- <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />-->
|
| | | <div class="center-menu">
|
| | | <span class="label">{{userStore.currentFactoryName}}</span>
|
| | | <span class="label">{{ userStore.currentFactoryName }}</span>
|
| | | <el-dropdown @command="handleFactoryChange" class="right-menu-item hover-effect" trigger="click">
|
| | | <div class="avatar-wrapper">
|
| | | <el-icon><Switch /></el-icon>
|
| | | <div>
|
| | | <el-icon size="20">
|
| | | <Switch />
|
| | | </el-icon>
|
| | | </div>
|
| | | <template #dropdown>
|
| | | <el-dropdown-menu >
|
| | | <el-dropdown-item
|
| | | v-for="item in factoryList"
|
| | | :key="item.deptId"
|
| | | :command="item"
|
| | | >
|
| | | <el-dropdown-menu>
|
| | | <el-dropdown-item v-for="item in factoryList" :key="item.deptId" :command="item">
|
| | | {{ item.deptName }}
|
| | | </el-dropdown-item>
|
| | | </el-dropdown-menu>
|
| | | </template>
|
| | | </el-dropdown>
|
| | |
|
| | | </div>
|
| | | <div class="right-menu">
|
| | | <div class="avatar-container">
|
| | |
| | | function toggleSideBar() {
|
| | | appStore.toggleSideBar()
|
| | | }
|
| | | // const redirect = ref(undefined)
|
| | | // watch(route, (newRoute) => {
|
| | | // redirect.value = newRoute.query && newRoute.query.redirect
|
| | | // }, { immediate: true })
|
| | |
|
| | | function handleCommand(command) {
|
| | | switch (command) {
|
| | |
| | | }
|
| | |
|
| | | function getUserLoginFacotryList() {
|
| | | if(userStore.id){
|
| | | userLoginFacotryList({userId:userStore.id}).then(res => {
|
| | | if (userStore.id) {
|
| | | userLoginFacotryList({ userId: userStore.id }).then(res => {
|
| | | console.log('res', res)
|
| | | factoryList.value = res.data
|
| | | })
|
| | | }else {
|
| | | } else {
|
| | | factoryList.value = []
|
| | | }
|
| | | }
|
| | |
| | | handleLogin(command.deptId);
|
| | | }
|
| | |
|
| | | function handleLogin(currentFatoryId){
|
| | | function handleLogin(currentFatoryId) {
|
| | | const loginForm = {
|
| | | username: Cookies.get("username"),
|
| | | password: Cookies.get("password") === undefined ? null : decrypt(Cookies.get("password")),
|
| | | currentFatoryId: currentFatoryId
|
| | | }
|
| | | userStore.loginCheckFactory(loginForm).then(res => {
|
| | | const query = route.query
|
| | | const otherQueryParams = Object.keys(query).reduce((acc, cur) => {
|
| | | if (cur !== "redirect") {
|
| | | acc[cur] = query[cur]
|
| | | }
|
| | | return acc
|
| | | }, {})
|
| | | router.push({ path: redirect.value || "/", query: otherQueryParams })
|
| | | }).catch(() => {
|
| | | forceReload();
|
| | | }).catch((err) => {
|
| | | console.log(err)
|
| | | })
|
| | | }
|
| | | function forceReload() {
|
| | | const currentUrl = window.location.origin + window.location.pathname;
|
| | | const timestamp = new Date().getTime();
|
| | | window.location.href = `${currentUrl}?reload=${timestamp}`;
|
| | | }
|
| | |
|
| | | getUserLoginFacotryList();
|
| | |
| | | position: relative;
|
| | | background: var(--navbar-bg);
|
| | | box-shadow: 0 1px 4px rgba(0, 21, 41, 0.08);
|
| | |
|
| | | .center-menu {
|
| | | line-height: 50px;
|
| | | position: absolute;
|
| | | left: 50%;
|
| | | transform: translateX(-50%);
|
| | | display: flex;
|
| | | align-items: center;
|
| | |
|
| | | .label {
|
| | | font-weight: bold;
|
| | | font-size: 18px;
|
| | | color: #333333;
|
| | | margin-right: 10px;
|
| | | }
|
| | | }
|
| | |
|