monitor.vue 36 KB

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