2025-06-18 11:23:00 +08:00
|
|
|
|
<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()
|
2025-06-30 16:21:41 +08:00
|
|
|
|
if(userProfile.value.dept.orgid!=0){
|
|
|
|
|
queryParams.orgid = userProfile.value.dept.orgid
|
|
|
|
|
}
|
2025-06-18 11:23:00 +08:00
|
|
|
|
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>
|