You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

308 lines
9.8 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. <template>
  2. <el-menu class="navbar" mode="horizontal">
  3. <hamburger class="hamburger-container" :toggleClick="toggleSideBar" :isActive="sidebar.opened"></hamburger>
  4. <breadcrumb class="breadcrumb-container hidden-sm-and-down"></breadcrumb>
  5. <div class="right-menu">
  6. <div class="hidden-sm-and-down" style="float:left;display:flex;align-items: center;height:100%;">
  7. <el-tooltip v-if="workShop.locationName" class="item" effect="dark" :content="workShop.branchId+' '+workShop.shopId+' '+workShop.locationId" placement="top-start">
  8. <el-tag>{{workShop.branchName}} {{workShop.locationName}}</el-tag>
  9. </el-tooltip>
  10. <el-tooltip v-else class="item" effect="dark" :content="workShop.branchId+' '+workShop.deptid" placement="top-start">
  11. <el-tag>{{workShop.branchName}} {{workShop.deptName}}</el-tag>
  12. </el-tooltip>
  13. <el-button @click="showSelectShopMethod" type="primary" v-if="workShop.isSuperAdmin||workShop.isPlatFormAdmin">切换商户</el-button>
  14. </div>
  15. <error-log class="errLog-container right-menu-item hidden-sm-and-down"></error-log>
  16. <screenfull class="screenfull right-menu-item"></screenfull>
  17. <lang-select class="international right-menu-item hidden-sm-and-down"></lang-select>
  18. <el-tooltip class="hidden-sm-and-down" effect="dark" :content="$t('navbar.theme')" placement="bottom">
  19. <theme-picker class="theme-switch right-menu-item"></theme-picker>
  20. </el-tooltip>
  21. <el-dropdown class="avatar-container right-menu-item" trigger="click">
  22. <div class="avatar-wrapper">
  23. <img v-if="userInfo && userInfo.headimgurl && userInfo.headimgurl!=null && userInfo.headimgurl!=='' " class="user-avatar" :src="userInfo.headimgurl">
  24. <img v-else class="user-avatar" src="../../../assets/image/user_img.gif">
  25. <i class="el-icon-caret-bottom"></i>
  26. </div>
  27. <el-dropdown-menu slot="dropdown">
  28. <router-link to="/">
  29. <el-dropdown-item>
  30. {{$t('navbar.dashboard')}}
  31. </el-dropdown-item>
  32. </router-link>
  33. <el-dropdown-item divided>
  34. 用户名{{userInfo.username}}
  35. </el-dropdown-item>
  36. <el-dropdown-item divided>
  37. 公司{{userInfo.branchName}}
  38. </el-dropdown-item>
  39. <el-dropdown-item divided>
  40. <div style=" overflow-x:auto; height:150px;">
  41. 部门及岗位 <el-form>
  42. <el-form-item v-for="(item ,index) in deptPostsTree" :label="item.deptName" :key="index">
  43. <div v-if="item.children!=null && item.children.length>0">
  44. <el-row v-for="(post,idx) in item.children" :key="idx">
  45. <el-tag>{{post.postName}}</el-tag>
  46. </el-row>
  47. </div>
  48. </el-form-item>
  49. </el-form>
  50. </div>
  51. </el-dropdown-item>
  52. <el-dropdown-item divided>
  53. <div style=" overflow-x:auto; height:150px;">
  54. 商户及门店 <el-form>
  55. <el-form-item label-width="300" v-for="item in shopLocationsTree" :label="item.shopName" :key="item.shopId">
  56. <el-row v-for="location in item.locations" :key="location.locationId">
  57. <el-col :span="24"><el-tag>{{location.locationName}}</el-tag><i v-if="location.locationId==userInfo.locationId" class="el-icon-check"></i>
  58. </el-col>
  59. </el-row>
  60. <el-row v-if="item.locations==null || item.locations.length<=0">
  61. <el-col :span="24"><el-tag> 无门店或者我不是该商户的门店管理员</el-tag> </el-col>
  62. </el-row>
  63. </el-form-item>
  64. </el-form>
  65. </div>
  66. </el-dropdown-item>
  67. <el-dropdown-item divided>
  68. <div style=" overflow-x:auto; height:150px;">
  69. 我拥有的角色 <el-form>
  70. <el-form-item label="">
  71. <el-row v-for="role in roles" :key="role.roleid">
  72. <el-tag v-if="role.roleid.indexOf('SCOPE')<0">{{role.rolename}}</el-tag>
  73. </el-row>
  74. </el-form-item>
  75. </el-form>
  76. </div>
  77. </el-dropdown-item>
  78. <el-dropdown-item divided>
  79. <span @click="logout" style="display:block;">{{$t('navbar.logOut')}}</span>
  80. </el-dropdown-item>
  81. </el-dropdown-menu>
  82. </el-dropdown>
  83. </div>
  84. </el-menu>
  85. </template>
  86. <script>
  87. import { mapGetters } from 'vuex'
  88. import Breadcrumb from '@/components/Breadcrumb'
  89. import Hamburger from '@/components/Hamburger'
  90. import ErrorLog from '@/components/ErrorLog'
  91. import Screenfull from '@/components/Screenfull'
  92. import LangSelect from '@/components/LangSelect'
  93. import ThemePicker from '@/components/ThemePicker';
  94. //import selectShopLocationBySysDept from '@/views/mdp/app/selectShopLocationBySysDept/selectShopLocationBySysDept';
  95. export default {
  96. components: {
  97. Breadcrumb,
  98. Hamburger,
  99. ErrorLog,
  100. Screenfull,
  101. LangSelect,
  102. ThemePicker
  103. },
  104. data:function(){
  105. return {
  106. selectShopVisible: false,
  107. postChecked:''
  108. }
  109. },
  110. computed: {
  111. screenWidth: function() {
  112. return screen.width;
  113. },
  114. ...mapGetters([
  115. 'sidebar',
  116. 'userInfo',
  117. 'roles',
  118. 'myPosts',
  119. 'myLocations',
  120. 'myShops',
  121. 'workShop'
  122. ]),
  123. 'deptPostsTree':function(){
  124. var deptPostsTree=[]
  125. if(this.myPosts==null ||this.myPosts.length<=0){
  126. return deptPostsTree
  127. }
  128. var checkedPostId=this.myPosts.length>0?this.myPosts[0].postId:''
  129. this.postChecked=checkedPostId
  130. this.myPosts.forEach(post=>{
  131. if(post.postId==checkedPostId){
  132. post.checked='1'
  133. }
  134. var deptPostArray=deptPostsTree.filter(dp=>dp.deptid==post.deptid)
  135. if(deptPostArray!=null && deptPostArray.length>0){
  136. if(deptPostArray[0].children && deptPostArray[0].children.length>0){
  137. if(!deptPostArray[0].children.some(i=>i.postId==post.postId)){
  138. deptPostArray[0].children.push(post)
  139. }
  140. }else{
  141. deptPostArray[0].children=[]
  142. deptPostArray[0].children.push(post)
  143. }
  144. }else{
  145. let deptPostsNode={deptid:post.deptid,deptName:post.deptName}
  146. deptPostsNode.children=[post]
  147. deptPostsTree.push(deptPostsNode)
  148. }
  149. })
  150. return deptPostsTree
  151. },
  152. 'shopLocationsTree':function(){
  153. let myShops=this.myShops;
  154. if(myShops==null||myShops.length<=0){
  155. return []
  156. }
  157. let myLocations=this.myLocations;
  158. myShops.forEach(shop=>{
  159. shop.locations=[];
  160. if(shop.shopId==this.userInfo.shopId){
  161. shop.checked=true
  162. }
  163. if(myLocations!=null && myLocations.length>0){
  164. myLocations.forEach(l=>{
  165. if(l.shopId==shop.shopId){
  166. if(l.locationId==this.userInfo.locationId){
  167. l.checked=true
  168. }
  169. shop.locations.push(l)
  170. }
  171. })
  172. }
  173. })
  174. return myShops
  175. }
  176. },
  177. methods: {
  178. toggleSideBar(toOpen) {
  179. this.$store.dispatch('toggleSideBar', toOpen)
  180. },
  181. logout() {
  182. this.$store.dispatch('LogOut').then(() => {
  183. location.reload()// In order to re-instantiate the vue-router object to avoid bugs
  184. })
  185. },
  186. showSelectShopMethod() {
  187. this.selectShopVisible = true;
  188. },
  189. sureMethod(row) {
  190. this.selectShopVisible = false;
  191. this.workShop.shopId=row.shopId;
  192. this.workShop.branchId=row.branchId;
  193. this.workShop.branchName=row.sysBranchName;
  194. this.workShop.locationId=row.id;
  195. this.workShop.deptid=row.deptid;
  196. this.workShop.locationName=row.businessName;
  197. this.$store.commit('SET_WORK_SHOP',this.workShop);
  198. },
  199. jumpToOtherSystem(name) {
  200. let href = window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION;
  201. if(name=='im'){
  202. href=window.location.protocol + "//" + window.location.host + "/" + name + "/" + process.env.VERSION+"/#/mdp/im/messages/messageChat";
  203. }
  204. console.log(href);
  205. window.open(href, '_blank');
  206. NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
  207. }
  208. },
  209. mounted() {
  210. if (screen.width <= 500) {
  211. this.toggleSideBar(false);
  212. } else {
  213. this.toggleSideBar(true);
  214. }
  215. }
  216. }
  217. </script>
  218. <style rel="stylesheet/scss" lang="scss" scoped>
  219. @import './iconfont.css';
  220. .navbar {
  221. height: 50px;
  222. line-height: 50px;
  223. border-radius: 0px !important;
  224. .hamburger-container {
  225. line-height: 58px;
  226. height: 50px;
  227. float: left;
  228. padding: 0 10px;
  229. }
  230. .breadcrumb-container{
  231. float: left;
  232. }
  233. .errLog-container {
  234. display: inline-block;
  235. vertical-align: top;
  236. }
  237. .right-menu {
  238. float: right;
  239. height: 100%;
  240. &:focus{
  241. outline: none;
  242. }
  243. .right-menu-item {
  244. display: inline-block;
  245. margin: 0 8px;
  246. }
  247. .screenfull {
  248. height: 20px;
  249. }
  250. .international{
  251. vertical-align: top;
  252. }
  253. .theme-switch {
  254. vertical-align: 15px;
  255. }
  256. .avatar-container {
  257. height: 50px;
  258. margin-right: 30px;
  259. .avatar-wrapper {
  260. cursor: pointer;
  261. margin-top: 5px;
  262. position: relative;
  263. .user-avatar {
  264. height: 40px;
  265. border-radius: 10px;
  266. }
  267. .el-icon-caret-bottom {
  268. position: absolute;
  269. right: -20px;
  270. top: 25px;
  271. font-size: 12px;
  272. }
  273. }
  274. }
  275. }
  276. }
  277. .iconfont {
  278. position: relative
  279. }
  280. .itemt:hover{
  281. cursor: pointer;
  282. color: rgb(52, 152, 219);
  283. }
  284. .big{
  285. display:flex;
  286. flex-direction:column;
  287. align-items:center;
  288. margin-right: 20px;
  289. }
  290. </style>