From b18534b98edecf5a5a01dd2e67f1ad3b6a2ff269 Mon Sep 17 00:00:00 2001 From: zjl Date: Fri, 13 Dec 2024 13:20:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=91=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/message/columns.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/views/dashboard/message/columns.ts b/src/views/dashboard/message/columns.ts index 9c0d462..1a85987 100644 --- a/src/views/dashboard/message/columns.ts +++ b/src/views/dashboard/message/columns.ts @@ -4,7 +4,7 @@ export const columns = [ { type: 'selection', width: 50, - fixed:"left" + fixed: 'left', }, { title: 'ID', @@ -15,20 +15,24 @@ export const columns = [ { title: '消息标题', key: 'title', + width: 250, }, { title: '消息状态', key: 'status', + width: 100, customRender({ record }) { - return h('span', record.status === 1 ? '已读' : '未读') + return h('span', record.status === 1 ? '已读' : '未读'); }, }, { title: '创建人', key: 'createUser', + width: 100, }, { title: '创建时间', key: 'createTime', + width: 180, }, ]; From 2d9003bca3648fb4f461759c5b2e9aa446160c5c Mon Sep 17 00:00:00 2001 From: zjl Date: Fri, 13 Dec 2024 13:24:52 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=88=91=E7=9A=84?= =?UTF-8?q?=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/dashboard/message/edit.vue | 30 +++++++++++- src/views/dashboard/message/index.vue | 69 ++++++++++++++++++++++----- 2 files changed, 87 insertions(+), 12 deletions(-) diff --git a/src/views/dashboard/message/edit.vue b/src/views/dashboard/message/edit.vue index 82f7ee2..c861206 100644 --- a/src/views/dashboard/message/edit.vue +++ b/src/views/dashboard/message/edit.vue @@ -28,6 +28,10 @@ import { onMounted, reactive } from 'vue'; const emit = defineEmits(['success', 'update:visible']); + + /** + * 定义表单参数 + */ const formData = reactive({ id: '', title: '', @@ -37,6 +41,9 @@ content: '', }); + /** + * 定义接收的参数 + */ const props = defineProps({ visible: { type: Boolean, @@ -49,16 +56,26 @@ default: 0, }, }); + + /** + * 定义模态 + */ const [modalRegister, { openModal }] = useModal({ title: '日志详情', subBtuText: '确定', width: 600, }); + /** + * 关闭弹窗 + */ const dialogClose = () => { emit('update:visible', false); }; + /** + * 设置表单参数 + */ const setFormData = async () => { const data = await getMessageDetail(props.messageId); for (const key in formData) { @@ -68,6 +85,11 @@ } } }; + + /** + * 获取类型文本描述 + * @param type 类型 + */ const getTyepText = (type) => { let typeText = ''; switch (type) { @@ -86,12 +108,18 @@ return typeText; }; + /** + * 钩子函数 + */ onMounted(() => { if (props.messageId) { setFormData(); } }); - //导出方法 + + /** + * 定义函数 + */ defineExpose({ openModal, }); diff --git a/src/views/dashboard/message/index.vue b/src/views/dashboard/message/index.vue index de45401..721b3d9 100644 --- a/src/views/dashboard/message/index.vue +++ b/src/views/dashboard/message/index.vue @@ -43,8 +43,7 @@ v-model:visible="editVisible" ref="createModalRef" @success="reloadTable('noRefresh')" - > - + /> @@ -62,10 +61,29 @@ import editDialog from './edit.vue'; import { useMessage, useDialog } from 'naive-ui'; import { renderIcon } from '@/utils'; + + /** + * 定义参数 + */ const messageId = ref(0); const message = useMessage(); const dialog = useDialog(); const activeName = ref(1); + const editVisible = ref(false); + const createModalRef = ref(); + const selectionData = ref([]); + const tableRef = ref(); + + /** + * 定义查询参数 + */ + const formParams = reactive({ + type: 1, + }); + + /** + * 定义数据源 + */ const messageTypeList = ref([ { name: '系统通知', @@ -80,14 +98,11 @@ value: 3, }, ]); - const editVisible = ref(false); - const createModalRef = ref(); - const selectionData = ref([]); - const tableRef = ref(); - const formParams = reactive({ - type: 1, - }); + /** + * 加载数据列表 + * @param res 参数 + */ const loadDataTable = async (res: any) => { selectionData.value = []; const result = await getMessageProfile({ ...formParams, ...res }); @@ -95,6 +110,10 @@ item.number = result.number; return result; }; + + /** + * 定义操作栏 + */ const actionColumn = reactive({ width: 300, title: '操作', @@ -115,7 +134,7 @@ label: '详情', icon: renderIcon(EyeOutlined), type: 'info', - onClick: handleInfo.bind(null, record), + onClick: handleDetail.bind(null, record), }, { label: '删除', @@ -127,22 +146,40 @@ }); }, }); + + /** + * 刷新数据列表 + * @param noRefresh 参数 + */ function reloadTable(noRefresh = '') { tableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); } + + /** + * 执行点击事件 + * @param e 参数 + */ const handleClick = (e) => { activeName.value = e; formParams.type = e; reloadTable(); }; - const handleInfo = async (record) => { + /** + * 执行查看详情 + * @param record 参数 + */ + const handleDetail = async (record) => { messageId.value = record.id; editVisible.value = true; await nextTick(); createModalRef.value.openModal(); }; + /** + * 执行删除 + * @param record 参数 + */ async function handleDelete(record) { dialog.warning({ title: '提示', @@ -156,6 +193,11 @@ }, }); } + + /** + * 执行设置已读 + * @param id 参数 + */ async function handleSetRead(id) { dialog.warning({ title: '提示', @@ -169,6 +211,11 @@ }, }); } + + /** + * 数据行选中事件 + * @param value 参数 + */ function onSelectionChange(value) { selectionData.value = value; }