| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355 |
- <template>
- <header
- class="fixed w-full top-0 z-100 border-b shadow-sm"
- :style="{
- backgroundColor: 'var(--header-bg)',
- borderColor: 'var(--header-border)',
- }"
- >
- <div class="flex items-center justify-between px-5 md:px-20 h-15">
- <div class="flex items-center gap-2 cursor-pointer" @click="goHome">
- <img :src="logo" alt="logo" class="w-9 h-9 rounded-md" />
- <img :src="logo2" alt="logo" class="h-10 hidden lg:flex" />
- <span
- class="text-[#828182] text-[14px]"
- style="text-wrap-mode: nowrap"
- >{{ $t("nav.title") }}</span
- >
- </div>
- <nav class="hidden lg:flex flex-1 mx-4 ml-60 text-sm">
- <ul class="flex items-center gap-6 text-[#303133] text-md">
- <!-- 首页 -->
- <li>
- <a
- class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
- :class="
- router.currentRoute.value.path === '/'
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- style="text-wrap-mode: nowrap"
- @click="router.push('/')"
- >
- {{ $t("nav.home") }}
- </a>
- </li>
- <!-- 流程门户 -->
- <li>
- <a
- style="text-wrap-mode: nowrap"
- class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
- :class="
- router.currentRoute.value.path.startsWith('/flow')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- @click="goFlow"
- >
- {{ $t("nav.flow") }}
- </a>
- </li>
- <!-- 驾驶舱门户 -->
- <li v-hasPermi="['portal:dashboard:view']">
- <a
- class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
- :class="
- router.currentRoute.value.path.startsWith('/drive')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- @click="goDrive"
- style="text-wrap-mode: nowrap"
- >
- {{ $t("nav.drive") }}
- </a>
- </li>
- <!-- 报表门户 (假设路径为 /report,请根据实际路由调整) -->
- <li>
- <a
- class="cursor-pointer px-3 py-1.5 rounded-md transition-all duration-300"
- :class="
- router.currentRoute.value.path.startsWith('/report')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- style="text-wrap-mode: nowrap"
- >
- {{ $t("nav.report") }}
- </a>
- </li>
- </ul>
- </nav>
- <div
- style="border-left: 1px solid #a5bbdb"
- class="hidden lg:flex items-center gap-3 h-[40%] pl-4"
- >
- <el-dropdown trigger="click" @command="handleLanguageCommand">
- <button
- class="flex items-center gap-1 px-2 py-1 rounded-md hover:bg-gray-500/20 transition-colors cursor-pointer"
- >
- <Icon
- icon="mdi:translate"
- class="text-[18px]! mt-1"
- style="color: var(--text-secondary)"
- />
- </button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- v-for="item in languageOptions"
- :key="item.value"
- :command="item.value"
- :disabled="currentLocale === item.value"
- >
- {{ item.label }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- <button
- @click="themeStore.toggleTheme()"
- class="p-2 rounded-full mt-1 hover:bg-gray-500/60 transition-colors cursor-pointer"
- >
- <Icon v-if="themeStore.theme === 'light'" icon="ri:moon-fill" />
- <Icon v-else icon="ri:sun-fill" />
- </button>
- <!-- 消息中心 -->
- <el-dropdown trigger="click" placement="bottom-end">
- <div class="flex items-center gap-2 cursor-pointer pr-6 pt-1">
- <el-badge
- :value="
- unreadMessageCount + oaUnreadCount + Number(unreadSRMCount)
- "
- class="item"
- v-if="hasUnreadMessages || oaHasUnreadCount"
- >
- <Icon
- icon="mdi:bell"
- class="w-5 h-5 text-[#a7aab0] hover:text-[#409EFF]"
- />
- </el-badge>
- <Icon
- v-else
- icon="mdi:bell"
- class="w-5 h-5 text-[#507698] hover:text-[#409EFF]"
- />
- </div>
- <template #dropdown>
- <el-dropdown-menu class="notification-dropdown">
- <div class="notification-tabs pl-2">
- <el-tabs v-model="activeTab" class="demo-tabs">
- <el-tab-pane label="OA" name="tasks">
- <template #label>
- <span class="custom-tabs-label">
- <span>OA</span>
- <el-badge
- :value="oaUnreadCount"
- class="item ml-1"
- v-if="oaHasUnreadCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <div>
- <span
- v-if="oaHasUnreadCount"
- class="cursor-pointer text-blue-500"
- @click="oaMarkAllAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <!-- OA消息 -->
- <div
- class="task-item"
- v-for="(task, index) in oaMessagesList"
- :key="index"
- >
- <div class="task-info">
- <p class="task-title">
- <span
- v-if="task.status === '0'"
- class="inline-block h-2 w-2 bg-[#f56c6c] rounded-full"
- ></span>
- <span class="pl-2 text-var(--tab-text)!">{{
- task.title
- }}</span>
- </p>
- <p class="message-desc">
- <span>{{ task.oaCreateTime }}</span>
- </p>
- </div>
- </div>
- <div v-if="!oaMessagesList.length" class="no-tasks">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <el-tab-pane label="CRM" name="messages">
- <template #label>
- <span class="custom-tabs-label">
- <span>CRM</span>
- <el-badge
- :value="unreadMessageCount"
- class="item ml-1"
- v-if="hasUnreadMessages"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadMessages"
- class="cursor-pointer text-blue-500"
- @click="markAllAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in messages"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.contentMajor }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!messages.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <!-- SRM消息 -->
- <el-tab-pane label="SRM" name="srm">
- <template #label>
- <span class="custom-tabs-label">
- <span>SRM</span>
- <el-badge
- :value="unreadSRMCount"
- class="item ml-1"
- v-if="hasUnreadSRMCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadSRMCount"
- class="cursor-pointer text-blue-500"
- @click="markSRMAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in srmMessageList"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.title }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!srmMessageList.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <!-- EHR消息 -->
- <el-tab-pane label="EHR" name="ehr">
- <template #label>
- <span class="custom-tabs-label">
- <span>EHR</span>
- <el-badge
- :value="unreadEHRCount"
- class="item ml-1"
- v-if="hasUnreadEHRCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadEHRCount"
- class="cursor-pointer text-blue-500"
- @click="markEHRAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in ehrMessageList"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.title }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!ehrMessageList.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- <template v-if="isLoggedIn">
- <el-dropdown @command="onUserCommand" trigger="click">
- <span class="flex items-center gap-2 cursor-pointer pr-2">
- <div class="avatar-wrapper">
- <img
- :src="userAvatar || person"
- alt="avatar"
- class="w-8 h-8 rounded-full avatar-image"
- />
- </div>
- <span class="text-sm user-name" style="text-wrap-mode: nowrap">{{
- userName
- }}</span>
- </span>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item command="profile">
- <span>{{ $t("common.person") }}</span>
- </el-dropdown-item>
- <el-dropdown-item command="logout">
- <span>{{ $t("common.logout") }}</span>
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </template>
- <template v-else>
- <div
- style="text-wrap: nowrap"
- class="text-md flex items-center justify-center cursor-pointer h-full py-4"
- @click="login"
- >
- {{ $t("common.login") }}
- </div>
- </template>
- </div>
- <div class="lg:hidden">
- <el-dropdown trigger="click" @command="handleLanguageCommand">
- <button
- class="rounded-md relative top-1 right-5 px-2 py-1 hover:bg-gray-500/20 transition-colors cursor-pointer"
- >
- <Icon
- icon="mdi:translate"
- class="text-[16px]"
- style="color: var(--text-secondary)"
- />
- </button>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item
- v-for="item in languageOptions"
- :key="item.value"
- :command="item.value"
- :disabled="currentLocale === item.value"
- >
- {{ item.label }}
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- <button
- @click="themeStore.toggleTheme()"
- class="rounded-full relative top-1 right-4 hover:bg-gray-500/60 transition-colors cursor-pointer"
- >
- <Icon v-if="themeStore.theme === 'light'" icon="ri:moon-fill" />
- <Icon v-else icon="ri:sun-fill" />
- </button>
- <el-dropdown trigger="click" placement="bottom-end">
- <div class="flex items-center gap-2 cursor-pointer pr-6 pt-1">
- <el-badge
- :value="
- unreadMessageCount + oaUnreadCount + Number(unreadSRMCount)
- "
- class="item"
- v-if="hasUnreadMessages || oaHasUnreadCount"
- >
- <Icon
- icon="mdi:bell"
- class="w-5 h-5 text-gray-600 hover:text-[#409EFF]"
- />
- </el-badge>
- <Icon
- v-else
- icon="mdi:bell"
- class="w-5 h-5 text-gray-600 hover:text-[#409EFF]"
- />
- </div>
- <template #dropdown>
- <el-dropdown-menu class="notification-dropdown">
- <div class="notification-tabs pl-2">
- <el-tabs v-model="activeTab" class="demo-tabs">
- <el-tab-pane label="OA" name="tasks">
- <template #label>
- <span class="custom-tabs-label">
- <span>OA</span>
- <el-badge
- :value="oaUnreadCount"
- class="item ml-1"
- v-if="oaHasUnreadCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <div>
- <span
- v-if="oaHasUnreadCount"
- class="cursor-pointer text-blue-500"
- @click="oaMarkAllAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <!-- OA消息 -->
- <div
- class="task-item"
- v-for="(task, index) in oaMessagesList"
- :key="index"
- >
- <div class="task-info">
- <p class="task-title">
- <span
- v-if="task.status === '0'"
- class="inline-block h-2 w-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span>
- {{ task.title }}
- </p>
- <p class="message-desc">
- <span>{{ task.oaCreateTime }}</span>
- </p>
- </div>
- </div>
- <div v-if="!oaMessagesList.length" class="no-tasks">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <el-tab-pane label="CRM" name="messages">
- <template #label>
- <span class="custom-tabs-label">
- <span>CRM</span>
- <el-badge
- :value="unreadMessageCount"
- class="item ml-1"
- v-if="hasUnreadMessages"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadMessages"
- class="cursor-pointer text-blue-500"
- @click="markAllAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in messages"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.contentMajor }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!messages.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <el-tab-pane label="SRM" name="srm">
- <template #label>
- <span class="custom-tabs-label">
- <span>SRM</span>
- <el-badge
- :value="unreadSRMCount"
- class="item ml-1"
- v-if="hasUnreadSRMCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadSRMCount"
- class="cursor-pointer text-blue-500"
- @click="markSRMAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in srmMessageList"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.title }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!srmMessageList.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- <!-- EHR消息 -->
- <el-tab-pane label="EHR" name="ehr">
- <template #label>
- <span class="custom-tabs-label">
- <span>EHR</span>
- <el-badge
- :value="unreadEHRCount"
- class="item ml-1"
- v-if="hasUnreadEHRCount"
- ></el-badge>
- </span>
- </template>
- <div class="tab-content">
- <!-- 消息中心内容 -->
- <div>
- <span
- v-if="hasUnreadEHRCount"
- class="cursor-pointer text-blue-500"
- @click="markEHRAsRead"
- >{{ $t("common.markAll") }}</span
- >
- </div>
- <div
- class="message-item"
- v-for="(item, index) in ehrMessageList"
- :key="index"
- >
- <div class="message-icon"></div>
- <div class="message-text">
- <!-- 未读就显示小红点 -->
- <p class="message-title flex items-center gap-5">
- <span
- v-if="item.status === '0'"
- class="w-2 h-2 bg-[#f56c6c] rounded-full text-var(--tab-text)!"
- ></span
- >{{ item.title }}
- </p>
- <p class="message-desc">
- {{ timestampToDateTime(item.createTime) }}
- </p>
- </div>
- </div>
- <div v-if="!ehrMessageList.length" class="no-messages">
- {{ $t("common.noMsg") }}
- </div>
- </div>
- </el-tab-pane>
- </el-tabs>
- </div>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- <el-button link @click="drawer = true">
- <i class="el-icon" />
- <Icon icon="fa:bars" class="icon" />
- </el-button>
- </div>
- </div>
- <el-drawer
- v-model="drawer"
- placement="right"
- size="80%"
- :with-header="false"
- >
- <div class="p-4 space-y-3">
- <ul class="flex flex-col gap-3 !text-[#303133]">
- <li>
- <a
- class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
- :class="
- router.currentRoute.value.path === '/'
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- @click="
- router.push('/');
- drawer = false;
- "
- >
- {{ $t("nav.home") }}
- </a>
- </li>
- <li>
- <a
- class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
- :class="
- router.currentRoute.value.path.startsWith('/flow')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- @click="goFlow"
- >
- {{ $t("nav.flow") }}
- </a>
- </li>
- <li v-hasPermi="['portal:dashboard:view']">
- <a
- class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
- :class="
- router.currentRoute.value.path.startsWith('/drive')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- @click="goDrive"
- >
- {{ $t("nav.drive") }}
- </a>
- </li>
- <li>
- <a
- class="block px-3 py-2 rounded-md transition-all duration-300 !text-black"
- :class="
- router.currentRoute.value.path.startsWith('/report')
- ? 'nav-item-active'
- : 'nav-item-default'
- "
- >
- {{ $t("nav.report") }}
- </a>
- </li>
- </ul>
- <div class="flex items-center gap-3 mt-3">
- <template v-if="isLoggedIn">
- <el-dropdown @command="onUserCommand" trigger="click">
- <span class="flex items-center gap-2 cursor-pointer pr-2">
- <div class="avatar-wrapper">
- <img
- :src="userAvatar || person"
- alt="avatar"
- class="w-8 h-8 rounded-full avatar-image"
- />
- </div>
- <span class="text-sm text-[#303133]">{{ userName }}</span>
- </span>
- <template #dropdown>
- <el-dropdown-menu>
- <el-dropdown-item command="profile">
- <span class="pl-2">{{ $t("common.person") }}</span>
- </el-dropdown-item>
- <el-dropdown-item command="logout">
- <span class="pl-2">{{ $t("common.logout") }}</span>
- </el-dropdown-item>
- </el-dropdown-menu>
- </template>
- </el-dropdown>
- </template>
- <el-button
- v-else
- type="primary"
- class="flex-1 bg-[#0050b3]!"
- @click="login"
- >{{ $t("common.login") }}</el-button
- >
- </div>
- </div>
- </el-drawer>
- </header>
- </template>
- <script setup lang="ts">
- import { Icon } from "@iconify/vue";
- import { ref, computed, onMounted, onBeforeUnmount } from "vue";
- import { useRouter } from "vue-router";
- import logo from "@/assets/images/logo.png";
- import logo2 from "@/assets/images/logo2.png";
- import person from "@/assets/images/person.png";
- import { useUserStoreWithOut } from "@/stores/useUserStore";
- import { useThemeStore } from "@/stores/useThemeStore";
- import {
- LOCALE_STORAGE_KEY,
- SUPPORTED_LOCALES,
- type AppLocale,
- useI18n,
- } from "@/i18n";
- const userStore = useUserStoreWithOut();
- const themeStore = useThemeStore();
- import {
- getNotifyMessages,
- getNotifyMessageList,
- markMessageAsRead,
- getUnreadNotifyMessageCount,
- getOANotifyMessages,
- getOANotifyMessageList,
- markOAMessageAsRead,
- getSRMNotifyMessages,
- getSRMNotifyMessageList,
- markSRMNotifyMessageRead,
- getEHRNotifyMessages,
- getEHRNotifyMessageList,
- markEHRNotifyMessageRead,
- } from "@api/user";
- import {
- getAccessToken,
- getRefreshToken,
- removeToken,
- setToken,
- } from "@utils/auth";
- import { deleteUserCache } from "@hooks/useCache";
- import { manualLogoutKey, reloginCancelKey } from "@/config/axios/service";
- // 新增消息中心状态
- const activeTab = ref("tasks");
- const messages = ref([]);
- const isLoggedIn = computed(
- () => !!userStore.isSetUser || !!userStore.user?.id,
- );
- const { locale } = useI18n();
- const userAvatar = computed(() => userStore.user?.avatar || "");
- const userName = computed(() => userStore.user?.nickname || "");
- const languageOptions: Array<{ label: string; value: AppLocale }> = [
- { label: "中文", value: "zh" },
- { label: "English", value: "en" },
- // 俄语
- { label: "Russian", value: "ru" },
- ];
- const currentLocale = computed(() =>
- SUPPORTED_LOCALES.includes(locale.value as AppLocale)
- ? (locale.value as AppLocale)
- : "zh",
- );
- // 是否有未读消息
- const hasUnreadMessages = computed(() => {
- return messages.value.some((msg) => msg.status === "0");
- });
- // oa是否有未读
- const oaHasUnreadCount = computed(() => {
- return oaMessagesList.value.some((msg) => msg.status === "0");
- });
- // 未读消息数量
- const unreadMessageCount = computed(() => {
- return messages.value.filter((msg) => msg.status === "0").length;
- });
- // oa未读消息数量
- const oaUnreadCount = computed(() => {
- return oaMessagesList.value.filter((msg) => msg.status === "0").length;
- });
- // oa未读
- const oaMessagesList = ref([]);
- let srmMessageList = ref([]);
- let ehrMessageList = ref([]);
- // srm未读
- const unreadSRMCount = computed(() => {
- return srmMessageList.value.filter((msg) => msg.status === "0").length;
- });
- // srm是否有未读消息
- const hasUnreadSRMCount = computed(() => {
- return srmMessageList.value.some((msg) => msg.status === "0");
- });
- // ehr未读
- const unreadEHRCount = computed(() => {
- return ehrMessageList.value.filter((msg) => msg.status === "0").length;
- });
- // ehr是否有未读消息
- const hasUnreadEHRCount = computed(() => {
- return ehrMessageList.value.some((msg) => msg.status === "0");
- });
- const unreadCount = ref(0); // 未读消息数量
- const getUnreadCount = async () => {
- if (!getAccessToken()) {
- unreadCount.value = 0;
- return;
- }
- const data = await getUnreadNotifyMessageCount();
- unreadCount.value = data;
- };
- let messageTimer: ReturnType<typeof setInterval> | undefined;
- let unreadTimer: ReturnType<typeof setInterval> | undefined;
- onMounted(async () => {
- if (isLoggedIn.value) {
- getUnreadCount();
- try {
- await getNotifyMessages(userStore.getUser.username);
- const messageList = await getNotifyMessageList(
- userStore.getUser.username,
- );
- messages.value = messageList.filter((msg) => msg.status === "0");
- } catch (error) {
- messages.value = [];
- }
- // oa消息
- try {
- await getOANotifyMessages(userStore.getUser.username);
- const oaMessageList = await getOANotifyMessageList(
- userStore.getUser.username,
- );
- oaMessagesList.value = oaMessageList.filter((msg) => msg.status === "0");
- } catch (error) {
- oaMessagesList.value = [];
- }
- try {
- // srm消息
- await getSRMNotifyMessages(userStore.getUser.username);
- const srmMessageLists = await getSRMNotifyMessageList(
- userStore.getUser.username,
- );
- srmMessageList.value = srmMessageLists.filter(
- (msg) => msg.status === "0",
- );
- } catch (error) {
- srmMessageList.value = [];
- }
- // EHR消息
- try {
- await getEHRNotifyMessages(userStore.getUser.username);
- const ehrMessageLists = await getEHRNotifyMessageList(
- userStore.getUser.username,
- );
- ehrMessageList.value = ehrMessageLists.filter(
- (msg) => msg.status === "0",
- );
- } catch (error) {
- ehrMessageList.value = [];
- }
- }
- messageTimer = setInterval(
- async () => {
- if (isLoggedIn.value) {
- try {
- await getNotifyMessages(userStore.getUser.username);
- const messageList = await getNotifyMessageList(
- userStore.getUser.username,
- );
- messages.value = messageList.filter((msg: any) => msg.status === "0");
- } catch (error) {
- messages.value = [];
- }
- // oa消息
- try {
- await getOANotifyMessages(userStore.getUser.username);
- const oaMessageList = await getOANotifyMessageList(
- userStore.getUser.username,
- );
- oaMessagesList.value = oaMessageList.filter(
- (msg: any) => msg.status === "0",
- );
- } catch (error) {
- oaMessagesList.value = [];
- }
- // srm消息
- try {
- await getSRMNotifyMessages(userStore.getUser.username);
- const srmMessageLists = await getSRMNotifyMessageList(
- userStore.getUser.username,
- );
- srmMessageList.value = srmMessageLists.filter(
- (msg: any) => msg.status === "0",
- );
- } catch (error) {
- srmMessageList.value = [];
- }
- // EHR消息
- try {
- await getEHRNotifyMessages(userStore.getUser.username);
- const ehrMessageLists = await getEHRNotifyMessageList(
- userStore.getUser.username,
- );
- ehrMessageList.value = ehrMessageLists.filter(
- (msg) => msg.status === "0",
- );
- } catch (error) {
- ehrMessageList.value = [];
- }
- }
- },
- 1000 * 60 * 5,
- );
- unreadTimer = setInterval(
- () => {
- if (userStore.getIsSetUser && getAccessToken()) {
- console.log("轮询刷新小红点");
- getUnreadCount();
- } else {
- unreadCount.value = 0;
- }
- },
- 1000 * 60 * 1,
- );
- });
- onBeforeUnmount(() => {
- if (messageTimer) {
- clearInterval(messageTimer);
- }
- if (unreadTimer) {
- clearInterval(unreadTimer);
- }
- });
- function timestampToDateTime(timestamp) {
- // 兼容 10位(秒) / 13位(毫秒)
- const len = String(timestamp).length;
- const date = new Date(Number(timestamp) * (len === 10 ? 1000 : 1));
- // 年
- const year = date.getFullYear();
- // 月(0~11 → +1)
- const month = String(date.getMonth() + 1).padStart(2, "0");
- // 日
- const day = String(date.getDate()).padStart(2, "0");
- // 时
- const hours = String(date.getHours()).padStart(2, "0");
- // 分
- const minutes = String(date.getMinutes()).padStart(2, "0");
- // 秒
- const seconds = String(date.getSeconds()).padStart(2, "0");
- return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
- }
- const router = useRouter();
- const drawer = ref(false);
- const setLanguage = (lang: AppLocale) => {
- locale.value = lang;
- localStorage.setItem(LOCALE_STORAGE_KEY, lang);
- document.documentElement.lang = lang;
- };
- const handleLanguageCommand = (command: string | number | object) => {
- if (
- typeof command === "string" &&
- SUPPORTED_LOCALES.includes(command as AppLocale)
- ) {
- setLanguage(command as AppLocale);
- }
- };
- // CRM标为已读
- const markAllAsRead = async () => {
- await markMessageAsRead(userStore.getUser.username);
- // 刷新消息列表
- const messageList = await getNotifyMessageList(userStore.getUser.username);
- messages.value = messageList.filter((msg: any) => msg.status === "0");
- };
- // oa全部标为已读
- const oaMarkAllAsRead = async () => {
- await markOAMessageAsRead(userStore.getUser.username);
- // 刷新消息列表
- const messageList = await getOANotifyMessageList(userStore.getUser.username);
- oaMessagesList.value = messageList.filter((msg: any) => msg.status === "0");
- };
- // srm全部标为已读
- const markSRMAsRead = async () => {
- await markSRMNotifyMessageRead(userStore.getUser.username);
- const messageList = await getSRMNotifyMessageList(userStore.getUser.username);
- srmMessageList.value = messageList.filter((msg: any) => msg.status === "0");
- };
- // EHR全部标为已读
- const markEHRAsRead = async () => {
- await markEHRNotifyMessageRead(userStore.getUser.username);
- const messageList = await getEHRNotifyMessageList(userStore.getUser.username);
- ehrMessageList.value = messageList.filter((msg: any) => msg.status === "0");
- };
- const goHome = () => {
- router.push({ path: "/" });
- };
- const login = () => {
- router.push({
- path: "/login",
- });
- };
- const goFlow = () => {
- router.push({ path: "/flow" });
- };
- const goDrive = () => {
- router.push({ path: "/drive" });
- };
- const onUserCommand = async (command: string) => {
- if (command === "logout") {
- // await userStore.loginOut();
- deleteUserCache(); // 删除用户缓存
- sessionStorage.setItem(manualLogoutKey, "true");
- sessionStorage.removeItem(reloginCancelKey);
- removeToken();
- const ua = window.navigator.userAgent.toLowerCase();
- const logoutRedirect =
- ua.includes("dingtalk") || ua.includes("dingtalkwork") ? "/" : "/login";
- window.location.href = logoutRedirect;
- }
- };
- </script>
- <style scoped>
- :deep(.el-scrollbar) {
- background: #a14e4e !important;
- }
- .avatar-wrapper {
- position: relative;
- overflow: hidden;
- border-radius: 50%;
- }
- .avatar-wrapper::before {
- content: "";
- position: absolute;
- top: 0;
- left: -100%;
- width: 50%;
- height: 100%;
- background: linear-gradient(
- 90deg,
- rgba(255, 255, 255, 0) 0%,
- rgba(255, 255, 255, 0.8) 50%,
- rgba(255, 255, 255, 0) 100%
- );
- transform: skewX(-25deg);
- transition: none;
- z-index: 1;
- opacity: 0;
- }
- .avatar-wrapper:hover::before {
- animation: shine 0.5s ease-out;
- }
- @keyframes shine {
- 0% {
- left: -100%;
- opacity: 0;
- }
- 10% {
- opacity: 1;
- }
- 100% {
- left: 100%;
- opacity: 0;
- }
- }
- .msg-title {
- color: var(--text-primary-down) !important;
- }
- .notification-dropdown {
- width: 400px !important;
- max-height: 500px;
- overflow: hidden;
- }
- .notification-tabs .el-tabs__header {
- margin-bottom: 0;
- padding: 10px;
- background-color: #f8f9fa;
- }
- .tab-content {
- max-height: 400px;
- overflow-y: auto;
- padding: 10px;
- }
- .message-item {
- display: flex;
- align-items: flex-start;
- padding: 12px 8px;
- border-bottom: 1px solid #eee;
- }
- .message-item:last-child {
- border-bottom: none;
- }
- .message-icon {
- margin-right: 12px;
- display: flex;
- align-items: center;
- }
- .message-text {
- flex: 1;
- }
- .message-title {
- font-weight: 500;
- /* color: #303133; */
- margin-bottom: 4px;
- }
- .message-desc {
- font-size: 13px;
- color: #909399;
- line-height: 1.4;
- margin-bottom: 4px;
- }
- .message-time {
- font-size: 12px;
- color: #c0c4cc;
- }
- .no-messages,
- .no-tasks {
- text-align: center;
- padding: 20px;
- color: #909399;
- font-style: italic;
- }
- .task-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 12px 8px;
- border-bottom: 1px solid #9ca3ba;
- }
- .task-item:last-child {
- border-bottom: none;
- }
- .task-info {
- flex: 1;
- }
- .task-title {
- font-weight: 500;
- /* color: #303133; */
- margin-bottom: 4px;
- }
- .task-desc {
- font-size: 13px;
- color: #909399;
- line-height: 1.4;
- margin-bottom: 4px;
- }
- .task-time {
- font-size: 12px;
- color: #c0c4cc;
- }
- .nav-item-default {
- background-color: #eeeeef; /* 浅灰色背景 */
- color: var(--text-secondary);
- border-radius: 100px;
- }
- .nav-item-default:hover {
- /* background-color: #e2e8f0; */
- color: #02409b !important; /* 品牌蓝文字 */
- }
- /* 激活状态:深蓝色背景,白色文字 */
- .nav-item-active {
- background-color: #063e8d !important; /* 指定的深蓝色背景 */
- color: var(--text-primary);
- font-weight: 500; /* 稍微加粗 */
- box-shadow: 0 2px 4px rgba(6, 62, 141, 0.2); /* 可选:轻微阴影 */
- border-radius: 100px;
- }
- .user-name {
- color: var(--text-secondary);
- }
- /* 确保移动端也生效,因为上面用了 block,可能需要调整一下内边距或显示方式 */
- @media (max-width: 1024px) {
- .nav-item-active,
- .nav-item-default {
- display: block;
- width: 100%;
- text-align: left;
- }
- }
- .nav-item-default {
- /* color: rgba(230, 237, 255, 0.8); */
- border-radius: 0;
- position: relative;
- background-color: transparent;
- }
- .nav-item-default:hover {
- color: #ffffff;
- background: rgba(255, 255, 255, 0.04);
- }
- .nav-item-active {
- /* color: #fff !important; */
- background: linear-gradient(
- 180deg,
- rgba(92, 103, 238, 0.32),
- rgba(36, 53, 118, 0.18)
- ) !important;
- /* box-shadow: inset 0 -2px 0 #6f8bff; */
- padding-bottom: 22px;
- padding-top: 22px;
- border-radius: 0;
- position: relative;
- }
- .nav-item-active::before {
- content: "";
- position: absolute;
- left: 50%;
- bottom: -2px;
- width: 100%;
- height: 2px;
- transform: translateX(-50%);
- border-radius: 999px;
- background: linear-gradient(
- to right,
- #5887f8 0%,
- #69b5f8 30%,
- #fff 50%,
- #69b5f8 70%,
- #5887f8 100%
- );
- box-shadow: 0 0 12px rgba(112, 120, 255, 0.95);
- }
- /* .nav-item-active::after {
- content: "";
- position: absolute;
- left: 50%;
- bottom: -10px;
- width: 46px;
- height: 3px;
- transform: translateX(-50%);
- border-radius: 999px;
- background: linear-gradient(90deg, #cc82ff, #5f89ff);
- box-shadow: 0 0 12px rgba(112, 120, 255, 0.95);
- } */
- .notification-dropdown {
- width: 400px !important;
- max-height: 500px;
- overflow: hidden;
- border: 1px solid rgba(109, 137, 213, 0.18);
- background: var(--bg-card);
- }
- /* 修改 Tab 标签文字颜色 */
- :deep(.el-tabs__item) {
- color: var(--text-primary) !important; /* 强制设置为白色 */
- }
- /* 选中状态的标签文字颜色(保持白色或根据需要调整) */
- :deep(.el-tabs__item.is-active) {
- color: #0088ff !important;
- }
- /* 如果需要修改底部激活条的颜色,可以保留或调整这个 */
- :deep(.el-tabs__active-bar) {
- background-color: #409eff !important; /* 例如改为品牌蓝,或者保持默认 */
- }
- /* 确保 hover 状态也是白色或高亮色 */
- :deep(.el-tabs__item:hover) {
- color: #008dff !important;
- }
- </style>
|