abnormalAlarmRecord.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <view>
  3. <u-navbar title="异常报警记录" title-color="#101010"></u-navbar>
  4. <view class="dropdown">
  5. <view class="dropdown-item" @click="show1=true">
  6. {{time}} <u-icon name="arrow-down" color="#999999"></u-icon>
  7. </view>
  8. <view class="dropdown-item" @click="show2=true">
  9. {{state}} <u-icon name="arrow-down" color="#999999"></u-icon>
  10. </view>
  11. <view class="dropdown-item" @click="show3=true">
  12. {{device}} <u-icon name="arrow-down" color="#999999"></u-icon>
  13. </view>
  14. </view>
  15. <u-picker mode="time" :defaultTime="defaultTime" v-model="show1" :params="params" @confirm="timeChange"></u-picker>
  16. <u-select v-model="show2" mode="single-column" :list="stateList" @confirm="stateChange"></u-select>
  17. <u-select v-model="show3" mode="single-column" :list="deviceList" @confirm="deviceChange"></u-select>
  18. <view class="records">
  19. <view class="records-item" v-for="(item, index) in abnormalRecordsList" :key="index"
  20. @click="gotoUrl('/pages/abnormal/abnormalAlarmDetails?id='+item.id)">
  21. <view class="icon icon1">
  22. <image class="img" src="@/assets/img/riFill-temp-cold-fill.svg" mode=""></image>
  23. </view>
  24. <!-- <view class="icon icon2">
  25. <image class="img" src="@/assets/img/riFill-cloud-off-fill.svg" mode=""></image>
  26. </view>
  27. <view class="icon icon3">
  28. <image class="img" src="@/assets/img/outputVoltage.svg" mode=""></image>
  29. </view> -->
  30. <view class="title">
  31. <view class="name">
  32. {{item.configName}}
  33. </view>
  34. <view class="date">
  35. {{item.createTime}}
  36. </view>
  37. </view>
  38. <view class="equipment">
  39. <view class="equipment1">
  40. {{item.meterName}}
  41. </view>
  42. <view class="equipment2">
  43. {{item.installationAddressSimple}}
  44. </view>
  45. </view>
  46. <view class="more">
  47. <u-icon name="arrow-right" color="#acacac"></u-icon>
  48. </view>
  49. </view>
  50. </view>
  51. <u-divider :isnone="abnormalRecordsList.length==0" nonetext="暂无异常报警记录" border-color="#CFD2D5">
  52. 已经到底了</u-divider>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. parseUnixTime,
  58. beforeTimeStamp,
  59. getWeek
  60. } from '@/apis/utils'
  61. import * as API from '@/apis/pagejs/index.js'
  62. export default {
  63. data() {
  64. return {
  65. abnormalRecordsList: [], // 异常告警记录
  66. queryDate: '',
  67. configId: '',
  68. pageIndex: 1,
  69. recordsTotal: 0,
  70. companyId: '',
  71. show1: false, // 时间选择
  72. defaultTime: '',
  73. params: {
  74. year: true,
  75. month: true,
  76. day: false,
  77. hour: false,
  78. minute: false,
  79. second: false,
  80. timestamp: false
  81. },
  82. time: '全部时间',
  83. show2: false, // 状态选择
  84. state: '全部状态',
  85. stateList: [],
  86. show3: false, // 设备选择
  87. device: '全部设备',
  88. deviceList: [],
  89. value1: 1,
  90. value2: 1,
  91. value3: 1,
  92. options1: [{
  93. label: '2024年2月',
  94. value: 1,
  95. },
  96. {
  97. label: '2024年3月',
  98. value: 2,
  99. },
  100. {
  101. label: '2024年4月',
  102. value: 3,
  103. }
  104. ],
  105. options2: [{
  106. label: '设备离线',
  107. value: 1,
  108. },
  109. {
  110. label: '温度异常',
  111. value: 2,
  112. },
  113. {
  114. label: '电压异常',
  115. value: 3,
  116. },
  117. {
  118. label: '功率因数异常',
  119. value: 4,
  120. },
  121. ],
  122. options3: [{
  123. label: '荆鹏集团',
  124. value: 1,
  125. },
  126. {
  127. label: '青少年宫',
  128. value: 2,
  129. },
  130. {
  131. label: '荆州院子',
  132. value: 3,
  133. },
  134. ],
  135. }
  136. },
  137. onLoad(op) {
  138. if(op.id) {
  139. this.companyId = op.id;
  140. }
  141. var date = new Date();
  142. var year = date.getFullYear();
  143. var month = date.getMonth()+1 >= 10 ? date.getMonth()+1 : '0'+(date.getMonth()+1);
  144. this.defaultTime = year + '-' + month;
  145. this.queryDate = year + '-' + month;
  146. this.time = year + '年' + parseInt(month) + '月';
  147. this.getAlarmConfiguration();
  148. this.getAbnormalAlarmRecord();
  149. },
  150. onReady() {
  151. },
  152. onReachBottom() {
  153. if (this.abnormalRecordsList.length < this.recordsTotal) {
  154. this.myLoadmore();
  155. }
  156. },
  157. methods: {
  158. // 异常告警记录
  159. getAbnormalAlarmRecord(bl) {
  160. uni.showLoading({
  161. title: "加载中",
  162. mask: true,
  163. })
  164. if (bl) {
  165. this.abnormalRecordsList = [];
  166. this.pageIndex = 1;
  167. }
  168. API.alarmRecord({
  169. queryDate: this.queryDate,
  170. configId: this.configId,
  171. pageIndex: this.pageIndex,
  172. pageSize: 20,
  173. companyId: this.companyId,
  174. classify: '2'
  175. }).then((res) => {
  176. uni.hideLoading();
  177. this.abnormalRecordsList = [
  178. ...this.abnormalRecordsList,
  179. ...res.data.data
  180. ];
  181. this.recordsTotal = res.data.recordsTotal;
  182. }).catch(error => {
  183. uni.showToast({
  184. title: error,
  185. icon: "none"
  186. })
  187. })
  188. },
  189. myLoadmore() {
  190. this.pageIndex += 1;
  191. this.getAbnormalAlarmRecord();
  192. },
  193. // 异常查询条件
  194. getAlarmConfiguration() {
  195. // uni.showLoading({
  196. // title: "加载中",
  197. // mask: true,
  198. // })
  199. API.alarmConfiguration({classify: '2'}).then((response) => {
  200. //uni.hideLoading();
  201. var list1 = [];
  202. var list2 = [];
  203. if(response.data.alarmConfigList && response.data.alarmConfigList.length != 0) {
  204. list1 = response.data.alarmConfigList.map(item => {
  205. return {
  206. label: item.name,
  207. value: item.id
  208. }
  209. });
  210. }
  211. list1.unshift({
  212. value: '',
  213. label: '全部状态'
  214. });
  215. if(response.data.companyInfoList && response.data.companyInfoList.length != 0) {
  216. list2 = response.data.companyInfoList.map(item => {
  217. if(item.id == this.companyId) {
  218. this.device = item.name;
  219. }
  220. return {
  221. label: item.name,
  222. value: item.id
  223. }
  224. });
  225. }
  226. list2.unshift({
  227. value: '',
  228. label: '全部设备'
  229. });
  230. this.stateList = list1;
  231. this.deviceList = list2;
  232. }).catch(error => {
  233. uni.showToast({
  234. title: error,
  235. icon: "none"
  236. })
  237. })
  238. },
  239. // 时间查询
  240. timeChange(params) {
  241. console.log(params)
  242. this.time = params.year + '年' + parseInt(params.month) + '月';
  243. this.queryDate = params.year + '-' + params.month;
  244. this.getAbnormalAlarmRecord(true);
  245. },
  246. // 状态查询
  247. stateChange(e) {
  248. console.log(e);
  249. this.configId = e[0].value;
  250. this.state = e[0].label;
  251. this.getAbnormalAlarmRecord(true);
  252. },
  253. // 设备查询
  254. deviceChange(e) {
  255. console.log(e);
  256. this.companyId = e[0].value;
  257. this.device = e[0].label;
  258. this.getAbnormalAlarmRecord(true);
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss" scoped>
  264. .dropdown {
  265. background-color: #fff;
  266. position: sticky;
  267. top: 88rpx;
  268. z-index: 999;
  269. padding: 18rpx 46rpx;
  270. display: flex;
  271. justify-content: space-around;
  272. border-bottom: 1px solid rgba(245, 245, 245, 1);
  273. .dropdown-item{
  274. //width: 33.33%;
  275. text-align: center;
  276. height: 60rpx;
  277. line-height: 60rpx;
  278. }
  279. }
  280. // 记录
  281. .records {
  282. background-color: #fff;
  283. // margin-top: 80rpx;
  284. .records-item {
  285. display: flex;
  286. align-items: center;
  287. padding: 24rpx 40rpx;
  288. border-top: 1px solid rgba(245, 245, 245, 1);
  289. .icon {
  290. width: 72rpx;
  291. height: 72rpx;
  292. border-radius: 4px;
  293. display: flex;
  294. align-items: center;
  295. justify-content: center;
  296. .img {
  297. width: 48rpx;
  298. height: 48rpx;
  299. }
  300. }
  301. .icon1 {
  302. background-color: rgba(255, 227, 218, 1);
  303. }
  304. .icon2 {
  305. background-color: rgba(230, 230, 230, 1);
  306. }
  307. .icon3 {
  308. background-color: rgba(212, 251, 220, 1);
  309. }
  310. .title {
  311. margin-left: 16rpx;
  312. .name {
  313. color: rgba(51, 51, 51, 1);
  314. font-weight: bold;
  315. }
  316. .date {
  317. color: rgba(119, 119, 119, 1);
  318. font-size: 24rpx;
  319. margin-top: 4rpx;
  320. }
  321. }
  322. .equipment {
  323. margin-left: auto;
  324. margin-right: 24rpx;
  325. .equipment1 {
  326. color: rgba(51, 51, 51, 1);
  327. font-weight: bold;
  328. }
  329. .equipment2 {
  330. color: rgba(119, 119, 119, 1);
  331. font-size: 24rpx;
  332. text-align: right;
  333. margin-top: 4rpx;
  334. }
  335. }
  336. }
  337. }
  338. </style>