|
@@ -1,9 +1,9 @@
|
|
|
<template>
|
|
|
<div class="navbar">
|
|
|
<hamburger id="hamburger-container" :is-active="appStore.sidebar.opened" class="hamburger-container"
|
|
|
- @toggleClick="toggleSideBar" />
|
|
|
- <breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container" />
|
|
|
- <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container" />
|
|
|
+ @toggleClick="toggleSideBar"/>
|
|
|
+ <breadcrumb v-if="!settingsStore.topNav" id="breadcrumb-container" class="breadcrumb-container"/>
|
|
|
+ <top-nav v-if="settingsStore.topNav" id="topmenu-container" class="topmenu-container"/>
|
|
|
|
|
|
<div class="right-menu">
|
|
|
<template v-if="appStore.device !== 'mobile'">
|
|
@@ -11,15 +11,15 @@
|
|
|
<el-tooltip :content="noticeContent" effect="dark" placement="bottom">
|
|
|
<div class="right-menu-item" style="height: 70%">
|
|
|
<el-badge :value="noticeCount" :max="99" :offset="[0, 10]" :hidden="noticeCount == 0 ? true : false"
|
|
|
- class="badge-container">
|
|
|
+ class="badge-container">
|
|
|
<el-icon @click="showDetail" style="cursor: pointer;">
|
|
|
- <BellFilled />
|
|
|
+ <BellFilled/>
|
|
|
</el-icon>
|
|
|
</el-badge>
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
<!-- 弹框组件 -->
|
|
|
- <el-dialog v-model="dialogVisible" title="通知" width="30%" :before-close="close">
|
|
|
+ <el-dialog v-model="dialogVisible2" title="通知" width="30%" :before-close="closeDetailDialog">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="24">
|
|
|
<div class="dialog-item">
|
|
@@ -30,13 +30,13 @@
|
|
|
<el-col :span="24">
|
|
|
<div class="dialog-item">
|
|
|
<span class="label">类型:</span>
|
|
|
- <el-select v-model="noticeType" disabled placeholder="请选择公告类型" style="width: 90%;">
|
|
|
- <el-option
|
|
|
- v-for="dict in sys_notice_type"
|
|
|
- :key="dict.value"
|
|
|
- :label="dict.label"
|
|
|
- :value="dict.value"
|
|
|
- ></el-option>
|
|
|
+ <el-select v-model="noticeType" disabled placeholder="请选择公告类型" style="width: 90%;">
|
|
|
+ <el-option
|
|
|
+ v-for="dict in sys_notice_type"
|
|
|
+ :key="dict.value"
|
|
|
+ :label="dict.label"
|
|
|
+ :value="dict.value"
|
|
|
+ ></el-option>
|
|
|
</el-select>
|
|
|
</div>
|
|
|
</el-col>
|
|
@@ -49,28 +49,64 @@
|
|
|
</el-row>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button type="primary" @click="close">已 读</el-button>
|
|
|
+ <el-button type="primary" @click="readInfo2">已 读</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
- <header-search id="header-search" class="right-menu-item" />
|
|
|
- <screenfull id="screenfull" class="right-menu-item hover-effect" />
|
|
|
+ <el-dialog v-model="dialogVisible" title="通知" width="50%" :before-close="closeListDialog">
|
|
|
+ <el-table v-loading="loading" :data="noticeList">
|
|
|
+ <el-table-column type="selection" width="55" align="center"/>
|
|
|
+ <!-- <el-table-column label="序号" align="center" prop="notice_id" width="100" />-->
|
|
|
+ <el-table-column
|
|
|
+ label="公告标题"
|
|
|
+ align="center"
|
|
|
+ prop="notice_title"
|
|
|
+ :show-overflow-tooltip="true"
|
|
|
+ />
|
|
|
+ <el-table-column label="公告类型" align="center" prop="notice_type" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sys_notice_type" :value="scope.row.notice_type"/>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <!-- <el-table-column label="状态" align="center" prop="status" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <dict-tag :options="sys_notice_status" :value="scope.row.status" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>-->
|
|
|
+ <el-table-column label="创建者" align="center" prop="create_by" width="100"/>
|
|
|
+ <el-table-column label="创建时间" align="center" prop="create_time" width="100">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ parseTime(scope.row.create_time, '{y}-{m}-{d}') }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180px">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-button link type="primary" icon="View" @click="handleUpdate(scope.row)" v-hasPermi="['system:notice:query']">查看</el-button>
|
|
|
+ <el-button link type="primary" icon="Check" @click="readInfo(scope.row)" >已读</el-button>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </el-dialog>
|
|
|
+ <header-search id="header-search" class="right-menu-item"/>
|
|
|
+ <screenfull id="screenfull" class="right-menu-item hover-effect"/>
|
|
|
<el-tooltip content="主题模式" effect="dark" placement="bottom">
|
|
|
<div class="right-menu-item hover-effect theme-switch-wrapper" @click="toggleTheme">
|
|
|
- <svg-icon v-if="settingsStore.isDark" icon-class="sunny" />
|
|
|
- <svg-icon v-if="!settingsStore.isDark" icon-class="moon" />
|
|
|
+ <svg-icon v-if="settingsStore.isDark" icon-class="sunny"/>
|
|
|
+ <svg-icon v-if="!settingsStore.isDark" icon-class="moon"/>
|
|
|
</div>
|
|
|
</el-tooltip>
|
|
|
|
|
|
<el-tooltip content="布局大小" effect="dark" placement="bottom">
|
|
|
- <size-select id="size-select" class="right-menu-item hover-effect" />
|
|
|
+ <size-select id="size-select" class="right-menu-item hover-effect"/>
|
|
|
</el-tooltip>
|
|
|
</template>
|
|
|
<div class="avatar-container">
|
|
|
<el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click">
|
|
|
<div class="avatar-wrapper">
|
|
|
- <img :src="userStore.avatar" class="user-avatar" />
|
|
|
- <el-icon><caret-bottom /></el-icon>
|
|
|
+ <img :src="userStore.avatar" class="user-avatar"/>
|
|
|
+ <el-icon>
|
|
|
+ <caret-bottom/>
|
|
|
+ </el-icon>
|
|
|
</div>
|
|
|
<template #dropdown>
|
|
|
<el-dropdown-menu>
|
|
@@ -92,7 +128,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
-import { ElMessageBox } from 'element-plus'
|
|
|
+import {ElMessageBox} from 'element-plus'
|
|
|
import Breadcrumb from '@/components/Breadcrumb'
|
|
|
import TopNav from '@/components/TopNav'
|
|
|
import Hamburger from '@/components/Hamburger'
|
|
@@ -101,18 +137,59 @@ import SizeSelect from '@/components/SizeSelect'
|
|
|
import HeaderSearch from '@/components/HeaderSearch'
|
|
|
import pmGit from '@/components/pm/Git'
|
|
|
import pmDoc from '@/components/pm/Doc'
|
|
|
-import { listNoticeRead } from "@/api/system/menu";
|
|
|
-import { getNotice, show } from "@/api/system/notice";
|
|
|
+import {listNoticeRead} from "@/api/system/menu";
|
|
|
+import {getNotice, show} from "@/api/system/notice";
|
|
|
import useAppStore from '@/store/modules/app'
|
|
|
import useUserStore from '@/store/modules/user'
|
|
|
import useSettingsStore from '@/store/modules/settings'
|
|
|
-const { proxy } = getCurrentInstance();
|
|
|
-const { sys_notice_status, sys_notice_type } = proxy.useDict("sys_notice_status", "sys_notice_type");
|
|
|
+
|
|
|
+const {proxy} = getCurrentInstance();
|
|
|
+const {sys_notice_status, sys_notice_type} = proxy.useDict("sys_notice_status", "sys_notice_type");
|
|
|
+
|
|
|
+import {connectToWebSocket} from "@/layout/components/websocket";
|
|
|
+import {ElNotification} from 'element-plus'
|
|
|
+
|
|
|
+const announcements = ref([])
|
|
|
+
|
|
|
+connectToWebSocket((newAnnounce) => {
|
|
|
+ announcements.value.unshift(newAnnounce)
|
|
|
+ if (newAnnounce) {
|
|
|
+ // 显示右侧提示信息
|
|
|
+ // ElNotification({
|
|
|
+ // title: '新公告',
|
|
|
+ // message: '您有新的公告,请注意查收',
|
|
|
+ // type: 'warning',
|
|
|
+ // duration: 5000,
|
|
|
+ // position: 'top-right'
|
|
|
+ // });
|
|
|
+ txt("新公告", "您有新的公告,请注意查收",'warning',6000);
|
|
|
+ getlistNotice()
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const getNoticeTypeLabel = (type) => {
|
|
|
+ const dict = sys_notice_type.value.find(item => item.value === type)
|
|
|
+ return dict ? dict.label : type
|
|
|
+}
|
|
|
+
|
|
|
+const markAsRead = (noticeId) => {
|
|
|
+ show({noticeId}).then(response => {
|
|
|
+ getlistNotice()
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+function showDetail() {
|
|
|
+ //getlistNotice()
|
|
|
+ dialogVisible.value = true
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
const appStore = useAppStore()
|
|
|
const userStore = useUserStore()
|
|
|
const settingsStore = useSettingsStore()
|
|
|
|
|
|
+const noticeList = ref([]);
|
|
|
+const loading = ref(true);
|
|
|
// 定义响应式变量
|
|
|
const noticeContentV = ref('暂无消息'); // 通知内容
|
|
|
const noticeContent = ref(''); // 通知内容
|
|
@@ -120,6 +197,7 @@ const noticeCount = ref(0); // 通知数量
|
|
|
const intervalId = ref(null); // 定时器 ID
|
|
|
const notice_id = ref(null); // 通知 ID
|
|
|
const dialogVisible = ref(false); // 控制弹框显示/隐藏
|
|
|
+const dialogVisible2 = ref(false); // 控制弹框显示/隐藏
|
|
|
const noticeTitle = ref(''); // 通知标题
|
|
|
const noticeType = ref(''); // 通知类型
|
|
|
const uniqueKey = ref(0); // 新增的唯一键属性
|
|
@@ -140,6 +218,7 @@ function handleCommand(command) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
function logout() {
|
|
|
ElMessageBox.confirm('确定注销并退出系统吗?', '提示', {
|
|
|
confirmButtonText: '确定',
|
|
@@ -149,39 +228,70 @@ function logout() {
|
|
|
userStore.logOut().then(() => {
|
|
|
location.href = '/index';
|
|
|
})
|
|
|
- }).catch(() => { });
|
|
|
+ }).catch(() => {
|
|
|
+ });
|
|
|
}
|
|
|
-function showDetail() {
|
|
|
- if (noticeCount.value === 0) {
|
|
|
+
|
|
|
+// function close() {
|
|
|
+// dialogVisible.value = false;
|
|
|
+// show({ noticeId: notice_id.value }).then(response => {
|
|
|
+// getlistNotice();
|
|
|
+// })
|
|
|
+// }
|
|
|
+function readInfo(row) {
|
|
|
+ // dialogVisible.value = false; // 关闭公告列表弹框
|
|
|
+ // dialogVisible2.value = false; // 同时关闭公告详情弹框
|
|
|
+ show({noticeId: row.notice_id}).then(response => {
|
|
|
getlistNotice();
|
|
|
- return;
|
|
|
- } else {
|
|
|
- dialogVisible.value = true;
|
|
|
- }
|
|
|
+ });
|
|
|
+ txt("已读公告信息", "您已成功读取公告信息",'success',3000);
|
|
|
}
|
|
|
-function close() {
|
|
|
- dialogVisible.value = false;
|
|
|
- show({ noticeId: notice_id.value }).then(response => {
|
|
|
+function readInfo2() {
|
|
|
+ //dialogVisible.value = false; // 关闭公告列表弹框
|
|
|
+ dialogVisible2.value = false; // 同时关闭公告详情弹框
|
|
|
+ show({noticeId: notice_id.value}).then(response => {
|
|
|
getlistNotice();
|
|
|
- })
|
|
|
+ });
|
|
|
+ txt("已读公告信息", "您已成功读取公告信息",'success',3000);
|
|
|
+}
|
|
|
+
|
|
|
+function closeListDialog() {
|
|
|
+ dialogVisible.value = false;
|
|
|
}
|
|
|
+
|
|
|
+function closeDetailDialog() {
|
|
|
+ dialogVisible2.value = false;
|
|
|
+}
|
|
|
+
|
|
|
getlistNotice()
|
|
|
+
|
|
|
function getlistNotice() {
|
|
|
+ loading.value = true;
|
|
|
listNoticeRead().then((response) => {
|
|
|
// 更新唯一键以强制重新渲染
|
|
|
noticeCount.value = response.data.length;
|
|
|
- if (response.data.length > 0) {
|
|
|
- noticeContentV.value = response.data[0].notice_content;
|
|
|
- noticeTitle.value = response.data[0].notice_title;
|
|
|
- noticeType.value = response.data[0].notice_type;
|
|
|
- notice_id.value = response.data[0].notice_id;
|
|
|
- }
|
|
|
+
|
|
|
+ loading.value = false;
|
|
|
+ noticeList.value = response.data;
|
|
|
noticeContent.value = "您有" + noticeCount.value + "条未读的信息 (点击铃铛查看消息)";
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+function handleUpdate(row) {
|
|
|
+ const noticeId = row.notice_id || ids.value;
|
|
|
+ getNotice(noticeId).then(response => {
|
|
|
+ //form.value = response.data;
|
|
|
+ dialogVisible2.value = true;
|
|
|
+ noticeContentV.value = response.data.noticeContent;
|
|
|
+ noticeTitle.value = response.data.noticeTitle;
|
|
|
+ noticeType.value = response.data.noticeType;
|
|
|
+ notice_id.value = response.data.noticeId;
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
|
|
|
const emits = defineEmits(['setLayout'])
|
|
|
+
|
|
|
function setLayout() {
|
|
|
emits('setLayout');
|
|
|
}
|
|
@@ -189,6 +299,16 @@ function setLayout() {
|
|
|
function toggleTheme() {
|
|
|
settingsStore.toggleTheme()
|
|
|
}
|
|
|
+
|
|
|
+function txt(title,msg,type,time) {
|
|
|
+ ElNotification({
|
|
|
+ title: title,
|
|
|
+ message: msg,
|
|
|
+ type: type,
|
|
|
+ duration: time,
|
|
|
+ position: 'top-right'
|
|
|
+ });
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<style lang='scss' scoped>
|