monitor.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850
  1. <!--监控中心-->
  2. <template>
  3. <div class="visual-con">
  4. <!--头部-->
  5. <vheader></vheader>
  6. <!--主体-->
  7. <div class="visual-body">
  8. <!-- 左侧 -->
  9. <div class="leftbar" :class="indentleft" ref="left">
  10. <div class="forthis">
  11. <dv-border-box-13 backgroundColor="rgba(12, 19, 38, .90)" style="padding-bottom: 1rem;">
  12. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  13. <div class="this-title">
  14. <span>事态感知</span>
  15. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  16. </div>
  17. <div class="i-list-con h-73">
  18. <div class="d-l-con-icon">
  19. <div class="icon-con w-33 m-btm-no" :class="{on:iconCurrentIndex1==index}"
  20. v-for="(item,index) in visuForestCloudMapDeviceBOList"
  21. v-on:click="selectDeviceType(index)">
  22. <!-- -->
  23. <div class="icon icon-dot"></div>
  24. <div class="icon-text">
  25. <h6>{{ item.deviceCount }}</h6>
  26. <h5>{{ item.deviceName }}</h5>
  27. </div>
  28. </div>
  29. <div class="icon-con w-33 m-btm-no">
  30. <div class="icon icon-dot"></div>
  31. <div class="icon-text">
  32. <h6>0</h6>
  33. <h5>传感器</h5>
  34. </div>
  35. </div>
  36. <div class="icon-con w-33 m-btm-no">
  37. <div class="icon icon-dot"></div>
  38. <div class="icon-text">
  39. <h6>0</h6>
  40. <h5>大喇叭</h5>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="overflow-y" style="height: 33vh;">
  45. <el-collapse accordion>
  46. <el-collapse-item v-for="(item,index) in region" :key="index">
  47. <!-- deptId -->
  48. <template slot="title">
  49. <div class="d-l-con sj-collapse" :class="{on:listCurrentIndex1==item.deptId}"
  50. v-on:click="selectCameraByDeptId(item.deptId)">
  51. <div class="d-l-l-text">
  52. <h4 class="collapse-title">{{ item.deptName }}</h4>
  53. </div>
  54. <div class="d-l-l-count">{{ item.deptCount }}</div>
  55. </div>
  56. </template>
  57. </el-collapse-item>
  58. </el-collapse>
  59. </div>
  60. <!-- 横向柱状 echart -->
  61. <div class="overflow-y" style="height: 33vh;">
  62. <div id="camera-chart" style="width: 100%;height:33vh;"></div>
  63. </div>
  64. </div>
  65. </dv-border-box-13>
  66. </div>
  67. </div>
  68. <!-- 地图 -->
  69. <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
  70. :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false" @preview="preview">
  71. </supermap>
  72. <!-- 右侧 -->
  73. <div class="rightbar" :class="indentright" ref="right">
  74. <div class="forthis">
  75. <dv-border-box-13 backgroundColor="rgba(12, 19, 38, .90)" style="padding-bottom: 1rem;">
  76. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  77. <div class="this-title">
  78. <span>列表</span>
  79. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  80. </div>
  81. <div class="i-list-con h-43">
  82. <div class="d-l-con" v-for="(item,index) in visuForestCloudCameraBOList"
  83. :class="{on:listCurrentIndex2 == index}"
  84. v-on:click="dropLocation(item.latitude,item.longitude,index)">
  85. <div class="d-l-l-text">
  86. <i class="iconfont sj-icon-jkzx icon-sxt"></i>
  87. <h4>{{ item.cameraName }}</h4>
  88. </div>
  89. </div>
  90. </div>
  91. </dv-border-box-13>
  92. </div>
  93. <div class="forthis">
  94. <dv-border-box-13 backgroundColor="rgba(12, 19, 38, .90)" style="padding-bottom: 1rem;">
  95. <img src="../assets/images/integrated/light.png" style="width: 100%; margin-top: .4rem;"/>
  96. <div class="this-title">
  97. <span>重点区域</span>
  98. <dv-decoration-3 style="width:150px;height:15px;margin-right: 1rem;"/>
  99. </div>
  100. <div class="i-list-con h-25">
  101. <div class="d-l-con" v-for="(item,index) in keyAreaList" :class="{on:listCurrentIndex3 == index}" @click="getRegionalFlag(item.id)">
  102. <div class="d-l-l-text">
  103. <i class="i-small"></i>
  104. <h4>{{ item.areaName }}</h4>
  105. </div>
  106. </div>
  107. </div>
  108. </dv-border-box-13>
  109. </div>
  110. </div>
  111. <vBottomMenu ref="bottomMenu"></vBottomMenu>
  112. <!-- <el-tooltip :content="indentText" placement="top" :disabled="indentdisabled">-->
  113. <!-- <div class="mascot" ref="mascot" :class="indentStyle" @click="indent"><img-->
  114. <!-- src="@/assets/images/mascot.png"/></div>-->
  115. <!-- </el-tooltip>-->
  116. </div>
  117. <eventLocation ref="eventLocation"></eventLocation>
  118. <TVWall ref="TVWall"></TVWall>
  119. <el-dialog :title="cameraTitle" :visible.sync="cameraVisible" v-if="cameraVisible" customClass="videoCustomWidth"
  120. @close="cancelEventLocationShow()">
  121. <div style="width:1020px;height:625px;position:relative;">
  122. <!--视频窗口展示---海康-->
  123. <div id="playWnd" class="playWnd" style="left: 0px; top: 0px;"></div>
  124. </div>
  125. </el-dialog>
  126. </div>
  127. </template>
  128. <script>
  129. import {
  130. selectDeviceType,
  131. selectCameraByDeptId,
  132. selectKeyAreaList,
  133. getRegionalFlag
  134. } from '@/api/monitor'
  135. import supermap from '@/components/supermap' //超图
  136. import vheader from '@/components/v-header.vue' //一体化共用头部
  137. import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
  138. import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗
  139. import TVWall from '@/components/TVWall.vue' //电视墙弹窗
  140. /** ----------------------------------摄像头预览开始------------------------------------- */
  141. import {
  142. getDahuaVideoServer
  143. } from '@/api/dahua/dahua'
  144. import {
  145. getHaiKangVideoServer
  146. } from '@/api/haikang/haikang'
  147. // import DHWs from '@/dahua/lib/DHWs'
  148. /** ----------------------------------摄像头预览结束------------------------------------- */
  149. // import echarts from 'echarts'
  150. let echarts = require('echarts')
  151. export default {
  152. components: {
  153. supermap,
  154. vheader,
  155. vBottomMenu,
  156. eventLocation,
  157. TVWall
  158. },
  159. created() {
  160. /** ----------------------------------摄像头预览开始------------------------------------- */
  161. // const DHWsInstance = DHWs.getInstance()
  162. // this.ws = DHWsInstance
  163. /** ----------------------------------摄像头预览结束------------------------------------- */
  164. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  165. window.showDialog = this.showDialog
  166. window.choseLayerSwitching = this.choseLayerSwitching
  167. window.choseLayerSwitchingList = this.choseLayerSwitchingList
  168. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  169. },
  170. mounted() {
  171. this.selectDeviceType(-1)
  172. this.selectKeyAreaList()
  173. },
  174. data() {
  175. return {
  176. iconCurrentIndex1: '-1',
  177. listCurrentIndex1: '-1',
  178. listCurrentIndex2: '-1',
  179. listCurrentIndex3: '-1',
  180. graphicsList:[],//重点区域
  181. /** ----------------------------------摄像头预览开始------------------------------------- */
  182. //大华
  183. activePanel: 'key1',
  184. isLogin: false,
  185. cameraParams: [],
  186. ws: null,
  187. //海康
  188. cameraTitle: '',
  189. cameraVisible: false,
  190. initCount: 0,
  191. pubKey: '',
  192. oWebControl: null,
  193. /** ----------------------------------摄像头预览结束------------------------------------- */
  194. visuForestCloudMapDeviceBOList: [],
  195. visuForestCloudCameraBOList: [],
  196. cameraMarkersList: [],
  197. sourceData: [],
  198. keyAreaList: [],//重点区域
  199. iframeBoo: true,
  200. open: false,
  201. iframeVue: null,
  202. activeName: 'info',
  203. radio: '1',
  204. region: [],
  205. //左右缩进
  206. indentStyle: '',
  207. indentleft: '',
  208. indentright: '',
  209. indentText: '收起左右栏',
  210. indentdisabled: false
  211. }
  212. },
  213. methods: {
  214. selectKeyAreaList() {
  215. this.keyAreaList=[]
  216. //获取重点区域列表
  217. let that = this
  218. selectKeyAreaList().then(res => {
  219. that.keyAreaList = res.data
  220. })
  221. },
  222. getRegionalFlag(id){
  223. //获取重点区域
  224. this.listCurrentIndex3=id
  225. let that = this
  226. getRegionalFlag(id).then(res => {
  227. that.graphicsList=[]
  228. //地图标记
  229. if (res.data != null && res.data.length > 0) {
  230. for (let i = 0; i < res.data.length; i++) {
  231. let latlng = {
  232. lat: res.data[i].lat,
  233. lng: res.data[i].lng
  234. }
  235. that.graphicsList.push(latlng)
  236. }
  237. setTimeout(() => {
  238. that.$refs.supermap.clearG()
  239. that.$refs.supermap.setGraphicsList(this.graphicsList, 'red')
  240. }, 1000)
  241. } else {
  242. that.$refs.supermap.clearG()
  243. }
  244. })
  245. },
  246. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  247. showDialog(click) {
  248. if (click == 'eventLocation') {
  249. this.$refs.eventLocation.showEventLocation()
  250. this.$refs.supermap.isEditableLayers = false
  251. this.$refs.bottomMenu.showChild = false
  252. this.$refs.bottomMenu.showBanChild = false
  253. this.$refs.bottomMenu.showChangChild = false
  254. } else if (click == 'editableLayers') {
  255. this.$refs.bottomMenu.showChild = false
  256. this.$refs.bottomMenu.showBanChild = false
  257. this.$refs.bottomMenu.showChangChild = false
  258. if (!this.$refs.supermap.isEditableLayers) {
  259. this.$refs.supermap.isEditableLayers = true
  260. } else {
  261. this.$refs.supermap.isEditableLayers = false
  262. }
  263. } else if (click == 'layerSwitching') {
  264. this.$refs.supermap.isEditableLayers = false
  265. this.$refs.bottomMenu.showBanChild = false
  266. this.$refs.bottomMenu.showChangChild = false
  267. if (!this.$refs.bottomMenu.showChild) {
  268. this.$refs.bottomMenu.showChild = true
  269. } else {
  270. this.$refs.bottomMenu.showChild = false
  271. }
  272. } else if (click == 'TVWall') {
  273. this.$refs.TVWall.showTVWall()
  274. this.$refs.supermap.isEditableLayers = false
  275. this.$refs.bottomMenu.showChild = false
  276. this.$refs.bottomMenu.showBanChild = false
  277. this.$refs.bottomMenu.showChangChild = false
  278. } else if (click == 'forestban') {
  279. this.$refs.supermap.isEditableLayers = false
  280. this.$refs.bottomMenu.showChild = false
  281. this.$refs.bottomMenu.showChangChild = false
  282. if (!this.$refs.bottomMenu.showBanChild) {
  283. this.$refs.bottomMenu.showBanChild = true
  284. } else {
  285. this.$refs.bottomMenu.showBanChild = false
  286. }
  287. } else if (click == 'forestchang') {
  288. this.$refs.supermap.isEditableLayers = false
  289. this.$refs.bottomMenu.showBanChild = false
  290. this.$refs.bottomMenu.showChild = false
  291. if (!this.$refs.bottomMenu.showChangChild) {
  292. this.$refs.bottomMenu.showChangChild = true
  293. } else {
  294. this.$refs.bottomMenu.showChangChild = false
  295. }
  296. }
  297. },
  298. //选择图层
  299. choseLayerSwitching(url, isClear) {
  300. this.$refs.supermap.layerSwitching(url, isClear)
  301. },
  302. //选择图层(传递数组)
  303. choseLayerSwitchingList(urlList) {
  304. this.$refs.supermap.layerSwitchingList(urlList)
  305. },
  306. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  307. cameraChat() {
  308. // 基于准备好的dom,初始化echarts实例
  309. let myChart = echarts.init(document.getElementById('camera-chart'))
  310. // 绘制图表
  311. const dfColor = ['#92E1FF', '#0097FB', '#30ECA6', '#FFC227', '#FF4848']
  312. myChart.setOption({
  313. dataset: {
  314. source: this.sourceData
  315. },
  316. tooltip: {
  317. trigger: 'item'
  318. },
  319. grid: {
  320. top: '5%',
  321. left: '2%',
  322. // right: "4%",
  323. bottom: '-15%',
  324. width: '75%',
  325. containLabel: true
  326. },
  327. xAxis: {
  328. show: false,
  329. type: 'value'
  330. },
  331. yAxis: {
  332. type: 'category', // 不设置类目轴,抽离的dataset数据展示不出来
  333. inverse: true,
  334. axisLabel: {
  335. show: true,
  336. textStyle: {
  337. color: '#5deaff',
  338. fontSize: '12'
  339. }
  340. },
  341. splitLine: {
  342. show: false
  343. },
  344. axisTick: {
  345. show: false
  346. },
  347. axisLine: {
  348. show: false
  349. }
  350. },
  351. series: [{
  352. type: 'bar',
  353. animationCurve: 'easeOutBack',
  354. barWidth: 5,
  355. label: {
  356. show: true,
  357. position: 'right',
  358. offset: [0, 0],
  359. color: '#88dfd5',
  360. // fontSize: "12",
  361. style: {
  362. fill: '#fff'
  363. }
  364. },
  365. backgroundBar: {
  366. show: true,
  367. style: {
  368. fill: 'rgba(97,152,255,0.20)'
  369. }
  370. },
  371. barStyle: {
  372. stroke: 'rgba(41,244,236,1)'
  373. },
  374. gradient: {
  375. color: ['rgba(41,244,236,1)', 'rgba(41,244,236,0)']
  376. },
  377. itemStyle: {
  378. label: {
  379. show: true
  380. },
  381. labelLine: {
  382. show: false
  383. },
  384. color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{
  385. offset: 0,
  386. color: 'rgba(41,244,236,0)'
  387. },
  388. {
  389. offset: 1,
  390. color: 'rgba(41,244,236,.5)'
  391. }
  392. ]),
  393. borderColor: '#a2f9f7',
  394. shadowBlur: 16,
  395. shadowColor: '#a2f9f7'
  396. }
  397. }]
  398. })
  399. },
  400. selectDeviceType(index) {
  401. this.iconCurrentIndex1 = index
  402. //获取左侧动态感知设备
  403. let that = this
  404. selectDeviceType().then(res => {
  405. that.cameraMarkersList=[]
  406. that.visuForestCloudMapDeviceBOList = res.data.visuForestCloudMapDeviceBOList
  407. that.region = res.data.visuForestCloudTodaySjfbBOList
  408. if (res.data.visuForestCloudTodaySjfbBOList != null && res.data.visuForestCloudTodaySjfbBOList
  409. .length > 0) {
  410. for (let i = 0; i < res.data.visuForestCloudTodaySjfbBOList.length; i++) {
  411. let aa = []
  412. aa.push(res.data.visuForestCloudTodaySjfbBOList[i].deptName)
  413. aa.push(Number(res.data.visuForestCloudTodaySjfbBOList[i].deptCount))
  414. this.sourceData.push(aa)
  415. }
  416. }
  417. that.visuForestCloudCameraBOList = res.data.visuForestCloudCameraBOList
  418. this.cameraChat()
  419. if (res.data.visuForestCloudCameraBOList != null && res.data.visuForestCloudCameraBOList
  420. .length > 0) {
  421. for (let i = 0; i < res.data.visuForestCloudCameraBOList.length; i++) {
  422. let markersMap = {
  423. lng: 124.59,
  424. lat: 43.02,
  425. icon: 'camera',
  426. bindPopupHtml: '',
  427. click: 'preview',
  428. parameter: '',
  429. keepBindPopup: false,
  430. isAggregation: false
  431. }
  432. if (res.data.visuForestCloudCameraBOList[i].channelCode != null) {
  433. markersMap.parameter = res.data.visuForestCloudCameraBOList[i].cameraCode
  434. } else {
  435. markersMap.parameter = []
  436. }
  437. markersMap.lng = res.data.visuForestCloudCameraBOList[i].longitude
  438. markersMap.lat = res.data.visuForestCloudCameraBOList[i].latitude
  439. markersMap.radius = res.data.visuForestCloudCameraBOList[i].cameraRadius
  440. markersMap.bindPopupHtml = '<div class="map-tip">' +
  441. '<span>' +
  442. ' <div class="d-l-con">' +
  443. ' <div class="d-l-l-text">' +
  444. ' <h4>经纬度:' + res.data.visuForestCloudCameraBOList[i].longitude +
  445. ',' + res.data.visuForestCloudCameraBOList[i].latitude + '</h4>' +
  446. ' </div>' +
  447. ' </div>' +
  448. ' </span>' +
  449. '<span>' +
  450. ' <div class="d-l-con">' +
  451. ' <div class="d-l-l-text">' +
  452. ' <h4>摄像头名称:' + res.data.visuForestCloudCameraBOList[i]
  453. .cameraName + '</h4>' +
  454. ' </div>' +
  455. ' </div>' +
  456. ' </span>' +
  457. '<span>' +
  458. ' <div class="d-l-con">' +
  459. ' <div class="d-l-l-text">' +
  460. ' <h4>摄像头类型:' + res.data.visuForestCloudCameraBOList[i]
  461. .cameraFactory + '</h4>' +
  462. ' </div>' +
  463. ' </div>' +
  464. ' </span>' +
  465. '<span>' +
  466. ' <div class="d-l-con">' +
  467. ' <div class="d-l-l-text">' +
  468. ' <h4>摄像头半径:' + res.data.visuForestCloudCameraBOList[i]
  469. .cameraRadius + '米</h4>' +
  470. ' </div>' +
  471. ' </div>' +
  472. ' </span>' +
  473. '</div>'
  474. this.cameraMarkersList.push(markersMap)
  475. // cameraAccount: "1"
  476. // cameraCode: "1000010"
  477. // cameraFactory: "2"
  478. // cameraIp: "1"
  479. // cameraName: "2"
  480. // cameraPasword: "2"
  481. // cameraPort: 2
  482. // cameraRadius: 20
  483. // cameraRegion: "3"
  484. // dataDeptId: null
  485. // dataStatus: null
  486. // eventType: null
  487. // height: "11"
  488. // id: "0d165fc362514f79b12a899ea66295fd"
  489. // latitude: "49.325625"
  490. // longitude: "125.3333"
  491. }
  492. setTimeout(() => {
  493. that.$refs.supermap.clearM(true)
  494. that.$refs.supermap.clearM(false)
  495. that.$refs.supermap.setMarkersRadius(this.cameraMarkersList)
  496. }, 1000)
  497. }
  498. })
  499. },
  500. dropLocation(lat, lng, index) {
  501. this.listCurrentIndex2 = index
  502. this.$refs.supermap.dropLocation(lat, lng)
  503. },
  504. selectCameraByDeptId(depId) {
  505. this.listCurrentIndex1 = depId
  506. let that = this
  507. that.cameraMarkersList = []
  508. that.visuForestCloudCameraBOList = []
  509. selectCameraByDeptId(depId).then(res => {
  510. //根据设备类型查看列表
  511. that.visuForestCloudCameraBOList = res.data
  512. if (res.data != null && res.data.length > 0) {
  513. for (let i = 0; i < res.data.length; i++) {
  514. let markersMap = {
  515. lng: 124.59,
  516. lat: 43.02,
  517. icon: 'camera',
  518. bindPopupHtml: '',
  519. click: 'preview',
  520. parameter: '',
  521. keepBindPopup: false,
  522. isAggregation: false
  523. }
  524. if (res.data[i].channelCode != null) {
  525. markersMap.parameter = res.data[i].cameraCode
  526. } else {
  527. markersMap.parameter = []
  528. }
  529. markersMap.lng = res.data[i].longitude
  530. markersMap.lat = res.data[i].latitude
  531. markersMap.radius = res.data[i].cameraRadius
  532. markersMap.bindPopupHtml = '<div class="map-tip">' +
  533. '<span>' +
  534. ' <div class="d-l-con">' +
  535. ' <div class="d-l-l-text">' +
  536. ' <h4>经纬度:' + res.data[i].longitude + ',' + res.data[i].latitude +
  537. '</h4>' +
  538. ' </div>' +
  539. ' </div>' +
  540. ' </span>' +
  541. '<span>' +
  542. ' <div class="d-l-con">' +
  543. ' <div class="d-l-l-text">' +
  544. ' <h4>摄像头名称:' + res.data[i].cameraName + '</h4>' +
  545. ' </div>' +
  546. ' </div>' +
  547. ' </span>' +
  548. '<span>' +
  549. ' <div class="d-l-con">' +
  550. ' <div class="d-l-l-text">' +
  551. ' <h4>摄像头类型:' + res.data[i]
  552. .cameraFactory + '</h4>' +
  553. ' </div>' +
  554. ' </div>' +
  555. ' </span>' +
  556. '<span>' +
  557. ' <div class="d-l-con">' +
  558. ' <div class="d-l-l-text">' +
  559. ' <h4>摄像头半径:' + res.data[i]
  560. .cameraRadius + '米</h4>' +
  561. ' </div>' +
  562. ' </div>' +
  563. ' </span>' +
  564. '</div>'
  565. this.cameraMarkersList.push(markersMap)
  566. // cameraAccount: "1"
  567. // cameraCode: "1000010"
  568. // cameraFactory: "2"
  569. // cameraIp: "1"
  570. // cameraName: "2"
  571. // cameraPasword: "2"
  572. // cameraPort: 2
  573. // cameraRadius: 20
  574. // cameraRegion: "3"
  575. // dataDeptId: null
  576. // dataStatus: null
  577. // eventType: null
  578. // height: "11"
  579. // id: "0d165fc362514f79b12a899ea66295fd"
  580. // latitude: "49.325625"
  581. // longitude: "125.3333"
  582. }
  583. setTimeout(() => {
  584. that.$refs.supermap.clearM(true)
  585. that.$refs.supermap.clearM(false)
  586. that.$refs.supermap.setMarkersRadius(this.cameraMarkersList)
  587. }, 1000)
  588. }
  589. })
  590. },
  591. //吉祥物收起左右框
  592. indent() {
  593. let list = document.getElementsByClassName('el-tooltip__popper')
  594. list[list.length - 1].style.display = 'none'
  595. if (this.indentStyle == '') {
  596. this.indentStyle = 'indent-style'
  597. this.indentleft = 'indent-left'
  598. this.indentright = 'indent-right'
  599. this.indentText = '展开左右栏'
  600. } else if (this.indentText == '展开左右栏') {
  601. this.indentStyle = ''
  602. this.indentleft = ''
  603. this.indentright = ''
  604. this.indentText = '收起左右栏'
  605. }
  606. },
  607. /** ----------------------------------摄像头预览开始------------------------------------- */
  608. alertLogin: function() {
  609. this.$modal.msg('登录中....')
  610. },
  611. alertLoginSuccess: function() {
  612. this.$modal.msgSuccess('登录成功!')
  613. },
  614. alertLoginFailed: function() {
  615. this.$modal.msgError('登陆失败!')
  616. },
  617. alertReinstall: function() {
  618. this.$modal.msgWarning('请重新安装客户端')
  619. },
  620. cancelEventLocationShow() {
  621. if (this.oWebControl != null) {
  622. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  623. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  624. },
  625. function() { // 断开与插件服务连接失败
  626. })
  627. }
  628. },
  629. /** 预览按钮操作 */
  630. preview(cameraCode) {
  631. let that = this
  632. // getDahuaVideoServer().then(newResponse => {
  633. // console.log(newResponse)
  634. // this.ws.detectConnectQt().then(res => {
  635. // if (res) { // 连接客户端成功
  636. // this.alertLogin()
  637. // this.ws.login({
  638. // loginIp: newResponse.loginIp,
  639. // loginPort: newResponse.loginPort,
  640. // userName: newResponse.userName,
  641. // userPwd: newResponse.userPwd,
  642. // token: '',
  643. // https: 1
  644. // })
  645. // this.ws.on('loginState', (res) => {
  646. // this.isLogin = res
  647. // console.log('---res-----', res)
  648. // if (res) {
  649. // this.alertLoginSuccess()
  650. // this.activePanel = 'key2'
  651. // this.realTimeVideoDialog(channelCode)
  652. // } else {
  653. // this.alertLoginFailed()
  654. // }
  655. // })
  656. // } else { // 连接客户端失败
  657. // this.alertReinstall()
  658. // }
  659. // })
  660. // })
  661. that.cameraVisible = true
  662. getHaiKangVideoServer({cameraCode:cameraCode}).then(newResponse => {
  663. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  664. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  665. setTimeout(function() {
  666. that.playhk(newResponse.data.channelCode)
  667. }, 5000)
  668. })
  669. },
  670. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  671. if (!this.isLogin) {
  672. this.$Message.info('正在登陆客户端,请稍等......')
  673. return false
  674. }
  675. this.ws.openVideo(cameraParams)
  676. },
  677. /** ----------------------------------摄像头预览结束------------------------------------- */
  678. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  679. // 创建播放实例
  680. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  681. let that=this
  682. that.oWebControl = new WebControl({
  683. szPluginContainer: 'playWnd', // 指定容器id
  684. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  685. iServicePortEnd: 15909,
  686. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  687. cbConnectSuccess: function() { // 创建WebControl实例成功
  688. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  689. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  690. }).then(function() { // 启动插件服务成功
  691. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  692. cbIntegrationCallBack: cbIntegrationCallBack
  693. })
  694. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  695. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  696. })
  697. }, function() { // 启动插件服务失败
  698. })
  699. },
  700. cbConnectError: function() { // 创建WebControl实例失败
  701. that.oWebControl = null
  702. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  703. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  704. initCount++
  705. if (initCount < 3) {
  706. setTimeout(function() {
  707. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  708. }, 3000)
  709. } else {
  710. $('#playWnd').html('插件启动失败,请检查插件是否安装!<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  711. }
  712. },
  713. cbConnectClose: function(bNormalClose) {
  714. // 异常断开:bNormalClose = false
  715. // JS_Disconnect正常断开:bNormalClose = true
  716. console.log('cbConnectClose')
  717. that.oWebControl = null
  718. }
  719. })
  720. },
  721. //播放海康摄像头
  722. playhk(channelCode) {
  723. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  724. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  725. var transMode = 1 //传输协议:0-UDP,1-TCP
  726. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  727. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  728. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  729. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  730. this.oWebControl.JS_RequestInterface({
  731. funcName: 'startPreview',
  732. argument: JSON.stringify({
  733. cameraIndexCode: cameraIndexCode, //监控点编号
  734. streamMode: streamMode, //主子码流标识
  735. transMode: transMode, //传输协议
  736. gpuMode: gpuMode, //是否开启GPU硬解
  737. wndId: wndId //可指定播放窗口
  738. })
  739. })
  740. },
  741. //初始化
  742. init(newappkey,newloginIp,newsecret,newloginPort) {
  743. let that = this
  744. that.getPubKey(function() {
  745. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  746. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  747. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  748. var ip = newloginIp //综合安防管理平台IP地址,必填
  749. var playMode = 0 //初始播放模式:0-预览,1-回放
  750. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  751. var snapDir = 'D:\\SnapDir' //抓图存储路径
  752. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  753. var layout = '1x1' //playMode指定模式的布局
  754. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  755. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  756. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  757. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  758. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  759. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  760. that.oWebControl.JS_RequestInterface({
  761. funcName: 'init',
  762. argument: JSON.stringify({
  763. appkey: appkey, //API网关提供的appkey
  764. secret: secret, //API网关提供的secret
  765. ip: ip, //API网关IP地址
  766. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  767. port: port, //端口
  768. snapDir: snapDir, //抓图存储路径
  769. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  770. layout: layout, //布局
  771. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  772. encryptedFields: encryptedFields, //加密字段
  773. showToolbar: showToolbar, //是否显示工具栏
  774. showSmart: showSmart, //是否显示智能信息
  775. buttonIDs: buttonIDs //自定义工具条按钮
  776. })
  777. }).then(function(oData) {
  778. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  779. })
  780. })
  781. },
  782. //获取公钥
  783. getPubKey(callback) {
  784. let that = this
  785. that.oWebControl.JS_RequestInterface({
  786. funcName: 'getRSAPubKey',
  787. argument: JSON.stringify({
  788. keyLength: 1024
  789. })
  790. }).then(function(oData) {
  791. console.log(oData)
  792. if (oData.responseMsg.data) {
  793. that.pubKey = oData.responseMsg.data
  794. callback()
  795. }
  796. })
  797. },
  798. //RSA加密
  799. setEncrypt(value) {
  800. var encrypt = new JSEncrypt()
  801. encrypt.setPublicKey(this.pubKey)
  802. return encrypt.encrypt(value)
  803. },
  804. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  805. }
  806. }
  807. // 推送消息
  808. function cbIntegrationCallBack(oData) {
  809. console.log(JSON.stringify(oData.responseMsg))
  810. }
  811. </script>
  812. <style rel="stylesheet/scss" lang="scss" scoped>
  813. @import '@/assets/styles/base.scss';
  814. .playWnd {
  815. margin: 4px 0 0 8px;
  816. width: 1020px; /*播放容器的宽和高设定*/
  817. height: 600px;
  818. border: 1px solid red;
  819. }
  820. </style>