You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
udiwms-vue-frame/src/layout/components/Navbar.vue

371 lines
9.9 KiB
Vue

2 years ago
<template>
<div class="navbar">
2 years ago
<hamburger id="hamburger-container" :is-active="sidebar.opened" class="hamburger-container"
@toggleClick="toggleSideBar"/>
2 years ago
<breadcrumb id="breadcrumb-container" class="breadcrumb-container" v-if="!topNav"/>
<top-nav id="topmenu-container" class="topmenu-container" v-if="topNav"/>
<div class="right-menu">
<template v-if="device!=='mobile'">
2 years ago
<div class="inv-hos-title">
<span style="font-weight: bold;color: #303133;">平和县医院</span>
<span
style="margin-right: 18px;margin-left:8px;color: #2d8cf0;font-size: 14px;">({{ inv }})</span>
</div>
<search id="header-search" class="right-menu-item"/>
<screenfull id="screenfull" class="right-menu-item hover-effect"/>
2 years ago
<el-tooltip content="布局大小" effect="dark" placement="bottom">
2 years ago
<size-select id="size-select" class="right-menu-item hover-effect"/>
2 years ago
</el-tooltip>
</template>
<el-dropdown class="avatar-container right-menu-item hover-effect" trigger="click">
<div class="avatar-wrapper">
<img :src="avatar" class="user-avatar">
2 years ago
<i class="el-icon-caret-bottom"/>
2 years ago
</div>
<el-dropdown-menu slot="dropdown">
2 years ago
<!-- <router-link to="/user/profile">-->
<!-- <el-dropdown-item>个人中心</el-dropdown-item>-->
<!-- </router-link>-->
2 years ago
<el-dropdown-item @click.native="setting = true">
<span>布局设置</span>
</el-dropdown-item>
2 years ago
<el-dropdown-item divided @click.native="changeInv">
<span>切换仓库</span>
</el-dropdown-item>
2 years ago
<el-dropdown-item divided @click.native="logout">
<span>退出登录</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
2 years ago
<el-dialog
title="请选择当前部门与仓库"
:visible.sync="selInvVisible"
:close-on-click-modal="false"
:close-on-press-escape="false"
width="35%"
v-if="selInvVisible"
>
<el-form :model="userInfo" label-width="100px" :rules="formRules" ref="dataForm">
<el-row :gutter="20">
<el-col :span="20">
<el-form-item prop="locDeptCode" label="当前部门:">
<el-select v-model="userInfo.locDeptCode" placeholder="请选择当前部门" clearable
style="width: 90%"
@change="deptChange">
<el-option
v-for="item in deptList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="20">
<el-form-item prop="locInvCode" label="当前仓库:">
<el-select v-model="userInfo.locInvCode" placeholder="请选择当前仓库" clearable
style="width: 90%"
>
<el-option
v-for="item in invList"
:key="item.name"
:label="item.name"
:value="item.code">
<span style="float: left">{{ item.name }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
</el-row>
<div style="margin-top: 8px ; color: #F71616; font-size: 12px">
<span>提示进入系统请先选择您当前所在部门与仓库&nbsp;</span>
</div>
<div style='text-align: center; margin-bottom: 10px;margin-top: 18px ;'>
<el-button type="primary" @click="submitInv"></el-button>
<el-button type="primary" @click="closeDialog"></el-button>
</div>
</el-form>
</el-dialog>
2 years ago
</div>
</template>
<script>
2 years ago
import {mapGetters} from 'vuex'
2 years ago
import Breadcrumb from '@/components/Breadcrumb'
import TopNav from '@/components/TopNav'
import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import RuoYiGit from '@/components/RuoYi/Git'
import RuoYiDoc from '@/components/RuoYi/Doc'
2 years ago
import store from "@/store";
import {filterAllByUser} from "@/api/system/invWarehouse";
import {filterSubByInv, findByDeptUser} from "@/api/system/invSubWarehouse";
import {updateInv} from "@/api/auth/authAdmin";
import {isRelogin} from "@/utils/request";
import router from "@/router";
2 years ago
export default {
2 years ago
data() {
return {
inv: store.getters.locInvName,
selInvVisible: false,
userInfo: {},
deptList: [],
invList: [],
formRules: {
locDeptCode: [
{required: true, message: "请选择当前部门", trigger: "blur"}
],
locInvCode: [
{required: true, message: "请选择当前仓库", trigger: "blur"}
],
},
};
},
2 years ago
components: {
Breadcrumb,
TopNav,
Hamburger,
Screenfull,
SizeSelect,
Search,
RuoYiGit,
RuoYiDoc
},
computed: {
...mapGetters([
'sidebar',
'avatar',
'device'
]),
setting: {
get() {
return this.$store.state.settings.showSettings
},
set(val) {
this.$store.dispatch('settings/changeSetting', {
key: 'showSettings',
value: val
})
}
},
topNav: {
get() {
return this.$store.state.settings.topNav
}
}
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
},
async logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$store.dispatch('LogOut').then(() => {
location.href = process.env.VUE_APP_CONTEXT_PATH + "index";
})
2 years ago
}).catch(() => {
});
},
changeInv() {
this.selInvVisible = true;
2 years ago
localStorage.setItem("insuranceCode", JSON.stringify( this.userInfo.locInvCode));
2 years ago
},
getDeptList() {
this.deptList = [];
filterAllByUser()
.then((response) => {
this.deptList = response.data || [];
this.getInvList();
})
.catch(() => {
});
},
deptChange() {
this.getInvList();
},
getInvList() {
this.invList = [];
let query = {
deptCode: this.userInfo.locDeptCode
};
findByDeptUser(query)
.then((response) => {
this.invList = response.data || [];
if (this.invList != null && this.invList.length == 1) {
this.userInfo.locInvCode = this.invList[0].code;
}
})
.catch(() => {
});
},
submitInv() {
this.$refs["dataForm"].validate(valid => {
if (valid) {
if (this.$isBlank(this.userInfo.locInvCode)) {
this.$message.error("当前仓库不能为空!");
return;
}
if (this.userInfo.customerId == 110) {
if (this.$isBlank(this.userInfo.locSubInvCode)) {
this.$message.error("当前分库不能为空!");
return;
}
}
updateInv(this.userInfo).then((res) => {
if (res.code == 20000) {
this.$message.success("设置成功!");
this.selInvVisible = false;
store.dispatch('GetInfo').then(() => {
this.inv = store.getters.locInvName
});
} else {
this.$message.error(res.message);
}
}).catch(() => {
this.selInvVisible = false;
});
}
});
},
closeDialog() {
this.selInvVisible = false;
2 years ago
this.userInfo.locInvCode=JSON.parse(localStorage.getItem("insuranceCode"));
2 years ago
},
},
created() {
this.userInfo = {
id: store.getters.adminId,
locInvCode: store.getters.locInvCode,
locDeptCode: store.getters.locDeptCode,
};
this.getDeptList();
this.getInvList()
2 years ago
}
}
</script>
<style lang="scss" scoped>
.navbar {
height: 50px;
overflow: hidden;
position: relative;
background: #fff;
2 years ago
box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
2 years ago
.hamburger-container {
line-height: 46px;
height: 100%;
float: left;
cursor: pointer;
transition: background .3s;
2 years ago
-webkit-tap-highlight-color: transparent;
2 years ago
&:hover {
background: rgba(0, 0, 0, .025)
}
}
.breadcrumb-container {
float: left;
}
.topmenu-container {
position: absolute;
left: 50px;
}
.errLog-container {
display: inline-block;
vertical-align: top;
}
.right-menu {
float: right;
height: 100%;
line-height: 50px;
&:focus {
outline: none;
}
.right-menu-item {
display: inline-block;
padding: 0 8px;
height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom;
&.hover-effect {
cursor: pointer;
transition: background .3s;
&:hover {
background: rgba(0, 0, 0, .025)
}
}
}
2 years ago
.inv-hos-title {
display: inline-block;
height: 100%;
font-size: 18px;
color: #5a5e66;
vertical-align: text-bottom;
}
2 years ago
.avatar-container {
margin-right: 30px;
.avatar-wrapper {
margin-top: 5px;
position: relative;
.user-avatar {
cursor: pointer;
width: 40px;
height: 40px;
border-radius: 10px;
}
.el-icon-caret-bottom {
cursor: pointer;
position: absolute;
right: -20px;
top: 25px;
font-size: 12px;
}
}
}
}
}
</style>