预警通知界面
This commit is contained in:
parent
f728fe1656
commit
1568704896
@ -6,6 +6,7 @@ export interface AlertMessageVO {
|
|||||||
alerttype: number // 预警类型:1 SOS/ 2 分析预警
|
alerttype: number // 预警类型:1 SOS/ 2 分析预警
|
||||||
content: string // 预警内容
|
content: string // 预警内容
|
||||||
userid: number // 用户ID
|
userid: number // 用户ID
|
||||||
|
username: string // 用户名称
|
||||||
status: number // 状态:0-未读 1-已读
|
status: number // 状态:0-未读 1-已读
|
||||||
createtime: Date // 创建时间
|
createtime: Date // 创建时间
|
||||||
updatetime: Date // 更新时间
|
updatetime: Date // 更新时间
|
||||||
|
147
src/views/notice/content.vue
Normal file
147
src/views/notice/content.vue
Normal 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>
|
@ -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>
|
@ -162,19 +162,6 @@ const openForm = (id: number) => {
|
|||||||
formRef.value.open(id)
|
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 () => {
|
const handleExport = async () => {
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user