monitor.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821
  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. <!-- &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(12, 19, 38, .90)" 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(12, 19, 38, .90)" 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 { treeselect } from '@/api/system/dept'
  162. import supermap from '@/components/supermap' //超图
  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. // 部门名称
  206. deptName: undefined,
  207. // 部门树选项
  208. deptOptions: undefined,
  209. defaultProps: {
  210. children: 'children',
  211. label: 'label'
  212. },
  213. iconCurrentIndex1: '-1',
  214. listCurrentIndex1: '-1',
  215. listCurrentIndex2: '-1',
  216. listCurrentIndex3: '-1',
  217. graphicsList:[],//重点区域
  218. /** ----------------------------------摄像头预览开始------------------------------------- */
  219. //大华
  220. activePanel: 'key1',
  221. isLogin: false,
  222. cameraParams: [],
  223. ws: null,
  224. //海康
  225. cameraTitle: '',
  226. cameraVisible: false,
  227. initCount: 0,
  228. pubKey: '',
  229. oWebControl: null,
  230. /** ----------------------------------摄像头预览结束------------------------------------- */
  231. visuForestCloudMapDeviceBOList: [],
  232. visuForestCloudCameraBOList: [],
  233. cameraMarkersList: [],
  234. sourceData: [],
  235. keyAreaList: [],//重点区域
  236. iframeBoo: true,
  237. open: false,
  238. iframeVue: null,
  239. activeName: 'info',
  240. radio: '1',
  241. region: [],
  242. //左右缩进
  243. indentStyle: '',
  244. indentleft: '',
  245. indentright: '',
  246. indentText: '收起左右栏',
  247. indentdisabled: false,
  248. domId: 'dom1',
  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. selectDeviceType(index) {
  374. this.iconCurrentIndex1 = index
  375. //获取左侧动态感知设备
  376. let that = this
  377. selectDeviceType().then(res => {
  378. that.cameraMarkersList=[]
  379. that.visuForestCloudMapDeviceBOList = res.data.visuForestCloudMapDeviceBOList
  380. that.region = res.data.visuForestCloudTodaySjfbBOList
  381. if (res.data.visuForestCloudTodaySjfbBOList != null && res.data.visuForestCloudTodaySjfbBOList
  382. .length > 0) {
  383. for (let i = 0; i < res.data.visuForestCloudTodaySjfbBOList.length; i++) {
  384. let aa = []
  385. aa.push(res.data.visuForestCloudTodaySjfbBOList[i].deptName)
  386. aa.push(Number(res.data.visuForestCloudTodaySjfbBOList[i].deptCount))
  387. this.sourceData.push(aa)
  388. }
  389. }
  390. that.visuForestCloudCameraBOList = res.data.visuForestCloudCameraBOList
  391. if (res.data.visuForestCloudCameraBOList != null && res.data.visuForestCloudCameraBOList
  392. .length > 0) {
  393. for (let i = 0; i < res.data.visuForestCloudCameraBOList.length; i++) {
  394. let markersMap = {
  395. lng: 124.59,
  396. lat: 43.02,
  397. icon: 'camera',
  398. bindPopupHtml: '',
  399. click: 'preview',
  400. parameter: '',
  401. keepBindPopup: false,
  402. isAggregation: false
  403. }
  404. if (res.data.visuForestCloudCameraBOList[i].channelCode != null) {
  405. markersMap.parameter = {code:res.data.visuForestCloudCameraBOList[i].cameraCode,
  406. type:res.data.visuForestCloudCameraBOList[i].cameraFactory}
  407. } else {
  408. markersMap.parameter = []
  409. }
  410. markersMap.lng = res.data.visuForestCloudCameraBOList[i].longitude
  411. markersMap.lat = res.data.visuForestCloudCameraBOList[i].latitude
  412. markersMap.radius = res.data.visuForestCloudCameraBOList[i].cameraRadius
  413. markersMap.bindPopupHtml = '<div class="map-tip">' +
  414. '<span>' +
  415. ' <div class="d-l-con">' +
  416. ' <div class="d-l-l-text">' +
  417. ' <h4>经纬度:' + res.data.visuForestCloudCameraBOList[i].longitude +
  418. ',' + res.data.visuForestCloudCameraBOList[i].latitude + '</h4>' +
  419. ' </div>' +
  420. ' </div>' +
  421. ' </span>' +
  422. '<span>' +
  423. ' <div class="d-l-con">' +
  424. ' <div class="d-l-l-text">' +
  425. ' <h4>摄像头名称:' + res.data.visuForestCloudCameraBOList[i]
  426. .cameraName + '</h4>' +
  427. ' </div>' +
  428. ' </div>' +
  429. ' </span>' +
  430. '<span>' +
  431. ' <div class="d-l-con">' +
  432. ' <div class="d-l-l-text">' +
  433. ' <h4>摄像头类型:' + (res.data.visuForestCloudCameraBOList[i].cameraFactory=="1"?"大华":"海康") + '</h4>' +
  434. ' </div>' +
  435. ' </div>' +
  436. ' </span>' +
  437. '<span>' +
  438. ' <div class="d-l-con">' +
  439. ' <div class="d-l-l-text">' +
  440. ' <h4>摄像头半径:' + res.data.visuForestCloudCameraBOList[i]
  441. .cameraRadius + '米</h4>' +
  442. ' </div>' +
  443. ' </div>' +
  444. ' </span>' +
  445. '</div>'
  446. this.cameraMarkersList.push(markersMap)
  447. // cameraAccount: "1"
  448. // cameraCode: "1000010"
  449. // cameraFactory: "2"
  450. // cameraIp: "1"
  451. // cameraName: "2"
  452. // cameraPasword: "2"
  453. // cameraPort: 2
  454. // cameraRadius: 20
  455. // cameraRegion: "3"
  456. // dataDeptId: null
  457. // dataStatus: null
  458. // eventType: null
  459. // height: "11"
  460. // id: "0d165fc362514f79b12a899ea66295fd"
  461. // latitude: "49.325625"
  462. // longitude: "125.3333"
  463. }
  464. setTimeout(() => {
  465. that.$refs.supermap.clearM(true)
  466. that.$refs.supermap.clearM(false)
  467. that.$refs.supermap.setMarkersRadius(this.cameraMarkersList)
  468. }, 1000)
  469. }
  470. })
  471. },
  472. dropLocation(lat, lng, index) {
  473. this.listCurrentIndex2 = index
  474. this.$refs.supermap.dropLocation(lat, lng)
  475. },
  476. selectCameraByDeptId(depId) {
  477. this.listCurrentIndex1 = depId
  478. let that = this
  479. that.cameraMarkersList = []
  480. that.visuForestCloudCameraBOList = []
  481. selectCameraByDeptId(depId).then(res => {
  482. //根据设备类型查看列表
  483. that.visuForestCloudCameraBOList = res.data
  484. if (res.data != null && res.data.length > 0) {
  485. for (let i = 0; i < res.data.length; i++) {
  486. let markersMap = {
  487. lng: 124.59,
  488. lat: 43.02,
  489. icon: 'camera',
  490. bindPopupHtml: '',
  491. click: 'preview',
  492. parameter: '',
  493. keepBindPopup: false,
  494. isAggregation: false
  495. }
  496. if (res.data[i].channelCode != null) {
  497. markersMap.parameter = {code:res.data[i].cameraCode,
  498. type:res.data[i].cameraFactory}
  499. } else {
  500. markersMap.parameter = []
  501. }
  502. markersMap.lng = res.data[i].longitude
  503. markersMap.lat = res.data[i].latitude
  504. markersMap.radius = res.data[i].cameraRadius
  505. markersMap.bindPopupHtml = '<div class="map-tip">' +
  506. '<span>' +
  507. ' <div class="d-l-con">' +
  508. ' <div class="d-l-l-text">' +
  509. ' <h4>经纬度:' + res.data[i].longitude + ',' + res.data[i].latitude +
  510. '</h4>' +
  511. ' </div>' +
  512. ' </div>' +
  513. ' </span>' +
  514. '<span>' +
  515. ' <div class="d-l-con">' +
  516. ' <div class="d-l-l-text">' +
  517. ' <h4>摄像头名称:' + res.data[i].cameraName + '</h4>' +
  518. ' </div>' +
  519. ' </div>' +
  520. ' </span>' +
  521. '<span>' +
  522. ' <div class="d-l-con">' +
  523. ' <div class="d-l-l-text">' +
  524. ' <h4>摄像头类型:' + (res.data[i].cameraFactory=="1"?"大华":"海康") + '</h4>' +
  525. ' </div>' +
  526. ' </div>' +
  527. ' </span>' +
  528. '<span>' +
  529. ' <div class="d-l-con">' +
  530. ' <div class="d-l-l-text">' +
  531. ' <h4>摄像头半径:' + res.data[i]
  532. .cameraRadius + '米</h4>' +
  533. ' </div>' +
  534. ' </div>' +
  535. ' </span>' +
  536. '</div>'
  537. this.cameraMarkersList.push(markersMap)
  538. // cameraAccount: "1"
  539. // cameraCode: "1000010"
  540. // cameraFactory: "2"
  541. // cameraIp: "1"
  542. // cameraName: "2"
  543. // cameraPasword: "2"
  544. // cameraPort: 2
  545. // cameraRadius: 20
  546. // cameraRegion: "3"
  547. // dataDeptId: null
  548. // dataStatus: null
  549. // eventType: null
  550. // height: "11"
  551. // id: "0d165fc362514f79b12a899ea66295fd"
  552. // latitude: "49.325625"
  553. // longitude: "125.3333"
  554. }
  555. setTimeout(() => {
  556. that.$refs.supermap.clearM(true)
  557. that.$refs.supermap.clearM(false)
  558. that.$refs.supermap.setMarkersRadius(this.cameraMarkersList)
  559. }, 1000)
  560. }
  561. })
  562. },
  563. //吉祥物收起左右框
  564. indent() {
  565. let list = document.getElementsByClassName('el-tooltip__popper')
  566. list[list.length - 1].style.display = 'none'
  567. if (this.indentStyle == '') {
  568. this.indentStyle = 'indent-style'
  569. this.indentleft = 'indent-left'
  570. this.indentright = 'indent-right'
  571. this.indentText = '展开左右栏'
  572. } else if (this.indentText == '展开左右栏') {
  573. this.indentStyle = ''
  574. this.indentleft = ''
  575. this.indentright = ''
  576. this.indentText = '收起左右栏'
  577. }
  578. },
  579. /** ----------------------------------摄像头预览开始------------------------------------- */
  580. alertLogin: function() {
  581. this.$modal.msg('登录中....')
  582. },
  583. alertLoginSuccess: function() {
  584. this.$modal.msgSuccess('登录成功!')
  585. },
  586. alertLoginFailed: function() {
  587. this.$modal.msgError('登陆失败!')
  588. },
  589. alertReinstall: function() {
  590. this.$modal.msgWarning('请重新安装客户端')
  591. },
  592. cancelEventLocationShow() {
  593. if (this.oWebControl != null) {
  594. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  595. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  596. },
  597. function() { // 断开与插件服务连接失败
  598. })
  599. }
  600. },
  601. /** 预览按钮操作 */
  602. preview(cameraParam) {
  603. if(cameraParam.type=='1'){
  604. getDahuaVideoServer().then(newResponse => {
  605. console.log(newResponse)
  606. this.ws.detectConnectQt().then(res => {
  607. if (res) { // 连接客户端成功
  608. this.alertLogin()
  609. this.ws.login({
  610. loginIp: newResponse.loginIp,
  611. loginPort: newResponse.loginPort,
  612. userName: newResponse.userName,
  613. userPwd: newResponse.userPwd,
  614. token: '',
  615. https: 1
  616. })
  617. this.ws.on('loginState', (res) => {
  618. this.isLogin = res
  619. console.log('---res-----', res)
  620. if (res) {
  621. this.alertLoginSuccess()
  622. this.activePanel = 'key2'
  623. this.realTimeVideoDialog(cameraParam.code)
  624. } else {
  625. this.alertLoginFailed()
  626. }
  627. })
  628. } else { // 连接客户端失败
  629. this.alertReinstall()
  630. }
  631. })
  632. })
  633. }else if(cameraParam.type=='0'){
  634. let that = this
  635. that.cameraVisible = true
  636. getHaiKangVideoServer({cameraCode:cameraParam.code}).then(newResponse => {
  637. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  638. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  639. setTimeout(function() {
  640. that.playhk(newResponse.data.channelCode)
  641. }, 5000)
  642. })
  643. }
  644. },
  645. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  646. if (!this.isLogin) {
  647. this.$Message.info('正在登陆客户端,请稍等......')
  648. return false
  649. }
  650. const params = [cameraParams];
  651. this.ws.openVideo(params)
  652. },
  653. /** ----------------------------------摄像头预览结束------------------------------------- */
  654. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  655. // 创建播放实例
  656. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  657. let that=this
  658. that.oWebControl = new WebControl({
  659. szPluginContainer: 'playWnd', // 指定容器id
  660. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  661. iServicePortEnd: 15909,
  662. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  663. cbConnectSuccess: function() { // 创建WebControl实例成功
  664. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  665. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  666. }).then(function() { // 启动插件服务成功
  667. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  668. cbIntegrationCallBack: cbIntegrationCallBack
  669. })
  670. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  671. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  672. })
  673. }, function() { // 启动插件服务失败
  674. })
  675. },
  676. cbConnectError: function() { // 创建WebControl实例失败
  677. that.oWebControl = null
  678. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  679. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  680. initCount++
  681. if (initCount < 3) {
  682. setTimeout(function() {
  683. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  684. }, 3000)
  685. } else {
  686. $('#playWnd').html('插件启动失败,请检查插件是否安装!<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  687. }
  688. },
  689. cbConnectClose: function(bNormalClose) {
  690. // 异常断开:bNormalClose = false
  691. // JS_Disconnect正常断开:bNormalClose = true
  692. console.log('cbConnectClose')
  693. that.oWebControl = null
  694. }
  695. })
  696. },
  697. //播放海康摄像头
  698. playhk(channelCode) {
  699. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  700. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  701. var transMode = 1 //传输协议:0-UDP,1-TCP
  702. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  703. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  704. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  705. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  706. this.oWebControl.JS_RequestInterface({
  707. funcName: 'startPreview',
  708. argument: JSON.stringify({
  709. cameraIndexCode: cameraIndexCode, //监控点编号
  710. streamMode: streamMode, //主子码流标识
  711. transMode: transMode, //传输协议
  712. gpuMode: gpuMode, //是否开启GPU硬解
  713. wndId: wndId //可指定播放窗口
  714. })
  715. })
  716. },
  717. //初始化
  718. init(newappkey,newloginIp,newsecret,newloginPort) {
  719. let that = this
  720. that.getPubKey(function() {
  721. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  722. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  723. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  724. var ip = newloginIp //综合安防管理平台IP地址,必填
  725. var playMode = 0 //初始播放模式:0-预览,1-回放
  726. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  727. var snapDir = 'D:\\SnapDir' //抓图存储路径
  728. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  729. var layout = '1x1' //playMode指定模式的布局
  730. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  731. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  732. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  733. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  734. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  735. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  736. that.oWebControl.JS_RequestInterface({
  737. funcName: 'init',
  738. argument: JSON.stringify({
  739. appkey: appkey, //API网关提供的appkey
  740. secret: secret, //API网关提供的secret
  741. ip: ip, //API网关IP地址
  742. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  743. port: port, //端口
  744. snapDir: snapDir, //抓图存储路径
  745. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  746. layout: layout, //布局
  747. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  748. encryptedFields: encryptedFields, //加密字段
  749. showToolbar: showToolbar, //是否显示工具栏
  750. showSmart: showSmart, //是否显示智能信息
  751. buttonIDs: buttonIDs //自定义工具条按钮
  752. })
  753. }).then(function(oData) {
  754. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  755. })
  756. })
  757. },
  758. //获取公钥
  759. getPubKey(callback) {
  760. let that = this
  761. that.oWebControl.JS_RequestInterface({
  762. funcName: 'getRSAPubKey',
  763. argument: JSON.stringify({
  764. keyLength: 1024
  765. })
  766. }).then(function(oData) {
  767. console.log(oData)
  768. if (oData.responseMsg.data) {
  769. that.pubKey = oData.responseMsg.data
  770. callback()
  771. }
  772. })
  773. },
  774. //RSA加密
  775. setEncrypt(value) {
  776. var encrypt = new JSEncrypt()
  777. encrypt.setPublicKey(this.pubKey)
  778. return encrypt.encrypt(value)
  779. },
  780. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  781. }
  782. }
  783. // 推送消息
  784. function cbIntegrationCallBack(oData) {
  785. console.log(JSON.stringify(oData.responseMsg))
  786. }
  787. </script>
  788. <style rel="stylesheet/scss" lang="scss" scoped>
  789. @import '@/assets/styles/base.scss';
  790. .playWnd {
  791. margin: 4px 0 0 8px;
  792. width: 1020px; /*播放容器的宽和高设定*/
  793. height: 600px;
  794. border: 1px solid red;
  795. }
  796. </style>