WarnLeftTop.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <!-- 报警信息左侧顶部组件:包含报警搜索、报警列表展示及详情查看功能 -->
  2. <template>
  3. <div class="search-table">
  4. <!-- 搜索区域:包含搜索输入框和筛选按钮 -->
  5. <div class="search-area">
  6. <a-input v-model:value="searchWarn" placeholder="搜索报警" size="small" />
  7. <div class="search-btn">
  8. <div class="btn-item">筛选</div>
  9. </div>
  10. </div>
  11. <!-- 内容区域:包含表头和表格数据 -->
  12. <div class="content-area">
  13. <!-- 表头:根据 warnTitle 配置动态渲染列标题 -->
  14. <div class="content-title">
  15. <div class="title-item" v-for="(item, index) in warnTitle" :key="index">{{ item.label }}</div>
  16. </div>
  17. <!-- 表格数据列表:遍历 tableData 渲染每行报警信息 -->
  18. <div class="table-content">
  19. <div class="content-item" v-for="(item, index) in tableData" :key="index">
  20. <div class="item-text" v-for="(ite, ind) in warnTitle" :key="ind">
  21. <!-- 报警时间列 -->
  22. <div v-if="ite.value == 'starttime'">{{ item[ite.value] }}</div>
  23. <!-- 报警名称列 -->
  24. <div v-if="ite.value == 'alarmName'">{{ item[ite.value] }}</div>
  25. <!-- 报警等级列:根据不同等级码显示对应颜色和文字 -->
  26. <!-- 101-低风险(蓝色) 102-一般风险(黄色) 103-较大风险(橙色) 104-重大风险(红色) 201-报警(深红色) -->
  27. <div v-if="ite.value == 'alarmLevel'"
  28. :style="{ color: item[ite.value] == 101 ? '#00d8ff' : item[ite.value] == 102 ? '#fcfc22' : item[ite.value] == 103 ? '#ff7010' : item[ite.value] == 104 ? '#df4e43' : item[ite.value] == 201 ? '#ff0000' : '' }">
  29. {{ item[ite.value] == 101 ? '低风险' : item[ite.value] ==
  30. 102 ? '一般风险' :
  31. item[ite.value] == 103 ? '较大风险' : item[ite.value] == 104 ? '重大风险' : item[ite.value] == 201 ? '报警' :
  32. '低风险' }}</div>
  33. <!-- 处理状态列:0-未处理(红色) 其他-已处理(绿色) -->
  34. <div v-if="ite.value == 'isok'" :style="{ color: item[ite.value] === 0 ? '#fd0404' : '#0eca74' }">{{
  35. item[ite.value] === 0 ? '未处理' : '已处理' }}</div>
  36. <!-- 操作列:点击"详情"触发详情查看 -->
  37. <div v-if="ite.value == 'operation'">
  38. <span :class="activeIndex == index ? 'text-look-active' : 'text-look'"
  39. @click="handlerDetail(item, index)">详情</span>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. </template>
  47. <script setup lang="ts">
  48. import { onMounted, ref, watch, type PropType } from 'vue'
  49. import { warnTitle } from '../hsqHome.data'
  50. // 接收父组件传入的报警数据列表
  51. let props = defineProps({
  52. tableData: {
  53. type: Array as PropType<any[]>,
  54. default: () => [],
  55. },
  56. })
  57. let activeIndex = ref(0)
  58. // 报警搜索关键词
  59. let searchWarn = ref('')
  60. // 定义事件:detail - 查看报警详情
  61. let $emit = defineEmits(['detail'])
  62. // 点击"详情"按钮,向父组件派发 detail 事件并传递当前行数据
  63. function handlerDetail(item: any, index: number) {
  64. activeIndex.value = index
  65. $emit('detail', item)
  66. }
  67. watch(() => props.tableData, (newVal) => {
  68. if (newVal.length > 0) {
  69. handlerDetail(newVal[0], 0)
  70. }
  71. }, { immediate: true })
  72. </script>
  73. <style lang="less" scoped>
  74. @import '/@/design/theme.less';
  75. @{theme-deepblue} {
  76. .search-table {}
  77. }
  78. /* 整体容器:定义背景图片变量及基础布局 */
  79. .search-table {
  80. --image-box-bg1: url('@/assets/images/home-container/configurable/hsq/2-6.png');
  81. --image-box-bg2: url('@/assets/images/home-container/configurable/hsq/2-24.png');
  82. position: relative;
  83. width: 100%;
  84. height: 100%;
  85. padding: 15px;
  86. box-sizing: border-box;
  87. }
  88. /* 搜索区域:输入框与筛选按钮水平排列 */
  89. .search-area {
  90. height: 42px;
  91. display: flex;
  92. justify-content: space-between;
  93. align-items: center;
  94. margin-bottom: 5px;
  95. }
  96. /* 筛选按钮外框 */
  97. .search-btn {
  98. width: 85px;
  99. height: 30px;
  100. border: 1px solid #01fefc;
  101. border-radius: 4px;
  102. padding: 3px;
  103. cursor: pointer;
  104. }
  105. /* 筛选按钮内部填充 */
  106. .btn-item {
  107. display: flex;
  108. justify-content: center;
  109. align-items: center;
  110. width: 100%;
  111. height: 100%;
  112. background-color: rgba(32, 166, 169);
  113. }
  114. /* 内容区域:占据搜索区域以下的所有空间 */
  115. .content-area {
  116. height: calc(100% - 47px);
  117. }
  118. /* 表头行:使用背景图片装饰 */
  119. .content-title {
  120. display: flex;
  121. justify-content: space-between;
  122. align-items: center;
  123. height: 34px;
  124. background: var(--image-box-bg2) no-repeat;
  125. background-size: 100% 100%;
  126. margin-bottom: 6px;
  127. }
  128. /* 表头列项:统一居中,青色文字,按列分配 flex 比例 */
  129. .title-item {
  130. display: flex;
  131. justify-content: center;
  132. align-items: center;
  133. color: #01fefc;
  134. &:nth-child(1) {
  135. flex: 2;
  136. }
  137. &:nth-child(2) {
  138. flex: 2;
  139. }
  140. &:nth-child(3) {
  141. flex: 1;
  142. }
  143. &:nth-child(4) {
  144. flex: 1;
  145. }
  146. &:nth-child(5) {
  147. flex: 1;
  148. }
  149. }
  150. /* 表格内容区:可纵向滚动 */
  151. .table-content {
  152. height: calc(100% - 40px);
  153. overflow-y: auto;
  154. }
  155. /* 数据行:奇偶行交替背景色 */
  156. .content-item {
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. //height: 36px;
  161. padding: 4px 0px;
  162. box-sizing: border-box;
  163. &:nth-child(odd) {
  164. background-color: #0e3455;
  165. }
  166. &:nth-child(even) {
  167. background-color: #114268;
  168. }
  169. }
  170. /* 数据单元格:居中对齐,按列分配 flex 比例(与表头一致) */
  171. .item-text {
  172. display: flex;
  173. justify-content: center;
  174. align-items: center;
  175. text-align: center;
  176. &:nth-child(1) {
  177. flex: 2;
  178. }
  179. &:nth-child(2) {
  180. flex: 2;
  181. }
  182. &:nth-child(3) {
  183. flex: 1;
  184. }
  185. &:nth-child(4) {
  186. flex: 1;
  187. }
  188. &:nth-child(5) {
  189. flex: 1;
  190. }
  191. }
  192. /* "详情"操作按钮样式 */
  193. .text-look {
  194. padding: 2px 8px;
  195. // margin: 0px 2px;
  196. border-radius: 2px;
  197. background-color: #2484bc;
  198. cursor: pointer;
  199. }
  200. .text-look-active {
  201. padding: 2px 8px;
  202. // margin: 0px 2px;
  203. border-radius: 2px;
  204. background-color: #2484bc;
  205. border: 1px solid #90cff3;
  206. cursor: pointer;
  207. }
  208. /* 搜索输入框:自定义背景图片,去除默认边框 */
  209. .zxm-input {
  210. height: 42px;
  211. color: #fff;
  212. background-color: transparent;
  213. border: none;
  214. background: var(--image-box-bg1) no-repeat;
  215. background-size: 100% 100%;
  216. }
  217. /* 小尺寸输入框内边距 */
  218. .zxm-input-sm {
  219. padding: 0px 20px;
  220. }
  221. /* 隐藏滚动条 */
  222. ::-webkit-scrollbar {
  223. display: none;
  224. }
  225. </style>