Keine Beschreibung

index.vue 13KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  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, isEqualArr } 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. dangerAidArr: [],
  121. first_Dan: true,
  122. serverSeqArr: [],
  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: '',
  134. jishiTime2: ''
  135. }
  136. },
  137. computed: {
  138. monitorShowList() {
  139. return this.monitorList.slice((this.currentNo - 1) * this.currentSize, this.currentNo * this.currentSize)
  140. }
  141. },
  142. created() {
  143. var that = this
  144. if (this.jishiTime) {
  145. clearTimeout(this.jishiTime)
  146. }
  147. if (urlParse('id')) {
  148. that.bridgeId = urlParse('id')
  149. that.bridgeName = urlParse('name')
  150. } else {
  151. that.bridgeId = Cookies.get('bridgeId')
  152. that.bridgeName = Cookies.get('bridgeName')
  153. }
  154. that.getDictoryData()
  155. queryInfo.qaiCb(function() {
  156. if (that.bridgeId) {
  157. that.serverSeqArr = queryInfo.queryServers(that.bridgeId, true)
  158. that.transducerList = queryInfo.queryTrans(that.bridgeId)
  159. if (that.serverSeqArr.length) {
  160. that.updateDataList()
  161. that.getDangerList()
  162. }
  163. }
  164. })
  165. },
  166. methods: {
  167. updateDataList() {
  168. var that = this
  169. clearTimeout(that.jishiTime)
  170. that.jishiTime = ''
  171. that.sysTime = ''
  172. that.monitorList = []
  173. that.monitorCache = []
  174. if (that.transducerList.length) {
  175. monModel.construct(that.monitorCache, that.transducerList)
  176. }
  177. that.getSysTime()
  178. },
  179. getDangerList() {
  180. var that = this
  181. var arr = this.serverSeqArr
  182. const param = {
  183. seq: arr,
  184. pageSize: 5,
  185. pageNo: 1
  186. }
  187. if (that.first_Dan) {
  188. this.loadprogress1 = true
  189. }
  190. getDangerList(param).then(res => {
  191. var dCache = that.dangerAidArr
  192. var DList = []
  193. if (res.success && res.data.data) {
  194. const dataS = res.data.data
  195. if (that.first_Dan) {
  196. that.first_Dan = false
  197. for (let i = 0; i < dataS.length; i++) {
  198. dCache.push(dataS[i].aid)
  199. if (dataS[i].alarmTime) {
  200. dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
  201. }
  202. dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
  203. }
  204. that.dangerList = dataS
  205. } else {
  206. for (let i = 0; i < dataS.length; i++) {
  207. DList.push(dataS[i].aid)
  208. if (dataS[i].alarmTime) {
  209. dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
  210. }
  211. dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
  212. }
  213. if (!isEqualArr(DList, dCache)) {
  214. dCache = []
  215. dCache = DList
  216. that.dangerList = dataS
  217. }
  218. }
  219. that.loadprogress1 = false
  220. if (that && !that._isDestroyed) {
  221. that.jishiTime2 = setTimeout(function() {
  222. if (that && !that._isDestroyed) {
  223. that.getDangerList(param)
  224. }
  225. }, 5000)
  226. } else {
  227. that.jishiTime2 = ''
  228. }
  229. } else {
  230. that.loadprogress1 = false
  231. }
  232. })
  233. },
  234. getSysTime() {
  235. var that = this
  236. var arr = this.serverSeqArr
  237. getSysTime({ seq: arr }).then(res => {
  238. if (res.success) {
  239. if (res.data && res.data.length > 0) {
  240. const nowt = parseTime(res.data[0].ctime, true, true)
  241. that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 2 * 1000
  242. that.first_Q = true
  243. } else {
  244. that.sysTime = (new Date()).getTime() + that.eastEightDistrict - 2 * 1000
  245. that.loadprogress2 = false
  246. }
  247. setTimeout(function() {
  248. const localTime = new Date().getTime() + that.eastEightDistrict
  249. that.localTimeiv = localTime - that.sysTime
  250. that.getTimingMonitor()
  251. }, 1)
  252. }
  253. })
  254. },
  255. formatTime(time) {
  256. var d = new Date()
  257. d.setTime(time)
  258. d = JSON.stringify(d).replace(/[^\d]/g, '').substring(0, 14)
  259. return d
  260. },
  261. getTimingMonitor() {
  262. var that = this
  263. var arr = this.serverSeqArr
  264. var startTime = this.formatTime(this.sysTime)
  265. var endTime = this.formatTime(this.sysTime)
  266. that.sysTime += 1000
  267. getMonitorByTime({ seq: arr, begin: startTime, end: endTime }).then(res => {
  268. var mList = []
  269. if (res.success && res.data) {
  270. if (that.first_Q) {
  271. if (res.data.length) {
  272. that.first_Q = false
  273. that.loadprogress2 = false
  274. var ftime = res.data[0].ctime
  275. var f_q_t = that.sysTime
  276. for (;;) {
  277. var fts = that.formatTime(f_q_t)
  278. var ftsE = that.formatTime(f_q_t + 500)
  279. if (fts >= ftime) {
  280. if (fts > that.sysTime) {
  281. monModel.setData(that.monitorCache, res.data, fts, ftsE, null)
  282. }
  283. }
  284. f_q_t += 1000
  285. if (f_q_t > that.sysTime) {
  286. break
  287. }
  288. }
  289. for (let l = 0; l < that.monitorCache.length; ++l) {
  290. mList.push(that.monitorCache[l].cd)
  291. }
  292. }
  293. } else {
  294. var xtime = that.formatTime(that.sysTime)
  295. var xtimeE = that.formatTime(that.sysTime + 500)
  296. monModel.setData(that.monitorCache, res.data, xtime, xtimeE, that.maxShowLength)
  297. for (let l = 0; l < that.monitorCache.length; ++l) {
  298. mList.push(that.monitorCache[l].cd)
  299. }
  300. }
  301. that.monitorList = mList
  302. if (that && !that._isDestroyed) {
  303. var st = new Date().getTime() + that.eastEightDistrict - that.localTimeiv
  304. var iv = that.sysTime - st
  305. if (iv < 0) {
  306. iv = 1
  307. }
  308. that.jishiTime = setTimeout(function() {
  309. if (that && !that._isDestroyed) {
  310. that.getTimingMonitor()
  311. }
  312. }, iv)
  313. } else {
  314. that.jishiTime = ''
  315. }
  316. }
  317. })
  318. },
  319. getDictoryData() {
  320. const that = this
  321. queryDict.applyDict('ZLLX', function(dictData) {
  322. dictData.map(item => {
  323. that.cableMain[item.code] = item.caption
  324. })
  325. }) // 主缆
  326. queryDict.applyDict('ZLWZ', function(dictData) {
  327. dictData.map(item => {
  328. that.addr[item.code] = item.caption
  329. })
  330. }) // 位置
  331. queryDict.applyDict('XZQH', function(dictData) {
  332. dictData.map(item => {
  333. that.citys[item.code] = item.fullCaption
  334. })
  335. }) // 城市级联
  336. },
  337. handleCurrentChange(val) {
  338. this.currentNo = val
  339. },
  340. alarmShow(id, flag, time, msg) {
  341. this.$router.replace({
  342. name: 'dangerDetail',
  343. query: { aid: id, msg: msg, _t: time, flag: flag }
  344. })
  345. },
  346. queryDangerInfo() {
  347. this.$router.replace({ name: 'dangerList' })
  348. },
  349. queryMonitorInfo() {
  350. this.$router.replace({ name: 'bridgeMonitor' })
  351. },
  352. queryBirdgeInfo() {
  353. this.$refs.BInfoDialog01.dialogTableVisible = true
  354. },
  355. queryServerInfo() {
  356. this.$refs.BInfoDialog02.queryServerList()
  357. this.$refs.BInfoDialog02.dialogTableVisible = true
  358. },
  359. queryBoxInfo() {
  360. this.$refs.BInfoDialog03.queryDeviceList()
  361. this.$refs.BInfoDialog03.dialogTableVisible = true
  362. },
  363. querySensorInfo() {
  364. this.$refs.BInfoDialog04.queryTransList()
  365. this.$refs.BInfoDialog04.dialogTableVisible = true
  366. },
  367. updatePersonInfo() {
  368. this.$refs.updatePersonInfo.getUserSelf()
  369. this.$refs.updatePersonInfo.dialogTableVisible = true
  370. },
  371. updateLoginPwd() {
  372. this.$refs.updateLoginPwd.dialogTableVisible = true
  373. }
  374. },
  375. beforeDestroy() {
  376. this.$once('hook:beforeDestroy', () => {
  377. clearTimeout(this.jishiTime)
  378. clearTimeout(this.jishiTime2)
  379. })
  380. }
  381. }
  382. </script>