2024-10-30 16:56:47 +08:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { onMounted, ref } from 'vue';
|
2025-04-07 14:48:04 +08:00
|
|
|
import { auth, columns, onDeleteBatch, onSearch, selectIds, updateMarkMessageReceived } from '@/views/message-management/message-received/utils';
|
2024-10-30 16:56:47 +08:00
|
|
|
import PureTableBar from '@/components/TableBar/src/bar';
|
|
|
|
import PureTable from '@pureadmin/table';
|
|
|
|
import Delete from '@iconify-icons/ep/delete';
|
|
|
|
import Refresh from '@iconify-icons/ep/refresh';
|
|
|
|
import { selectUserinfo } from '@/components/Table/Userinfo/columns';
|
|
|
|
import { $t } from '@/plugins/i18n';
|
|
|
|
import { useRenderIcon } from '@/components/CommonIcon/src/hooks';
|
|
|
|
import { FormInstance } from 'element-plus';
|
2025-04-07 14:48:04 +08:00
|
|
|
import { messageLevel } from '@/views/message-management/message-editing/utils';
|
2024-11-01 16:42:06 +08:00
|
|
|
import { isReadStatus } from '@/enums/baseConstant';
|
2024-11-03 21:33:23 +08:00
|
|
|
import { useMessageReceivedStore } from '@/store/message/messageReceived';
|
2024-11-04 01:11:28 +08:00
|
|
|
import { useMessageTypeStore } from '@/store/message/messageType';
|
|
|
|
import { Message } from '@element-plus/icons-vue';
|
2024-11-05 19:36:23 +08:00
|
|
|
import { hasAuth } from '@/router/utils';
|
2024-10-30 16:56:47 +08:00
|
|
|
|
|
|
|
const tableRef = ref();
|
|
|
|
const formRef = ref();
|
2024-11-03 21:33:23 +08:00
|
|
|
const messageReceivedStore = useMessageReceivedStore();
|
2024-11-04 01:11:28 +08:00
|
|
|
const messageTypeStore = useMessageTypeStore();
|
2024-10-30 16:56:47 +08:00
|
|
|
|
|
|
|
/** 当前页改变时 */
|
|
|
|
const onCurrentPageChange = async (value: number) => {
|
2024-11-03 21:33:23 +08:00
|
|
|
messageReceivedStore.pagination.currentPage = value;
|
2024-10-30 16:56:47 +08:00
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
2024-11-05 19:36:23 +08:00
|
|
|
/** 当分页发生变化 */
|
2024-10-30 16:56:47 +08:00
|
|
|
const onPageSizeChange = async (value: number) => {
|
2024-11-03 21:33:23 +08:00
|
|
|
messageReceivedStore.pagination.pageSize = value;
|
2024-10-30 16:56:47 +08:00
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
2024-11-05 19:36:23 +08:00
|
|
|
/** 选择多行 */
|
2024-10-30 16:56:47 +08:00
|
|
|
const onSelectionChange = (rows: Array<any>) => {
|
2024-11-03 21:33:23 +08:00
|
|
|
selectIds.value = rows.map((row: any) => row.id);
|
2024-10-30 16:56:47 +08:00
|
|
|
};
|
|
|
|
|
2024-11-05 19:36:23 +08:00
|
|
|
/** 重置表单 */
|
2024-10-30 16:56:47 +08:00
|
|
|
const resetForm = async (formEl: FormInstance | undefined) => {
|
|
|
|
if (!formEl) return;
|
|
|
|
formEl.resetFields();
|
|
|
|
await onSearch();
|
|
|
|
};
|
|
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
onSearch();
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
|
|
<div class="main">
|
2024-11-05 19:36:23 +08:00
|
|
|
<Auth :value="auth.search">
|
|
|
|
<el-form ref="formRef" :inline="true" :model="messageReceivedStore.form" class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px] overflow-auto">
|
|
|
|
<!-- 消息标题 -->
|
|
|
|
<el-form-item :label="$t('title')" prop="title">
|
|
|
|
<el-input v-model="messageReceivedStore.form.title" :placeholder="`${$t('input')}${$t('title')}`" class="!w-[180px]" clearable />
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 发送人昵称 -->
|
|
|
|
<el-form-item :label="$t('sendNickname')" prop="sendNickname">
|
|
|
|
<el-input v-model="messageReceivedStore.form.sendNickname" :placeholder="`${$t('input')}${$t('sendNickname')}`" class="!w-[180px]" clearable />
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 消息类型 -->
|
|
|
|
<el-form-item :label="$t('messageType')" prop="messageType">
|
|
|
|
<el-select v-model="messageReceivedStore.form.messageType" :placeholder="`${$t('select')}${$t('messageType')}`" class="!w-[180px]" clearable filterable>
|
|
|
|
<el-option v-for="(item, index) in messageTypeStore.allMessageTypeList" :key="index" :label="item.messageName" :navigationBar="false" :value="item.messageType" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 编辑器类型 -->
|
|
|
|
<el-form-item :label="$t('editorType')" prop="editorType">
|
|
|
|
<el-select v-model="messageReceivedStore.form.editorType" :placeholder="`${$t('select')}${$t('editorType')}`" class="!w-[180px]" clearable filterable>
|
|
|
|
<el-option v-for="(item, index) in ['rich', 'markdown']" :key="index" :label="item" :navigationBar="false" :value="item" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 消息等级 -->
|
|
|
|
<el-form-item :label="$t('level')" prop="level">
|
|
|
|
<el-select v-model="messageReceivedStore.form.level" :placeholder="$t('level')" class="!w-[180px]" clearable filterable remote remote-show-suffix>
|
|
|
|
<el-option v-for="item in messageLevel" :key="item" :label="$t(item)" :value="item" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 消息等级简介 -->
|
|
|
|
<el-form-item :label="$t('extra')" prop="extra">
|
|
|
|
<el-input v-model="messageReceivedStore.form.extra" class="!w-[180px]" maxlength="20" minlength="10" show-word-limit type="text" />
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<!-- 0:未读 1:已读 -->
|
|
|
|
<el-form-item :label="$t('status')" prop="status">
|
|
|
|
<el-select v-model="messageReceivedStore.form.status" :placeholder="$t('status')" class="!w-[180px]" clearable filterable remote remote-show-suffix>
|
|
|
|
<el-option v-for="(item, index) in isReadStatus" :key="index" :label="item.label" :value="item.value" />
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item>
|
|
|
|
<el-button :icon="useRenderIcon('ri:search-line')" :loading="messageReceivedStore.loading" type="primary" @click="onSearch"> {{ $t('search') }} </el-button>
|
|
|
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm(formRef)"> {{ $t('buttons.reset') }}</el-button>
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</Auth>
|
2024-10-30 16:56:47 +08:00
|
|
|
|
|
|
|
<PureTableBar :columns="columns" title="系统消息" @fullscreen="tableRef.setAdaptive()" @refresh="onSearch">
|
|
|
|
<template #buttons>
|
2024-11-03 21:33:23 +08:00
|
|
|
<!-- 标为已读 -->
|
2024-11-05 19:36:23 +08:00
|
|
|
<el-button v-if="hasAuth(auth.update)" :disabled="!(selectIds.length > 0)" :icon="useRenderIcon('octicon:read-24')" type="primary" @click="updateMarkMessageReceived(true)">
|
2024-11-03 21:33:23 +08:00
|
|
|
{{ $t('markAsRead') }}
|
|
|
|
</el-button>
|
|
|
|
|
2024-11-04 01:11:28 +08:00
|
|
|
<!-- 标为未读 -->
|
2024-11-05 19:36:23 +08:00
|
|
|
<el-button v-if="hasAuth(auth.update)" :disabled="!(selectIds.length > 0)" :icon="Message" type="primary" @click="updateMarkMessageReceived(false)">
|
2024-11-04 01:11:28 +08:00
|
|
|
{{ $t('markAsUnread') }}
|
|
|
|
</el-button>
|
|
|
|
|
2024-10-30 16:56:47 +08:00
|
|
|
<!-- 批量删除按钮 -->
|
2024-11-05 19:36:23 +08:00
|
|
|
<el-button v-if="hasAuth(auth.deleted)" :disabled="!(selectIds.length > 0)" :icon="useRenderIcon(Delete)" type="danger" @click="onDeleteBatch">
|
2024-10-30 16:56:47 +08:00
|
|
|
{{ $t('delete_batches') }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot="{ size, dynamicColumns }">
|
|
|
|
<pure-table
|
|
|
|
ref="tableRef"
|
|
|
|
:adaptiveConfig="{ offsetBottom: 96 }"
|
|
|
|
:columns="dynamicColumns"
|
2024-11-03 21:33:23 +08:00
|
|
|
:data="messageReceivedStore.datalist"
|
2024-10-30 16:56:47 +08:00
|
|
|
:header-cell-style="{ background: 'var(--el-fill-color-light)', color: 'var(--el-text-color-primary)' }"
|
2024-11-03 21:33:23 +08:00
|
|
|
:loading="messageReceivedStore.loading"
|
|
|
|
:pagination="messageReceivedStore.pagination"
|
2024-10-30 16:56:47 +08:00
|
|
|
:size="size"
|
|
|
|
adaptive
|
|
|
|
align-whole="center"
|
|
|
|
border
|
|
|
|
highlight-current-row
|
|
|
|
row-key="id"
|
|
|
|
showOverflowTooltip
|
|
|
|
table-layout="auto"
|
|
|
|
@page-size-change="onPageSizeChange"
|
|
|
|
@selection-change="onSelectionChange"
|
|
|
|
@page-current-change="onCurrentPageChange"
|
|
|
|
>
|
2024-11-04 01:11:28 +08:00
|
|
|
<template #sendNickname="{ row }">
|
|
|
|
<el-button link type="primary" @click="selectUserinfo(row.sendUserId)">
|
|
|
|
{{ row.sendNickname }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #receivedUserNickname="{ row }">
|
|
|
|
<el-button link type="primary" @click="selectUserinfo(row.receivedUserId)">
|
|
|
|
{{ row.receivedUserNickname }}
|
|
|
|
</el-button>
|
|
|
|
</template>
|
|
|
|
|
2024-11-03 18:56:28 +08:00
|
|
|
<template #cover="{ row }">
|
|
|
|
<el-image :initial-index="0" :preview-src-list="[row.cover]" :src="row.cover" class="w-[50px] h-[50px]" fit="cover" loading="lazy" preview-teleported />
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #extra="{ row }">
|
|
|
|
<el-text type="danger">{{ row.extra }}</el-text>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #messageType="{ row }">
|
|
|
|
<el-tag effect="plain" round>{{ row.messageType }}</el-tag>
|
|
|
|
</template>
|
|
|
|
|
2024-10-30 16:56:47 +08:00
|
|
|
<template #createUser="{ row }">
|
2024-10-30 23:44:10 +08:00
|
|
|
<el-button v-show="row.createUser" link type="primary" @click="selectUserinfo(row.createUser)">
|
|
|
|
{{ row.createUsername }}
|
|
|
|
</el-button>
|
2024-10-30 16:56:47 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #updateUser="{ row }">
|
2024-10-30 23:44:10 +08:00
|
|
|
<el-button v-show="row.updateUser" link type="primary" @click="selectUserinfo(row.updateUser)">
|
|
|
|
{{ row.updateUsername }}
|
|
|
|
</el-button>
|
2024-10-30 16:56:47 +08:00
|
|
|
</template>
|
|
|
|
</pure-table>
|
|
|
|
</template>
|
|
|
|
</PureTableBar>
|
|
|
|
</div>
|
|
|
|
</template>
|