声脉桥梁云监控平台

index.vue 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. <template>
  2. <div class="dashboard-editor-container">
  3. <BInfoDialog01 ref="BInfoDialog01"></BInfoDialog01>
  4. <BInfoDialog02 ref="BInfoDialog02"></BInfoDialog02>
  5. <BInfoDialog03 ref="BInfoDialog03"></BInfoDialog03>
  6. <BInfoDialog04 ref="BInfoDialog04"></BInfoDialog04>
  7. <updatePersonInfo ref="updatePersonInfo"></updatePersonInfo>
  8. <updateLoginPwd ref="updateLoginPwd"></updateLoginPwd>
  9. <el-row :gutter="20">
  10. <el-col :xs="24" :sm="15" :lg="18">
  11. <el-card class="box-card block-group">
  12. <div slot="header" class="block-title">
  13. <span>报警信息</span>
  14. <el-button type="text" @click="queryDangerInfo">查看全部</el-button>
  15. </div>
  16. <div class="load-box" v-loading="loadprogress1">
  17. <ul class="item-ul" v-if="dangerList.length">
  18. <li :class="!item.readed ? 'readed-li' : ''" v-for="item in dangerList" :key="item.index" @click="alarmShow(item.aid, item.readed, item.alarmTime, item.device)">
  19. <span>{{item.alarmTime}}</span>
  20. <span>{{item.device}},请点击查看。</span>
  21. <span class="svg-container" v-if="!item.readed">
  22. <svg-icon icon-class="unread"></svg-icon>
  23. </span>
  24. </li>
  25. </ul>
  26. <DefaultPage v-if="!dangerList.length && !loadprogress1"></DefaultPage>
  27. </div>
  28. </el-card>
  29. <el-card class="box-card block-group">
  30. <div slot="header" class="block-title">
  31. <span>实时监测</span>
  32. <el-button v-if="serverSeqArr.length" type="text" @click="updateDataList">刷新</el-button>
  33. </div>
  34. <div class="load-box" v-loading="loadprogress2">
  35. <el-row class="line-chart-box" v-if="monitorList.length">
  36. <el-col :xs="24" :sm="24" :lg="24" v-for="item in monitorShowList" :key="item.index">
  37. <lineChart :chartData="item" :maxXcount="maxShowLength"></lineChart>
  38. </el-col>
  39. </el-row>
  40. <DefaultPage v-if="!monitorList.length && !loadprogress2"></DefaultPage>
  41. </div>
  42. <div class="pagination-container">
  43. <el-pagination
  44. background
  45. @current-change="handleCurrentChange"
  46. :current-page.sync="currentNo"
  47. :page-size="currentSize"
  48. layout="prev, pager, next, jumper"
  49. :total="this.monitorList.length">
  50. </el-pagination>
  51. </div>
  52. </el-card>
  53. </el-col>
  54. <el-col :xs="24" :sm="9" :lg="6">
  55. <el-card class="box-card block-group">
  56. <div slot="header" class="block-title">
  57. <span>基础信息查看</span>
  58. </div>
  59. <el-row :gutter="10" class="item-row">
  60. <el-col :span="12"><div class="grid-content" @click="queryBirdgeInfo">桥梁信息</div></el-col>
  61. <el-col :span="12"><div class="grid-content" @click="queryServerInfo">采集服务器信息</div></el-col>
  62. <el-col :span="12"><div class="grid-content" @click="queryBoxInfo">采集盒信息</div></el-col>
  63. <el-col :span="12"><div class="grid-content" @click="querySensorInfo">传感器信息</div></el-col>
  64. </el-row>
  65. </el-card>
  66. <el-card class="box-card block-group">
  67. <div slot="header" class="block-title">
  68. <span>常用操作</span>
  69. </div>
  70. <el-row :gutter="10" class="item-row">
  71. <el-col :span="12"><div class="grid-content" @click="queryDangerInfo">历史报警信息查询</div></el-col>
  72. <el-col :span="12"><div class="grid-content" @click="queryMonitorInfo">历史监测信息查询</div></el-col>
  73. <el-col :span="12"><div class="grid-content" @click="updatePersonInfo">修改个人信息</div></el-col>
  74. <el-col :span="12"><div class="grid-content" @click="updateLoginPwd">修改登录密码</div></el-col>
  75. </el-row>
  76. </el-card>
  77. </el-col>
  78. </el-row>
  79. </div>
  80. </template>
  81. <script>
  82. import '@/styles/roleuser.scss'
  83. import Cookies from 'js-cookie'
  84. import queryInfo from '@/utils/queryInfo'
  85. import queryDict from '@/utils/queryDict'
  86. import monModel from '@/utils/timingConstruct'
  87. import { urlParse, parseTime } from '@/utils'
  88. import { getDangerList, getSysTime, getMonitorByTime } from '@/api/bridgeInfo'
  89. import lineChart from '../lineChart/LineChart'
  90. import BInfoDialog01 from './components/BInfoDialog01'
  91. import BInfoDialog02 from './components/BInfoDialog02'
  92. import BInfoDialog03 from './components/BInfoDialog03'
  93. import BInfoDialog04 from './components/BInfoDialog04'
  94. import updatePersonInfo from './components/updatePersonInfo'
  95. import updateLoginPwd from './components/updateLoginPwd'
  96. import DefaultPage from '@/components/DefaultPage'
  97. export default {
  98. name: 'dashboard-other',
  99. components: {
  100. lineChart,
  101. BInfoDialog01,
  102. BInfoDialog02,
  103. BInfoDialog03,
  104. BInfoDialog04,
  105. updatePersonInfo,
  106. updateLoginPwd,
  107. DefaultPage
  108. },
  109. data() {
  110. return {
  111. loadprogress1: true,
  112. loadprogress2: true,
  113. bridgeId: '',
  114. bridgeName: '',
  115. dialogW: '860px',
  116. citys: {},
  117. cableMain: {},
  118. addr: {},
  119. dangerList: '',
  120. serverSeqArr: [],
  121. serverList: [],
  122. deviceList: [],
  123. transducerList: [],
  124. currentNo: 1,
  125. currentSize: 4,
  126. currentTime: '',
  127. sysTime: '',
  128. localTimeiv: '',
  129. eastEightDistrict: 8 * 60 * 60 * 1000,
  130. maxShowLength: 300,
  131. monitorList: [],
  132. monitorCache: [],
  133. jishiTime: null
  134. }
  135. },
  136. watch: {
  137. $route(to, from) {
  138. if (to.path !== '/bridgeHome/bridgeDetail') {
  139. clearTimeout(this.jishiTime)
  140. this.jishiTime = null
  141. }
  142. }
  143. },
  144. computed: {
  145. monitorShowList() {
  146. return this.monitorList.slice((this.currentNo - 1) * this.currentSize, this.currentNo * this.currentSize)
  147. }
  148. },
  149. created() {
  150. var that = this
  151. if (urlParse('id')) {
  152. that.bridgeId = urlParse('id')
  153. that.bridgeName = urlParse('name')
  154. } else {
  155. that.bridgeId = Cookies.get('bridgeId')
  156. that.bridgeName = Cookies.get('bridgeName')
  157. }
  158. that.getDictoryData()
  159. queryInfo.qaiCb(function() {
  160. if (that.bridgeId) {
  161. that.serverSeqArr = queryInfo.queryServers(that.bridgeId, true)
  162. if (that.serverSeqArr.length) {
  163. that.updateDataList()
  164. that.getDangerList()
  165. }
  166. }
  167. })
  168. },
  169. methods: {
  170. updateDataList() {
  171. clearTimeout(this.jishiTime)
  172. this.jishiTime = null
  173. this.monitorList = []
  174. this.monitorCache = []
  175. this.getSysTime()
  176. },
  177. getDangerList() {
  178. var arr = this.serverSeqArr
  179. const param = {
  180. seq: arr,
  181. pageSize: 5,
  182. pageNo: 1
  183. }
  184. this.loadprogress1 = true
  185. getDangerList(param).then(res => {
  186. if (res.success && res.data.data) {
  187. this.loadprogress1 = false
  188. const dataS = res.data.data
  189. for (let i = 0; i < dataS.length; i++) {
  190. if (dataS[i].alarmTime) {
  191. dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
  192. }
  193. dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
  194. }
  195. this.dangerList = dataS
  196. }
  197. })
  198. },
  199. getSysTime() {
  200. var that = this
  201. var arr = this.serverSeqArr
  202. getSysTime({ seq: arr }).then(res => {
  203. if (res.success && res.data && res.data.length > 0) {
  204. const nowt = parseTime(res.data[0].ctime, true, true)
  205. that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 2 * 1000
  206. const localTime = new Date().getTime() + that.eastEightDistrict
  207. that.localTimeiv = localTime - that.sysTime
  208. that.first_Q = true
  209. that.getTimingMonitor()
  210. } else {
  211. that.loadprogress2 = false
  212. }
  213. })
  214. },
  215. formatTime(time) {
  216. var d = new Date()
  217. d.setTime(time)
  218. d = JSON.stringify(d).replace(/[^\d]/g, '').substring(0, 14)
  219. return d
  220. },
  221. getTimingMonitor() {
  222. var that = this
  223. var arr = this.serverSeqArr
  224. var startTime = this.formatTime(this.sysTime)
  225. var endTime = this.formatTime(this.sysTime)
  226. that.sysTime += 1000
  227. getMonitorByTime({ seq: arr, begin: startTime, end: endTime }).then(res => {
  228. var mCache = that.monitorCache
  229. var mList = []
  230. if (res.success && res.data) {
  231. if (that.first_Q) {
  232. that.loadprogress2 = false
  233. if (res.data.length) {
  234. that.first_Q = false
  235. var ftime = res.data[0].ctime
  236. monModel.construct(mCache, res.data)
  237. var f_q_t = that.sysTime
  238. for (;;) {
  239. var fts = that.formatTime(f_q_t)
  240. var ftsE = that.formatTime(f_q_t + 500)
  241. if (fts >= ftime) {
  242. if (fts > that.sysTime) {
  243. monModel.setData(mCache, res.data, fts, ftsE, null)
  244. }
  245. }
  246. f_q_t += 1000
  247. if (f_q_t > that.sysTime) {
  248. break
  249. }
  250. }
  251. for (let l = 0; l < mCache.length; ++l) {
  252. mList.push(mCache[l].cd)
  253. }
  254. }
  255. } else {
  256. var xtime = that.formatTime(that.sysTime)
  257. var xtimeE = that.formatTime(that.sysTime + 500)
  258. monModel.setData(mCache, res.data, xtime, xtimeE, that.maxShowLength)
  259. for (let l = 0; l < mCache.length; ++l) {
  260. mList.push(mCache[l].cd)
  261. }
  262. }
  263. that.monitorList = mList
  264. var st = new Date().getTime() + that.eastEightDistrict - that.localTimeiv
  265. var iv = that.sysTime - st
  266. if (iv < 0) {
  267. iv = 1
  268. }
  269. that.jishiTime = setTimeout(() => {
  270. that.getTimingMonitor()
  271. }, iv)
  272. }
  273. })
  274. },
  275. getDictoryData() {
  276. const that = this
  277. queryDict.applyDict('ZLLX', function(dictData) {
  278. dictData.map(item => {
  279. that.cableMain[item.code] = item.caption
  280. })
  281. }) // 主缆
  282. queryDict.applyDict('ZLWZ', function(dictData) {
  283. dictData.map(item => {
  284. that.addr[item.code] = item.caption
  285. })
  286. }) // 位置
  287. queryDict.applyDict('XZQH', function(dictData) {
  288. dictData.map(item => {
  289. that.citys[item.code] = item.fullCaption
  290. })
  291. }) // 城市级联
  292. },
  293. handleCurrentChange(val) {
  294. this.currentNo = val
  295. },
  296. alarmShow(id, flag, time, msg) {
  297. this.$router.replace({
  298. name: 'dangerDetail',
  299. query: { aid: id, msg: msg, _t: time, flag: flag }
  300. })
  301. },
  302. queryDangerInfo() {
  303. this.$router.replace({ name: 'dangerList' })
  304. },
  305. queryMonitorInfo() {
  306. this.$router.replace({ name: 'bridgeMonitor' })
  307. },
  308. queryBirdgeInfo() {
  309. this.$refs.BInfoDialog01.dialogTableVisible = true
  310. },
  311. queryServerInfo() {
  312. this.$refs.BInfoDialog02.queryServerList()
  313. this.$refs.BInfoDialog02.dialogTableVisible = true
  314. },
  315. queryBoxInfo() {
  316. this.$refs.BInfoDialog03.queryDeviceList()
  317. this.$refs.BInfoDialog03.dialogTableVisible = true
  318. },
  319. querySensorInfo() {
  320. this.$refs.BInfoDialog04.queryTransList()
  321. this.$refs.BInfoDialog04.dialogTableVisible = true
  322. },
  323. updatePersonInfo() {
  324. this.$refs.updatePersonInfo.getUserSelf()
  325. this.$refs.updatePersonInfo.dialogTableVisible = true
  326. },
  327. updateLoginPwd() {
  328. this.$refs.updateLoginPwd.dialogTableVisible = true
  329. }
  330. },
  331. beforeDestroy() {
  332. clearTimeout(this.jishiTime)
  333. }
  334. }
  335. </script>