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',
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,
},
];

View File

@ -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,
});

View File

@ -43,8 +43,7 @@
v-model:visible="editVisible"
ref="createModalRef"
@success="reloadTable('noRefresh')"
>
</editDialog>
/>
</PageWrapper>
</template>
@ -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;
}