detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. <template>
  2. <view>
  3. <cu-custom id="custom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png"
  5. :isBack="true">
  6. <block slot="backText">返回</block>
  7. <block slot="content">
  8. 告警详情
  9. </block>
  10. </cu-custom>
  11. <My_listbox ref="List" :pullDown="false" @getlist="getlist" :empty="empty">
  12. <view class="detail" v-if="detail.lasteventtime">
  13. <view class="title">
  14. {{ detail.eventname || ' --' }}
  15. </view>
  16. <view class="row">设备:{{ detail.devicename }}({{ detail.serialnumber }})</view>
  17. <view class="time-row">最近告警时间: <view class="tag" :style="{
  18. color: tagStyleList[detail.lasteventlevel - 1].color,
  19. backgroundColor: tagStyleList[detail.lasteventlevel - 1].backgroundColor,
  20. }">{{ tagStyleList[detail.lasteventlevel - 1].name }}</view> <text class="time">{{
  21. detail.lasteventtime }}</text>
  22. </view>
  23. </view>
  24. <view class="head" :style="{ top: tovw(CustomBar) }">
  25. <view class="left">
  26. 告警日志
  27. </view>
  28. <time-horizon @onConfirm="dateRange" />
  29. </view>
  30. <view class="item" v-for="item in list" :key="item.eventtime">
  31. <view class="time">{{ item.eventtime }}</view>
  32. <view class="row">
  33. {{ item.showValue }}
  34. <text class="text" :style="{ color: tagStyleList[item.level + 1].color }">
  35. {{ tagStyleList[item.level + 1].name }}告警
  36. </text>
  37. </view>
  38. </view>
  39. <view style="height: 30px;" />
  40. </My_listbox>
  41. </view>
  42. </template>
  43. <script>
  44. import { styleList } from "./modules/styleList";
  45. let fun = null;
  46. export default {
  47. data() {
  48. return {
  49. empty: true,
  50. w_event_logid: 0,
  51. detail: {},
  52. CustomBar: 0,
  53. tagStyleList: styleList,
  54. "content": {
  55. "pageNumber": 1,
  56. "pageSize": 20,
  57. "where": {
  58. "begindate": "",
  59. "enddate": ""
  60. }
  61. },
  62. list: []
  63. }
  64. },
  65. onLoad(e) {
  66. if (e.id == 0) {
  67. uni.showToast({
  68. title: '查询错误',
  69. icon: "none",
  70. mask: true,
  71. })
  72. setTimeout(() => {
  73. uni.navigateBack();
  74. }, 1000)
  75. } else {
  76. this.content.w_event_logid = e.id;
  77. this.getDetail()
  78. this.getlist();
  79. }
  80. },
  81. mounted() {
  82. this.$refs.List.setHeight();
  83. },
  84. methods: {
  85. getDetail() {
  86. this.$Http.basic({
  87. "id": 20230821152602,
  88. content: {
  89. "w_event_logid": this.content.w_event_logid
  90. }
  91. }).then(res => {
  92. console.log("告警详情", res)
  93. if (this.cutoff(res.msg)) return;
  94. this.detail = res.data;
  95. })
  96. },
  97. getlist(init = false) {
  98. let content = this.content;
  99. if (init) {
  100. content.pageNumber = 1;
  101. content.pageTotal = 1;
  102. }
  103. if (content.pageNumber > content.pageTotal) return;
  104. this.$Http.basic({
  105. "id": 20230816095902,
  106. content
  107. }).then(res => {
  108. console.log("告警日志", res)
  109. if (this.cutoff(res.msg)) return;
  110. fun && fun();
  111. content.pageNumber += 1;
  112. content.pageTotal = res.pageTotal;
  113. this.content = content;
  114. let list = res.data.map(v => {
  115. v.showValue = ""
  116. v.paramvalues.forEach(item => {
  117. v.showValue += `当前设备${item.paramname}值为${item.paramvalue},${item.symbol + item.eventvalue}时触发`
  118. })
  119. return v
  120. })
  121. this.list = res.pageNumber == 1 ? list : this.list.concat(list)
  122. this.empty = res.data.length == 0;
  123. })
  124. },
  125. dateRange(e, callback) {
  126. this.content.where.begindate = e[0];
  127. this.content.where.enddate = e[1];
  128. fun = callback;
  129. this.getlist(true);
  130. }
  131. },
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .detail {
  136. background: #fff;
  137. width: 355px;
  138. margin: 10px auto 0;
  139. border-radius: 4px;
  140. padding: 10px;
  141. box-sizing: border-box;
  142. .title {
  143. font-size: 16px;
  144. }
  145. .row,
  146. .time-row {
  147. font-size: 14px;
  148. line-height: 22px;
  149. margin-top: 4px;
  150. }
  151. .time-row {
  152. display: flex;
  153. .tag {
  154. padding: 0 6px;
  155. border-radius: 4px;
  156. margin-right: 6px;
  157. }
  158. .time {
  159. color: #052E5D;
  160. flex-wrap: bold;
  161. }
  162. }
  163. }
  164. .head {
  165. height: 40px;
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. width: 355px;
  170. margin: 0 auto;
  171. box-sizing: border-box;
  172. padding: 0 10px;
  173. background: #052E5D;
  174. position: sticky;
  175. z-index: 9;
  176. .left {
  177. color: #fff;
  178. font-weight: bold;
  179. }
  180. }
  181. .item {
  182. width: 355px;
  183. padding: 10px;
  184. box-sizing: border-box;
  185. border-radius: 4px;
  186. margin: 0 auto 10px;
  187. background: #fff;
  188. .time {
  189. color: #333;
  190. flex-wrap: bold;
  191. margin-bottom: 8px;
  192. }
  193. .row {
  194. color: #999;
  195. }
  196. }
  197. </style>