bjqd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索区 -->
  4. <el-form :model="queryParams" ref="queryRef" :inline="true" class="search-form">
  5. <el-form-item label="设备名称">
  6. <el-input v-model="queryParams.deviceName" placeholder="请输入设备名称" clearable style="width: 180px" />
  7. </el-form-item>
  8. <el-form-item label="告警等级">
  9. <el-select v-model="queryParams.alarmLevel" placeholder="请选择" clearable style="width: 160px">
  10. <el-option label="最高" :value="1" />
  11. <el-option label="高" :value="2" />
  12. <el-option label="中" :value="3" />
  13. <el-option label="低" :value="4" />
  14. </el-select>
  15. </el-form-item>
  16. <el-form-item label="处理状态">
  17. <el-select v-model="queryParams.alarmStatus" placeholder="请选择" clearable style="width: 140px">
  18. <el-option label="未处理" :value="0" />
  19. <el-option label="已处理" :value="1" />
  20. </el-select>
  21. </el-form-item>
  22. <el-form-item label="时间范围">
  23. <el-date-picker
  24. v-model="queryParams.dateRange"
  25. type="daterange"
  26. range-separator="至"
  27. start-placeholder="开始日期"
  28. end-placeholder="结束日期"
  29. style="width: 240px"
  30. value-format="YYYY-MM-DD"
  31. />
  32. </el-form-item>
  33. <el-form-item>
  34. <el-button type="primary" @click="handleQuery">搜索</el-button>
  35. <el-button @click="resetQuery">重置</el-button>
  36. </el-form-item>
  37. </el-form>
  38. <!-- 数据表格 -->
  39. <el-table :data="tableData" v-loading="loading" border style="width: 100%" size="default">
  40. <el-table-column label="设备名称" prop="deviceName" min-width="130" show-overflow-tooltip />
  41. <el-table-column label="设备编码" prop="deviceCode" min-width="120" show-overflow-tooltip />
  42. <el-table-column label="设备类型" prop="deviceType" min-width="100" show-overflow-tooltip />
  43. <el-table-column label="预警类型" prop="warningType" min-width="100" show-overflow-tooltip />
  44. <el-table-column label="实际值" prop="actualValue" min-width="80" align="center" />
  45. <el-table-column label="阈值范围" min-width="130" align="center">
  46. <template #default="{ row }">
  47. {{ row.minValue ?? '-' }} ~ {{ row.maxValue ?? '-' }}
  48. </template>
  49. </el-table-column>
  50. <el-table-column label="告警等级" min-width="90" align="center">
  51. <template #default="{ row }">
  52. <span :class="levelClass(row.alarmLevel)">{{ levelText(row.alarmLevel) }}</span>
  53. </template>
  54. </el-table-column>
  55. <el-table-column label="处理状态" min-width="90" align="center">
  56. <template #default="{ row }">
  57. <el-tag :type="statusTagType(row.alarmStatus)" size="small" effect="plain">{{ statusText(row.alarmStatus) }}</el-tag>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="报警时间" prop="alarmTime" min-width="160" />
  61. <el-table-column label="操作" width="80" align="center" fixed="right">
  62. <template #default="{ row }">
  63. <el-button link type="primary" @click="handleView(row)">查看</el-button>
  64. </template>
  65. </el-table-column>
  66. </el-table>
  67. <!-- 分页 -->
  68. <div class="pagination-wrap">
  69. <el-pagination
  70. v-model:current-page="pageNum"
  71. v-model:page-size="pageSize"
  72. :page-sizes="[10, 20, 50, 100]"
  73. :total="total"
  74. layout="total, sizes, prev, pager, next, jumper"
  75. @size-change="handleSizeChange"
  76. @current-change="handlePageChange"
  77. />
  78. </div>
  79. <!-- 查看详情弹窗 -->
  80. <el-drawer v-model="dialogVisible" title="报警详情" size="680px" :before-close="handleClose" class="detail-drawer" direction="rtl">
  81. <div class="detail-panel">
  82. <div class="detail-top">
  83. <div class="detail-image">
  84. <el-icon :size="48" color="#b0c4de"><Monitor /></el-icon>
  85. </div>
  86. <div class="detail-info">
  87. <div class="detail-number">编号: {{ currentRow.id }}</div>
  88. <el-row :gutter="16">
  89. <el-col :span="12">
  90. <div class="info-item">
  91. <span class="info-label">设备名称</span>
  92. <span class="info-value">{{ currentRow.deviceName || '-' }}</span>
  93. </div>
  94. </el-col>
  95. <el-col :span="12">
  96. <div class="info-item">
  97. <span class="info-label">设备编码</span>
  98. <span class="info-value">{{ currentRow.deviceCode || '-' }}</span>
  99. </div>
  100. </el-col>
  101. </el-row>
  102. <el-row :gutter="16">
  103. <el-col :span="12">
  104. <div class="info-item">
  105. <span class="info-label">设备类型</span>
  106. <span class="info-value">{{ currentRow.deviceType || '-' }}</span>
  107. </div>
  108. </el-col>
  109. <el-col :span="12">
  110. <div class="info-item">
  111. <span class="info-label">预警类型</span>
  112. <span class="info-value">{{ currentRow.warningType || '-' }}</span>
  113. </div>
  114. </el-col>
  115. </el-row>
  116. <el-row :gutter="16">
  117. <el-col :span="12">
  118. <div class="info-item">
  119. <span class="info-label">实际值</span>
  120. <span class="info-value">{{ currentRow.actualValue ?? '-' }}</span>
  121. </div>
  122. </el-col>
  123. <el-col :span="12">
  124. <div class="info-item">
  125. <span class="info-label">阈值范围</span>
  126. <span class="info-value">{{ currentRow.minValue ?? '-' }} ~ {{ currentRow.maxValue ?? '-' }}</span>
  127. </div>
  128. </el-col>
  129. </el-row>
  130. <el-row :gutter="16">
  131. <el-col :span="12">
  132. <div class="info-item">
  133. <span class="info-label">告警等级</span>
  134. <span class="info-value">
  135. <span :class="levelClass(currentRow.alarmLevel)">{{ levelText(currentRow.alarmLevel) }}</span>
  136. </span>
  137. </div>
  138. </el-col>
  139. <el-col :span="12">
  140. <div class="info-item">
  141. <span class="info-label">处理状态</span>
  142. <span class="info-value">
  143. <el-tag :type="statusTagType(currentRow.alarmStatus)" size="small" effect="plain">{{ statusText(currentRow.alarmStatus) }}</el-tag>
  144. </span>
  145. </div>
  146. </el-col>
  147. </el-row>
  148. <el-row :gutter="16">
  149. <el-col :span="12">
  150. <div class="info-item">
  151. <span class="info-label">报警时间</span>
  152. <span class="info-value">{{ currentRow.alarmTime || '-' }}</span>
  153. </div>
  154. </el-col>
  155. <el-col :span="12">
  156. <div class="info-item">
  157. <span class="info-label">偏离比率</span>
  158. <span class="info-value">{{ currentRow.deviationRatio ?? '-' }}</span>
  159. </div>
  160. </el-col>
  161. </el-row>
  162. <div class="info-item desc-item" v-if="currentRow.remark">
  163. <span class="info-label">备注</span>
  164. <span class="info-value desc-text">{{ currentRow.remark }}</span>
  165. </div>
  166. </div>
  167. </div>
  168. </div>
  169. </el-drawer>
  170. </div>
  171. </template>
  172. <script setup name="Bjqd">
  173. import { ref, onMounted } from 'vue'
  174. import { ElMessage } from 'element-plus'
  175. import { Monitor } from '@element-plus/icons-vue'
  176. import { getAlarmDataPage } from '@/api/drainage'
  177. // ==================== 搜索参数 ====================
  178. const queryParams = ref({
  179. deviceName: '',
  180. alarmLevel: '',
  181. alarmStatus: '',
  182. dateRange: []
  183. })
  184. const queryRef = ref(null)
  185. function handleQuery() {
  186. pageNum.value = 1
  187. loadData()
  188. }
  189. function resetQuery() {
  190. queryParams.value = { deviceName: '', alarmLevel: '', alarmStatus: '', dateRange: [] }
  191. pageNum.value = 1
  192. loadData()
  193. }
  194. // ==================== 等级/状态映射(alarm_data表) ====================
  195. const levelMap = { 1: '最高', 2: '高', 3: '中', 4: '低' }
  196. const statusMap = { 0: '未处理', 1: '已处理' }
  197. function levelText(level) {
  198. return levelMap[level] || '-'
  199. }
  200. function levelClass(level) {
  201. const map = { 1: 'level-critical', 2: 'level-major', 3: 'level-minor', 4: 'level-low' }
  202. return map[level] || ''
  203. }
  204. function statusText(status) {
  205. return statusMap[status] ?? '-'
  206. }
  207. function statusTagType(status) {
  208. const map = { 0: 'warning', 1: 'success' }
  209. return map[status] || 'info'
  210. }
  211. // ==================== 表格数据(服务端分页) ====================
  212. const tableData = ref([])
  213. const total = ref(0)
  214. const loading = ref(false)
  215. const pageNum = ref(1)
  216. const pageSize = ref(10)
  217. async function loadData() {
  218. loading.value = true
  219. try {
  220. const params = { equipmentType: 'drainage' }
  221. if (queryParams.value.deviceName) params.deviceName = queryParams.value.deviceName
  222. if (queryParams.value.alarmLevel !== '' && queryParams.value.alarmLevel !== null) params.alarmLevel = queryParams.value.alarmLevel
  223. if (queryParams.value.alarmStatus !== '' && queryParams.value.alarmStatus !== null) params.alarmStatus = queryParams.value.alarmStatus
  224. if (queryParams.value.dateRange && queryParams.value.dateRange.length === 2) {
  225. params.startTime = queryParams.value.dateRange[0]
  226. params.endTime = queryParams.value.dateRange[1]
  227. }
  228. const res = await getAlarmDataPage(pageNum.value, pageSize.value, params)
  229. const pageData = res.code !== undefined ? res.data : res
  230. tableData.value = pageData.records || pageData.rows || []
  231. total.value = pageData.total || 0
  232. } catch (error) {
  233. console.error('加载报警清单失败', error)
  234. ElMessage.error('加载报警清单失败')
  235. } finally {
  236. loading.value = false
  237. }
  238. }
  239. function handlePageChange() {
  240. loadData()
  241. }
  242. function handleSizeChange() {
  243. pageNum.value = 1
  244. loadData()
  245. }
  246. // ==================== 查看详情 ====================
  247. const dialogVisible = ref(false)
  248. const currentRow = ref({})
  249. function handleView(row) {
  250. currentRow.value = { ...row }
  251. dialogVisible.value = true
  252. }
  253. function handleClose() {
  254. dialogVisible.value = false
  255. }
  256. // ==================== 生命周期 ====================
  257. onMounted(() => {
  258. loadData()
  259. })
  260. </script>
  261. <style scoped>
  262. .app-container {
  263. padding: 20px;
  264. background: #fff;
  265. min-height: calc(100vh - 84px);
  266. }
  267. .search-form {
  268. margin-bottom: 16px;
  269. padding: 16px 16px 0;
  270. background: #f5f7fa;
  271. border-radius: 6px;
  272. }
  273. .pagination-wrap {
  274. margin-top: 16px;
  275. display: flex;
  276. justify-content: flex-end;
  277. }
  278. /* 等级彩色文字 */
  279. .level-critical {
  280. color: #f56c6c;
  281. font-weight: 700;
  282. }
  283. .level-major {
  284. color: #e6a23c;
  285. font-weight: 700;
  286. }
  287. .level-minor {
  288. color: #409eff;
  289. font-weight: 600;
  290. }
  291. .level-low {
  292. color: #67c238;
  293. font-weight: 600;
  294. }
  295. /* 详情弹窗 */
  296. .detail-panel {
  297. padding: 0 4px;
  298. }
  299. .detail-top {
  300. display: flex;
  301. gap: 24px;
  302. }
  303. .detail-image {
  304. width: 150px;
  305. height: 150px;
  306. flex-shrink: 0;
  307. background: #dce6f0;
  308. border-radius: 8px;
  309. display: flex;
  310. align-items: center;
  311. justify-content: center;
  312. border: 1px solid #c0cfe0;
  313. }
  314. .detail-info {
  315. flex: 1;
  316. }
  317. .detail-number {
  318. font-size: 20px;
  319. font-weight: 700;
  320. color: #303133;
  321. margin-bottom: 14px;
  322. }
  323. .info-item {
  324. display: flex;
  325. align-items: flex-start;
  326. margin-bottom: 10px;
  327. line-height: 22px;
  328. }
  329. .info-label {
  330. color: #909399;
  331. font-size: 14px;
  332. white-space: nowrap;
  333. min-width: 65px;
  334. flex-shrink: 0;
  335. }
  336. .info-value {
  337. color: #303133;
  338. font-size: 14px;
  339. flex: 1;
  340. }
  341. .desc-item {
  342. align-items: flex-start;
  343. }
  344. .desc-text {
  345. line-height: 22px;
  346. color: #606266;
  347. }
  348. /* 底部操作区 */
  349. .detail-footer {
  350. margin-top: 20px;
  351. padding-top: 16px;
  352. border-top: 1px solid #ebeef5;
  353. }
  354. .dispatch-row {
  355. display: flex;
  356. align-items: center;
  357. }
  358. .dispatch-label {
  359. font-size: 14px;
  360. color: #303133;
  361. font-weight: 600;
  362. white-space: nowrap;
  363. }
  364. </style>