wms-naivevue/src/views/data/message/edit.vue

123 lines
2.7 KiB
Vue

<template>
<basicModal @register="modalRegister" ref="modalRef" class="basicModal basicFormModal">
<template #default>
<n-descriptions
class="margin-top"
:column="2"
bordered
:labelStyle="{ width: '120px' }"
label-placement="left"
>
<n-descriptions-item label="消息标题">
{{ formData.title }}
</n-descriptions-item>
<n-descriptions-item label="消息类型">
{{ getTyepText(formData.type) }}
</n-descriptions-item>
<n-descriptions-item label="业务类型">
{{ formData.bizType == 1 ? '订单' : '其他' }}
</n-descriptions-item>
<n-descriptions-item label="消息状态">
{{ formData.status == 1 ? '已读' : '未读' }}
</n-descriptions-item>
<n-descriptions-item label="消息内容">
{{ formData.content }}
</n-descriptions-item>
</n-descriptions>
</template>
<template #action>
<n-button @click="handleClose">取消</n-button>
</template>
</basicModal>
</template>
<script lang="ts" setup>
import { getMessageDetail } from '@/api/data/message';
import { onMounted, ref } from 'vue';
import { useModal } from '@/components/Modal';
/**
* 定义参数变量
*/
const emit = defineEmits(['success', 'update:visible']);
const formData = ref({});
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: '消息详情',
subBtuText: '确定',
width: 800,
});
/**
* 定义接收的参数
*/
const props = defineProps({
visible: {
type: Boolean,
required: true,
default: false,
},
messageId: {
type: Number,
required: true,
default: 0,
},
});
/**
* 关闭窗体
*/
const handleClose = () => {
emit('update:visible', false);
};
/**
* 设置表单数据
*/
const setFormData = async () => {
const data = await getMessageDetail(props.messageId);
formData.value = data;
};
/**
* 获取类型描述
* @param type 类型
*/
const getTyepText = (type) => {
let typeText = '';
switch (type) {
case 1:
typeText = '系统通知';
break;
case 2:
typeText = '用户私信 ';
break;
case 3:
typeText = '代办事项';
break;
default:
break;
}
return typeText;
};
/**
* 钩子函数
*/
onMounted(() => {
if (props.messageId) {
setFormData();
}
});
/**
* 定义函数
*/
defineExpose({
openModal,
});
</script>
<style lang="less" scoped>
:deep(.ant-descriptions__body .ant-descriptions__table .ant-descriptions__cell) {
word-break: break-all;
}
</style>