p-header.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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="headerspan">
  17. <!-- <span>市场经济管理平台</span> -->
  18. <img
  19. :src="
  20. parentorgid === '00440063000000000000'
  21. ? require('../assets/newlogo2.png')
  22. : require('../assets/newlogo.png')
  23. "
  24. style="text-align: center; vertical-align: middle"
  25. alt=""
  26. />
  27. </div>
  28. <div class="bars">
  29. <div class="bars-item" @click="handleGoToCalendar">
  30. <i class="el-icon-date"></i>
  31. 日历
  32. </div>
  33. <div class="bars-item user-info">你好{{ username }}</div>
  34. <div class="bars-item" @click="handleHelp">
  35. <i class="el-icon-time"></i>
  36. {{ $formatDate(date, "YYYY-MM-DD") }}
  37. </div>
  38. <div class="bars-item" @click="handleGoToKnowledge">
  39. <i class="el-icon-chat-dot-round"></i>
  40. 知识库
  41. </div>
  42. <div class="bars-item" @click="handleLogout">
  43. <!-- <i class="el-icon-guide"></i> -->
  44. <svg
  45. t="1654163202752"
  46. class="icon"
  47. viewBox="0 0 1024 1024"
  48. version="1.1"
  49. xmlns="http://www.w3.org/2000/svg"
  50. p-id="9307"
  51. id="mx_n_1654163202756"
  52. width="18"
  53. height="18"
  54. >
  55. <path
  56. d="M768 819.2h-256V204.8L256 102.4h512v102.4h102.4V0H0v819.2l512 204.8v-102.4h358.4v-204.8h-102.4v102.4z"
  57. p-id="9308"
  58. fill="#ffffff"
  59. ></path>
  60. <path
  61. d="M1024 460.8l-256-153.6v102.4h-204.8v102.4h204.8v102.4l256-153.6z"
  62. p-id="9309"
  63. fill="#ffffff"
  64. ></path>
  65. </svg>
  66. <span>退出</span>
  67. </div>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. export default {
  73. props: {
  74. username: {
  75. required: false,
  76. type: String,
  77. default: "admin",
  78. },
  79. },
  80. data() {
  81. return {
  82. parentorgid: "",
  83. currentIndex: "5",
  84. date: new Date(),
  85. routeChecked: [
  86. {
  87. name: "数据视图",
  88. icon: "iconfont icon-icon_huabanfuben",
  89. rountPath: "/funcInit",
  90. },
  91. {
  92. name: "网格视图",
  93. icon: "iconfont icon-wanggeshezhi",
  94. rountPath: "/loginInit",
  95. },
  96. {
  97. name: "工作台",
  98. icon: "iconfont icon-gongzuotai",
  99. rountPath: "/excel",
  100. },
  101. ],
  102. };
  103. },
  104. created() {
  105. this.runInitDate();
  106. // if (!this.collapse) {
  107. // this.$store.commit("setCollapse");
  108. // }
  109. //this.menuClose();
  110. this.getDept();
  111. },
  112. methods: {
  113. getDept() {
  114. this.$http({
  115. url: "/sysmgr/csysdept/queryGroupListByLoginNo",
  116. method: "post",
  117. headers: {
  118. "Content-Type": "application/json",
  119. },
  120. data: {},
  121. }).then((res) => {
  122. console.log(res.data[0].parentorgid);
  123. this.parentorgid = res.data[0].parentorgid;
  124. if (res.data[0].parentorgid === "00440063000000000000") {
  125. document.title = "IT工作台";
  126. }
  127. });
  128. },
  129. handleGoToCalendar() {
  130. this.$http({
  131. url: "/sysmgr/csysdept/queryGroupListByLoginNo",
  132. method: "post",
  133. headers: {
  134. "Content-Type": "application/json",
  135. },
  136. data: {},
  137. }).then((res) => {
  138. console.log("header" + res.data[0].parentorgid);
  139. if (res.data[0].parentorgid === "00440063000000000000") {
  140. this.$router.push("calendarnet");
  141. } else {
  142. this.$router.push("calendar");
  143. }
  144. });
  145. },
  146. handleGoToKnowledge() {
  147. this.$http({
  148. url: "/sysmgr/csysdept/queryGroupListByLoginNo",
  149. method: "post",
  150. headers: {
  151. "Content-Type": "application/json",
  152. },
  153. data: {},
  154. }).then((res) => {
  155. console.log("header" + res.data[0].parentorgid);
  156. if (res.data[0].parentorgid === "00440063000000000000") {
  157. this.$router.push("itknowledgetop");
  158. } else {
  159. this.$router.push("knowledgetop");
  160. }
  161. });
  162. },
  163. handleCall() {
  164. this.$switchTab(
  165. this,
  166. { rountPath: "/knowledgetop", name: "知识库" },
  167. "knowledgetop"
  168. );
  169. },
  170. change(index, item) {
  171. this.currentIndex = index;
  172. let set = new Set(this.$store.state.tabList);
  173. set.add(item);
  174. this.$store.commit("setDefaultActive", item.rountPath);
  175. this.$store.commit("setTabList", Array.from(set));
  176. },
  177. initDate() {
  178. this.date = new Date();
  179. },
  180. runInitDate() {
  181. let _this = this;
  182. let rn = setTimeout(() => {
  183. _this.initDate();
  184. _this.runInitDate();
  185. clearTimeout(rn);
  186. }, 500);
  187. },
  188. handleLogout() {
  189. console.log(123);
  190. this.$confirm("正在退出登录,是否继续", "提示", {
  191. type: "warning",
  192. })
  193. .then((res) => {
  194. if (res === "confirm") {
  195. this.$store.commit("setUserInfo", undefined);
  196. this.$store.commit("setToken", undefined);
  197. this.$store.commit("setMenus", undefined);
  198. this.$store.commit("setTabList", []);
  199. this.$cookie.delete("userInfo");
  200. this.$cookie.delete("menus");
  201. this.$cookie.delete("token");
  202. window.sessionStorage.agileauthtoken = undefined;
  203. window.sessionStorage.menus = undefined;
  204. window.sessionStorage.userInfo = undefined;
  205. window.sessionStorage.childrenMenus = undefined;
  206. window.sessionStorage.removeItem("antiSpoofingSearchParams");
  207. window.opener = null;
  208. window.open(" ", "_self");
  209. window.close();
  210. // window.parent.close();
  211. //返回到登录页面
  212. // this.$router.push("/login");
  213. // this.$http({
  214. // url: "http://cas.hl.cmcc/cas/logout",
  215. // method: "get",
  216. // headers: {
  217. // "Access-Control-Allow-Origin": "http://cas.hl.cmcc/cas/logout",
  218. // },
  219. // }).then((res) => {
  220. // //TODO先执行退出登录
  221. // this.$store.commit("setUserInfo", undefined);
  222. // this.$store.commit("setToken", undefined);
  223. // this.$store.commit("setMenus", undefined);
  224. // this.$store.commit("setTabList", []);
  225. // this.$cookie.delete("userInfo");
  226. // this.$cookie.delete("menus");
  227. // this.$cookie.delete("token");
  228. // window.sessionStorage.agileauthtoken = undefined;
  229. // window.sessionStorage.menus = undefined;
  230. // window.sessionStorage.userInfo = undefined;
  231. // window.sessionStorage.childrenMenus = undefined;
  232. //
  233. // window.location.href = " http://cas.hl.cmcc/cas/login?service=http%3A%2F%2F10.230.26.15%3A8000%2Fspfm%2Fsysmgr%2FssLogin%3FsysFlag%3D0";
  234. // });
  235. }
  236. })
  237. .catch((err) => {
  238. throw err;
  239. });
  240. },
  241. handleSetting() {},
  242. handleHelp() {},
  243. menuClose() {
  244. this.$store.commit("setCollapse");
  245. this.$emit("collapse");
  246. },
  247. },
  248. computed: {
  249. collapse() {
  250. return this.$store.state.collapse;
  251. },
  252. },
  253. };
  254. </script>
  255. <style scoped="scoped" lang="scss">
  256. .p-header {
  257. color: #fff;
  258. height: 100%;
  259. background-color: #0056a9;
  260. .headerspan {
  261. float: left;
  262. width: 300px;
  263. line-height: 60px;
  264. margin-left: 20px;
  265. // background: url(../assets/logo.png) no-repeat 20px center;
  266. // text-indent: 25px;
  267. // font-size: 18px;
  268. // font-weight: bolder;
  269. color: #ffffff;
  270. // span {
  271. // margin-left: 40px;
  272. // }
  273. img {
  274. width: 207px;
  275. height: 35px;
  276. }
  277. }
  278. .active {
  279. color: #0b82ff;
  280. }
  281. .iconfont {
  282. vertical-align: bottom;
  283. font-size: 21px;
  284. }
  285. .title {
  286. padding-top: 16px;
  287. padding-left: 15px;
  288. color: rgba(255, 255, 255, 0.6);
  289. font-size: 14px;
  290. float: left;
  291. cursor: pointer;
  292. span {
  293. font-size: 15px;
  294. }
  295. i {
  296. font-size: 20px;
  297. }
  298. }
  299. .bars {
  300. float: right;
  301. padding-top: 16px;
  302. padding-right: 31px;
  303. .bars-item {
  304. display: inline-block;
  305. margin-left: 30px;
  306. cursor: pointer;
  307. font-family: SourceHanSansCN-Normal;
  308. font-size: 18px;
  309. color: #ffffff;
  310. position: relative;
  311. letter-spacing: 0;
  312. svg {
  313. position: absolute;
  314. top: 55%;
  315. bottom: 50%;
  316. transform: translate(-50%, -50%);
  317. }
  318. span {
  319. margin-left: 15px;
  320. }
  321. }
  322. .user-info {
  323. font-size: 18px;
  324. }
  325. }
  326. }
  327. </style>