lsyjgl.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375
  1. <template>
  2. <div class="app-container lsyjgl-page">
  3. <!-- ==================== 搜索区域 ==================== -->
  4. <div class="search-panel">
  5. <div class="search-form">
  6. <div class="form-item">
  7. <span class="form-label">设备名称:</span>
  8. <el-input v-model="filters.equipmentName" placeholder="请输入" clearable style="width:200px" />
  9. </div>
  10. <div class="form-item">
  11. <span class="form-label">预警级别:</span>
  12. <el-select v-model="filters.warningLevel" placeholder="请选择" clearable style="width:160px">
  13. <el-option label="严重" :value="1" />
  14. <el-option label="重要" :value="2" />
  15. <el-option label="一般" :value="3" />
  16. </el-select>
  17. </div>
  18. <div class="form-item">
  19. <span class="form-label">处理状态:</span>
  20. <el-select v-model="filters.status" placeholder="请选择" clearable style="width:160px">
  21. <el-option label="已处理" :value="1" />
  22. <el-option label="已完成" :value="2" />
  23. </el-select>
  24. </div>
  25. <el-button type="primary" @click="handleSearch">搜索</el-button>
  26. <el-button @click="handleClear">清除</el-button>
  27. </div>
  28. </div>
  29. <!-- ==================== 数据表格 ==================== -->
  30. <div class="table-panel">
  31. <el-table :data="tableData" border style="width:100%" v-loading="loading">
  32. <el-table-column prop="warningNo" label="预警编号" min-width="140" />
  33. <el-table-column prop="equipmentName" label="设备名称" min-width="140" show-overflow-tooltip />
  34. <el-table-column prop="warningLevel" label="预警级别" width="90" align="center">
  35. <template #default="{ row }">
  36. <el-tag :type="levelTagType(row.warningLevel)" size="small">{{ levelText(row.warningLevel) }}</el-tag>
  37. </template>
  38. </el-table-column>
  39. <el-table-column prop="currentValue" label="当前值" width="100" />
  40. <el-table-column prop="thresholdValue" label="阈值" width="100" />
  41. <el-table-column prop="location" label="位置" min-width="180" show-overflow-tooltip />
  42. <el-table-column prop="warningTime" label="预警时间" width="160" />
  43. <el-table-column prop="status" label="处理状态" width="90" align="center">
  44. <template #default="{ row }">
  45. <el-tag :type="statusTagType(row.status)" size="small">{{ statusText(row.status) }}</el-tag>
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="firstApproveTime" label="处理时间" width="160" />
  49. <el-table-column label="操作" width="140" fixed="right">
  50. <template #default="{ row }">
  51. <el-button link type="primary" @click="handleView(row)">查看</el-button>
  52. <el-button link type="danger" @click="handleDelete(row)">删除</el-button>
  53. </template>
  54. </el-table-column>
  55. </el-table>
  56. <el-pagination
  57. v-model:current-page="pageNum"
  58. v-model:page-size="pageSize"
  59. :page-sizes="[10, 20, 50, 100]"
  60. :total="total"
  61. layout="total, sizes, prev, pager, next, jumper"
  62. style="margin-top: 16px; justify-content: flex-end"
  63. @size-change="loadData"
  64. @current-change="loadData"
  65. />
  66. </div>
  67. <!-- ==================== 查看详情弹窗 ==================== -->
  68. <el-dialog
  69. v-model="dialogVisible"
  70. title="历史预警详情"
  71. width="680px"
  72. :close-on-click-modal="false"
  73. >
  74. <div class="detail-body" v-if="currentDetail">
  75. <!-- 右侧信息 -->
  76. <div class="detail-info">
  77. <div class="info-code">预警编号:{{ currentDetail.warningNo }}</div>
  78. <div class="info-grid">
  79. <div class="info-row">
  80. <div class="info-item">
  81. <span class="info-label">设备名称:</span>
  82. <span class="info-value">{{ currentDetail.equipmentName }}</span>
  83. </div>
  84. <div class="info-item">
  85. <span class="info-label">预警级别:</span>
  86. <span class="info-value">
  87. <el-tag :type="levelTagType(currentDetail.warningLevel)" size="small">{{ levelText(currentDetail.warningLevel) }}</el-tag>
  88. </span>
  89. </div>
  90. </div>
  91. <div class="info-row">
  92. <div class="info-item">
  93. <span class="info-label">当前值:</span>
  94. <span class="info-value">{{ currentDetail.currentValue }}</span>
  95. </div>
  96. <div class="info-item">
  97. <span class="info-label">阈值:</span>
  98. <span class="info-value">{{ currentDetail.thresholdValue }}</span>
  99. </div>
  100. </div>
  101. <div class="info-row">
  102. <div class="info-item">
  103. <span class="info-label">预警时间:</span>
  104. <span class="info-value">{{ currentDetail.warningTime }}</span>
  105. </div>
  106. </div>
  107. <div class="info-row">
  108. <div class="info-item">
  109. <span class="info-label">处理状态:</span>
  110. <span class="info-value">
  111. <el-tag :type="statusTagType(currentDetail.status)" size="small">{{ statusText(currentDetail.status) }}</el-tag>
  112. </span>
  113. </div>
  114. <div class="info-item">
  115. <span class="info-label">处理时间:</span>
  116. <span class="info-value">{{ currentDetail.firstApproveTime || '-' }}</span>
  117. </div>
  118. </div>
  119. <div class="info-row single">
  120. <div class="info-item">
  121. <span class="info-label">位置:</span>
  122. <span class="info-value desc-text">{{ currentDetail.location }}</span>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. <template #footer>
  129. <el-button @click="dialogVisible = false">关闭</el-button>
  130. </template>
  131. </el-dialog>
  132. </div>
  133. </template>
  134. <script setup name="Lsyjgl">
  135. import { ref, reactive, onMounted } from 'vue'
  136. import { ElMessage, ElMessageBox } from 'element-plus'
  137. import { getWarningHistoryPage, deleteWarning } from '@/api/drainage'
  138. // ==================== 等级/状态工具方法 ====================
  139. function levelText(level) {
  140. const map = { 1: '严重', 2: '重要', 3: '一般' }
  141. return map[level] || '-'
  142. }
  143. function levelTagType(level) {
  144. const map = { 1: 'danger', 2: 'warning', 3: '' }
  145. return map[level] || 'info'
  146. }
  147. function statusText(status) {
  148. const map = { 0: '待处理', 1: '已处理', 2: '已完成' }
  149. return map[status] ?? '-'
  150. }
  151. function statusTagType(status) {
  152. const map = { 0: 'warning', 1: 'info', 2: 'success' }
  153. return map[status] || 'info'
  154. }
  155. // ==================== 表格数据 ====================
  156. const tableData = ref([])
  157. const total = ref(0)
  158. const loading = ref(false)
  159. const pageNum = ref(1)
  160. const pageSize = ref(10)
  161. // ==================== 搜索筛选 ====================
  162. const filters = reactive({
  163. equipmentName: '',
  164. warningLevel: '',
  165. status: ''
  166. })
  167. // ==================== 数据加载 ====================
  168. async function loadData() {
  169. loading.value = true
  170. try {
  171. const params = {
  172. equipmentType: 'drainage'
  173. }
  174. if (filters.equipmentName) params.equipmentName = filters.equipmentName
  175. if (filters.warningLevel) params.warningLevel = filters.warningLevel
  176. if (filters.status !== '' && filters.status !== null) params.status = filters.status
  177. const res = await getWarningHistoryPage(pageNum.value, pageSize.value, params)
  178. const pageData = res.code !== undefined ? res.data : res
  179. tableData.value = pageData.records || []
  180. total.value = pageData.total || 0
  181. } catch (error) {
  182. console.error('加载历史预警列表失败', error)
  183. ElMessage.error('加载历史预警列表失败')
  184. } finally {
  185. loading.value = false
  186. }
  187. }
  188. function handleSearch() {
  189. pageNum.value = 1
  190. loadData()
  191. }
  192. function handleClear() {
  193. filters.equipmentName = ''
  194. filters.warningLevel = ''
  195. filters.status = ''
  196. pageNum.value = 1
  197. loadData()
  198. }
  199. // ==================== 操作:删除 ====================
  200. async function handleDelete(row) {
  201. try {
  202. await ElMessageBox.confirm('确认删除该预警?删除后不可恢复。', '提示', { type: 'warning' })
  203. await deleteWarning(row.id)
  204. ElMessage.success('删除成功')
  205. loadData()
  206. } catch (error) {
  207. if (error !== 'cancel') console.error('删除预警失败', error)
  208. }
  209. }
  210. // ==================== 查看详情弹窗 ====================
  211. const dialogVisible = ref(false)
  212. const currentDetail = ref(null)
  213. function handleView(row) {
  214. currentDetail.value = { ...row }
  215. dialogVisible.value = true
  216. }
  217. onMounted(() => {
  218. loadData()
  219. })
  220. </script>
  221. <style scoped>
  222. .lsyjgl-page {
  223. background: #fff;
  224. min-height: 100%;
  225. padding: 16px;
  226. }
  227. /* 搜索区 */
  228. .search-panel {
  229. background: #fff;
  230. border: 1px solid #e4e7ed;
  231. border-radius: 4px;
  232. padding: 16px 20px;
  233. margin-bottom: 16px;
  234. }
  235. .search-form {
  236. display: flex;
  237. align-items: center;
  238. flex-wrap: wrap;
  239. gap: 12px;
  240. }
  241. .form-item {
  242. display: flex;
  243. align-items: center;
  244. }
  245. .form-label {
  246. font-size: 14px;
  247. color: #606266;
  248. white-space: nowrap;
  249. margin-right: 4px;
  250. }
  251. /* 表格区 */
  252. .table-panel {
  253. background: #fff;
  254. border-radius: 4px;
  255. }
  256. /* 所属类型标签 */
  257. .type-tag {
  258. font-weight: 500;
  259. font-size: 13px;
  260. }
  261. .type-pipe {
  262. color: #409eff;
  263. }
  264. .type-point {
  265. color: #67c23a;
  266. }
  267. .type-well {
  268. color: #e6a23c;
  269. }
  270. /* 详情弹窗 */
  271. .detail-body {
  272. display: flex;
  273. gap: 24px;
  274. padding: 8px 4px;
  275. }
  276. /* 左侧图片占位 */
  277. .detail-img {
  278. flex-shrink: 0;
  279. width: 150px;
  280. height: 150px;
  281. background: #d9ecff;
  282. border: 2px solid #b3d8ff;
  283. border-radius: 4px;
  284. display: flex;
  285. align-items: center;
  286. justify-content: center;
  287. }
  288. .img-placeholder-icon {
  289. font-size: 64px;
  290. color: #409eff;
  291. opacity: 0.7;
  292. }
  293. /* 右侧详情信息 */
  294. .detail-info {
  295. flex: 1;
  296. display: flex;
  297. flex-direction: column;
  298. gap: 10px;
  299. }
  300. .info-code {
  301. font-size: 15px;
  302. font-weight: 600;
  303. color: #303133;
  304. padding-bottom: 6px;
  305. border-bottom: 1px solid #f0f0f0;
  306. }
  307. .info-grid {
  308. display: flex;
  309. flex-direction: column;
  310. gap: 8px;
  311. }
  312. .info-row {
  313. display: flex;
  314. gap: 16px;
  315. }
  316. .info-row.single {
  317. display: block;
  318. }
  319. .info-item {
  320. flex: 1;
  321. display: flex;
  322. align-items: baseline;
  323. font-size: 14px;
  324. }
  325. .info-label {
  326. color: #909399;
  327. white-space: nowrap;
  328. min-width: 64px;
  329. }
  330. .info-value {
  331. color: #303133;
  332. }
  333. .desc-text {
  334. color: #606266;
  335. line-height: 1.6;
  336. word-break: break-all;
  337. }
  338. </style>