header.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. <template>
  2. <!-- 风险管理 -->
  3. <div v-if="isOemByEnum(OemType.manager)">
  4. <img src="../../assets/images/logoHeader.png" />
  5. <span>{{getCompanyName()}}</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>{{getCompanyName()}}</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 v-if="isOemByEnum(OemType.wrspot)">
  30. <a-popover trigger="click"
  31. placement="bottom"
  32. overlayClassName="friendPopover">
  33. <template #content>
  34. <Friend />
  35. </template>
  36. <span class="friendIcon">
  37. <svg class="icon svg-icon"
  38. aria-hidden="true">
  39. <use xlink:href="#icon-pengyou1" />
  40. </svg>
  41. </span>
  42. </a-popover>
  43. </div>
  44. <div class="news-container">
  45. <a-badge @click="openNotice"
  46. :dot="getUnReadNoticeLength() > 0">
  47. <svg class="icon svg-icon"
  48. aria-hidden="true">
  49. <use xlink:href="#icon-xiaoxi" />
  50. </svg>
  51. </a-badge>
  52. </div>
  53. <div>
  54. <a-popover v-model:visible="visible"
  55. trigger="click"
  56. placement="bottomRight">
  57. <template #content>
  58. <div v-for="item in setMenu"
  59. class="popItem"
  60. @click="chooseSetMenu(item.path)"
  61. :key="item.path">{{ item.name }}</div>
  62. </template>
  63. <a-avatar :size="24">
  64. <template #icon>
  65. <SettingFilled />
  66. <!-- <svg class="icon svg-icon" aria-hidden="true">
  67. <use xlink:href="#icon-yonghu1" />
  68. </svg>-->
  69. </template>
  70. </a-avatar>
  71. </a-popover>
  72. <Setting />
  73. </div>
  74. </div>
  75. </template>
  76. <script lang="ts">
  77. import { defineComponent, ref, provide } from 'vue';
  78. import { openModal } from '@/common/setup/modal/index';
  79. import { UserOutlined, SettingFilled } from '@ant-design/icons-vue';
  80. import Setting from '@/views/setting/index.vue';
  81. import { getUserName, getCompanyName } from '@/services/bus/user';
  82. import { logout } from '@/services/bus/login';
  83. import APP from '@/services';
  84. import Router from '@/router';
  85. import { handleNotice } from '@/views/setting/notice/setup';
  86. import { isOemByEnum, OemType } from '@/common/config/projectName';
  87. import { changeTheme, ThemeEnum } from '@/common/config/theme';
  88. import { initData } from '@/common/methods';
  89. import Friend from '@/views/setting/friends/index.vue';
  90. // 设置
  91. const setFn = () => {
  92. const visible = ref<boolean>(false);
  93. const chooseSetupItem = ref<string>('');
  94. provide('ControlModal', chooseSetupItem);
  95. const setMenu = ref([{ name: '退出', path: 'logout' }]);
  96. // const setMenu = [
  97. // // { name: '修改密码', path: 'password' },
  98. // // { name: '收货地址', path: 'addresss' },
  99. // // // {name: '发票', path: 'setup-password'},
  100. // // { name: '手机号码绑定/解绑', path: 'phone' },
  101. // // { name: '关于我们', path: 'aboutUs' },
  102. // { name: '白主题', path: ThemeEnum.light },
  103. // { name: '黑主题', path: ThemeEnum.dark },
  104. // { name: '退出', path: 'logout' },
  105. // ];
  106. initData(() => {
  107. if (isOemByEnum(OemType.wrspot)) {
  108. const theme = [
  109. { name: '白主题', path: ThemeEnum.light },
  110. { name: '黑主题', path: ThemeEnum.dark },
  111. ];
  112. setMenu.value = [...theme, ...setMenu.value];
  113. }
  114. });
  115. const { openAction } = openModal('logout');
  116. function chooseSetMenu(path: string) {
  117. if (path === 'logout') {
  118. logout();
  119. APP.closeServer();
  120. Router.replace('/login');
  121. } else {
  122. changeTheme(path as ThemeEnum);
  123. // openAction();
  124. }
  125. visible.value = false;
  126. }
  127. return { visible, setMenu, chooseSetMenu };
  128. };
  129. // 搜索
  130. const onSearch = () => {
  131. function search(value: string) {}
  132. return { search };
  133. };
  134. export default defineComponent({
  135. components: {
  136. UserOutlined,
  137. Setting,
  138. Friend,
  139. SettingFilled,
  140. },
  141. props: {
  142. collapsed: {
  143. default: true,
  144. type: Boolean,
  145. },
  146. },
  147. setup() {
  148. const { openAction: openNotice } = openModal('notice');
  149. const { getUnReadNoticeLength } = handleNotice();
  150. return {
  151. openNotice,
  152. getUserName,
  153. getUnReadNoticeLength,
  154. ...setFn(),
  155. ...onSearch(),
  156. isOemByEnum,
  157. OemType,
  158. getCompanyName,
  159. };
  160. },
  161. });
  162. </script>
  163. <style lang="less">
  164. .friendIcon {
  165. .icon {
  166. font-size: 20px;
  167. line-height: 32px;
  168. margin: 6px 5px;
  169. }
  170. }
  171. </style>