abnormalAlarmRecord.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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: 10,
  173. companyId: this.companyId
  174. }).then((res) => {
  175. uni.hideLoading();
  176. this.abnormalRecordsList = [
  177. ...this.abnormalRecordsList,
  178. ...res.data.data
  179. ];
  180. this.recordsTotal = res.data.recordsTotal;
  181. }).catch(error => {
  182. uni.showToast({
  183. title: error,
  184. icon: "none"
  185. })
  186. })
  187. },
  188. myLoadmore() {
  189. this.pageIndex += 1;
  190. this.getAbnormalAlarmRecord();
  191. },
  192. // 异常查询条件
  193. getAlarmConfiguration() {
  194. uni.showLoading({
  195. title: "加载中",
  196. mask: true,
  197. })
  198. API.alarmConfiguration().then((response) => {
  199. uni.hideLoading();
  200. var list1 = [];
  201. var list2 = [];
  202. if(response.data.alarmConfigList && response.data.alarmConfigList.length != 0) {
  203. list1 = response.data.alarmConfigList.map(item => {
  204. return {
  205. label: item.name,
  206. value: item.id
  207. }
  208. });
  209. }
  210. list1.unshift({
  211. value: '',
  212. label: '全部状态'
  213. });
  214. if(response.data.companyInfoList && response.data.companyInfoList.length != 0) {
  215. list2 = response.data.companyInfoList.map(item => {
  216. if(item.id == this.companyId) {
  217. this.device = item.name;
  218. }
  219. return {
  220. label: item.name,
  221. value: item.id
  222. }
  223. });
  224. }
  225. list2.unshift({
  226. value: '',
  227. label: '全部设备'
  228. });
  229. this.stateList = list1;
  230. this.deviceList = list2;
  231. }).catch(error => {
  232. uni.showToast({
  233. title: error,
  234. icon: "none"
  235. })
  236. })
  237. },
  238. // 时间查询
  239. timeChange(params) {
  240. console.log(params)
  241. this.time = params.year + '年' + parseInt(params.month) + '月';
  242. this.queryDate = params.year + '-' + params.month;
  243. this.getAbnormalAlarmRecord(true);
  244. },
  245. // 状态查询
  246. stateChange(e) {
  247. console.log(e);
  248. this.configId = e[0].value;
  249. this.state = e[0].label;
  250. this.getAbnormalAlarmRecord(true);
  251. },
  252. // 设备查询
  253. deviceChange(e) {
  254. console.log(e);
  255. this.companyId = e[0].value;
  256. this.device = e[0].label;
  257. this.getAbnormalAlarmRecord(true);
  258. }
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .dropdown {
  264. background-color: #fff;
  265. position: sticky;
  266. top: 88rpx;
  267. z-index: 999;
  268. padding: 18rpx 46rpx;
  269. display: flex;
  270. border-bottom: 1px solid rgba(245, 245, 245, 1);
  271. .dropdown-item{
  272. width: 33.33%;
  273. text-align: center;
  274. height: 60rpx;
  275. line-height: 60rpx;
  276. }
  277. }
  278. // 记录
  279. .records {
  280. background-color: #fff;
  281. // margin-top: 80rpx;
  282. .records-item {
  283. display: flex;
  284. align-items: center;
  285. padding: 24rpx 40rpx;
  286. border-top: 1px solid rgba(245, 245, 245, 1);
  287. .icon {
  288. width: 72rpx;
  289. height: 72rpx;
  290. border-radius: 4px;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. .img {
  295. width: 48rpx;
  296. height: 48rpx;
  297. }
  298. }
  299. .icon1 {
  300. background-color: rgba(255, 227, 218, 1);
  301. }
  302. .icon2 {
  303. background-color: rgba(230, 230, 230, 1);
  304. }
  305. .icon3 {
  306. background-color: rgba(212, 251, 220, 1);
  307. }
  308. .title {
  309. margin-left: 16rpx;
  310. .name {
  311. color: rgba(51, 51, 51, 1);
  312. font-weight: bold;
  313. }
  314. .date {
  315. color: rgba(119, 119, 119, 1);
  316. font-size: 24rpx;
  317. margin-top: 4rpx;
  318. }
  319. }
  320. .equipment {
  321. margin-left: auto;
  322. margin-right: 24rpx;
  323. .equipment1 {
  324. color: rgba(51, 51, 51, 1);
  325. font-weight: bold;
  326. }
  327. .equipment2 {
  328. color: rgba(119, 119, 119, 1);
  329. font-size: 24rpx;
  330. text-align: right;
  331. margin-top: 4rpx;
  332. }
  333. }
  334. }
  335. }
  336. </style>