Aucune description

index.vue 13KB

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