2024-11-25 14:05:31 +08:00
|
|
|
|
<template>
|
|
|
|
|
<div class="system-menu-dialog-container">
|
|
|
|
|
<el-dialog :title="state.dialog.title" v-model="state.dialog.isShowDialog" width="400px">
|
|
|
|
|
<el-form ref="menuDialogFormRef" :model="state.ruleForm" size="default" label-width="120px" v-loading="state.dialog.loading">
|
|
|
|
|
<el-form-item label="标题:">
|
2024-11-26 11:35:51 +08:00
|
|
|
|
{{ state.ruleForm.title }}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="发送者:">
|
2024-11-26 11:35:51 +08:00
|
|
|
|
{{ state.ruleForm.sendUserName }}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="接收者:">
|
2024-11-26 11:35:51 +08:00
|
|
|
|
{{ state.ruleForm.userName }}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="内容:">
|
2024-11-26 11:35:51 +08:00
|
|
|
|
{{ state.ruleForm.message }}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="时间:">
|
2024-11-26 11:35:51 +08:00
|
|
|
|
{{ dateFormatter() }}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<template #footer>
|
|
|
|
|
<span class="dialog-footer">
|
|
|
|
|
<el-button plain @click="onCancel" size="default">关 闭</el-button>
|
|
|
|
|
</span>
|
|
|
|
|
</template>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script setup lang="ts" name="messagePushDialog">
|
|
|
|
|
import { ElMessage } from 'element-plus';
|
2024-11-26 11:35:51 +08:00
|
|
|
|
import { reactive, ref } from 'vue';
|
2024-11-25 14:05:31 +08:00
|
|
|
|
import { messagePushApi } from '/@/api/messagePush';
|
|
|
|
|
|
|
|
|
|
// 定义变量内容
|
|
|
|
|
const menuDialogFormRef = ref();
|
|
|
|
|
const state = reactive({
|
|
|
|
|
ruleForm: {
|
|
|
|
|
id: '',
|
|
|
|
|
title: '',
|
2024-11-26 11:35:51 +08:00
|
|
|
|
sendUserName: '',
|
|
|
|
|
userName: '',
|
|
|
|
|
message: '',
|
|
|
|
|
createtime: [],
|
2024-11-25 14:05:31 +08:00
|
|
|
|
},
|
|
|
|
|
dialog: {
|
|
|
|
|
isShowDialog: false,
|
|
|
|
|
title: '',
|
2024-11-26 11:35:51 +08:00
|
|
|
|
loading: false,
|
2024-11-25 14:05:31 +08:00
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 引入 api 请求接口
|
|
|
|
|
const mesApi = messagePushApi();
|
|
|
|
|
|
|
|
|
|
// 日期格式化
|
|
|
|
|
const dateFormatter = () => {
|
2024-11-26 11:35:51 +08:00
|
|
|
|
if (state.ruleForm.createtime === null) return '暂无';
|
2024-11-25 14:05:31 +08:00
|
|
|
|
let date = state.ruleForm.createtime;
|
2024-11-26 11:35:51 +08:00
|
|
|
|
return `${date[0]}-${date[1]}-${date[2]} ${date[3]}:${date[4]}:${date[5]}`;
|
|
|
|
|
};
|
2024-11-25 14:05:31 +08:00
|
|
|
|
|
|
|
|
|
// 获取信息详情
|
2024-11-26 11:35:51 +08:00
|
|
|
|
const getDetail = async (id?: number) => {
|
|
|
|
|
try {
|
2024-11-25 14:05:31 +08:00
|
|
|
|
state.dialog.loading = true;
|
|
|
|
|
let res = await mesApi.getMessagePushDetail(id);
|
2024-11-26 11:35:51 +08:00
|
|
|
|
console.log(res);
|
|
|
|
|
if (res?.success) {
|
|
|
|
|
// 当res.data为null时,给state.ruleForm赋值为空对象
|
|
|
|
|
if (res.data === null) {
|
|
|
|
|
state.ruleForm = {
|
|
|
|
|
id: '',
|
|
|
|
|
title: '无',
|
|
|
|
|
sendUserName: '无',
|
|
|
|
|
userName: '无',
|
|
|
|
|
message: '无',
|
|
|
|
|
createtime: [],
|
|
|
|
|
};
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-25 14:05:31 +08:00
|
|
|
|
state.ruleForm = res.data;
|
2024-11-26 11:35:51 +08:00
|
|
|
|
} else {
|
2024-11-25 14:05:31 +08:00
|
|
|
|
ElMessage.error('信息详情获取失败!');
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
} finally {
|
|
|
|
|
state.dialog.loading = false;
|
|
|
|
|
}
|
2024-11-26 11:35:51 +08:00
|
|
|
|
};
|
2024-11-25 14:05:31 +08:00
|
|
|
|
|
|
|
|
|
// 打开弹窗
|
|
|
|
|
const openDialog = (id?: any) => {
|
2024-11-26 11:35:51 +08:00
|
|
|
|
state.dialog.isShowDialog = true;
|
|
|
|
|
getDetail(id);
|
2024-11-25 14:05:31 +08:00
|
|
|
|
};
|
|
|
|
|
// 关闭弹窗
|
|
|
|
|
const closeDialog = () => {
|
2024-11-26 11:35:51 +08:00
|
|
|
|
console.log('close');
|
2024-11-25 14:05:31 +08:00
|
|
|
|
state.dialog.isShowDialog = false;
|
2024-11-26 11:35:51 +08:00
|
|
|
|
console.log(state.dialog.isShowDialog);
|
2024-11-25 14:05:31 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 取消
|
|
|
|
|
const onCancel = () => {
|
|
|
|
|
closeDialog();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 暴露变量
|
|
|
|
|
defineExpose({
|
|
|
|
|
openDialog,
|
|
|
|
|
});
|
|
|
|
|
</script>
|