abnormalAlarmRecord.vue 9.4 KB

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