index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <template>
  2. <div class="rooms" v-if="show">
  3. <div class="eq-top">
  4. <img src="/static/img/backIcon.jpg" alt="" @click="back">
  5. <span>空间详情 / </span>
  6. <strong>{{RoomName}}-{{objectId}}报警详情</strong>
  7. </div>
  8. <div class="eq-head" v-if="false">
  9. <div class="f-left"></div>
  10. <div class="f-right">
  11. <p class="f-salarm">近期多次出现以下报警:“电流谐波畸变率过高”、“室温温度传感器出错”、“电压过压”。可能存在设备或零件老化,请多加关注!</p>
  12. <Icon type="md-close" class="close-btn" @click="closeBox"/>
  13. </div>
  14. </div>
  15. <div class="eq-bottom">
  16. <div class="alarm-top">
  17. <span @click="onClickTab(0)" :class="{active: activeIndex== 0}">当前未恢复</span>
  18. <span @click="onClickTab(1)" :class="{active: activeIndex== 1}">近期报警记录</span>
  19. <span @click="onClickTab(2)" :class="{active: activeIndex== 2}">手动处理备注</span>
  20. <span @click="onClickTab(3)" :class="{active: activeIndex== 3}">空间内报警的设备</span>
  21. </div>
  22. <div v-if="activeIndex==0">
  23. <table-alarm :tableData="tableData" @setSort='setSort'></table-alarm>
  24. </div>
  25. <div v-if="activeIndex==1">
  26. <div class="my-select-type">
  27. <my-select :dateLimitDays='dateLimitDays' @setSelectParams="setSelectParams" @setChangeAlarm='setChangeAlarm' :datePickerKey='datePickerKey' :changeAlarm='changeAlarm' :alarmNameList='alarmNameList'></my-select>
  28. </div>
  29. <history-table :historyTableData='historyTableData' :total='total' :Current='pageCurrent'
  30. :pageSize='pageSize' @changeCurrentPage='changeCurrentPage' @setSort='setSort'></history-table>
  31. </div>
  32. <div v-if="activeIndex==2 && show">
  33. <my-handle :objectId='objectId'></my-handle>
  34. </div>
  35. <div v-if="activeIndex==3 && show">
  36. <room-eq></room-eq>
  37. </div>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import tableAlarm from '../main/TableAlarm.vue'
  43. import mySelect from '../equipment/EqSelect.vue'
  44. import myHandle from '../equipment/Handle.vue'
  45. import historyTable from '../main/HistoryTable'
  46. import roomEq from './RoomEq.vue'
  47. import {formatTime, secondsToDay} from '../../tools/formatTime.js'
  48. import dataPickerConfig from '../../tools/dataPickerConfig.js'
  49. // import {mapActions, mapMutations, mapGetters, mapState} from 'vuex'
  50. import axios from 'axios'
  51. export default {
  52. components: {
  53. tableAlarm,
  54. mySelect,
  55. myHandle,
  56. roomEq,
  57. historyTable
  58. },
  59. mixins: [],
  60. props: {
  61. },
  62. data () {
  63. return {
  64. show: false,
  65. datePickerKey: 'oneMonth',
  66. dateLimitDays: Number.MAX_SAFE_INTEGER,
  67. activeIndex: 0,
  68. pageSize: 15,
  69. historyTableData: [],
  70. tableData: [],
  71. total: null,
  72. pageCurrent: 1,
  73. status: 'alarm', // 区分3个tab的状态
  74. autoHandle: null, // 区分3个tab的手动自动
  75. order: { // 选填,没有order字段时按照默认顺序排序
  76. column: '', // 要排序的列名,只支持level,duration,ctime
  77. asc: true // true升序,false降序
  78. },
  79. selectParams: { // 所有下拉框的默认值
  80. selectedLevel: [], // 级别
  81. selectedType: [], // 类型
  82. selectedCode: [],
  83. selectedPosition: {
  84. buildingId: [],
  85. floorId: [],
  86. spaceId: []
  87. }, // 位置
  88. selectedDurationTime: '', // 持续时间
  89. selectedStartTime: { // 开始时间
  90. dStart: '',
  91. dEnd: ''
  92. },
  93. alarmName: []
  94. },
  95. alarmNameList: [],
  96. objectId: 'Sp1101080002001000007',
  97. RoomName: "",
  98. changeAlarm: 0
  99. }
  100. },
  101. computed: {
  102. },
  103. mounted () {
  104. // this.getDataList()
  105. // this.saveAlarmName()
  106. this.getEqNameAndId()
  107. },
  108. methods: {
  109. getEqNameAndId () {
  110. let hostUrl = location.search
  111. let pid = hostUrl.split('&')[0].toString().split('=')[1]
  112. this.$store.commit('setProId', pid)
  113. this.$store.commit(`setSecret`, '')
  114. this.RoomName = decodeURI(hostUrl.split('&')[2])
  115. this.objectId = hostUrl.split('&')[1]
  116. console.log(pid, this.RoomName, this.objectId)
  117. this.getDataList(this.objectId)
  118. this.saveAlarmName(this.objectId)
  119. this.show = true
  120. },
  121. // 监控到如果时间改变,重新触发请求报警条目的函数
  122. setChangeAlarm () {
  123. this.saveAlarmName(this.objectId)
  124. },
  125. // 存储条目数
  126. saveAlarmName (objectId) {
  127. console.log(objectId)
  128. let ctime = {}
  129. if (Object.values(this.selectParams.selectedStartTime).some(i => i.length)) {
  130. ctime = {
  131. $gte: this.selectParams.selectedStartTime.dStart,
  132. $lte: this.selectParams.selectedStartTime.dEnd
  133. }
  134. } else {
  135. ctime = null
  136. }
  137. let params = {
  138. objectId: objectId,
  139. ctime: ctime
  140. }
  141. axios.post(`/dp-auxiliary/alarm-system/alarm/alarmName/list?projectId=${this.$store.state.projId}&secret=${this.$store.state.secret}`, params).then(res => {
  142. let data = res.data
  143. if (data.Result == 'success') {
  144. this.alarmNameList = data.Content
  145. this.alarmNameList = this.alarmNameList.map(el => {
  146. return {value: el, text: el}
  147. })
  148. }
  149. })
  150. },
  151. back () {
  152. history.go(-1)
  153. },
  154. closeBox () {
  155. document.querySelector('.eq-head').style.display = 'none'
  156. },
  157. // 触发排序函数
  158. setSort (col) {
  159. this.order.column = col.key
  160. this.order.asc = col.order == 'asc'
  161. this.getDataList(this.objectId)
  162. },
  163. // 每个下拉框值变化触发表格数据的返回值
  164. setSelectParams (obj) {
  165. this.selectParams = obj
  166. if (this.change == 1) {
  167. this.saveAlarmName(this.objectId)
  168. }
  169. if (this.activeIndex == 0) {
  170. this.status = 'alarm'
  171. this.autoHandle = null
  172. } else if (this.activeIndex == 2) {
  173. this.status = 'alarm'
  174. this.autoHandle = false
  175. } else {
  176. this.status = null
  177. this.autoHandle = null
  178. }
  179. this.getDataList(this.objectId)
  180. },
  181. // 3个按钮的点击传参数
  182. onClickTab (status) {
  183. this.activeIndex = status
  184. if (status == 0) {
  185. this.status = 'alarm'
  186. this.autoHandle = null
  187. this.dateLimitDays = Number.MAX_SAFE_INTEGER
  188. this.getDataList(this.objectId)
  189. } else if (status == 2) {
  190. this.status = 'alarm'
  191. this.autoHandle = false
  192. this.dateLimitDays = Number.MAX_SAFE_INTEGER
  193. } else if (status == 1) {
  194. debugger
  195. this.status = null
  196. this.autoHandle = null
  197. this.dateLimitDays = 30
  198. this.selectParams.selectedStartTime.dStart = dataPickerConfig[this.datePickerKey].dStart // 20181215000000
  199. this.selectParams.selectedStartTime.dEnd = dataPickerConfig[this.datePickerKey].dEnd
  200. this.getDataList(this.objectId)
  201. this.saveAlarmName(this.objectId)
  202. }
  203. },
  204. // 默认未恢复的请求函数
  205. getDataList (objectId) {
  206. // 得到项目id和secret
  207. let params
  208. // 持续时间的转换
  209. let duration = {}
  210. if (Object.values(this.selectParams.selectedDurationTime).some(i => i.length)) {
  211. if (this.selectParams.selectedDurationTime == '5m') {
  212. duration.$lt = 5 * 60
  213. } else if (this.selectParams.selectedDurationTime == '2h') {
  214. duration.$gte = 300
  215. duration.$lte = 2 * 60 * 60
  216. } else if (this.selectParams.selectedDurationTime == '24h') {
  217. duration.$gte = 2 * 60 * 60
  218. duration.$lte = 24 * 60 * 60
  219. } else if (this.selectParams.selectedDurationTime == '1d') {
  220. duration.$gt = 24 * 60 * 60
  221. }
  222. } else {
  223. duration = null
  224. }
  225. // 开始时间的转换
  226. let ctime = {}
  227. if (Object.values(this.selectParams.selectedStartTime).some(i => i.length)) {
  228. ctime = {
  229. $gte: this.selectParams.selectedStartTime.dStart,
  230. $lte: this.selectParams.selectedStartTime.dEnd
  231. }
  232. } else {
  233. ctime = null
  234. }
  235. let order = null
  236. if (Object.values(this.order).some(i => i.length)) {
  237. order = this.order
  238. }
  239. // 参数的添加
  240. if (this.activeIndex == 0) {
  241. params = {
  242. criteria: {
  243. objectId: objectId,
  244. status: this.status
  245. },
  246. order: order
  247. }
  248. } if (this.activeIndex == 1) {
  249. params = {
  250. criteria: {
  251. levels: this.selectParams.selectedLevel.length > 0 ? this.selectParams.selectedLevel : null, // 选填,报警等级
  252. objectId: objectId,
  253. ctime: ctime,
  254. duration: duration,
  255. alarmName: this.selectParams.alarmName.length > 0 ? this.selectParams.alarmName : null, // 报警条目
  256. status: this.status,
  257. autoHandle: this.autoHandle
  258. },
  259. order: order
  260. }
  261. }
  262. // 请求表格数据
  263. axios.post(`/dp-auxiliary/alarm-system/alarm/list?projectId=${this.$store.state.projId}&secret=${this.$store.state.secret}`, params)
  264. .then(res => {
  265. let data = res.data
  266. if (data.Result == 'success') {
  267. this.tableData = data.Content
  268. this.total = data.Count
  269. this.tableData.forEach(el => {
  270. el.cTime = formatTime(el.ctime)
  271. el.durationT = secondsToDay(el.duration)
  272. el.alarmName = el.alarmName ? el.alarmName : ''
  273. el.location = el.source ? el.source : ''
  274. el.content = el.alarmName + '/' + el.location
  275. if (!el.autoHandle) {
  276. el.deal = 0
  277. } else {
  278. if (el.event.type == 1) {
  279. el.deal = 1
  280. } else if (el.event.type == 2) {
  281. el.deal = 2
  282. } else {
  283. el.deal = 3
  284. }
  285. }
  286. })
  287. // 自己分页
  288. if (this.activeIndex == 1) {
  289. this.changeCurrentPage(this.pageCurrent)
  290. }
  291. }
  292. })
  293. },
  294. // 分页 点击的是哪页
  295. changeCurrentPage (index) {
  296. this.historyTableData = []
  297. // 需要显示开始数据的index,(因为数据是从0开始的,页码是从1开始的,需要-1)
  298. let _start = (index - 1) * this.pageSize
  299. // 需要显示结束数据的index
  300. let _end = index * this.pageSize
  301. // 截取需要显示的数据
  302. this.historyTableData = this.tableData.slice(_start, _end)
  303. this.pageCurrent = index
  304. }
  305. }
  306. }
  307. </script>
  308. <style scoped lang="less" >
  309. .rooms {
  310. .eq-top {
  311. margin-bottom: 20px;
  312. >img {
  313. vertical-align: middle;
  314. cursor: pointer;
  315. border: 1px solid #CACACA;
  316. border-radius: 2px;
  317. }
  318. >span {
  319. font-size: 16px;
  320. color: #728DEE;
  321. }
  322. }
  323. .eq-head {
  324. width: 100%;
  325. background: #FFF6F5;
  326. border-radius: 2px;
  327. font-size: 14px;
  328. display: flex;
  329. margin:10px 0 20px 0;
  330. //height: 60px;
  331. position: relative;
  332. .f-left {
  333. width: 8px;
  334. background: #F08378;
  335. display: inline-block;
  336. }
  337. .f-right {
  338. padding: 20px 0 20px 38px;
  339. display: inline-block;
  340. .close-btn {
  341. position: absolute;
  342. right: 12px;
  343. top: 22px;
  344. }
  345. .f-salarm {
  346. font-size: 16px;
  347. color: #F08378;
  348. font-weight: bold;
  349. }
  350. }
  351. }
  352. .eq-bottom {
  353. background: #FFFFFF;
  354. box-shadow: 0 2px 10px 0 rgba(44,48,62,0.06);
  355. border-radius: 2px;
  356. padding-top:30px;
  357. .alarm-top {
  358. margin-bottom: 40px;
  359. display: flex;
  360. justify-content: center;
  361. span {
  362. text-align: center;
  363. padding: 6px 20px;
  364. color: #62697b;
  365. cursor: pointer;
  366. border: 1px solid #cacaca;
  367. border-right: none;
  368. &:last-child {
  369. border-right: 1px solid #cacaca;
  370. border-top-right-radius: 3px;
  371. border-bottom-right-radius: 3px;
  372. }
  373. &:first-child {
  374. border-top-left-radius: 3px;
  375. border-bottom-left-radius: 3px;
  376. }
  377. &:hover,
  378. &.active {
  379. background: #728DEE;
  380. color: #fff;
  381. }
  382. }
  383. }
  384. .my-select-type {
  385. padding-left: 30px;
  386. padding-right: 20px;
  387. }
  388. }
  389. }
  390. </style>