<!-- Description: 报警管理列表页面 Author: 李亚光 Date: 2023-05-28 --> <script lang="ts" setup name="AlarmList"> import { ElMessage, ElMessageBox } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getAlarmListPage } from '@/api/alarm' import { getDictByCode } from '@/api/system/dict' const { proxy } = getCurrentInstance() as any const listQuery = reactive({ alarmEndTime: '', alarmLocation: '', alarmStartTime: '', alarmType: '', offset: 1, limit: 20, }) // 筛选条件 const columns = ref<TableColumn[]>([]) columns.value = [ { text: '报警设备', value: 'deviceName', align: 'center' }, { text: '报警位置', value: 'location', align: 'center' }, { text: '报警类别', value: 'alarmTypeName', align: 'center' }, { text: '设备状态', value: 'statusName', align: 'center' }, { text: '报警时间', value: 'time', align: 'center' }, ] const list = ref([]) // 列表数据 const total = ref(0)// 数据总数 const listLoading = ref(true)// 加载动画 const fetchData = () => { getAlarmListPage(listQuery).then((res) => { list.value = res.data.rows total.value = res.data.total listLoading.value = false }) } fetchData() // 删除 const del = (row: any) => { ElMessageBox.confirm( '确定要删除该报警吗?', '确认操作', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning', }, ).then(() => { // delArea(row.id).then((response) => { // if (response.code === 200) { // ElMessage({ // message: '删除成功', // type: 'success', // }) // fetchData(true) // } // }) }) } // 查询数据 const search = () => { fetchData() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size: number; page: number }) => { if (val && val.size) { listQuery.limit = val.size } if (val && val.page) { listQuery.offset = val.page } fetchData() } // 获取报警类型 const alarmTypeList = ref<any[]>() const fetchAlarmType = () => { getDictByCode('alarmType').then((res) => { alarmTypeList.value = res.data }) } fetchAlarmType() const clear = () => { listQuery.alarmLocation = '' listQuery.alarmType = '' listQuery.alarmStartTime = '' listQuery.alarmEndTime = '' fetchData() } const cancel = (row: any) => { } </script> <template> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @clear="clear"> <search-item> <el-input v-model.trim="listQuery.alarmLocation" placeholder="报警位置" clearable /> </search-item> <search-item> <el-select v-model="listQuery.alarmType" clearable placeholder="报警类型"> <el-option v-for="(item, index) in alarmTypeList" :key="index" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-date-picker v-model="listQuery.alarmStartTime" type="datetime" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" placeholder="报警开始时间" /> </search-item> <search-item> <el-date-picker v-model="listQuery.alarmEndTime" type="datetime" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" placeholder="报警结束时间" /> </search-item> </search-area> <table-container> <template #btns-right> <!-- <icon-button v-if="proxy.hasPerm(Perm.ADD)" icon="icon-add" title="新增" @click="add" /> <el-button></el-button> --> </template> <!-- 查询结果Table显示 --> <normal-table :data="list" :columns="columns" :total="total" :query="listQuery" :list-loading="listLoading" @change="changePage"> <template #preColumns> <el-table-column label="#" width="55" align="center"> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> <template #columns> <el-table-column label="操作" width="160" align="center"> <template #default="scope"> <el-button type="primary" link size="small" @click="cancel(scope.row)"> 消警 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template> <style lang="scss" scoped> // 样式 </style>