p-header.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <div class="p-header">
  3. <div class="title" @click="menuClose">
  4. <i v-if="this.$store.state.collapse" class="el-icon-s-fold"></i
  5. ><i v-else class="el-icon-s-unfold"></i>
  6. </div>
  7. <!-- <div
  8. class="title"
  9. v-for="(item, index) in routeChecked"
  10. :key="index"
  11. :style="item.rountPath == $store.state.defaultActive ? 'color:white' : ''"
  12. @click="change(index, item)"
  13. >
  14. <span :class="item.icon"></span>{{ item.name }}
  15. </div> -->
  16. <div class="bars">
  17. <div class="bars-item user-info">Hello,{{ username }}</div>
  18. <div class="bars-item" @click="handleGoToCalendar">
  19. <i class="el-icon-date"></i>
  20. 日历
  21. </div>
  22. <div class="bars-item" @click="handleHelp">
  23. <i class="el-icon-time"></i>
  24. {{ $formatDate(date, "YYYY-MM-DD") }}
  25. </div>
  26. <div class="bars-item" @click="handleCall">
  27. <i class="el-icon-chat-dot-round"></i>
  28. 知识库
  29. </div>
  30. <div class="bars-item" @click="handleLogout">
  31. <i class="el-icon-guide"></i>
  32. 退出
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. props: {
  40. username: {
  41. required: false,
  42. type: String,
  43. default: "admin",
  44. },
  45. },
  46. data() {
  47. return {
  48. currentIndex: "5",
  49. date: new Date(),
  50. routeChecked: [
  51. {
  52. name: "数据视图",
  53. icon: "iconfont icon-icon_huabanfuben",
  54. rountPath: "/funcInit",
  55. },
  56. {
  57. name: "网格视图",
  58. icon: "iconfont icon-wanggeshezhi",
  59. rountPath: "/loginInit",
  60. },
  61. {
  62. name: "工作台",
  63. icon: "iconfont icon-gongzuotai",
  64. rountPath: "/excel",
  65. },
  66. ],
  67. };
  68. },
  69. created() {
  70. this.runInitDate();
  71. // if (!this.collapse) {
  72. // this.$store.commit("setCollapse");
  73. // }
  74. //this.menuClose();
  75. },
  76. methods: {
  77. handleGoToCalendar(){
  78. this.$http({
  79. url: "/sysmgr/csysdept/queryGroupListByLoginNo",
  80. method: "post",
  81. headers: {
  82. "Content-Type": "application/json",
  83. },
  84. data: {},
  85. }).then((res) => {
  86. console.log("header"+res.data[0].parentorgid)
  87. if(res.data[0].parentorgid==='00440063000000000000'){
  88. this.$router.push('calendarnet');
  89. }else{
  90. this.$router.push('calendar');
  91. }
  92. });
  93. },
  94. handleCall() {
  95. this.$switchTab(this, { rountPath: "/knowledgetop", name: "知识库" },'knowledgetop');
  96. },
  97. change(index, item) {
  98. this.currentIndex = index;
  99. let set = new Set(this.$store.state.tabList);
  100. set.add(item);
  101. this.$store.commit("setDefaultActive", item.rountPath);
  102. this.$store.commit("setTabList", Array.from(set));
  103. },
  104. initDate() {
  105. this.date = new Date();
  106. },
  107. runInitDate() {
  108. let _this = this;
  109. let rn = setTimeout(() => {
  110. _this.initDate();
  111. _this.runInitDate();
  112. clearTimeout(rn);
  113. }, 500);
  114. },
  115. handleLogout() {
  116. this.$confirm("正在退出登录,是否继续", "提示", {
  117. type: "warning",
  118. })
  119. .then((res) => {
  120. if (res === "confirm") {
  121. this.$store.commit("setUserInfo", undefined);
  122. this.$store.commit("setToken", undefined);
  123. this.$store.commit("setMenus", undefined);
  124. this.$store.commit("setTabList", []);
  125. this.$cookie.delete("userInfo");
  126. this.$cookie.delete("menus");
  127. this.$cookie.delete("token");
  128. window.sessionStorage.agileauthtoken = undefined;
  129. window.sessionStorage.menus = undefined;
  130. window.sessionStorage.userInfo = undefined;
  131. window.sessionStorage.childrenMenus = undefined;
  132. window.opener=null;
  133. window.open(' ','_self');
  134. window.close();
  135. // window.parent.close();
  136. //返回到登录页面
  137. // this.$router.push("/login");
  138. // this.$http({
  139. // url: "http://cas.hl.cmcc/cas/logout",
  140. // method: "get",
  141. // headers: {
  142. // "Access-Control-Allow-Origin": "http://cas.hl.cmcc/cas/logout",
  143. // },
  144. // }).then((res) => {
  145. // //TODO先执行退出登录
  146. // this.$store.commit("setUserInfo", undefined);
  147. // this.$store.commit("setToken", undefined);
  148. // this.$store.commit("setMenus", undefined);
  149. // this.$store.commit("setTabList", []);
  150. // this.$cookie.delete("userInfo");
  151. // this.$cookie.delete("menus");
  152. // this.$cookie.delete("token");
  153. // window.sessionStorage.agileauthtoken = undefined;
  154. // window.sessionStorage.menus = undefined;
  155. // window.sessionStorage.userInfo = undefined;
  156. // window.sessionStorage.childrenMenus = undefined;
  157. //
  158. // window.location.href = " http://cas.hl.cmcc/cas/login?service=http%3A%2F%2F10.230.26.15%3A8000%2Fspfm%2Fsysmgr%2FssLogin%3FsysFlag%3D0";
  159. // });
  160. }
  161. })
  162. .catch((err) => {
  163. throw err;
  164. });
  165. },
  166. handleSetting() {},
  167. handleHelp() {},
  168. menuClose() {
  169. this.$store.commit("setCollapse");
  170. this.$emit("collapse");
  171. },
  172. },
  173. computed: {
  174. collapse() {
  175. return this.$store.state.collapse;
  176. },
  177. },
  178. };
  179. </script>
  180. <style scoped="scoped" lang="scss">
  181. .p-header {
  182. color: #fff;
  183. height: 100%;
  184. background-color: #0b82ff;
  185. .active {
  186. color: #0b82ff;
  187. }
  188. .iconfont {
  189. vertical-align: bottom;
  190. font-size: 21px;
  191. }
  192. .title {
  193. padding-top: 16px;
  194. padding-left: 15px;
  195. color: rgba(255, 255, 255, 0.6);
  196. font-size: 14px;
  197. float: left;
  198. cursor: pointer;
  199. span {
  200. font-size: 15px;
  201. }
  202. i {
  203. font-size: 20px;
  204. }
  205. }
  206. .bars {
  207. float: right;
  208. padding-top: 16px;
  209. padding-right: 31px;
  210. .bars-item {
  211. display: inline-block;
  212. margin-left: 30px;
  213. cursor: pointer;
  214. font-family: SourceHanSansCN-Normal;
  215. font-size: 14px;
  216. color: #ffffff;
  217. letter-spacing: 0;
  218. }
  219. .user-info {
  220. font-size: 18px;
  221. }
  222. }
  223. }
  224. </style>