2021-07-02 19:19:38 +08:00
|
|
|
<template>
|
2022-08-23 17:42:43 +08:00
|
|
|
<de-layout-content
|
|
|
|
v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
|
2022-10-11 15:09:32 +08:00
|
|
|
:header="$t('components.message_list')"
|
2022-08-23 17:42:43 +08:00
|
|
|
>
|
|
|
|
<div class="organization">
|
2022-10-11 15:09:32 +08:00
|
|
|
<el-tabs
|
|
|
|
v-model="tabActive"
|
|
|
|
@tab-click="changeTab"
|
|
|
|
>
|
|
|
|
<el-tab-pane
|
|
|
|
:label="$t('components.unread_message')"
|
|
|
|
name="unread"
|
|
|
|
/>
|
|
|
|
<el-tab-pane
|
|
|
|
:label="$t('components.read_message')"
|
|
|
|
name="readed"
|
|
|
|
/>
|
|
|
|
<el-tab-pane
|
|
|
|
:label="$t('components.all_messages')"
|
|
|
|
name="allMsg"
|
|
|
|
/>
|
2022-08-23 17:42:43 +08:00
|
|
|
</el-tabs>
|
|
|
|
<div class="tabs-container">
|
|
|
|
<div class="msg-cont">
|
|
|
|
<el-row class="top-operate">
|
|
|
|
<el-col :span="12">
|
|
|
|
<template v-if="tabActive === 'unread'">
|
2022-10-11 15:09:32 +08:00
|
|
|
<deBtn
|
|
|
|
secondary
|
|
|
|
@click="allMarkReaded"
|
|
|
|
>{{
|
|
|
|
$t("webmsg.all_mark_readed")
|
|
|
|
}}</deBtn>
|
|
|
|
<deBtn
|
|
|
|
key="mark_readed"
|
|
|
|
secondary
|
|
|
|
:disabled="multipleSelection.length === 0"
|
|
|
|
@click="markReaded"
|
|
|
|
>{{ $t("webmsg.mark_readed") }}</deBtn>
|
2022-08-23 17:42:43 +08:00
|
|
|
</template>
|
2022-10-11 15:09:32 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
<deBtn
|
|
|
|
v-if="tabActive === 'readed'"
|
2022-08-31 23:53:31 +08:00
|
|
|
key="delete"
|
2022-10-11 15:09:32 +08:00
|
|
|
secondary
|
2022-08-23 17:42:43 +08:00
|
|
|
:disabled="multipleSelection.length === 0"
|
|
|
|
@click="deleteBatch"
|
2022-10-11 15:09:32 +08:00
|
|
|
>{{ $t("commons.delete") }}</deBtn>
|
2022-08-23 17:42:43 +08:00
|
|
|
|
|
|
|
</el-col>
|
2022-10-11 15:09:32 +08:00
|
|
|
<el-col
|
|
|
|
class="right-user"
|
|
|
|
:span="12"
|
|
|
|
>
|
2022-08-23 17:42:43 +08:00
|
|
|
<el-select
|
|
|
|
v-model="selectType"
|
2022-10-11 15:09:32 +08:00
|
|
|
class="name-email-search"
|
2022-08-23 17:42:43 +08:00
|
|
|
size="small"
|
|
|
|
@change="typeChange"
|
|
|
|
>
|
|
|
|
<el-option
|
|
|
|
v-for="(item, index) in $store.getters.msgTypes.filter(
|
|
|
|
(type) => type.pid <= 0
|
|
|
|
)"
|
|
|
|
:key="index"
|
|
|
|
:label="$t('webmsg.' + item.typeName)"
|
|
|
|
:value="item.msgTypeId"
|
2022-10-11 15:09:32 +08:00
|
|
|
/>
|
2022-08-23 17:42:43 +08:00
|
|
|
</el-select>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
2022-10-11 15:09:32 +08:00
|
|
|
<div
|
|
|
|
:key="tabActive"
|
|
|
|
class="table-container"
|
|
|
|
>
|
2022-08-23 17:42:43 +08:00
|
|
|
<grid-table
|
|
|
|
:key="tabActive"
|
2022-10-11 15:09:32 +08:00
|
|
|
:table-data="data"
|
|
|
|
:multiple-selection="multipleSelection"
|
2022-08-23 17:42:43 +08:00
|
|
|
:columns="[]"
|
|
|
|
:pagination="paginationConfig"
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
@sort-change="sortChange"
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
>
|
2022-10-11 15:09:32 +08:00
|
|
|
<el-table-column
|
|
|
|
type="selection"
|
|
|
|
width="55"
|
|
|
|
/>
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-10-11 15:09:32 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="content"
|
|
|
|
:label="$t('webmsg.content')"
|
|
|
|
>
|
2022-08-23 17:42:43 +08:00
|
|
|
<template slot-scope="scope">
|
|
|
|
<span style="display: flex; flex: 1">
|
|
|
|
<span>
|
|
|
|
<svg-icon
|
|
|
|
v-if="!scope.row.status"
|
|
|
|
icon-class="unread-msg"
|
|
|
|
style="color: red"
|
|
|
|
/>
|
2022-10-11 15:09:32 +08:00
|
|
|
<svg-icon
|
|
|
|
v-else
|
|
|
|
icon-class="readed-msg"
|
|
|
|
/>
|
2022-08-23 17:42:43 +08:00
|
|
|
</span>
|
|
|
|
<span
|
|
|
|
style="margin-left: 6px"
|
|
|
|
class="de-msg-a"
|
|
|
|
@click="toDetail(scope.row)"
|
|
|
|
>
|
|
|
|
{{ scope.row.content }}
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="createTime"
|
|
|
|
sortable="custom"
|
|
|
|
:label="$t('webmsg.sned_time')"
|
|
|
|
width="180"
|
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ scope.row.createTime | timestampFormatDate }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
<el-table-column
|
|
|
|
prop="typeId"
|
|
|
|
sortable="custom"
|
|
|
|
:label="$t('webmsg.type')"
|
|
|
|
width="140"
|
|
|
|
>
|
|
|
|
<template slot-scope="scope">
|
|
|
|
<span>{{ getTypeName(scope.row.typeId) }}</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</grid-table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</de-layout-content>
|
2021-07-02 19:19:38 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2022-10-11 15:09:32 +08:00
|
|
|
import DeLayoutContent from '@/components/business/DeLayoutContent'
|
|
|
|
import GridTable from '@/components/gridTable/index.vue'
|
2022-08-23 17:42:43 +08:00
|
|
|
import { query, updateStatus, batchRead, allRead, batchDelete } from '@/api/system/msg'
|
2022-10-11 15:09:32 +08:00
|
|
|
import { msgTypes, getTypeName, loadMsgTypes } from '@/utils/webMsg'
|
|
|
|
import bus from '@/utils/bus'
|
|
|
|
import { addOrder, formatOrders } from '@/utils/index'
|
|
|
|
import msgCfm from '@/components/msgCfm/index'
|
|
|
|
import { mapGetters } from 'vuex'
|
2021-07-02 19:19:38 +08:00
|
|
|
export default {
|
|
|
|
components: {
|
2022-08-23 17:42:43 +08:00
|
|
|
DeLayoutContent,
|
2022-10-11 15:09:32 +08:00
|
|
|
GridTable
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2022-08-23 17:42:43 +08:00
|
|
|
mixins: [msgCfm],
|
2021-07-02 19:19:38 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2022-08-23 17:42:43 +08:00
|
|
|
multipleSelection: [],
|
2022-10-11 15:09:32 +08:00
|
|
|
tabActive: 'unread',
|
2021-07-02 19:19:38 +08:00
|
|
|
selectType: -1,
|
|
|
|
msgTypes: msgTypes,
|
|
|
|
data: [],
|
2022-08-23 17:42:43 +08:00
|
|
|
allTypes: [
|
2022-10-11 15:09:32 +08:00
|
|
|
{ name: 'mysql', type: 'jdbc' },
|
|
|
|
{ name: 'sqlServer', type: 'jdbc' }
|
2022-08-23 17:42:43 +08:00
|
|
|
],
|
2021-07-02 19:19:38 +08:00
|
|
|
|
|
|
|
columns: [],
|
|
|
|
|
|
|
|
paginationConfig: {
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 10,
|
2022-10-11 15:09:32 +08:00
|
|
|
total: 0
|
2021-07-06 15:24:34 +08:00
|
|
|
},
|
2022-10-11 15:09:32 +08:00
|
|
|
orderConditions: []
|
|
|
|
}
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2021-07-29 17:59:31 +08:00
|
|
|
computed: {
|
2022-10-11 15:09:32 +08:00
|
|
|
...mapGetters(['permission_routes'])
|
2021-07-29 17:59:31 +08:00
|
|
|
},
|
2021-07-02 19:19:38 +08:00
|
|
|
mounted() {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.search()
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2021-07-09 18:37:07 +08:00
|
|
|
created() {
|
|
|
|
// 先加载消息类型
|
2022-10-11 15:09:32 +08:00
|
|
|
loadMsgTypes()
|
2021-07-09 18:37:07 +08:00
|
|
|
},
|
2021-07-02 19:19:38 +08:00
|
|
|
methods: {
|
2022-08-23 17:42:43 +08:00
|
|
|
changeTab(val) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.initSearch()
|
2022-08-23 17:42:43 +08:00
|
|
|
},
|
|
|
|
handleSelectionChange(val) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.multipleSelection = val
|
2022-08-23 17:42:43 +08:00
|
|
|
},
|
|
|
|
handleSizeChange(pageSize) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.paginationConfig.currentPage = 1
|
|
|
|
this.paginationConfig.pageSize = pageSize
|
|
|
|
this.search()
|
2022-08-23 17:42:43 +08:00
|
|
|
},
|
|
|
|
handleCurrentChange(currentPage) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.paginationConfig.currentPage = currentPage
|
|
|
|
this.search()
|
2022-08-23 17:42:43 +08:00
|
|
|
},
|
|
|
|
initSearch() {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.handleCurrentChange(1)
|
2022-08-23 17:42:43 +08:00
|
|
|
},
|
|
|
|
allMarkReaded() {
|
|
|
|
allRead().then(res => {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.openMessageSuccess('components.all_read_successfully')
|
2022-08-23 17:42:43 +08:00
|
|
|
bus.$emit('refresh-top-notification')
|
|
|
|
this.initSearch()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
markReaded() {
|
|
|
|
const param = this.multipleSelection.map(item => item.msgId)
|
|
|
|
batchRead(param).then(res => {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.openMessageSuccess('webmsg.mark_success')
|
2022-08-23 17:42:43 +08:00
|
|
|
bus.$emit('refresh-top-notification')
|
|
|
|
this.initSearch()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteBatch() {
|
|
|
|
const param = this.multipleSelection.map(item => item.msgId)
|
|
|
|
batchDelete(param).then(res => {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.openMessageSuccess('commons.delete_success')
|
2022-08-23 17:42:43 +08:00
|
|
|
this.initSearch()
|
|
|
|
})
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
search() {
|
2022-10-11 15:09:32 +08:00
|
|
|
const param = {}
|
2021-07-02 19:19:38 +08:00
|
|
|
|
|
|
|
if (this.selectType >= 0) {
|
2022-10-11 15:09:32 +08:00
|
|
|
param.type = this.selectType
|
2021-07-02 19:19:38 +08:00
|
|
|
}
|
2021-07-06 15:24:34 +08:00
|
|
|
|
|
|
|
if (this.orderConditions.length === 0) {
|
2022-10-11 15:09:32 +08:00
|
|
|
param.orders = ['create_time desc ']
|
2021-07-06 15:24:34 +08:00
|
|
|
} else {
|
2022-10-11 15:09:32 +08:00
|
|
|
param.orders = formatOrders(this.orderConditions)
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
|
|
|
|
2022-10-11 15:09:32 +08:00
|
|
|
if (this.tabActive !== 'allMsg') {
|
|
|
|
param.status = this.tabActive === 'readed'
|
2022-08-23 17:42:43 +08:00
|
|
|
}
|
|
|
|
|
2022-10-11 15:09:32 +08:00
|
|
|
const { currentPage, pageSize } = this.paginationConfig
|
2022-08-23 17:42:43 +08:00
|
|
|
query(currentPage, pageSize, param).then((response) => {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.data = response.data.listObject
|
|
|
|
this.paginationConfig.total = response.data.itemCount
|
|
|
|
})
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
getTypeName(value) {
|
2022-10-11 15:09:32 +08:00
|
|
|
return this.$t('webmsg.' + getTypeName(value))
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2022-08-23 17:42:43 +08:00
|
|
|
typeChange() {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.initSearch()
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
toDetail(row) {
|
2022-08-23 17:42:43 +08:00
|
|
|
const param = {
|
|
|
|
...{
|
|
|
|
msgNotification: true,
|
|
|
|
msgType: row.typeId,
|
2022-10-11 15:09:32 +08:00
|
|
|
sourceParam: row.param
|
|
|
|
}
|
|
|
|
}
|
2021-07-29 17:59:31 +08:00
|
|
|
if (this.hasPermissionRoute(row.router)) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.$router.push({ name: row.router, params: param })
|
|
|
|
row.status || this.setReaded(row)
|
|
|
|
return
|
2021-07-29 17:59:31 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
this.$warning(this.$t('commons.no_target_permission'))
|
2021-07-29 17:59:31 +08:00
|
|
|
},
|
|
|
|
hasPermissionRoute(name, permission_routes) {
|
2022-10-11 15:09:32 +08:00
|
|
|
permission_routes = permission_routes || this.permission_routes
|
2021-07-29 17:59:31 +08:00
|
|
|
for (let index = 0; index < permission_routes.length; index++) {
|
2022-10-11 15:09:32 +08:00
|
|
|
const route = permission_routes[index]
|
|
|
|
if (route.name && route.name === name) return true
|
|
|
|
if (route.children && this.hasPermissionRoute(name, route.children)) { return true }
|
2021-07-29 17:59:31 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
return false
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
// 设置已读
|
|
|
|
setReaded(row) {
|
2022-08-23 17:42:43 +08:00
|
|
|
updateStatus(row.msgId).then((res) => {
|
2022-10-11 15:09:32 +08:00
|
|
|
bus.$emit('refresh-top-notification')
|
|
|
|
this.search()
|
|
|
|
})
|
2021-07-06 15:24:34 +08:00
|
|
|
},
|
|
|
|
sortChange({ column, prop, order }) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.orderConditions = []
|
2021-07-06 15:24:34 +08:00
|
|
|
if (!order) {
|
2022-10-11 15:09:32 +08:00
|
|
|
this.search()
|
|
|
|
return
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
if (prop === 'createTime') {
|
|
|
|
prop = 'create_time'
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
if (prop === 'typeId') {
|
|
|
|
prop = 'type_id'
|
2021-07-22 16:59:34 +08:00
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
addOrder({ field: prop, value: order }, this.orderConditions)
|
|
|
|
this.search()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-02 19:19:38 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
2022-08-23 17:42:43 +08:00
|
|
|
.de-msg-a:hover {
|
|
|
|
text-decoration: underline !important;
|
|
|
|
color: #0a7be0 !important;
|
|
|
|
cursor: pointer !important;
|
|
|
|
}
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
.table-container {
|
|
|
|
height: calc(100% - 50px);
|
|
|
|
}
|
|
|
|
.top-operate {
|
|
|
|
margin-bottom: 16px;
|
|
|
|
.right-user {
|
|
|
|
text-align: right;
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
|
|
|
.name-email-search {
|
|
|
|
width: 240px;
|
2021-07-02 19:19:38 +08:00
|
|
|
}
|
|
|
|
}
|
2022-08-23 17:42:43 +08:00
|
|
|
</style>
|
|
|
|
<style scoped lang="scss">
|
|
|
|
.organization {
|
|
|
|
height: 100%;
|
|
|
|
background-color: var(--MainBG, #f5f6f7);
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
.tabs-container {
|
|
|
|
height: calc(100% - 48px);
|
|
|
|
background: var(--ContentBG, #ffffff);
|
|
|
|
overflow-x: auto;
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
.msg-cont {
|
|
|
|
padding: 24px;
|
|
|
|
height: 100%;
|
|
|
|
box-sizing: border-box;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2022-10-11 15:09:32 +08:00
|
|
|
</style>
|