预警通知界面

This commit is contained in:
Flow 2025-06-18 11:23:00 +08:00
parent f728fe1656
commit 1568704896
5 changed files with 314 additions and 13 deletions

View File

@ -6,6 +6,7 @@ export interface AlertMessageVO {
alerttype: number // 预警类型1 SOS/ 2 分析预警
content: string // 预警内容
userid: number // 用户ID
username: string // 用户名称
status: number // 状态0-未读 1-已读
createtime: Date // 创建时间
updatetime: Date // 更新时间

View File

@ -0,0 +1,147 @@
<template>
<el-dialog
v-model="visible"
title="预警内容"
width="600px"
:before-close="handleClose"
destroy-on-close
>
<div v-loading="loading" class="content-container">
<div class="time-info">
<span class="time-label">预警时间</span>
<span class="time-value">{{ formatTime(alertData.createtime) }}</span>
</div>
<div class="content-section">
<div class="content-label">预警内容</div>
<div class="content-box">
{{ alertData.content }}
</div>
</div>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleClose">关闭</el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { formatDate } from '@/utils/formatTime'
import { AlertMessageApi, AlertMessageVO } from '@/api/alertmessage'
defineOptions({ name: 'AlertContent' })
//
const emit = defineEmits<{
refresh: []
}>()
const message = useMessage()
const visible = ref(false)
const loading = ref(false)
const alertData = ref<AlertMessageVO>({} as AlertMessageVO)
//
const formatTime = (time: string | number | Date) => {
if (!time) return ''
return formatDate(new Date(time))
}
//
const getAlertDetail = async (id: number) => {
loading.value = true
try {
const data = await AlertMessageApi.getAlertMessage(id)
alertData.value = data
} catch (error) {
message.error('获取预警详情失败')
console.error('获取预警详情失败:', error)
} finally {
loading.value = false
}
}
//
const open = async (id: number) => {
visible.value = true
await getAlertDetail(id)
}
//
const handleClose = async () => {
try {
//
if (alertData.value.id && alertData.value.status !== 1) {
await AlertMessageApi.updateAlertMessage({
...alertData.value,
status: 1
})
//
emit('refresh')
}
} catch (error) {
console.error('更新状态失败:', error)
} finally {
visible.value = false
alertData.value = {} as AlertMessageVO
}
}
//
defineExpose({
open
})
</script>
<style scoped>
.content-container {
padding: 20px 0;
}
.time-info {
margin-bottom: 20px;
padding: 12px 16px;
background-color: #f8f9fa;
border-radius: 6px;
border-left: 4px solid #409eff;
}
.time-label {
font-weight: 600;
color: #606266;
}
.time-value {
color: #303133;
margin-left: 8px;
}
.content-section {
margin-top: 16px;
}
.content-label {
font-weight: 600;
color: #606266;
margin-bottom: 12px;
}
.content-box {
min-height: 120px;
padding: 16px;
background-color: #f5f7fa;
border-radius: 6px;
white-space: pre-wrap;
word-break: break-all;
line-height: 1.6;
border: 1px solid #e4e7ed;
}
.dialog-footer {
text-align: right;
}
</style>

View File

@ -0,0 +1,166 @@
<template>
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="预警类型" prop="alerttype">
<el-select
v-model="queryParams.alerttype"
placeholder="请选择预警类型"
clearable
class="!w-240px"
>
<el-option label="SOS" value="1" />
<el-option label="分析预警" value="2" />
</el-select>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="请选择状态"
clearable
class="!w-240px"
>
<el-option label="未读" value="0" />
<el-option label="已读" value="1" />
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="编号" align="center" prop="id" />
<el-table-column label="预警类型" align="center" prop="alerttype" :formatter="alertTypeFormatter" />
<el-table-column label="用户ID" align="center" prop="userid" />
<el-table-column label="用户名称" align="center" prop="username" />
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormatter" >
<template #default="scope">
<el-tag v-if="scope.row.status === 0" type="danger">未读</el-tag>
<el-tag v-else type="success">已读</el-tag>
</template>
</el-table-column>
<el-table-column label="设备ID" align="center" prop="devicecode" />
<el-table-column label="操作" align="center" min-width="120px">
<template #default="scope">
<el-button
link
type="primary"
@click="openForm('update', scope.row.id)"
>
查看内容
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗添加/修改 -->
<content ref="contentRef" @refresh="getList"></content>
</template>
<script setup lang="ts">
import { getUserProfile } from '@/api/system/user/profile'
import { AlertMessageApi, AlertMessageVO } from '@/api/alertmessage'
import content from './content.vue'
/** 预警信息 列表 */
defineOptions({ name: 'AlertMessage' })
const message = useMessage() //
const { t } = useI18n() //
const loading = ref(true) //
const list = ref<AlertMessageVO[]>([]) //
const total = ref(0) //
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
alerttype: undefined,
content: undefined,
userid: undefined,
username: undefined,
status: undefined,
createtime: [],
updatetime: [],
devicecode: undefined,
devicetype: undefined,
orgid: undefined,
orgname: undefined,
})
const queryFormRef = ref() //
const contentRef = ref() //
const userProfile = ref()
//
const alertTypeFormatter = (row: any, column: any, cellValue: any) => {
const typeMap: Record<string, string> = {
'1': 'SOS',
'2': '分析预警'
}
return typeMap[cellValue] || cellValue
}
//
const statusFormatter = (row: any, column: any, cellValue: any) => {
const statusMap: Record<string, string> = {
'0': '未读',
'1': '已读'
}
return statusMap[cellValue] || cellValue
}
/** 查询列表 */
const getList = async () => {
//
userProfile.value = await getUserProfile()
queryParams.orgid = userProfile.value.dept.id
loading.value = true
try {
const data = await AlertMessageApi.getAlertMessagePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
const openForm = (type: string, id?: number) => {
if (id) {
contentRef.value.open(id)
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>

View File

@ -162,19 +162,6 @@ const openForm = (id: number) => {
formRef.value.open(id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
//
await message.delConfirm()
//
await DoctornoticeApi.deleteDoctornotice(id)
message.success(t('common.delSuccess'))
//
await getList()
} catch { }
}
/** 导出按钮操作 */
const handleExport = async () => {
try {