2021-07-02 19:19:38 +08:00
|
|
|
<template>
|
|
|
|
|
|
|
|
<el-popover
|
|
|
|
|
|
|
|
v-model="visible"
|
|
|
|
width="350"
|
|
|
|
trigger="click"
|
|
|
|
placement="top-end"
|
|
|
|
style="display: flex;align-items: center;"
|
|
|
|
class="international"
|
|
|
|
>
|
|
|
|
<div style="height: 30px;">
|
|
|
|
<div style="float: left;font-size:16px;font-weight:bold;">
|
2021-07-03 18:01:30 +08:00
|
|
|
<span>{{ $t('webmsg.web_msg') }}</span>
|
2021-07-02 19:19:38 +08:00
|
|
|
</div>
|
|
|
|
<div v-if="showSetting" style="float: right;">
|
|
|
|
<a href="#" style="text-detext-decoratext-decoration:none;cursor:point;" @click="msgSetting">消息规则</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<el-divider class="msg-line-class" />
|
|
|
|
<el-table
|
|
|
|
class="de-msg-data-table"
|
|
|
|
:data="data"
|
|
|
|
:show-header="false"
|
|
|
|
:highlight-current-row="true"
|
|
|
|
style="width: 100%"
|
|
|
|
>
|
|
|
|
<el-table-column prop="content" :label="$t('commons.name')">
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<div class="start-item">
|
|
|
|
<div class="filter-db-row star-item-content" @click="showDetail(scope.row)">
|
|
|
|
<!-- <svg-icon icon-class="panel" class="ds-icon-scene" /> -->
|
2021-07-03 18:01:30 +08:00
|
|
|
<div class="title-div"><span>【{{ $t(getTypeName(scope.row.type)) }}】 {{ scope.row.content }}</span></div>
|
2021-07-02 19:19:38 +08:00
|
|
|
<div class="title-div"><span>{{ scope.row.createTime | timestampFormatDate }}</span></div>
|
|
|
|
</div>
|
|
|
|
<!-- <div class="star-item-close">
|
|
|
|
<i class="el-icon-delete " @click="remove(scope.row)" />
|
|
|
|
</div> -->
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
2021-07-06 15:24:34 +08:00
|
|
|
<div class="msg-foot-class" @click="showMore">
|
2021-07-02 19:19:38 +08:00
|
|
|
<el-row style="padding: 5px 0;margin-bottom: -5px;cursor:point;" @click="showMore">
|
2021-07-06 15:24:34 +08:00
|
|
|
<span>{{ $t('webmsg.show_more') }}</span>
|
2021-07-02 19:19:38 +08:00
|
|
|
</el-row>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div slot="reference">
|
|
|
|
<div>
|
|
|
|
<svg-icon
|
|
|
|
class-name="notification"
|
|
|
|
icon-class="notification"
|
|
|
|
/>
|
2021-07-03 18:01:30 +08:00
|
|
|
<span v-if="paginationConfig.total" class="msg-number">{{ paginationConfig.total }}</span>
|
2021-07-02 19:19:38 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</el-popover>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { query, updateStatus } from '@/api/system/msg'
|
|
|
|
import { msgTypes, getTypeName } from '@/utils/webMsg'
|
2021-07-06 15:24:34 +08:00
|
|
|
import { mapGetters } from 'vuex'
|
|
|
|
import bus from '@/utils/bus'
|
2021-07-02 19:19:38 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
msgTypes: msgTypes,
|
|
|
|
showSetting: false,
|
|
|
|
data: [],
|
|
|
|
visible: false,
|
|
|
|
paginationConfig: {
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 5,
|
|
|
|
total: 0
|
2021-07-05 18:18:06 +08:00
|
|
|
},
|
|
|
|
timer: null
|
2021-07-02 19:19:38 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
2021-07-06 15:24:34 +08:00
|
|
|
...mapGetters([
|
|
|
|
'permission_routes'
|
|
|
|
])
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.search()
|
2021-07-03 18:01:30 +08:00
|
|
|
// 每30s定时刷新拉取消息
|
2021-07-05 18:18:06 +08:00
|
|
|
this.timer = setInterval(() => {
|
2021-07-03 18:01:30 +08:00
|
|
|
this.search()
|
|
|
|
}, 30000)
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2021-07-06 15:24:34 +08:00
|
|
|
mounted() {
|
|
|
|
bus.$on('refresh-top-notification', () => {
|
|
|
|
this.search()
|
|
|
|
})
|
|
|
|
},
|
2021-07-05 18:18:06 +08:00
|
|
|
beforeDestroy() {
|
|
|
|
this.timer && clearInterval(this.timer)
|
|
|
|
},
|
|
|
|
destroyed() {
|
|
|
|
this.timer && clearInterval(this.timer)
|
|
|
|
},
|
2021-07-02 19:19:38 +08:00
|
|
|
methods: {
|
2021-07-05 18:18:06 +08:00
|
|
|
// handClick(lang) {
|
|
|
|
// console.log(lang)
|
|
|
|
// },
|
2021-07-02 19:19:38 +08:00
|
|
|
showDetail(row) {
|
2021-07-03 18:01:30 +08:00
|
|
|
const param = { ...{ msgNotification: true, msgType: row.type, sourceParam: row.param }}
|
2021-07-02 19:19:38 +08:00
|
|
|
this.visible = false
|
2021-07-06 15:24:34 +08:00
|
|
|
if (this.$route && this.$route.name && this.$route.name.includes('panel') && row.type === 0) {
|
|
|
|
bus.$emit('to-msg-share', param)
|
|
|
|
} else if (this.$route && this.$route.name && this.$route.name.includes('dataset') && row.type === 1) {
|
|
|
|
bus.$emit('to-msg-dataset', param)
|
|
|
|
} else {
|
|
|
|
this.$router.push({ name: row.router, params: param })
|
|
|
|
}
|
|
|
|
|
|
|
|
row.status || this.setReaded(row.msgId)
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
remove(row) {
|
|
|
|
|
|
|
|
},
|
|
|
|
msgSetting() {
|
|
|
|
|
|
|
|
},
|
|
|
|
showMore() {
|
|
|
|
const routerName = 'sys-msg-web-all'
|
|
|
|
this.visible = false
|
|
|
|
this.$router.push({ name: routerName })
|
2021-07-06 15:24:34 +08:00
|
|
|
this.openSystem()
|
|
|
|
},
|
|
|
|
openSystem() {
|
|
|
|
const path = '/system'
|
|
|
|
let route = this.permission_routes.find(
|
|
|
|
item => item.path === '/' + path.split('/')[1]
|
|
|
|
)
|
|
|
|
// 如果找不到这个路由,说明是首页
|
|
|
|
if (!route) {
|
|
|
|
route = this.permission_routes.find(item => item.path === '/')
|
|
|
|
}
|
|
|
|
this.$store.commit('permission/SET_CURRENT_ROUTES', route)
|
|
|
|
// this.setSidebarHide(route)
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
search() {
|
2021-07-03 18:01:30 +08:00
|
|
|
const param = {
|
2021-07-06 15:24:34 +08:00
|
|
|
status: false,
|
|
|
|
orders: [' create_time desc ']
|
2021-07-03 18:01:30 +08:00
|
|
|
}
|
2021-07-02 19:19:38 +08:00
|
|
|
const { currentPage, pageSize } = this.paginationConfig
|
|
|
|
query(currentPage, pageSize, param).then(response => {
|
|
|
|
this.data = response.data.listObject
|
|
|
|
this.paginationConfig.total = response.data.itemCount
|
|
|
|
})
|
|
|
|
},
|
|
|
|
getTypeName(value) {
|
|
|
|
return getTypeName(value)
|
|
|
|
},
|
|
|
|
open() {
|
|
|
|
this.visible = true
|
|
|
|
},
|
|
|
|
// 设置已读
|
|
|
|
setReaded(msgId) {
|
|
|
|
updateStatus(msgId).then(res => {
|
|
|
|
this.search()
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.msg-number {
|
|
|
|
min-width: 14px;
|
|
|
|
text-align: center;
|
|
|
|
line-height: 14px;
|
|
|
|
display: inline-block;
|
|
|
|
position: fixed;
|
|
|
|
right: 155px;
|
|
|
|
top: 8px;
|
|
|
|
background: red;
|
|
|
|
color: #fff;
|
|
|
|
border-radius: 17px;
|
|
|
|
padding: 4px 7px;
|
|
|
|
font-size: 16px;
|
|
|
|
transform: scale(.7);
|
|
|
|
font-family: Tahoma!important;
|
|
|
|
}
|
|
|
|
.title-div {
|
|
|
|
|
|
|
|
width: 100%;
|
|
|
|
span {
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
-o-text-overflow: ellipsis;
|
|
|
|
white-space:nowrap;
|
|
|
|
width:290px;
|
|
|
|
height:24px;
|
|
|
|
display:block;
|
|
|
|
font-size: 10px !important;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.msg-line-class {
|
|
|
|
margin: 0 0 !important;
|
|
|
|
}
|
|
|
|
.msg-foot-class {
|
|
|
|
padding-top: 5px;
|
|
|
|
:hover {
|
|
|
|
cursor: pointer;
|
|
|
|
background-color: #f4f4f5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|