😎调整站内信页面

This commit is contained in:
zuohuaijun 2024-07-01 02:47:16 +08:00
parent 62878fb55c
commit fc685e7044
7 changed files with 142 additions and 106 deletions

View File

@ -1,70 +1,79 @@
<template>
<div class="notice-container">
<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
<el-form :model="state.queryParams" ref="queryForm" :inline="true">
<el-form-item label="标题">
<el-input v-model="state.queryParams.title" placeholder="标题" clearable />
</el-form-item>
<el-form-item label="类型">
<el-select v-model="state.queryParams.type" placeholder="类型" clearable>
<el-option label="通知" :value="1" />
<el-option label="公告" :value="2" />
</el-select>
</el-form-item>
<el-form-item>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery"> 重置 </el-button>
</el-button-group>
</el-form-item>
<div class="notice-container" v-loading="options.loading">
<el-card shadow="hover" :body-style="{ padding: '5px 5px 0 5px', display: 'flex', width: '100%', height: '100%', alignItems: 'start' }">
<el-form :model="state.queryParams" ref="queryForm" :show-message="false" :inlineMessage="true" :label-width="'60px'" style="flex: 1 1 0%">
<el-row :gutter="10">
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="标题" prop="title">
<el-input v-model="state.queryParams.title" placeholder="标题" clearable @keyup.enter.native="handleQuery(true)" />
</el-form-item>
</el-col>
<el-col class="mb5" :xs="24" :sm="12" :md="8" :lg="6" :xl="6">
<el-form-item label="类型" prop="type">
<el-select v-model="state.queryParams.type" placeholder="类型" clearable @clear="state.queryParams.type = undefined">
<el-option label="通知" :value="1" />
<el-option label="公告" :value="2" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
<el-divider style="height: calc(100% - 5px); margin: 0 10px" direction="vertical" />
<el-row>
<el-col>
<el-button-group>
<el-button type="primary" icon="ele-Search" @click="handleQuery(true)" :loading="options.loading"> 查询 </el-button>
<el-button icon="ele-Refresh" @click="resetQuery" :loading="options.loading"> 重置 </el-button>
</el-button-group>
</el-col>
</el-row>
</el-card>
<el-card class="full-table" shadow="hover" style="margin-top: 5px">
<el-table :data="state.noticeData" style="width: 100%" v-loading="state.loading" border :row-class-name="tableRowClassName">
<el-table-column type="index" label="序号" width="55" align="center" />
<el-table-column prop="sysNotice.title" label="标题" header-align="center" show-overflow-tooltip />
<el-table-column prop="sysNotice.content" label="内容" header-align="center" show-overflow-tooltip>
<template #default="scope"> {{ removeHtml(scope.row.sysNotice.content) }} </template>
</el-table-column>
<el-table-column prop="sysNotice.type" label="类型" width="100" align="center" show-overflow-tooltip>
<template #default="scope">
<el-tag v-if="scope.row.sysNotice.type === 1"> 通知 </el-tag>
<el-tag type="warning" v-else> 公告 </el-tag>
</template>
</el-table-column>
<el-table-column prop="sysNotice.createTime" label="创建时间" align="center" show-overflow-tooltip />
<el-table-column prop="readStatus" label="阅读状态" width="100" align="center" show-overflow-tooltip>
<template #default="scope">
<el-tag type="info" v-if="scope.row.readStatus === 1"> 已读 </el-tag>
<el-tag type="danger" v-else> 未读 </el-tag>
</template>
</el-table-column>
<el-table-column prop="sysNotice.publicUserName" label="发布者" align="center" show-overflow-tooltip />
<el-table-column prop="sysNotice.publicTime" label="发布时间" align="center" show-overflow-tooltip />
<el-table-column label="操作" width="80" fixed="right" align="center" show-overflow-tooltip>
<template #default="scope">
<el-button icon="ele-InfoFilled" size="small" text type="primary" @click="viewDetail(scope.row)"> 详情 </el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
v-model:currentPage="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
:page-sizes="[10, 20, 50, 100]"
small
background
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
layout="total, sizes, prev, pager, next, jumper"
/>
<vxe-grid ref="xGrid" class="xGrid-style" v-bind="options" @cell-dblclick="({ row }: any) => handleView(row)" @sort-change="sortChange">
<template #toolbar_buttons> </template>
<template #toolbar_tools> </template>
<template #empty>
<el-empty :image-size="200" />
</template>
<template #row_type="{ row }">
<el-tag v-if="row.sysNotice.type === 1" type="success">通知</el-tag>
<el-tag v-else type="warning">公告</el-tag>
</template>
<template #row_readStatus="{ row }">
<el-tag v-if="row.readStatus === 1" type="info">已读</el-tag>
<el-tag v-else type="danger">未读</el-tag>
</template>
<template #row_buttons="{ row }">
<el-tooltip content="详情" placement="top">
<el-button icon="ele-InfoFilled" text type="primary" @click="handleView(row)"> </el-button>
</el-tooltip>
</template>
<template #pager>
<vxe-pager
:loading="options.loading"
v-model:current-page="state.tableParams.page"
v-model:page-size="state.tableParams.pageSize"
:total="state.tableParams.total"
@page-change="pageChange"
/>
</template>
</vxe-grid>
</el-card>
<el-dialog v-model="state.dialogVisible" title="消息详情" draggable width="769px">
<el-dialog v-model="state.visible" draggable overflow destroy-on-close width="769px">
<template #header>
<div style="color: #fff">
<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Bell /> </el-icon>
<span>消息详情</span>
</div>
</template>
<p v-html="state.content"></p>
<template #footer>
<span class="dialog-footer">
<el-button type="primary" @click="state.dialogVisible = false">确认</el-button>
<el-button type="primary" @click="state.visible = false">确认</el-button>
</span>
</template>
</el-dialog>
@ -72,76 +81,109 @@
</template>
<script setup lang="ts" name="notice">
import { onMounted, reactive } from 'vue';
import { onMounted, reactive, ref } from 'vue';
import commonFunction from '/@/utils/commonFunction';
import { VxeGridInstance, VxePagerEvents, VxePagerDefines } from 'vxe-table';
import { useVxeTable } from '/@/hooks/vxeTableOptionsHook';
import { getAPI } from '/@/utils/axios-utils';
import { SysNoticeApi } from '/@/api-services/api';
import { SysNoticeUser } from '/@/api-services/models';
const xGrid = ref<VxeGridInstance>();
const { removeHtml } = commonFunction();
const state = reactive({
loading: false,
noticeData: [] as Array<SysNoticeUser>,
queryParams: {
title: undefined,
type: undefined,
},
tableParams: {
page: 1,
pageSize: 20,
pageSize: 50,
field: 'id', //
order: 'desc', //
descStr: 'desc', //
total: 0 as any,
},
editNoticeTitle: '',
dialogVisible: false,
visible: false,
title: '',
content: '',
});
//
const options = useVxeTable<SysNoticeUser>({
id: 'sysNoticeUser',
name: '消息',
columns: [
// { type: 'checkbox', width: 40, fixed: 'left' },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'sysNotice.title', title: '标题', minWidth: 200, showOverflow: 'tooltip' },
{ field: 'sysNotice.content', title: '内容', minWidth: 180, showOverflow: 'tooltip', slots: { default: (scope: any) => removeHtml(scope.row.sysNotice.content) } },
{ field: 'sysNotice.type', title: '类型', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_type' } },
{ field: 'sysNotice.createTime', title: '创建时间', minWidth: 150, showOverflow: 'tooltip' },
{ field: 'readStatus', title: '阅读状态', minWidth: 100, showOverflow: 'tooltip', slots: { default: 'row_readStatus' } },
{ field: 'sysNotice.publicUserName', title: '发布者', minWidth: 120, showOverflow: 'tooltip' },
{ field: 'sysNotice.publicTime', title: '发布时间', minWidth: 150, showOverflow: 'tooltip' },
{ title: '操作', fixed: 'right', width: 100, showOverflow: true, slots: { default: 'row_buttons' } },
],
searchCallback: () => handleQuery(),
queryAllCallback: () => fetchData({ pageSize: 99999 }),
});
//
onMounted(async () => {
handleQuery();
await handleQuery();
});
//
const handleQuery = async () => {
state.loading = true;
var res = await getAPI(SysNoticeApi).apiSysNoticePageReceivedGet(state.queryParams.title, state.queryParams.type, state.tableParams.page, state.tableParams.pageSize);
state.noticeData = res.data.result?.items ?? [];
const handleQuery = async (reset = false) => {
options.loading = true;
if (reset) state.tableParams.page = 1;
var res = await fetchData(null);
xGrid.value?.loadData(res.data.result?.items ?? []);
state.tableParams.total = res.data.result?.total;
state.loading = false;
options.loading = false;
};
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
return getAPI(SysNoticeApi).apiSysNoticePageReceivedGet(params);
};
//
const resetQuery = () => {
state.queryParams.title = undefined;
state.queryParams.type = undefined;
handleQuery();
handleQuery(true);
};
//
const handleSizeChange = (val: number) => {
state.tableParams.pageSize = val;
handleQuery();
};
//
const handleCurrentChange = (val: number) => {
state.tableParams.page = val;
handleQuery();
};
//
const viewDetail = async (row: any) => {
state.content = row.sysNotice.content;
state.dialogVisible = true;
//
const pageChange: VxePagerEvents.PageChange = ({ currentPage, pageSize }: VxePagerDefines.PageChangeEventParams) => {
state.tableParams.page = currentPage;
state.tableParams.pageSize = pageSize;
handleQuery();
};
//
const sortChange = (options: any) => {
state.tableParams.field = options.field;
state.tableParams.order = options.order;
handleQuery();
};
//
const handleView = async (row: any) => {
state.content = row.sysNotice.content;
state.visible = true;
row.readStatus = 1;
// mittBus.emit('noticeRead', row.sysNotice.id);
await getAPI(SysNoticeApi).apiSysNoticeSetReadPost({ id: row.sysNotice.id });
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const tableRowClassName = ({ row, rowIndex }: { row: SysNoticeUser; rowIndex: number }) => {
return row.readStatus === 1 ? 'info-row' : '';
};
</script>
<style lang="scss">
// .el-table .info-row {
// --el-table-tr-bg-color: var(--el-color-info-light-9);
// }
<style lang="scss" scoped>
:deep(.el-dialog__body) {
min-height: 600px;
}
</style>

View File

@ -135,7 +135,7 @@ const options = useVxeTable<SysLdap>({
name: '系统域登录信息配置',
columns: [
// { type: 'checkbox', width: 40, fixed: 'left' },
{ type: 'seq', title: '序号', width: 50, fixed: 'left' },
{ type: 'seq', title: '序号', width: 60, fixed: 'left' },
{ field: 'host', title: '主机', minWidth: 120, showOverflow: 'tooltip' },
{ field: 'port', title: '端口', minWidth: 90, showOverflow: 'tooltip' },
{ field: 'baseDn', title: '用户搜索基准', minWidth: 140, showOverflow: 'tooltip' },
@ -252,10 +252,4 @@ const handlePrint = async (row: any) => {
:deep(.el-input-number) {
width: 100%;
}
:deep(.xGrid-style .vxe-body--row.warning-row) {
background-color: var(--el-color-warning-light-9);
}
:deep(.xGrid-style .vxe-body--row.success-row) {
background-color: var(--el-color-success-light-9);
}
</style>

View File

@ -148,7 +148,7 @@ const handleQuery = async (reset = false) => {
options.loading = false;
};
//
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
return getAPI(SysNoticeApi).apiSysNoticePagePost(params);

View File

@ -159,7 +159,7 @@ const handleQuery = async (updateTree: boolean = false) => {
state.treeData = res.data.result ?? [];
};
//
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, tableParams);
return getAPI(SysOrgApi).apiSysOrgListGet(params.id, params.name, params.code, params.type);

View File

@ -133,7 +133,7 @@ const handleQuery = async (reset = false) => {
options.loading = false;
};
//
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
return getAPI(SysPosApi).apiSysPosPagePost(params);

View File

@ -154,7 +154,7 @@ const handleQuery = async (reset = false) => {
options.loading = false;
};
//
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
return getAPI(SysRoleApi).apiSysRolePagePost(params);

View File

@ -184,7 +184,7 @@ const handleQuery = async (reset = false) => {
options.loading = false;
};
//
//
const fetchData = async (tableParams: any) => {
let params = Object.assign(state.queryParams, state.tableParams, tableParams);
return getAPI(SysUserApi).apiSysUserPagePost(params);