<!-- Description: 规则引擎-特殊报警规则管理 Author: 李亚光 Date: 2024-09-04 --> <script lang="ts" setup name="RuleAlarmSpecialManage"> import { ElLoading, ElMessage, ElMessageBox } from 'element-plus' import { getDeviceTypeListPage } from '@/api/home/device/type' const deviceTypeList = ref<any[]>([]) // 设备类型列表 // 表格数据 const list = ref([]) const total = ref(0) // 初始展示列 const columns = ref<any>([ { text: '设备编号', value: '', align: 'center' }, { text: '设备类型', value: '', align: 'center' }, { text: '绑定点位', value: '', align: 'center' }, { text: '详细位置', value: '', align: 'center' }, { text: '报警规则', value: '', align: 'center' }, { text: '操作时间', value: '', align: 'center' }, { text: '操作人', value: '', align: 'center' }, ]) // 最终展示列 const columnsConfig = ref([]) // 修改列 const editColumns = (data: any) => { columnsConfig.value = data } const loadingTable = ref(true) // 查询条件 const listQuery = ref({ limit: 20, offset: 1, }) // 开始结束时间 // const datetimerange = ref() // watch(() => datetimerange.value, (newVal) => { // listQuery.value.begTime = '' // listQuery.value.endTime = '' // if (Array.isArray(newVal)) { // if (newVal.length) { // listQuery.value.begTime = `${newVal[0]} 00:00:00` // listQuery.value.endTime = `${newVal[1]} 23:59:59` // } // } // }) // 查询数据 const fetchData = () => { loadingTable.value = true // getOperationListPage(listQuery.value).then((res) => { // list.value = res.data.rows.map((item: any) => ({ // ...item, // deviceTypeName: deviceTypeList.value.filter((citem: any) => citem.id === item.deviceType)[0].typeName, // })) // total.value = res.data.total loadingTable.value = false // }).catch(() => { // loadingTable.value = false // }) } // 重置查询条件f const reset = () => { listQuery.value = { limit: 20, offset: 1, } fetchData() } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 const changePage = (val: { size: number; page: number }) => { if (val && val.size) { listQuery.value.limit = val.size } if (val && val.page) { listQuery.value.offset = val.page } fetchData() } // 查看轨迹详情 const detail = (row: any) => { } // 获取字典 const fetchDict = async () => { // 获取设备类型 const res = await getDeviceTypeListPage({ limit: 9999, offset: 1 }) deviceTypeList.value = res.data.rows } onMounted(async () => { await fetchDict() fetchData() }) </script> <template> <!-- 布局 --> <app-container> <!-- 筛选条件 --> <search-area :need-clear="true" @search="fetchData" @clear="reset"> <search-item> <el-input v-model="listQuery.devcode" placeholder="设备编号" clearable /> </search-item> <search-item> <el-select v-model="listQuery.deviceType" placeholder="设备类型" clearable filterable class="select" style="width: 192px;" > <el-option v-for="item in deviceTypeList" :key="item.id" :label="item.typeName" :value="item.id" /> </el-select> </search-item> </search-area> <!-- 表头标题 --> <table-container :is-config="true" config-title="alarm-rule-special" :columns="columns" :config-columns="columnsConfig" :edit="editColumns" > <template #btns-right> <!-- 操作 --> <div> <el-button type="primary"> 新增 </el-button> </div> </template> <!-- 查询结果Table显示 --> <normal-table :data="list" :total="total" :columns="columnsConfig" :query="listQuery" :list-loading="loadingTable" @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="140" align="center"> <template #default="scope"> <el-button type="primary" link size="small"> 查看 </el-button> <el-button type="primary" link size="small" @click="detail(scope.row)"> 编辑 </el-button> <el-button type="danger" link size="small"> 删除 </el-button> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template>