This commit is contained in:
陈红丽 2024-12-13 13:25:07 +08:00
commit e802fe53b1
3 changed files with 93 additions and 14 deletions

View File

@ -4,7 +4,7 @@ export const columns = [
{ {
type: 'selection', type: 'selection',
width: 50, width: 50,
fixed:"left" fixed: 'left',
}, },
{ {
title: 'ID', title: 'ID',
@ -15,20 +15,24 @@ export const columns = [
{ {
title: '消息标题', title: '消息标题',
key: 'title', key: 'title',
width: 250,
}, },
{ {
title: '消息状态', title: '消息状态',
key: 'status', key: 'status',
width: 100,
customRender({ record }) { customRender({ record }) {
return h('span', record.status === 1 ? '已读' : '未读') return h('span', record.status === 1 ? '已读' : '未读');
}, },
}, },
{ {
title: '创建人', title: '创建人',
key: 'createUser', key: 'createUser',
width: 100,
}, },
{ {
title: '创建时间', title: '创建时间',
key: 'createTime', key: 'createTime',
width: 180,
}, },
]; ];

View File

@ -28,6 +28,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: '',
@ -37,6 +41,9 @@
content: '', content: '',
}); });
/**
* 定义接收的参数
*/
const props = defineProps({ const props = defineProps({
visible: { visible: {
type: Boolean, type: Boolean,
@ -49,16 +56,26 @@
default: 0, default: 0,
}, },
}); });
/**
* 定义模态
*/
const [modalRegister, { openModal }] = useModal({ const [modalRegister, { openModal }] = useModal({
title: '日志详情', title: '日志详情',
subBtuText: '确定', subBtuText: '确定',
width: 600, width: 600,
}); });
/**
* 关闭弹窗
*/
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) {
@ -68,6 +85,11 @@
} }
} }
}; };
/**
* 获取类型文本描述
* @param type 类型
*/
const getTyepText = (type) => { const getTyepText = (type) => {
let typeText = ''; let typeText = '';
switch (type) { switch (type) {
@ -86,12 +108,18 @@
return typeText; return typeText;
}; };
/**
* 钩子函数
*/
onMounted(() => { onMounted(() => {
if (props.messageId) { if (props.messageId) {
setFormData(); setFormData();
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -43,8 +43,7 @@
v-model:visible="editVisible" v-model:visible="editVisible"
ref="createModalRef" ref="createModalRef"
@success="reloadTable('noRefresh')" @success="reloadTable('noRefresh')"
> />
</editDialog>
</PageWrapper> </PageWrapper>
</template> </template>
@ -62,10 +61,29 @@
import editDialog from './edit.vue'; import editDialog from './edit.vue';
import { useMessage, useDialog } from 'naive-ui'; import { useMessage, useDialog } from 'naive-ui';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/**
* 定义参数
*/
const messageId = ref(0); const messageId = ref(0);
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
const activeName = ref(1); 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([ const messageTypeList = ref([
{ {
name: '系统通知', name: '系统通知',
@ -80,14 +98,11 @@
value: 3, 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) => { const loadDataTable = async (res: any) => {
selectionData.value = []; selectionData.value = [];
const result = await getMessageProfile({ ...formParams, ...res }); const result = await getMessageProfile({ ...formParams, ...res });
@ -95,6 +110,10 @@
item.number = result.number; item.number = result.number;
return result; return result;
}; };
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 300, width: 300,
title: '操作', title: '操作',
@ -115,7 +134,7 @@
label: '详情', label: '详情',
icon: renderIcon(EyeOutlined), icon: renderIcon(EyeOutlined),
type: 'info', type: 'info',
onClick: handleInfo.bind(null, record), onClick: handleDetail.bind(null, record),
}, },
{ {
label: '删除', label: '删除',
@ -127,22 +146,40 @@
}); });
}, },
}); });
/**
* 刷新数据列表
* @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 = e; formParams.type = e;
reloadTable(); reloadTable();
}; };
const handleInfo = async (record) => { /**
* 执行查看详情
* @param record 参数
*/
const handleDetail = async (record) => {
messageId.value = record.id; messageId.value = record.id;
editVisible.value = true; editVisible.value = true;
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
}; };
/**
* 执行删除
* @param record 参数
*/
async function handleDelete(record) { async function handleDelete(record) {
dialog.warning({ dialog.warning({
title: '提示', title: '提示',
@ -156,6 +193,11 @@
}, },
}); });
} }
/**
* 执行设置已读
* @param id 参数
*/
async function handleSetRead(id) { async function handleSetRead(id) {
dialog.warning({ dialog.warning({
title: '提示', title: '提示',
@ -169,6 +211,11 @@
}, },
}); });
} }
/**
* 数据行选中事件
* @param value 参数
*/
function onSelectionChange(value) { function onSelectionChange(value) {
selectionData.value = value; selectionData.value = value;
} }