header.vue 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355
  1. <template>
  2. <header
  3. class="fixed w-full top-0 z-100 border-b shadow-sm"
  4. :style="{
  5. backgroundColor: 'var(--header-bg)',
  6. borderColor: 'var(--header-border)',
  7. }"
  8. >
  9. <div class="flex items-center justify-between px-5 md:px-20 h-15">
  10. <div class="flex items-center gap-2 cursor-pointer" @click="goHome">
  11. <img :src="logo" alt="logo" class="w-9 h-9 rounded-md" />
  12. <img :src="logo2" alt="logo" class="h-10 hidden lg:flex" />
  13. <span
  14. class="text-[#828182] text-[14px]"
  15. style="text-wrap-mode: nowrap"
  16. >{{ $t("nav.title") }}</span
  17. >
  18. </div>
  19. <nav class="hidden lg:flex flex-1 mx-4 ml-60 text-sm">
  20. <ul class="flex items-center gap-6 text-[#303133] text-md">
  21. <!-- 首页 -->
  22. <li>
  23. <a
  24. class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
  25. :class="
  26. router.currentRoute.value.path === '/'
  27. ? 'nav-item-active'
  28. : 'nav-item-default'
  29. "
  30. style="text-wrap-mode: nowrap"
  31. @click="router.push('/')"
  32. >
  33. {{ $t("nav.home") }}
  34. </a>
  35. </li>
  36. <!-- 流程门户 -->
  37. <li>
  38. <a
  39. style="text-wrap-mode: nowrap"
  40. class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
  41. :class="
  42. router.currentRoute.value.path.startsWith('/flow')
  43. ? 'nav-item-active'
  44. : 'nav-item-default'
  45. "
  46. @click="goFlow"
  47. >
  48. {{ $t("nav.flow") }}
  49. </a>
  50. </li>
  51. <!-- 驾驶舱门户 -->
  52. <li v-hasPermi="['portal:dashboard:view']">
  53. <a
  54. class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
  55. :class="
  56. router.currentRoute.value.path.startsWith('/drive')
  57. ? 'nav-item-active'
  58. : 'nav-item-default'
  59. "
  60. @click="goDrive"
  61. style="text-wrap-mode: nowrap"
  62. >
  63. {{ $t("nav.drive") }}
  64. </a>
  65. </li>
  66. <!-- 报表门户 (假设路径为 /report,请根据实际路由调整) -->
  67. <li>
  68. <a
  69. class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
  70. :class="
  71. router.currentRoute.value.path.startsWith('/report')
  72. ? 'nav-item-active'
  73. : 'nav-item-default'
  74. "
  75. style="text-wrap-mode: nowrap"
  76. >
  77. {{ $t("nav.report") }}
  78. </a>
  79. </li>
  80. </ul>
  81. </nav>
  82. <div
  83. style="border-left: 1px solid #a5bbdb"
  84. class="hidden lg:flex items-center gap-3 h-[40%] pl-4"
  85. >
  86. <el-dropdown trigger="click" @command="handleLanguageCommand">
  87. <button
  88. class="flex items-center gap-1 px-2 py-1 rounded-md hover:bg-gray-500/20 transition-colors cursor-pointer"
  89. >
  90. <Icon
  91. icon="mdi:translate"
  92. class="text-[18px]! mt-1"
  93. style="color: var(--text-secondary)"
  94. />
  95. </button>
  96. <template #dropdown>
  97. <el-dropdown-menu>
  98. <el-dropdown-item
  99. v-for="item in languageOptions"
  100. :key="item.value"
  101. :command="item.value"
  102. :disabled="currentLocale === item.value"
  103. >
  104. {{ item.label }}
  105. </el-dropdown-item>
  106. </el-dropdown-menu>
  107. </template>
  108. </el-dropdown>
  109. <button
  110. @click="themeStore.toggleTheme()"
  111. class="p-2 rounded-full mt-1 hover:bg-gray-500/60 transition-colors cursor-pointer"
  112. >
  113. <Icon v-if="themeStore.theme === 'light'" icon="ri:moon-fill" />
  114. <Icon v-else icon="ri:sun-fill" />
  115. </button>
  116. <!-- 消息中心 -->
  117. <el-dropdown trigger="click" placement="bottom-end">
  118. <div class="flex items-center gap-2 cursor-pointer pr-6 pt-1">
  119. <el-badge
  120. :value="
  121. unreadMessageCount + oaUnreadCount + Number(unreadSRMCount)
  122. "
  123. class="item"
  124. v-if="hasUnreadMessages || oaHasUnreadCount"
  125. >
  126. <Icon
  127. icon="mdi:bell"
  128. class="w-5 h-5 text-[#a7aab0] hover:text-[#409EFF]"
  129. />
  130. </el-badge>
  131. <Icon
  132. v-else
  133. icon="mdi:bell"
  134. class="w-5 h-5 text-[#507698] hover:text-[#409EFF]"
  135. />
  136. </div>
  137. <template #dropdown>
  138. <el-dropdown-menu class="notification-dropdown">
  139. <div class="notification-tabs pl-2">
  140. <el-tabs v-model="activeTab" class="demo-tabs">
  141. <el-tab-pane label="OA" name="tasks">
  142. <template #label>
  143. <span class="custom-tabs-label">
  144. <span>OA</span>
  145. <el-badge
  146. :value="oaUnreadCount"
  147. class="item ml-1"
  148. v-if="oaHasUnreadCount"
  149. ></el-badge>
  150. </span>
  151. </template>
  152. <div class="tab-content">
  153. <div>
  154. <span
  155. v-if="oaHasUnreadCount"
  156. class="cursor-pointer text-blue-500"
  157. @click="oaMarkAllAsRead"
  158. >{{ $t("common.markAll") }}</span
  159. >
  160. </div>
  161. <!-- OA消息 -->
  162. <div
  163. class="task-item"
  164. v-for="(task, index) in oaMessagesList"
  165. :key="index"
  166. >
  167. <div class="task-info">
  168. <p class="task-title">
  169. <span
  170. v-if="task.status === '0'"
  171. class="inline-block h-2 w-2 bg-[#f56c6c] rounded-full"
  172. ></span>
  173. <span class="pl-2 text-var(--tab-text)!">{{
  174. task.title
  175. }}</span>
  176. </p>
  177. <p class="message-desc">
  178. <span>{{ task.oaCreateTime }}</span>
  179. </p>
  180. </div>
  181. </div>
  182. <div v-if="!oaMessagesList.length" class="no-tasks">
  183. {{ $t("common.noMsg") }}
  184. </div>
  185. </div>
  186. </el-tab-pane>
  187. <el-tab-pane label="CRM" name="messages">
  188. <template #label>
  189. <span class="custom-tabs-label">
  190. <span>CRM</span>
  191. <el-badge
  192. :value="unreadMessageCount"
  193. class="item ml-1"
  194. v-if="hasUnreadMessages"
  195. ></el-badge>
  196. </span>
  197. </template>
  198. <div class="tab-content">
  199. <!-- 消息中心内容 -->
  200. <div>
  201. <span
  202. v-if="hasUnreadMessages"
  203. class="cursor-pointer text-blue-500"
  204. @click="markAllAsRead"
  205. >{{ $t("common.markAll") }}</span
  206. >
  207. </div>
  208. <div
  209. class="message-item"
  210. v-for="(item, index) in messages"
  211. :key="index"
  212. >
  213. <div class="message-icon"></div>
  214. <div class="message-text">
  215. <!-- 未读就显示小红点 -->
  216. <p class="message-title flex items-center gap-5">
  217. <span
  218. v-if="item.status === '0'"
  219. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  220. ></span
  221. >{{ item.contentMajor }}
  222. </p>
  223. <p class="message-desc">
  224. {{ timestampToDateTime(item.createTime) }}
  225. </p>
  226. </div>
  227. </div>
  228. <div v-if="!messages.length" class="no-messages">
  229. {{ $t("common.noMsg") }}
  230. </div>
  231. </div>
  232. </el-tab-pane>
  233. <!-- SRM消息 -->
  234. <el-tab-pane label="SRM" name="srm">
  235. <template #label>
  236. <span class="custom-tabs-label">
  237. <span>SRM</span>
  238. <el-badge
  239. :value="unreadSRMCount"
  240. class="item ml-1"
  241. v-if="hasUnreadSRMCount"
  242. ></el-badge>
  243. </span>
  244. </template>
  245. <div class="tab-content">
  246. <!-- 消息中心内容 -->
  247. <div>
  248. <span
  249. v-if="hasUnreadSRMCount"
  250. class="cursor-pointer text-blue-500"
  251. @click="markSRMAsRead"
  252. >{{ $t("common.markAll") }}</span
  253. >
  254. </div>
  255. <div
  256. class="message-item"
  257. v-for="(item, index) in srmMessageList"
  258. :key="index"
  259. >
  260. <div class="message-icon"></div>
  261. <div class="message-text">
  262. <!-- 未读就显示小红点 -->
  263. <p class="message-title flex items-center gap-5">
  264. <span
  265. v-if="item.status === '0'"
  266. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  267. ></span
  268. >{{ item.title }}
  269. </p>
  270. <p class="message-desc">
  271. {{ timestampToDateTime(item.createTime) }}
  272. </p>
  273. </div>
  274. </div>
  275. <div v-if="!srmMessageList.length" class="no-messages">
  276. {{ $t("common.noMsg") }}
  277. </div>
  278. </div>
  279. </el-tab-pane>
  280. <!-- EHR消息 -->
  281. <el-tab-pane label="EHR" name="ehr">
  282. <template #label>
  283. <span class="custom-tabs-label">
  284. <span>EHR</span>
  285. <el-badge
  286. :value="unreadEHRCount"
  287. class="item ml-1"
  288. v-if="hasUnreadEHRCount"
  289. ></el-badge>
  290. </span>
  291. </template>
  292. <div class="tab-content">
  293. <!-- 消息中心内容 -->
  294. <div>
  295. <span
  296. v-if="hasUnreadEHRCount"
  297. class="cursor-pointer text-blue-500"
  298. @click="markEHRAsRead"
  299. >{{ $t("common.markAll") }}</span
  300. >
  301. </div>
  302. <div
  303. class="message-item"
  304. v-for="(item, index) in ehrMessageList"
  305. :key="index"
  306. >
  307. <div class="message-icon"></div>
  308. <div class="message-text">
  309. <!-- 未读就显示小红点 -->
  310. <p class="message-title flex items-center gap-5">
  311. <span
  312. v-if="item.status === '0'"
  313. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  314. ></span
  315. >{{ item.title }}
  316. </p>
  317. <p class="message-desc">
  318. {{ timestampToDateTime(item.createTime) }}
  319. </p>
  320. </div>
  321. </div>
  322. <div v-if="!ehrMessageList.length" class="no-messages">
  323. {{ $t("common.noMsg") }}
  324. </div>
  325. </div>
  326. </el-tab-pane>
  327. </el-tabs>
  328. </div>
  329. </el-dropdown-menu>
  330. </template>
  331. </el-dropdown>
  332. <template v-if="isLoggedIn">
  333. <el-dropdown @command="onUserCommand" trigger="click">
  334. <span class="flex items-center gap-2 cursor-pointer pr-2">
  335. <div class="avatar-wrapper">
  336. <img
  337. :src="userAvatar || person"
  338. alt="avatar"
  339. class="w-8 h-8 rounded-full avatar-image"
  340. />
  341. </div>
  342. <span class="text-sm user-name" style="text-wrap-mode: nowrap">{{
  343. userName
  344. }}</span>
  345. </span>
  346. <template #dropdown>
  347. <el-dropdown-menu>
  348. <el-dropdown-item command="profile">
  349. <span>{{ $t("common.person") }}</span>
  350. </el-dropdown-item>
  351. <el-dropdown-item command="logout">
  352. <span>{{ $t("common.logout") }}</span>
  353. </el-dropdown-item>
  354. </el-dropdown-menu>
  355. </template>
  356. </el-dropdown>
  357. </template>
  358. <template v-else>
  359. <div
  360. style="text-wrap: nowrap"
  361. class="text-md flex items-center justify-center cursor-pointer h-full py-4"
  362. @click="login"
  363. >
  364. {{ $t("common.login") }}
  365. </div>
  366. </template>
  367. </div>
  368. <div class="lg:hidden">
  369. <el-dropdown trigger="click" @command="handleLanguageCommand">
  370. <button
  371. class="rounded-md relative top-1 right-5 px-2 py-1 hover:bg-gray-500/20 transition-colors cursor-pointer"
  372. >
  373. <Icon
  374. icon="mdi:translate"
  375. class="text-[16px]"
  376. style="color: var(--text-secondary)"
  377. />
  378. </button>
  379. <template #dropdown>
  380. <el-dropdown-menu>
  381. <el-dropdown-item
  382. v-for="item in languageOptions"
  383. :key="item.value"
  384. :command="item.value"
  385. :disabled="currentLocale === item.value"
  386. >
  387. {{ item.label }}
  388. </el-dropdown-item>
  389. </el-dropdown-menu>
  390. </template>
  391. </el-dropdown>
  392. <button
  393. @click="themeStore.toggleTheme()"
  394. class="rounded-full relative top-1 right-4 hover:bg-gray-500/60 transition-colors cursor-pointer"
  395. >
  396. <Icon v-if="themeStore.theme === 'light'" icon="ri:moon-fill" />
  397. <Icon v-else icon="ri:sun-fill" />
  398. </button>
  399. <el-dropdown trigger="click" placement="bottom-end">
  400. <div class="flex items-center gap-2 cursor-pointer pr-6 pt-1">
  401. <el-badge
  402. :value="
  403. unreadMessageCount + oaUnreadCount + Number(unreadSRMCount)
  404. "
  405. class="item"
  406. v-if="hasUnreadMessages || oaHasUnreadCount"
  407. >
  408. <Icon
  409. icon="mdi:bell"
  410. class="w-5 h-5 text-gray-600 hover:text-[#409EFF]"
  411. />
  412. </el-badge>
  413. <Icon
  414. v-else
  415. icon="mdi:bell"
  416. class="w-5 h-5 text-gray-600 hover:text-[#409EFF]"
  417. />
  418. </div>
  419. <template #dropdown>
  420. <el-dropdown-menu class="notification-dropdown">
  421. <div class="notification-tabs pl-2">
  422. <el-tabs v-model="activeTab" class="demo-tabs">
  423. <el-tab-pane label="OA" name="tasks">
  424. <template #label>
  425. <span class="custom-tabs-label">
  426. <span>OA</span>
  427. <el-badge
  428. :value="oaUnreadCount"
  429. class="item ml-1"
  430. v-if="oaHasUnreadCount"
  431. ></el-badge>
  432. </span>
  433. </template>
  434. <div class="tab-content">
  435. <div>
  436. <span
  437. v-if="oaHasUnreadCount"
  438. class="cursor-pointer text-blue-500"
  439. @click="oaMarkAllAsRead"
  440. >{{ $t("common.markAll") }}</span
  441. >
  442. </div>
  443. <!-- OA消息 -->
  444. <div
  445. class="task-item"
  446. v-for="(task, index) in oaMessagesList"
  447. :key="index"
  448. >
  449. <div class="task-info">
  450. <p class="task-title">
  451. <span
  452. v-if="task.status === '0'"
  453. class="inline-block h-2 w-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  454. ></span>
  455. {{ task.title }}
  456. </p>
  457. <p class="message-desc">
  458. <span>{{ task.oaCreateTime }}</span>
  459. </p>
  460. </div>
  461. </div>
  462. <div v-if="!oaMessagesList.length" class="no-tasks">
  463. {{ $t("common.noMsg") }}
  464. </div>
  465. </div>
  466. </el-tab-pane>
  467. <el-tab-pane label="CRM" name="messages">
  468. <template #label>
  469. <span class="custom-tabs-label">
  470. <span>CRM</span>
  471. <el-badge
  472. :value="unreadMessageCount"
  473. class="item ml-1"
  474. v-if="hasUnreadMessages"
  475. ></el-badge>
  476. </span>
  477. </template>
  478. <div class="tab-content">
  479. <!-- 消息中心内容 -->
  480. <div>
  481. <span
  482. v-if="hasUnreadMessages"
  483. class="cursor-pointer text-blue-500"
  484. @click="markAllAsRead"
  485. >{{ $t("common.markAll") }}</span
  486. >
  487. </div>
  488. <div
  489. class="message-item"
  490. v-for="(item, index) in messages"
  491. :key="index"
  492. >
  493. <div class="message-icon"></div>
  494. <div class="message-text">
  495. <!-- 未读就显示小红点 -->
  496. <p class="message-title flex items-center gap-5">
  497. <span
  498. v-if="item.status === '0'"
  499. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  500. ></span
  501. >{{ item.contentMajor }}
  502. </p>
  503. <p class="message-desc">
  504. {{ timestampToDateTime(item.createTime) }}
  505. </p>
  506. </div>
  507. </div>
  508. <div v-if="!messages.length" class="no-messages">
  509. {{ $t("common.noMsg") }}
  510. </div>
  511. </div>
  512. </el-tab-pane>
  513. <el-tab-pane label="SRM" name="srm">
  514. <template #label>
  515. <span class="custom-tabs-label">
  516. <span>SRM</span>
  517. <el-badge
  518. :value="unreadSRMCount"
  519. class="item ml-1"
  520. v-if="hasUnreadSRMCount"
  521. ></el-badge>
  522. </span>
  523. </template>
  524. <div class="tab-content">
  525. <!-- 消息中心内容 -->
  526. <div>
  527. <span
  528. v-if="hasUnreadSRMCount"
  529. class="cursor-pointer text-blue-500"
  530. @click="markSRMAsRead"
  531. >{{ $t("common.markAll") }}</span
  532. >
  533. </div>
  534. <div
  535. class="message-item"
  536. v-for="(item, index) in srmMessageList"
  537. :key="index"
  538. >
  539. <div class="message-icon"></div>
  540. <div class="message-text">
  541. <!-- 未读就显示小红点 -->
  542. <p class="message-title flex items-center gap-5">
  543. <span
  544. v-if="item.status === '0'"
  545. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  546. ></span
  547. >{{ item.title }}
  548. </p>
  549. <p class="message-desc">
  550. {{ timestampToDateTime(item.createTime) }}
  551. </p>
  552. </div>
  553. </div>
  554. <div v-if="!srmMessageList.length" class="no-messages">
  555. {{ $t("common.noMsg") }}
  556. </div>
  557. </div>
  558. </el-tab-pane>
  559. <!-- EHR消息 -->
  560. <el-tab-pane label="EHR" name="ehr">
  561. <template #label>
  562. <span class="custom-tabs-label">
  563. <span>EHR</span>
  564. <el-badge
  565. :value="unreadEHRCount"
  566. class="item ml-1"
  567. v-if="hasUnreadEHRCount"
  568. ></el-badge>
  569. </span>
  570. </template>
  571. <div class="tab-content">
  572. <!-- 消息中心内容 -->
  573. <div>
  574. <span
  575. v-if="hasUnreadEHRCount"
  576. class="cursor-pointer text-blue-500"
  577. @click="markEHRAsRead"
  578. >{{ $t("common.markAll") }}</span
  579. >
  580. </div>
  581. <div
  582. class="message-item"
  583. v-for="(item, index) in ehrMessageList"
  584. :key="index"
  585. >
  586. <div class="message-icon"></div>
  587. <div class="message-text">
  588. <!-- 未读就显示小红点 -->
  589. <p class="message-title flex items-center gap-5">
  590. <span
  591. v-if="item.status === '0'"
  592. class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
  593. ></span
  594. >{{ item.title }}
  595. </p>
  596. <p class="message-desc">
  597. {{ timestampToDateTime(item.createTime) }}
  598. </p>
  599. </div>
  600. </div>
  601. <div v-if="!ehrMessageList.length" class="no-messages">
  602. {{ $t("common.noMsg") }}
  603. </div>
  604. </div>
  605. </el-tab-pane>
  606. </el-tabs>
  607. </div>
  608. </el-dropdown-menu>
  609. </template>
  610. </el-dropdown>
  611. <el-button link @click="drawer = true">
  612. <i class="el-icon" />
  613. <Icon icon="fa:bars" class="icon" />
  614. </el-button>
  615. </div>
  616. </div>
  617. <el-drawer
  618. v-model="drawer"
  619. placement="right"
  620. size="80%"
  621. :with-header="false"
  622. >
  623. <div class="p-4 space-y-3">
  624. <ul class="flex flex-col gap-3 !text-[#303133]">
  625. <li>
  626. <a
  627. class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
  628. :class="
  629. router.currentRoute.value.path === '/'
  630. ? 'nav-item-active'
  631. : 'nav-item-default'
  632. "
  633. @click="
  634. router.push('/');
  635. drawer = false;
  636. "
  637. >
  638. {{ $t("nav.home") }}
  639. </a>
  640. </li>
  641. <li>
  642. <a
  643. class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
  644. :class="
  645. router.currentRoute.value.path.startsWith('/flow')
  646. ? 'nav-item-active'
  647. : 'nav-item-default'
  648. "
  649. @click="goFlow"
  650. >
  651. {{ $t("nav.flow") }}
  652. </a>
  653. </li>
  654. <li v-hasPermi="['portal:dashboard:view']">
  655. <a
  656. class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
  657. :class="
  658. router.currentRoute.value.path.startsWith('/drive')
  659. ? 'nav-item-active'
  660. : 'nav-item-default'
  661. "
  662. @click="goDrive"
  663. >
  664. {{ $t("nav.drive") }}
  665. </a>
  666. </li>
  667. <li>
  668. <a
  669. class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
  670. :class="
  671. router.currentRoute.value.path.startsWith('/report')
  672. ? 'nav-item-active'
  673. : 'nav-item-default'
  674. "
  675. >
  676. {{ $t("nav.report") }}
  677. </a>
  678. </li>
  679. </ul>
  680. <div class="flex items-center gap-3 mt-3">
  681. <template v-if="isLoggedIn">
  682. <el-dropdown @command="onUserCommand" trigger="click">
  683. <span class="flex items-center gap-2 cursor-pointer pr-2">
  684. <div class="avatar-wrapper">
  685. <img
  686. :src="userAvatar || person"
  687. alt="avatar"
  688. class="w-8 h-8 rounded-full avatar-image"
  689. />
  690. </div>
  691. <span class="text-sm text-[#303133]">{{ userName }}</span>
  692. </span>
  693. <template #dropdown>
  694. <el-dropdown-menu>
  695. <el-dropdown-item command="profile">
  696. <span class="pl-2">{{ $t("common.person") }}</span>
  697. </el-dropdown-item>
  698. <el-dropdown-item command="logout">
  699. <span class="pl-2">{{ $t("common.logout") }}</span>
  700. </el-dropdown-item>
  701. </el-dropdown-menu>
  702. </template>
  703. </el-dropdown>
  704. </template>
  705. <el-button
  706. v-else
  707. type="primary"
  708. class="flex-1 bg-[#0050b3]!"
  709. @click="login"
  710. >{{ $t("common.login") }}</el-button
  711. >
  712. </div>
  713. </div>
  714. </el-drawer>
  715. </header>
  716. </template>
  717. <script setup lang="ts">
  718. import { Icon } from "@iconify/vue";
  719. import { ref, computed, onMounted, onBeforeUnmount } from "vue";
  720. import { useRouter } from "vue-router";
  721. import logo from "@/assets/images/logo.png";
  722. import logo2 from "@/assets/images/logo2.png";
  723. import person from "@/assets/images/person.png";
  724. import { useUserStoreWithOut } from "@/stores/useUserStore";
  725. import { useThemeStore } from "@/stores/useThemeStore";
  726. import {
  727. LOCALE_STORAGE_KEY,
  728. SUPPORTED_LOCALES,
  729. type AppLocale,
  730. useI18n,
  731. } from "@/i18n";
  732. const userStore = useUserStoreWithOut();
  733. const themeStore = useThemeStore();
  734. import {
  735. getNotifyMessages,
  736. getNotifyMessageList,
  737. markMessageAsRead,
  738. getUnreadNotifyMessageCount,
  739. getOANotifyMessages,
  740. getOANotifyMessageList,
  741. markOAMessageAsRead,
  742. getSRMNotifyMessages,
  743. getSRMNotifyMessageList,
  744. markSRMNotifyMessageRead,
  745. getEHRNotifyMessages,
  746. getEHRNotifyMessageList,
  747. markEHRNotifyMessageRead,
  748. } from "@api/user";
  749. import {
  750. getAccessToken,
  751. getRefreshToken,
  752. removeToken,
  753. setToken,
  754. } from "@utils/auth";
  755. import { deleteUserCache } from "@hooks/useCache";
  756. import { manualLogoutKey, reloginCancelKey } from "@/config/axios/service";
  757. // 新增消息中心状态
  758. const activeTab = ref("tasks");
  759. const messages = ref([]);
  760. const isLoggedIn = computed(
  761. () => !!userStore.isSetUser || !!userStore.user?.id,
  762. );
  763. const { locale } = useI18n();
  764. const userAvatar = computed(() => userStore.user?.avatar || "");
  765. const userName = computed(() => userStore.user?.nickname || "");
  766. const languageOptions: Array<{ label: string; value: AppLocale }> = [
  767. { label: "中文", value: "zh" },
  768. { label: "English", value: "en" },
  769. // 俄语
  770. { label: "Russian", value: "ru" },
  771. ];
  772. const currentLocale = computed(() =>
  773. SUPPORTED_LOCALES.includes(locale.value as AppLocale)
  774. ? (locale.value as AppLocale)
  775. : "zh",
  776. );
  777. // 是否有未读消息
  778. const hasUnreadMessages = computed(() => {
  779. return messages.value.some((msg) => msg.status === "0");
  780. });
  781. // oa是否有未读
  782. const oaHasUnreadCount = computed(() => {
  783. return oaMessagesList.value.some((msg) => msg.status === "0");
  784. });
  785. // 未读消息数量
  786. const unreadMessageCount = computed(() => {
  787. return messages.value.filter((msg) => msg.status === "0").length;
  788. });
  789. // oa未读消息数量
  790. const oaUnreadCount = computed(() => {
  791. return oaMessagesList.value.filter((msg) => msg.status === "0").length;
  792. });
  793. // oa未读
  794. const oaMessagesList = ref([]);
  795. let srmMessageList = ref([]);
  796. let ehrMessageList = ref([]);
  797. // srm未读
  798. const unreadSRMCount = computed(() => {
  799. return srmMessageList.value.filter((msg) => msg.status === "0").length;
  800. });
  801. // srm是否有未读消息
  802. const hasUnreadSRMCount = computed(() => {
  803. return srmMessageList.value.some((msg) => msg.status === "0");
  804. });
  805. // ehr未读
  806. const unreadEHRCount = computed(() => {
  807. return ehrMessageList.value.filter((msg) => msg.status === "0").length;
  808. });
  809. // ehr是否有未读消息
  810. const hasUnreadEHRCount = computed(() => {
  811. return ehrMessageList.value.some((msg) => msg.status === "0");
  812. });
  813. const unreadCount = ref(0); // 未读消息数量
  814. const getUnreadCount = async () => {
  815. if (!getAccessToken()) {
  816. unreadCount.value = 0;
  817. return;
  818. }
  819. const data = await getUnreadNotifyMessageCount();
  820. unreadCount.value = data;
  821. };
  822. let messageTimer: ReturnType<typeof setInterval> | undefined;
  823. let unreadTimer: ReturnType<typeof setInterval> | undefined;
  824. onMounted(async () => {
  825. if (isLoggedIn.value) {
  826. getUnreadCount();
  827. try {
  828. await getNotifyMessages(userStore.getUser.username);
  829. const messageList = await getNotifyMessageList(
  830. userStore.getUser.username,
  831. );
  832. messages.value = messageList.filter((msg) => msg.status === "0");
  833. } catch (error) {
  834. messages.value = [];
  835. }
  836. // oa消息
  837. try {
  838. await getOANotifyMessages(userStore.getUser.username);
  839. const oaMessageList = await getOANotifyMessageList(
  840. userStore.getUser.username,
  841. );
  842. oaMessagesList.value = oaMessageList.filter((msg) => msg.status === "0");
  843. } catch (error) {
  844. oaMessagesList.value = [];
  845. }
  846. try {
  847. // srm消息
  848. await getSRMNotifyMessages(userStore.getUser.username);
  849. const srmMessageLists = await getSRMNotifyMessageList(
  850. userStore.getUser.username,
  851. );
  852. srmMessageList.value = srmMessageLists.filter(
  853. (msg) => msg.status === "0",
  854. );
  855. } catch (error) {
  856. srmMessageList.value = [];
  857. }
  858. // EHR消息
  859. try {
  860. await getEHRNotifyMessages(userStore.getUser.username);
  861. const ehrMessageLists = await getEHRNotifyMessageList(
  862. userStore.getUser.username,
  863. );
  864. ehrMessageList.value = ehrMessageLists.filter(
  865. (msg) => msg.status === "0",
  866. );
  867. } catch (error) {
  868. ehrMessageList.value = [];
  869. }
  870. }
  871. messageTimer = setInterval(
  872. async () => {
  873. if (isLoggedIn.value) {
  874. try {
  875. await getNotifyMessages(userStore.getUser.username);
  876. const messageList = await getNotifyMessageList(
  877. userStore.getUser.username,
  878. );
  879. messages.value = messageList.filter((msg: any) => msg.status === "0");
  880. } catch (error) {
  881. messages.value = [];
  882. }
  883. // oa消息
  884. try {
  885. await getOANotifyMessages(userStore.getUser.username);
  886. const oaMessageList = await getOANotifyMessageList(
  887. userStore.getUser.username,
  888. );
  889. oaMessagesList.value = oaMessageList.filter(
  890. (msg: any) => msg.status === "0",
  891. );
  892. } catch (error) {
  893. oaMessagesList.value = [];
  894. }
  895. // srm消息
  896. try {
  897. await getSRMNotifyMessages(userStore.getUser.username);
  898. const srmMessageLists = await getSRMNotifyMessageList(
  899. userStore.getUser.username,
  900. );
  901. srmMessageList.value = srmMessageLists.filter(
  902. (msg: any) => msg.status === "0",
  903. );
  904. } catch (error) {
  905. srmMessageList.value = [];
  906. }
  907. // EHR消息
  908. try {
  909. await getEHRNotifyMessages(userStore.getUser.username);
  910. const ehrMessageLists = await getEHRNotifyMessageList(
  911. userStore.getUser.username,
  912. );
  913. ehrMessageList.value = ehrMessageLists.filter(
  914. (msg) => msg.status === "0",
  915. );
  916. } catch (error) {
  917. ehrMessageList.value = [];
  918. }
  919. }
  920. },
  921. 1000 * 60 * 5,
  922. );
  923. unreadTimer = setInterval(
  924. () => {
  925. if (userStore.getIsSetUser && getAccessToken()) {
  926. console.log("轮询刷新小红点");
  927. getUnreadCount();
  928. } else {
  929. unreadCount.value = 0;
  930. }
  931. },
  932. 1000 * 60 * 1,
  933. );
  934. });
  935. onBeforeUnmount(() => {
  936. if (messageTimer) {
  937. clearInterval(messageTimer);
  938. }
  939. if (unreadTimer) {
  940. clearInterval(unreadTimer);
  941. }
  942. });
  943. function timestampToDateTime(timestamp) {
  944. // 兼容 10位(秒) / 13位(毫秒)
  945. const len = String(timestamp).length;
  946. const date = new Date(Number(timestamp) * (len === 10 ? 1000 : 1));
  947. // 年
  948. const year = date.getFullYear();
  949. // 月(0~11 → +1)
  950. const month = String(date.getMonth() + 1).padStart(2, "0");
  951. // 日
  952. const day = String(date.getDate()).padStart(2, "0");
  953. // 时
  954. const hours = String(date.getHours()).padStart(2, "0");
  955. // 分
  956. const minutes = String(date.getMinutes()).padStart(2, "0");
  957. // 秒
  958. const seconds = String(date.getSeconds()).padStart(2, "0");
  959. return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
  960. }
  961. const router = useRouter();
  962. const drawer = ref(false);
  963. const setLanguage = (lang: AppLocale) => {
  964. locale.value = lang;
  965. localStorage.setItem(LOCALE_STORAGE_KEY, lang);
  966. document.documentElement.lang = lang;
  967. };
  968. const handleLanguageCommand = (command: string | number | object) => {
  969. if (
  970. typeof command === "string" &&
  971. SUPPORTED_LOCALES.includes(command as AppLocale)
  972. ) {
  973. setLanguage(command as AppLocale);
  974. }
  975. };
  976. // CRM标为已读
  977. const markAllAsRead = async () => {
  978. await markMessageAsRead(userStore.getUser.username);
  979. // 刷新消息列表
  980. const messageList = await getNotifyMessageList(userStore.getUser.username);
  981. messages.value = messageList.filter((msg: any) => msg.status === "0");
  982. };
  983. // oa全部标为已读
  984. const oaMarkAllAsRead = async () => {
  985. await markOAMessageAsRead(userStore.getUser.username);
  986. // 刷新消息列表
  987. const messageList = await getOANotifyMessageList(userStore.getUser.username);
  988. oaMessagesList.value = messageList.filter((msg: any) => msg.status === "0");
  989. };
  990. // srm全部标为已读
  991. const markSRMAsRead = async () => {
  992. await markSRMNotifyMessageRead(userStore.getUser.username);
  993. const messageList = await getSRMNotifyMessageList(userStore.getUser.username);
  994. srmMessageList.value = messageList.filter((msg: any) => msg.status === "0");
  995. };
  996. // EHR全部标为已读
  997. const markEHRAsRead = async () => {
  998. await markEHRNotifyMessageRead(userStore.getUser.username);
  999. const messageList = await getEHRNotifyMessageList(userStore.getUser.username);
  1000. ehrMessageList.value = messageList.filter((msg: any) => msg.status === "0");
  1001. };
  1002. const goHome = () => {
  1003. router.push({ path: "/" });
  1004. };
  1005. const login = () => {
  1006. router.push({
  1007. path: "/login",
  1008. });
  1009. };
  1010. const goFlow = () => {
  1011. router.push({ path: "/flow" });
  1012. };
  1013. const goDrive = () => {
  1014. router.push({ path: "/drive" });
  1015. };
  1016. const onUserCommand = async (command: string) => {
  1017. if (command === "logout") {
  1018. // await userStore.loginOut();
  1019. deleteUserCache(); // 删除用户缓存
  1020. sessionStorage.setItem(manualLogoutKey, "true");
  1021. sessionStorage.removeItem(reloginCancelKey);
  1022. removeToken();
  1023. const ua = window.navigator.userAgent.toLowerCase();
  1024. const logoutRedirect =
  1025. ua.includes("dingtalk") || ua.includes("dingtalkwork") ? "/" : "/login";
  1026. window.location.href = logoutRedirect;
  1027. }
  1028. };
  1029. </script>
  1030. <style scoped>
  1031. :deep(.el-scrollbar) {
  1032. background: #a14e4e !important;
  1033. }
  1034. .avatar-wrapper {
  1035. position: relative;
  1036. overflow: hidden;
  1037. border-radius: 50%;
  1038. }
  1039. .avatar-wrapper::before {
  1040. content: "";
  1041. position: absolute;
  1042. top: 0;
  1043. left: -100%;
  1044. width: 50%;
  1045. height: 100%;
  1046. background: linear-gradient(
  1047. 90deg,
  1048. rgba(255, 255, 255, 0) 0%,
  1049. rgba(255, 255, 255, 0.8) 50%,
  1050. rgba(255, 255, 255, 0) 100%
  1051. );
  1052. transform: skewX(-25deg);
  1053. transition: none;
  1054. z-index: 1;
  1055. opacity: 0;
  1056. }
  1057. .avatar-wrapper:hover::before {
  1058. animation: shine 0.5s ease-out;
  1059. }
  1060. @keyframes shine {
  1061. 0% {
  1062. left: -100%;
  1063. opacity: 0;
  1064. }
  1065. 10% {
  1066. opacity: 1;
  1067. }
  1068. 100% {
  1069. left: 100%;
  1070. opacity: 0;
  1071. }
  1072. }
  1073. .msg-title {
  1074. color: var(--text-primary-down) !important;
  1075. }
  1076. .notification-dropdown {
  1077. width: 400px !important;
  1078. max-height: 500px;
  1079. overflow: hidden;
  1080. }
  1081. .notification-tabs .el-tabs__header {
  1082. margin-bottom: 0;
  1083. padding: 10px;
  1084. background-color: #f8f9fa;
  1085. }
  1086. .tab-content {
  1087. max-height: 400px;
  1088. overflow-y: auto;
  1089. padding: 10px;
  1090. }
  1091. .message-item {
  1092. display: flex;
  1093. align-items: flex-start;
  1094. padding: 12px 8px;
  1095. border-bottom: 1px solid #eee;
  1096. }
  1097. .message-item:last-child {
  1098. border-bottom: none;
  1099. }
  1100. .message-icon {
  1101. margin-right: 12px;
  1102. display: flex;
  1103. align-items: center;
  1104. }
  1105. .message-text {
  1106. flex: 1;
  1107. }
  1108. .message-title {
  1109. font-weight: 500;
  1110. /* color: #303133; */
  1111. margin-bottom: 4px;
  1112. }
  1113. .message-desc {
  1114. font-size: 13px;
  1115. color: #909399;
  1116. line-height: 1.4;
  1117. margin-bottom: 4px;
  1118. }
  1119. .message-time {
  1120. font-size: 12px;
  1121. color: #c0c4cc;
  1122. }
  1123. .no-messages,
  1124. .no-tasks {
  1125. text-align: center;
  1126. padding: 20px;
  1127. color: #909399;
  1128. font-style: italic;
  1129. }
  1130. .task-item {
  1131. display: flex;
  1132. align-items: center;
  1133. justify-content: space-between;
  1134. padding: 12px 8px;
  1135. border-bottom: 1px solid #9ca3ba;
  1136. }
  1137. .task-item:last-child {
  1138. border-bottom: none;
  1139. }
  1140. .task-info {
  1141. flex: 1;
  1142. }
  1143. .task-title {
  1144. font-weight: 500;
  1145. /* color: #303133; */
  1146. margin-bottom: 4px;
  1147. }
  1148. .task-desc {
  1149. font-size: 13px;
  1150. color: #909399;
  1151. line-height: 1.4;
  1152. margin-bottom: 4px;
  1153. }
  1154. .task-time {
  1155. font-size: 12px;
  1156. color: #c0c4cc;
  1157. }
  1158. .nav-item-default {
  1159. background-color: #eeeeef; /* 浅灰色背景 */
  1160. color: var(--text-secondary);
  1161. border-radius: 100px;
  1162. }
  1163. .nav-item-default:hover {
  1164. /* background-color: #e2e8f0; */
  1165. color: #02409b !important; /* 品牌蓝文字 */
  1166. }
  1167. /* 激活状态:深蓝色背景,白色文字 */
  1168. .nav-item-active {
  1169. background-color: #063e8d !important; /* 指定的深蓝色背景 */
  1170. color: var(--text-primary);
  1171. font-weight: 500; /* 稍微加粗 */
  1172. box-shadow: 0 2px 4px rgba(6, 62, 141, 0.2); /* 可选:轻微阴影 */
  1173. border-radius: 100px;
  1174. }
  1175. .user-name {
  1176. color: var(--text-secondary);
  1177. }
  1178. /* 确保移动端也生效,因为上面用了 block,可能需要调整一下内边距或显示方式 */
  1179. @media (max-width: 1024px) {
  1180. .nav-item-active,
  1181. .nav-item-default {
  1182. display: block;
  1183. width: 100%;
  1184. text-align: left;
  1185. }
  1186. }
  1187. .nav-item-default {
  1188. /* color: rgba(230, 237, 255, 0.8); */
  1189. border-radius: 0;
  1190. position: relative;
  1191. background-color: transparent;
  1192. }
  1193. .nav-item-default:hover {
  1194. color: #ffffff;
  1195. background: rgba(255, 255, 255, 0.04);
  1196. }
  1197. .nav-item-active {
  1198. /* color: #fff !important; */
  1199. background: linear-gradient(
  1200. 180deg,
  1201. rgba(92, 103, 238, 0.32),
  1202. rgba(36, 53, 118, 0.18)
  1203. ) !important;
  1204. /* box-shadow: inset 0 -2px 0 #6f8bff; */
  1205. padding-bottom: 22px;
  1206. padding-top: 22px;
  1207. border-radius: 0;
  1208. position: relative;
  1209. }
  1210. .nav-item-active::before {
  1211. content: "";
  1212. position: absolute;
  1213. left: 50%;
  1214. bottom: -2px;
  1215. width: 100%;
  1216. height: 2px;
  1217. transform: translateX(-50%);
  1218. border-radius: 999px;
  1219. background: linear-gradient(
  1220. to right,
  1221. #5887f8 0%,
  1222. #69b5f8 30%,
  1223. #fff 50%,
  1224. #69b5f8 70%,
  1225. #5887f8 100%
  1226. );
  1227. box-shadow: 0 0 12px rgba(112, 120, 255, 0.95);
  1228. }
  1229. /* .nav-item-active::after {
  1230. content: "";
  1231. position: absolute;
  1232. left: 50%;
  1233. bottom: -10px;
  1234. width: 46px;
  1235. height: 3px;
  1236. transform: translateX(-50%);
  1237. border-radius: 999px;
  1238. background: linear-gradient(90deg, #cc82ff, #5f89ff);
  1239. box-shadow: 0 0 12px rgba(112, 120, 255, 0.95);
  1240. } */
  1241. .notification-dropdown {
  1242. width: 400px !important;
  1243. max-height: 500px;
  1244. overflow: hidden;
  1245. border: 1px solid rgba(109, 137, 213, 0.18);
  1246. background: var(--bg-card);
  1247. }
  1248. /* 修改 Tab 标签文字颜色 */
  1249. :deep(.el-tabs__item) {
  1250. color: var(--text-primary) !important; /* 强制设置为白色 */
  1251. }
  1252. /* 选中状态的标签文字颜色(保持白色或根据需要调整) */
  1253. :deep(.el-tabs__item.is-active) {
  1254. color: #0088ff !important;
  1255. }
  1256. /* 如果需要修改底部激活条的颜色,可以保留或调整这个 */
  1257. :deep(.el-tabs__active-bar) {
  1258. background-color: #409eff !important; /* 例如改为品牌蓝,或者保持默认 */
  1259. }
  1260. /* 确保 hover 状态也是白色或高亮色 */
  1261. :deep(.el-tabs__item:hover) {
  1262. color: #008dff !important;
  1263. }
  1264. </style>