修复消息详情接口返回数据为空,会导致弹窗无法关闭

This commit is contained in:
hr1201 2024-11-26 11:35:51 +08:00
parent 8fdb1078ae
commit 3522ef30ea

View File

@ -38,15 +38,15 @@ const state = reactive({
ruleForm: { ruleForm: {
id: '', id: '',
title: '', title: '',
sendUserName: "", sendUserName: '',
userName: "", userName: '',
message: "", message: '',
createtime: [] createtime: [],
}, },
dialog: { dialog: {
isShowDialog: false, isShowDialog: false,
title: '', title: '',
loading: false loading: false,
}, },
}); });
@ -55,37 +55,50 @@ const mesApi = messagePushApi();
// //
const dateFormatter = () => { const dateFormatter = () => {
if(state.ruleForm.createtime === null) return '暂无'; if (state.ruleForm.createtime === null) return '暂无';
let date = state.ruleForm.createtime; let date = state.ruleForm.createtime;
return `${date[0]}-${date[1]}-${date[2]} ${date[3]}:${date[4]}:${date[5]}`; return `${date[0]}-${date[1]}-${date[2]} ${date[3]}:${date[4]}:${date[5]}`;
} };
// //
const getDetail = async(id? : number) => { const getDetail = async (id?: number) => {
try { try {
state.dialog.loading = true; state.dialog.loading = true;
let res = await mesApi.getMessagePushDetail(id); let res = await mesApi.getMessagePushDetail(id);
if(res?.success){ console.log(res);
if (res?.success) {
// res.datanullstate.ruleForm
if (res.data === null) {
state.ruleForm = {
id: '',
title: '无',
sendUserName: '无',
userName: '无',
message: '无',
createtime: [],
};
return;
}
state.ruleForm = res.data; state.ruleForm = res.data;
}else{ } else {
ElMessage.error('信息详情获取失败!'); ElMessage.error('信息详情获取失败!');
} }
} catch (error) { } catch (error) {
} finally { } finally {
state.dialog.loading = false; state.dialog.loading = false;
} }
} };
// //
const openDialog = (id?: any) => { const openDialog = (id?: any) => {
console.log(id)
state.dialog.isShowDialog = true; state.dialog.isShowDialog = true;
state.dialog.title = '人才信息';
getDetail(id); getDetail(id);
}; };
// //
const closeDialog = () => { const closeDialog = () => {
console.log('close');
state.dialog.isShowDialog = false; state.dialog.isShowDialog = false;
console.log(state.dialog.isShowDialog);
}; };
// //