优化我的消息

This commit is contained in:
zjl 2024-12-13 13:57:19 +08:00
parent 32d3811b56
commit 22c9f916f5
3 changed files with 98 additions and 23 deletions

View File

@ -8,14 +8,18 @@ export const columns = [
{ {
label: 'ID', label: 'ID',
prop: 'id', prop: 'id',
fixed: 'left',
width: 50,
}, },
{ {
label: '消息标题', label: '消息标题',
prop: 'title', prop: 'title',
width: 250,
}, },
{ {
label: '消息状态', label: '消息状态',
prop: 'status', prop: 'status',
width: 100,
render(record) { render(record) {
return h('span', record.row.status === 1 ? '已读' : '未读'); return h('span', record.row.status === 1 ? '已读' : '未读');
}, },
@ -23,9 +27,11 @@ export const columns = [
{ {
label: '创建人', label: '创建人',
prop: 'createUser', prop: 'createUser',
width: 100,
}, },
{ {
label: '创建时间', label: '创建时间',
prop: 'createTime', prop: 'createTime',
width: 180,
}, },
]; ];

View File

@ -31,6 +31,10 @@
import { onMounted, reactive } from 'vue'; import { onMounted, reactive } from 'vue';
const emit = defineEmits(['success', 'update:visible']); const emit = defineEmits(['success', 'update:visible']);
/**
* 定义表单参数
*/
const formData = reactive({ const formData = reactive({
id: '', id: '',
title: '', title: '',
@ -40,6 +44,9 @@
content: '', content: '',
}); });
/**
* 定义接收的参数
*/
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
@ -53,10 +60,16 @@
}, },
}); });
/**
* 关闭弹窗
*/
const dialogClose = () => { const dialogClose = () => {
emit('update:visible', false); emit('update:visible', false);
}; };
/**
* 设置表单参数
*/
const setFormData = async () => { const setFormData = async () => {
const data = await getMessageDetail(props.messageId); const data = await getMessageDetail(props.messageId);
for (const key in formData) { for (const key in formData) {
@ -66,6 +79,11 @@
} }
} }
}; };
/**
* 获取类型文本描述
* @param type 类型
*/
const getTyepText = (type) => { const getTyepText = (type) => {
let typeText = ''; let typeText = '';
switch (type) { switch (type) {
@ -84,6 +102,9 @@
return typeText; return typeText;
}; };
/**
* 钩子函数
*/
onMounted(() => { onMounted(() => {
if (props.messageId) { if (props.messageId) {
setFormData(); setFormData();

View File

@ -2,11 +2,7 @@
<PageWrapper> <PageWrapper>
<el-card shadow="never" size="small" class="proCard tabsCard"> <el-card shadow="never" size="small" class="proCard tabsCard">
<el-tabs v-model="activeName" @tab-change="handleClick"> <el-tabs v-model="activeName" @tab-change="handleClick">
<el-tab-pane <el-tab-pane :name="item.value" v-for="(item, index) in messageTypeList" :key="index">
:name="item.value"
v-for="(item, index) in messageTypeList"
:key="index"
>
<template #label> <template #label>
<span class="custom-tabs-label"> <span class="custom-tabs-label">
<el-badge :value="item.number ? item.number : ''" :max="99" class="item"> <el-badge :value="item.number ? item.number : ''" :max="99" class="item">
@ -57,10 +53,28 @@
} from '@/api/dashboard/message'; } from '@/api/dashboard/message';
import { columns } from './columns'; import { columns } from './columns';
import { message, confirm } from '@/utils/auth'; import { message, confirm } from '@/utils/auth';
/**
* 定义参数
*/
const editDialog = defineAsyncComponent(() => import('./edit.vue')); const editDialog = defineAsyncComponent(() => import('./edit.vue'));
const messageId = ref(0); const messageId = ref(0);
const docHeight = ref(500); const docHeight = ref(500);
const activeName = ref(1); const activeName = ref(1);
const editVisible = ref(false);
const selectionData = ref([]);
const tableRef = ref();
/**
* 定义查询参数
*/
const formParams = reactive({
type: 1,
});
/**
* 定义数据源
*/
const messageTypeList = ref([ const messageTypeList = ref([
{ {
name: '系统通知', name: '系统通知',
@ -75,14 +89,12 @@
value: 3, value: 3,
}, },
]); ]);
const editVisible = ref(false);
const selectionData = ref([]); /**
const tableRef = ref(); * 定义操作栏
const formParams = reactive({ */
type: 1,
});
const actionColumn = reactive({ const actionColumn = reactive({
width: 250, width: 280,
label: '操作', label: '操作',
prop: 'action', prop: 'action',
fixed: 'right', fixed: 'right',
@ -92,6 +104,7 @@
actions: [ actions: [
{ {
label: '确认', label: '确认',
icon: 'Check',
type: 'warning', type: 'warning',
onClick: handleSetRead.bind(null, record), onClick: handleSetRead.bind(null, record),
}, },
@ -99,7 +112,7 @@
label: '详情', label: '详情',
icon: 'View', icon: 'View',
type: 'warning', type: 'warning',
onClick: handleInfo.bind(null, record), onClick: handleDetail.bind(null, record),
}, },
{ {
label: '删除', label: '删除',
@ -112,6 +125,10 @@
}, },
}); });
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res: any) => { const loadDataTable = async (res: any) => {
const result = await getMessageProfile({ ...formParams, ...res }); const result = await getMessageProfile({ ...formParams, ...res });
let item = messageTypeList.value.find((item, index) => item.value == activeName.value); let item = messageTypeList.value.find((item, index) => item.value == activeName.value);
@ -119,21 +136,38 @@
return result; return result;
}; };
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
tableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); tableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行点击事件
* @param e 参数
*/
const handleClick = (e) => { const handleClick = (e) => {
activeName.value = e activeName.value = e;
formParams.type = activeName.value; formParams.type = activeName.value;
reloadTable(); reloadTable();
}; };
const handleInfo = async (record: Recordable) => { /**
* 执行查看详情
* @param record 参数
*/
const handleDetail = async (record: Recordable) => {
messageId.value = record.row.id; messageId.value = record.row.id;
await nextTick(); await nextTick();
editVisible.value = true; editVisible.value = true;
}; };
/**
* 执行删除
* @param record 参数
*/
async function handleDelete(record: Recordable) { async function handleDelete(record: Recordable) {
let ids = []; let ids = [];
if (!record) { if (!record) {
@ -144,6 +178,11 @@
message('删除成功'); message('删除成功');
reloadTable(); reloadTable();
} }
/**
* 执行已读
* @param record 参数
*/
async function handleSetRead(record: Recordable) { async function handleSetRead(record: Recordable) {
let ids = []; let ids = [];
if (!record) { if (!record) {
@ -154,9 +193,18 @@
message('标记成功'); message('标记成功');
reloadTable(); reloadTable();
} }
/**
* 数据行选中事件
* @param value 参数
*/
function onSelectionChange(value) { function onSelectionChange(value) {
selectionData.value = value; selectionData.value = value;
} }
/**
* 钩子函数
*/
onMounted(() => { onMounted(() => {
docHeight.value = document.body.clientHeight - 145; docHeight.value = document.body.clientHeight - 145;
}); });