monitor.vue 34 KB

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