header.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <template>
  2. <!-- 风险管理 -->
  3. <div v-if="isOemByEnum(OemType.manager)">
  4. <img src="../../assets/images/logoHeader.png" />
  5. <span>深圳市多元世纪信息技术股份有限公司</span>
  6. </div>
  7. <!-- 云融 -->
  8. <div v-else-if="isOemByEnum(OemType.wrspot)">
  9. <img src="../../assets/images/headLogo.jpg" />
  10. <span>云融</span>
  11. </div>
  12. <div v-else>
  13. <img src="../../assets/images/logoHeader.png" />
  14. <span>深圳市多元世纪信息技术股份有限公司</span>
  15. </div>
  16. <div class="m-layout-header-right">
  17. <div @click="openDrawer">
  18. <span>{{ getUserName() }},您好!</span>
  19. </div>
  20. <div class="relative">
  21. <!-- <a-input-search ref="userNameInput"
  22. class="searchInput"
  23. placeholder="请输入代码/名称"
  24. @pressEnter="search">
  25. readonly
  26. </a-input-search>-->
  27. <!-- <a-icon type="search" /> -->
  28. </div>
  29. <div class="news-container">
  30. <a-badge @click="openNotice"
  31. :dot="getUnReadNoticeLength() > 0">
  32. <svg class="icon svg-icon"
  33. aria-hidden="true">
  34. <use xlink:href="#icon-xiaoxi" />
  35. </svg>
  36. </a-badge>
  37. </div>
  38. <div>
  39. <a-popover v-model:visible="visible"
  40. trigger="click"
  41. placement="bottomRight">
  42. <template #content>
  43. <div v-for="item in setMenu"
  44. class="popItem"
  45. @click="chooseSetMenu(item.path)"
  46. :key="item.path">{{ item.name }}</div>
  47. </template>
  48. <a-avatar :size="24">
  49. <template #icon>
  50. <!-- <SettingFilled /> -->
  51. <svg class="icon svg-icon"
  52. aria-hidden="true">
  53. <use xlink:href="#icon-yonghu4" />
  54. </svg>
  55. </template>
  56. </a-avatar>
  57. </a-popover>
  58. <Setting />
  59. </div>
  60. </div>
  61. </template>
  62. <script lang="ts">
  63. import { defineComponent, ref, provide } from 'vue';
  64. import { openModal } from '@/common/setup/modal/index';
  65. import { UserOutlined } from '@ant-design/icons-vue';
  66. import Setting from '@/views/setting/index.vue';
  67. import { getUserName } from '@/services/bus/user';
  68. import { logout } from '@/services/bus/login';
  69. import APP from '@/services';
  70. import Router from '@/router';
  71. import { handleNotice } from '@/views/setting/notice/setup';
  72. import { isOemByEnum, OemType } from '@/common/config/projectName';
  73. import { changeTheme, ThemeEnum } from '@/common/config/theme';
  74. import { initData } from '@/common/methods';
  75. // 设置
  76. const setFn = () => {
  77. const visible = ref<boolean>(false);
  78. const chooseSetupItem = ref<string>('');
  79. provide('ControlModal', chooseSetupItem);
  80. const setMenu = ref([{ name: '退出', path: 'logout' }]);
  81. // const setMenu = [
  82. // // { name: '修改密码', path: 'password' },
  83. // // { name: '收货地址', path: 'addresss' },
  84. // // // {name: '发票', path: 'setup-password'},
  85. // // { name: '手机号码绑定/解绑', path: 'phone' },
  86. // // { name: '关于我们', path: 'aboutUs' },
  87. // { name: '白主题', path: ThemeEnum.light },
  88. // { name: '黑主题', path: ThemeEnum.dark },
  89. // { name: '退出', path: 'logout' },
  90. // ];
  91. initData(() => {
  92. if (isOemByEnum(OemType.wrspot)) {
  93. const theme = [
  94. { name: '白主题', path: ThemeEnum.light },
  95. { name: '黑主题', path: ThemeEnum.dark },
  96. ];
  97. setMenu.value = [...theme, ...setMenu.value];
  98. }
  99. });
  100. const { openAction } = openModal('logout');
  101. function chooseSetMenu(path: string) {
  102. if (path === 'logout') {
  103. logout();
  104. APP.closeServer();
  105. Router.replace('/login');
  106. } else {
  107. changeTheme(path as ThemeEnum);
  108. // openAction();
  109. }
  110. visible.value = false;
  111. }
  112. return { visible, setMenu, chooseSetMenu };
  113. };
  114. // 搜索
  115. const onSearch = () => {
  116. function search(value: string) {}
  117. return { search };
  118. };
  119. export default defineComponent({
  120. components: {
  121. UserOutlined,
  122. Setting,
  123. },
  124. props: {
  125. collapsed: {
  126. default: true,
  127. type: Boolean,
  128. },
  129. },
  130. setup() {
  131. const { openAction: openNotice } = openModal('notice');
  132. const { getUnReadNoticeLength } = handleNotice();
  133. return {
  134. openNotice,
  135. getUserName,
  136. getUnReadNoticeLength,
  137. ...setFn(),
  138. ...onSearch(),
  139. isOemByEnum,
  140. OemType,
  141. };
  142. },
  143. });
  144. </script>