2021-07-02 19:19:38 +08:00
|
|
|
<template>
|
2022-08-23 17:42:43 +08:00
|
|
|
<de-layout-content
|
2022-08-26 13:00:23 +08:00
|
|
|
:header="$t('components.message_list')"
|
2022-08-23 17:42:43 +08:00
|
|
|
v-loading="$store.getters.loadingMap[$store.getters.currentPath]"
|
|
|
|
>
|
|
|
|
<div class="organization">
|
|
|
|
<el-tabs v-model="tabActive" @tab-click="changeTab">
|
2022-08-26 13:00:23 +08:00
|
|
|
<el-tab-pane :label="$t('components.unread_message')" name="unread"> </el-tab-pane>
|
|
|
|
<el-tab-pane :label="$t('components.read_message')" name="readed"> </el-tab-pane>
|
|
|
|
<el-tab-pane :label="$t('components.all_messages')" name="allMsg"> </el-tab-pane>
|
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'">
|
|
|
|
<deBtn secondary @click="allMarkReaded">{{
|
|
|
|
$t("webmsg.all_mark_readed")
|
|
|
|
}}</deBtn>
|
|
|
|
<deBtn
|
|
|
|
secondary
|
|
|
|
:disabled="multipleSelection.length === 0"
|
|
|
|
@click="markReaded"
|
|
|
|
>{{ $t("webmsg.mark_readed") }}</deBtn
|
|
|
|
>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<deBtn
|
|
|
|
v-if="tabActive === 'readed'"
|
|
|
|
secondary
|
|
|
|
:disabled="multipleSelection.length === 0"
|
|
|
|
@click="deleteBatch"
|
|
|
|
>{{ $t("commons.delete") }}</deBtn
|
|
|
|
>
|
|
|
|
|
|
|
|
</el-col>
|
|
|
|
<el-col class="right-user" :span="12">
|
|
|
|
<el-select
|
|
|
|
class="name-email-search"
|
|
|
|
v-model="selectType"
|
|
|
|
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"
|
|
|
|
></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
<div class="table-container" :key="tabActive">
|
|
|
|
<grid-table
|
|
|
|
:key="tabActive"
|
|
|
|
:tableData="data"
|
|
|
|
:multipleSelection="multipleSelection"
|
|
|
|
:columns="[]"
|
|
|
|
:pagination="paginationConfig"
|
|
|
|
@selection-change="handleSelectionChange"
|
|
|
|
@sort-change="sortChange"
|
|
|
|
@size-change="handleSizeChange"
|
|
|
|
@current-change="handleCurrentChange"
|
|
|
|
>
|
|
|
|
<el-table-column type="selection" width="55" />
|
2021-07-02 19:19:38 +08:00
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
<el-table-column prop="content" :label="$t('webmsg.content')">
|
|
|
|
<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"
|
|
|
|
/>
|
|
|
|
<svg-icon v-else icon-class="readed-msg" />
|
|
|
|
</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-08-23 17:42:43 +08:00
|
|
|
import DeLayoutContent from "@/components/business/DeLayoutContent";
|
|
|
|
import GridTable from "@/components/gridTable/index.vue";
|
|
|
|
import { query, updateStatus, batchRead, allRead, batchDelete } from '@/api/system/msg'
|
|
|
|
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,
|
|
|
|
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: [],
|
|
|
|
tabActive: "unread",
|
2021-07-02 19:19:38 +08:00
|
|
|
selectType: -1,
|
|
|
|
msgTypes: msgTypes,
|
|
|
|
data: [],
|
2022-08-23 17:42:43 +08:00
|
|
|
allTypes: [
|
|
|
|
{ name: "mysql", type: "jdbc" },
|
|
|
|
{ name: "sqlServer", type: "jdbc" },
|
|
|
|
],
|
2021-07-02 19:19:38 +08:00
|
|
|
|
|
|
|
columns: [],
|
|
|
|
|
|
|
|
paginationConfig: {
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 10,
|
2022-08-23 17:42:43 +08:00
|
|
|
total: 0,
|
2021-07-06 15:24:34 +08:00
|
|
|
},
|
2022-08-23 17:42:43 +08:00
|
|
|
orderConditions: [],
|
|
|
|
};
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2021-07-29 17:59:31 +08:00
|
|
|
computed: {
|
2022-08-23 17:42:43 +08:00
|
|
|
...mapGetters(["permission_routes"]),
|
2021-07-29 17:59:31 +08:00
|
|
|
},
|
2021-07-02 19:19:38 +08:00
|
|
|
mounted() {
|
2022-08-23 17:42:43 +08:00
|
|
|
this.search();
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
2021-07-09 18:37:07 +08:00
|
|
|
created() {
|
|
|
|
// 先加载消息类型
|
2022-08-23 17:42:43 +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) {
|
|
|
|
this.initSearch();
|
|
|
|
},
|
|
|
|
handleSelectionChange(val) {
|
|
|
|
this.multipleSelection = val;
|
|
|
|
},
|
|
|
|
handleSizeChange(pageSize) {
|
|
|
|
this.paginationConfig.currentPage = 1;
|
|
|
|
this.paginationConfig.pageSize = pageSize;
|
|
|
|
this.search();
|
|
|
|
},
|
|
|
|
handleCurrentChange(currentPage) {
|
|
|
|
this.paginationConfig.currentPage = currentPage;
|
|
|
|
this.search();
|
|
|
|
},
|
|
|
|
initSearch() {
|
|
|
|
this.handleCurrentChange(1);
|
|
|
|
},
|
|
|
|
allMarkReaded() {
|
|
|
|
allRead().then(res => {
|
2022-08-26 13:00:23 +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 => {
|
|
|
|
this.openMessageSuccess('webmsg.mark_success');
|
|
|
|
bus.$emit('refresh-top-notification')
|
|
|
|
this.initSearch()
|
|
|
|
})
|
|
|
|
},
|
|
|
|
deleteBatch() {
|
|
|
|
const param = this.multipleSelection.map(item => item.msgId)
|
|
|
|
batchDelete(param).then(res => {
|
|
|
|
this.openMessageSuccess('commons.delete_success');
|
|
|
|
this.initSearch()
|
|
|
|
})
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
search() {
|
2022-08-23 17:42:43 +08:00
|
|
|
const param = {};
|
2021-07-02 19:19:38 +08:00
|
|
|
|
|
|
|
if (this.selectType >= 0) {
|
2022-08-23 17:42:43 +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-08-23 17:42:43 +08:00
|
|
|
param.orders = ["create_time desc "];
|
2021-07-06 15:24:34 +08:00
|
|
|
} else {
|
2022-08-23 17:42:43 +08:00
|
|
|
param.orders = formatOrders(this.orderConditions);
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
|
|
|
|
2022-08-23 17:42:43 +08:00
|
|
|
if (this.tabActive !== "allMsg") {
|
|
|
|
param.status = this.tabActive === "readed";
|
|
|
|
}
|
|
|
|
|
|
|
|
const { currentPage, pageSize } = this.paginationConfig;
|
|
|
|
query(currentPage, pageSize, param).then((response) => {
|
|
|
|
this.data = response.data.listObject;
|
|
|
|
this.paginationConfig.total = response.data.itemCount;
|
|
|
|
});
|
2021-07-02 19:19:38 +08:00
|
|
|
},
|
|
|
|
getTypeName(value) {
|
2022-08-23 17:42:43 +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() {
|
|
|
|
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,
|
|
|
|
sourceParam: row.param,
|
|
|
|
},
|
|
|
|
};
|
2021-07-29 17:59:31 +08:00
|
|
|
if (this.hasPermissionRoute(row.router)) {
|
2022-08-23 17:42:43 +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-08-23 17:42:43 +08:00
|
|
|
this.$warning(this.$t("commons.no_target_permission"));
|
2021-07-29 17:59:31 +08:00
|
|
|
},
|
|
|
|
hasPermissionRoute(name, permission_routes) {
|
2022-08-23 17:42:43 +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-08-23 17:42:43 +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-08-23 17:42:43 +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) => {
|
|
|
|
bus.$emit("refresh-top-notification");
|
|
|
|
this.search();
|
|
|
|
});
|
2021-07-06 15:24:34 +08:00
|
|
|
},
|
|
|
|
sortChange({ column, prop, order }) {
|
2022-08-23 17:42:43 +08:00
|
|
|
this.orderConditions = [];
|
2021-07-06 15:24:34 +08:00
|
|
|
if (!order) {
|
2022-08-23 17:42:43 +08:00
|
|
|
this.search();
|
|
|
|
return;
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
2022-08-23 17:42:43 +08:00
|
|
|
if (prop === "createTime") {
|
|
|
|
prop = "create_time";
|
2021-07-06 15:24:34 +08:00
|
|
|
}
|
2022-08-23 17:42:43 +08:00
|
|
|
if (prop === "typeId") {
|
|
|
|
prop = "type_id";
|
2021-07-22 16:59:34 +08:00
|
|
|
}
|
2022-08-23 17:42:43 +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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|