waterquality.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  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 :color="['#0e7957', '#0da24c']" backgroundColor="#09140e" 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-82" style="height: 70vh !important;">
  18. <div class="d-l-con" v-for="(item,index) in visuForestCloudCameraBOList"
  19. :class="{on:listCurrentIndex2 == index}"
  20. v-on:click="dropLocation(item.latitude,item.longitude,index)">
  21. <div class="d-l-l-text">
  22. <i class="iconfont sj-icon-jkzx icon-sxt"></i>
  23. <h4>{{ item.deviceName }}</h4>
  24. </div>
  25. </div>
  26. </div>
  27. </dv-border-box-13>
  28. </div>
  29. </div>
  30. <!-- 地图 -->
  31. <supermap ref="supermap" style="width: 100%;height: 100vh;" :mapDiv="'forestMap'" class="indexSupermapClass"
  32. :mapSite="{doubleClickZoom:false}" :codes="['9fa5']" :isSideBySide="false" @preview="preview">
  33. </supermap>
  34. <vBottomMenu ref="bottomMenu"></vBottomMenu>
  35. </div>
  36. <eventLocation ref="eventLocation"></eventLocation>
  37. <TVWall ref="TVWall"></TVWall>
  38. <!--<el-dialog :title="cameraTitle" :visible.sync="cameraVisible" v-if="cameraVisible" customClass="videoCustomWidth"-->
  39. <!--@close="cancelEventLocationShow()">-->
  40. <!--<div style="width:1020px;height:625px;position:relative;">-->
  41. <!--&lt;!&ndash;视频窗口展示-&#45;&#45;海康&ndash;&gt;-->
  42. <!--<div id="playWnd" class="playWnd" style="left: 0px; top: 0px;"></div>-->
  43. <!--</div>-->
  44. <!--</el-dialog>-->
  45. </div>
  46. </template>
  47. <script>
  48. import {
  49. selectListDevice
  50. } from '@/api/monitor'
  51. import supermap from '@/components/supermap' //超图
  52. import vheader from '@/components/v-header.vue' //一体化共用头部
  53. import vBottomMenu from '@/components/vBottomMenu.vue' //一体化公共底部菜单
  54. import eventLocation from '@/components/eventLocation.vue' //事件定位弹窗
  55. import TVWall from '@/components/TVWall.vue' //电视墙弹窗
  56. /** ----------------------------------摄像头预览开始------------------------------------- */
  57. import {
  58. getDahuaVideoServer
  59. } from '@/api/dahua/dahua'
  60. import {
  61. getHaiKangVideoServer
  62. } from '@/api/haikang/haikang'
  63. import DHWs from '@/dahua/lib/DHWs'
  64. /** ----------------------------------摄像头预览结束------------------------------------- */
  65. // import echarts from 'echarts'
  66. let echarts = require('echarts')
  67. export default {
  68. components: {
  69. supermap,
  70. vheader,
  71. vBottomMenu,
  72. eventLocation,
  73. TVWall
  74. },
  75. created() {
  76. /** ----------------------------------摄像头预览开始------------------------------------- */
  77. const DHWsInstance = DHWs.getInstance()
  78. this.ws = DHWsInstance
  79. /** ----------------------------------摄像头预览结束------------------------------------- */
  80. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  81. window.showDialog = this.showDialog
  82. window.choseLayerSwitching = this.choseLayerSwitching
  83. window.choseLayerSwitchingList = this.choseLayerSwitchingList
  84. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  85. },
  86. mounted() {
  87. this.selectListDevice({deviceType:'1'});
  88. },
  89. data() {
  90. return {
  91. listCurrentIndex2: '-1',
  92. /** ----------------------------------摄像头预览开始------------------------------------- */
  93. //大华
  94. activePanel: 'key1',
  95. isLogin: false,
  96. cameraParams: [],
  97. ws: null,
  98. //海康
  99. cameraTitle: '',
  100. cameraVisible: false,
  101. initCount: 0,
  102. pubKey: '',
  103. oWebControl: null,
  104. /** ----------------------------------摄像头预览结束------------------------------------- */
  105. visuForestCloudCameraBOList: [],
  106. cameraMarkersList: [],
  107. sourceData: [],
  108. iframeBoo: true,
  109. open: false,
  110. iframeVue: null,
  111. activeName: 'info',
  112. radio: '1',
  113. region: [],
  114. //左右缩进
  115. indentStyle: '',
  116. indentleft: '',
  117. indentright: '',
  118. indentText: '收起左右栏',
  119. indentdisabled: false,
  120. domId: 'dom1',
  121. }
  122. },
  123. methods: {
  124. /** ----------------------------------底部按钮公用组件开始------------------------------------- */
  125. showDialog(click) {
  126. if (click == 'eventLocation') {
  127. this.$refs.eventLocation.showEventLocation()
  128. this.$refs.supermap.isEditableLayers = false
  129. this.$refs.bottomMenu.showChild = false
  130. this.$refs.bottomMenu.showBanChild = false
  131. this.$refs.bottomMenu.showChangChild = false
  132. } else if (click == 'editableLayers') {
  133. this.$refs.bottomMenu.showChild = false
  134. this.$refs.bottomMenu.showBanChild = false
  135. this.$refs.bottomMenu.showChangChild = false
  136. if (!this.$refs.supermap.isEditableLayers) {
  137. this.$refs.supermap.isEditableLayers = true
  138. } else {
  139. this.$refs.supermap.isEditableLayers = false
  140. }
  141. } else if (click == 'layerSwitching') {
  142. this.$refs.supermap.isEditableLayers = false
  143. this.$refs.bottomMenu.showBanChild = false
  144. this.$refs.bottomMenu.showChangChild = false
  145. if (!this.$refs.bottomMenu.showChild) {
  146. this.$refs.bottomMenu.showChild = true
  147. } else {
  148. this.$refs.bottomMenu.showChild = false
  149. }
  150. } else if (click == 'TVWall') {
  151. this.$refs.TVWall.showTVWall()
  152. this.$refs.supermap.isEditableLayers = false
  153. this.$refs.bottomMenu.showChild = false
  154. this.$refs.bottomMenu.showBanChild = false
  155. this.$refs.bottomMenu.showChangChild = false
  156. } else if (click == 'forestban') {
  157. this.$refs.supermap.isEditableLayers = false
  158. this.$refs.bottomMenu.showChild = false
  159. this.$refs.bottomMenu.showChangChild = false
  160. if (!this.$refs.bottomMenu.showBanChild) {
  161. this.$refs.bottomMenu.showBanChild = true
  162. } else {
  163. this.$refs.bottomMenu.showBanChild = false
  164. }
  165. } else if (click == 'forestchang') {
  166. this.$refs.supermap.isEditableLayers = false
  167. this.$refs.bottomMenu.showBanChild = false
  168. this.$refs.bottomMenu.showChild = false
  169. if (!this.$refs.bottomMenu.showChangChild) {
  170. this.$refs.bottomMenu.showChangChild = true
  171. } else {
  172. this.$refs.bottomMenu.showChangChild = false
  173. }
  174. }
  175. },
  176. /** ----------------------------------底部按钮公用组件结束------------------------------------- */
  177. dropLocation(lat, lng, index) {
  178. this.listCurrentIndex2 = index
  179. this.$refs.supermap.dropLocation(lat, lng)
  180. },
  181. selectListDevice(param){
  182. let that = this
  183. selectListDevice(param).then(res => {
  184. that.visuForestCloudCameraBOList = res.data;
  185. if (res.data != null && res.data.length > 0) {
  186. for (let i = 0; i < res.data.length; i++) {
  187. let markersMap = {
  188. lng: 124.59,
  189. lat: 43.02,
  190. icon: 'sensor',
  191. bindPopupHtml: '',
  192. click: '',
  193. parameter: '',
  194. keepBindPopup: false,
  195. isAggregation: false
  196. }
  197. markersMap.lng = res.data[i].longitude
  198. markersMap.lat = res.data[i].latitude
  199. markersMap.bindPopupHtml = '<div class="map-tip">' +
  200. '<span>' +
  201. ' <div class="d-l-con">' +
  202. ' <div class="d-l-l-text">' +
  203. ' <h4>经纬度:' + res.data[i].longitude +',' + res.data[i].latitude + '</h4>' +
  204. ' </div>' +
  205. ' </div>' +
  206. ' </span>' +
  207. '<span>' +
  208. ' <div class="d-l-con">' +
  209. ' <div class="d-l-l-text">' +
  210. ' <h4>设备名称:' + res.data[i].deviceName + '</h4>' +
  211. ' </div>' +
  212. ' </div>' +
  213. ' </span>' +
  214. '<span>' +
  215. ' <div class="d-l-con">' +
  216. ' <div class="d-l-l-text">' +
  217. ' <h4>品牌:' + res.data[i].brand + '</h4>' +
  218. ' </div>' +
  219. ' </div>' +
  220. ' </span>' +
  221. '<span>' +
  222. '</div>'
  223. that.cameraMarkersList.push(markersMap)
  224. }
  225. setTimeout(() => {
  226. that.$refs.supermap.clearM(false)
  227. that.$refs.supermap.clearM(true)
  228. that.$refs.supermap.setMarkers(that.cameraMarkersList)
  229. }, 1000)
  230. } else {
  231. setTimeout(() => {
  232. that.$refs.supermap.clearM(false)
  233. that.$refs.supermap.clearM(true)
  234. }, 1000)
  235. }
  236. })
  237. },
  238. //吉祥物收起左右框
  239. indent() {
  240. let list = document.getElementsByClassName('el-tooltip__popper')
  241. list[list.length - 1].style.display = 'none'
  242. if (this.indentStyle == '') {
  243. this.indentStyle = 'indent-style'
  244. this.indentleft = 'indent-left'
  245. this.indentright = 'indent-right'
  246. this.indentText = '展开左右栏'
  247. } else if (this.indentText == '展开左右栏') {
  248. this.indentStyle = ''
  249. this.indentleft = ''
  250. this.indentright = ''
  251. this.indentText = '收起左右栏'
  252. }
  253. },
  254. /** ----------------------------------摄像头预览开始------------------------------------- */
  255. alertLogin: function() {
  256. this.$modal.msg('登录中....')
  257. },
  258. alertLoginSuccess: function() {
  259. this.$modal.msgSuccess('登录成功!')
  260. },
  261. alertLoginFailed: function() {
  262. this.$modal.msgError('登陆失败!')
  263. },
  264. alertReinstall: function() {
  265. this.$modal.msgWarning('请重新安装客户端')
  266. },
  267. cancelEventLocationShow() {
  268. if (this.oWebControl != null) {
  269. this.oWebControl.JS_HideWnd() // 先让窗口隐藏,规避可能的插件窗口滞后于浏览器消失问题
  270. this.oWebControl.JS_Disconnect().then(function() { // 断开与插件服务连接成功
  271. },
  272. function() { // 断开与插件服务连接失败
  273. })
  274. }
  275. },
  276. /** 预览按钮操作 */
  277. preview(cameraParam) {
  278. if(cameraParam.type=='1'){
  279. getDahuaVideoServer().then(newResponse => {
  280. console.log(newResponse)
  281. this.ws.detectConnectQt().then(res => {
  282. if (res) { // 连接客户端成功
  283. this.alertLogin()
  284. this.ws.login({
  285. loginIp: newResponse.loginIp,
  286. loginPort: newResponse.loginPort,
  287. userName: newResponse.userName,
  288. userPwd: newResponse.userPwd,
  289. token: '',
  290. https: 1
  291. })
  292. this.ws.on('loginState', (res) => {
  293. this.isLogin = res
  294. console.log('---res-----', res)
  295. if (res) {
  296. this.alertLoginSuccess()
  297. this.activePanel = 'key2'
  298. this.realTimeVideoDialog(cameraParam.code)
  299. } else {
  300. this.alertLoginFailed()
  301. }
  302. })
  303. } else { // 连接客户端失败
  304. this.alertReinstall()
  305. }
  306. })
  307. })
  308. }else if(cameraParam.type=='0'){
  309. let that = this
  310. that.cameraVisible = true
  311. getHaiKangVideoServer({cameraCode:cameraParam.code}).then(newResponse => {
  312. that.cameraTitle = '摄像头-'+newResponse.data.cameraName
  313. that.initPlugin(newResponse.data.appkey,newResponse.data.loginIp,newResponse.data.secret,newResponse.data.loginPort)
  314. setTimeout(function() {
  315. that.playhk(newResponse.data.channelCode)
  316. }, 5000)
  317. })
  318. }
  319. },
  320. realTimeVideoDialog(cameraParams) { // 调用弹窗实时播放接口
  321. if (!this.isLogin) {
  322. this.$Message.info('正在登陆客户端,请稍等......')
  323. return false
  324. }
  325. const params = [cameraParams];
  326. this.ws.openVideo(params)
  327. },
  328. /** ----------------------------------摄像头预览结束------------------------------------- */
  329. /** ----------------------------------海康摄像头预览开始------------------------------------- */
  330. // 创建播放实例
  331. initPlugin(newappkey,newloginIp,newsecret,newloginPort) {
  332. let that=this
  333. that.oWebControl = new WebControl({
  334. szPluginContainer: 'playWnd', // 指定容器id
  335. iServicePortStart: 15900, // 指定起止端口号,建议使用该值
  336. iServicePortEnd: 15909,
  337. szClassId: '23BF3B0A-2C56-4D97-9C03-0CB103AA8F11', // 用于IE10使用ActiveX的clsid
  338. cbConnectSuccess: function() { // 创建WebControl实例成功
  339. that.oWebControl.JS_StartService('window', { // WebControl实例创建成功后需要启动服务
  340. dllPath: './VideoPluginConnect.dll' // 值"./VideoPluginConnect.dll"写死
  341. }).then(function() { // 启动插件服务成功
  342. that.oWebControl.JS_SetWindowControlCallback({ // 设置消息回调
  343. cbIntegrationCallBack: cbIntegrationCallBack
  344. })
  345. that.oWebControl.JS_CreateWnd('playWnd', 1020, 600).then(function() { //JS_CreateWnd创建视频播放窗口,宽高可设定
  346. that.init(newappkey,newloginIp,newsecret,newloginPort) // 创建播放实例成功后初始化
  347. })
  348. }, function() { // 启动插件服务失败
  349. })
  350. },
  351. cbConnectError: function() { // 创建WebControl实例失败
  352. that.oWebControl = null
  353. $('#playWnd').html('插件未启动,正在尝试启动,请稍候...<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  354. WebControl.JS_WakeUp('VideoWebPlugin://') // 程序未启动时执行error函数,采用wakeup来启动程序
  355. initCount++
  356. if (initCount < 3) {
  357. setTimeout(function() {
  358. that.initPlugin(newappkey,newloginIp,newsecret,newloginPort)
  359. }, 3000)
  360. } else {
  361. $('#playWnd').html('插件启动失败,请检查插件是否安装!<a href="./hk/VideoWebPlugin.exe">点击下载插件</a>')
  362. }
  363. },
  364. cbConnectClose: function(bNormalClose) {
  365. // 异常断开:bNormalClose = false
  366. // JS_Disconnect正常断开:bNormalClose = true
  367. console.log('cbConnectClose')
  368. that.oWebControl = null
  369. }
  370. })
  371. },
  372. //播放海康摄像头
  373. playhk(channelCode) {
  374. var cameraIndexCode = channelCode //获取输入的监控点编号值,必填
  375. var streamMode = 0 //主子码流标识:0-主码流,1-子码流
  376. var transMode = 1 //传输协议:0-UDP,1-TCP
  377. var gpuMode = 0 //是否启用GPU硬解,0-不启用,1-启用
  378. var wndId = -1 //播放窗口序号(在2x2以上布局下可指定播放窗口)
  379. cameraIndexCode = cameraIndexCode.replace(/(^\s*)/g, '')
  380. cameraIndexCode = cameraIndexCode.replace(/(\s*$)/g, '')
  381. this.oWebControl.JS_RequestInterface({
  382. funcName: 'startPreview',
  383. argument: JSON.stringify({
  384. cameraIndexCode: cameraIndexCode, //监控点编号
  385. streamMode: streamMode, //主子码流标识
  386. transMode: transMode, //传输协议
  387. gpuMode: gpuMode, //是否开启GPU硬解
  388. wndId: wndId //可指定播放窗口
  389. })
  390. })
  391. },
  392. //初始化
  393. init(newappkey,newloginIp,newsecret,newloginPort) {
  394. let that = this
  395. that.getPubKey(function() {
  396. ////////////////////////////////// 请自行修改以下变量值 ////////////////////////////////////
  397. var appkey = newappkey //综合安防管理平台提供的appkey,必填
  398. var secret = that.setEncrypt(newsecret) //综合安防管理平台提供的secret,必填
  399. var ip = newloginIp //综合安防管理平台IP地址,必填
  400. var playMode = 0 //初始播放模式:0-预览,1-回放
  401. var port = Number(newloginPort) //综合安防管理平台端口,若启用HTTPS协议,默认443
  402. var snapDir = 'D:\\SnapDir' //抓图存储路径
  403. var videoDir = 'D:\\VideoDir' //紧急录像或录像剪辑存储路径
  404. var layout = '1x1' //playMode指定模式的布局
  405. var enableHTTPS = 1 //是否启用HTTPS协议与综合安防管理平台交互,这里总是填1
  406. var encryptedFields = 'secret' //加密字段,默认加密领域为secret
  407. var showToolbar = 1 //是否显示工具栏,0-不显示,非0-显示
  408. var showSmart = 1 //是否显示智能信息(如配置移动侦测后画面上的线框),0-不显示,非0-显示
  409. var buttonIDs = '0,16,256,257,258,259,260,512,513,514,515,516,517,768,769' //自定义工具条按钮
  410. ////////////////////////////////// 请自行修改以上变量值 ////////////////////////////////////
  411. that.oWebControl.JS_RequestInterface({
  412. funcName: 'init',
  413. argument: JSON.stringify({
  414. appkey: appkey, //API网关提供的appkey
  415. secret: secret, //API网关提供的secret
  416. ip: ip, //API网关IP地址
  417. playMode: playMode, //播放模式(决定显示预览还是回放界面)
  418. port: port, //端口
  419. snapDir: snapDir, //抓图存储路径
  420. videoDir: videoDir, //紧急录像或录像剪辑存储路径
  421. layout: layout, //布局
  422. enableHTTPS: enableHTTPS, //是否启用HTTPS协议
  423. encryptedFields: encryptedFields, //加密字段
  424. showToolbar: showToolbar, //是否显示工具栏
  425. showSmart: showSmart, //是否显示智能信息
  426. buttonIDs: buttonIDs //自定义工具条按钮
  427. })
  428. }).then(function(oData) {
  429. that.oWebControl.JS_Resize(1020, 600) // 初始化后resize一次,规避firefox下首次显示窗口后插件窗口未与DIV窗口重合问题
  430. })
  431. })
  432. },
  433. //获取公钥
  434. getPubKey(callback) {
  435. let that = this
  436. that.oWebControl.JS_RequestInterface({
  437. funcName: 'getRSAPubKey',
  438. argument: JSON.stringify({
  439. keyLength: 1024
  440. })
  441. }).then(function(oData) {
  442. console.log(oData)
  443. if (oData.responseMsg.data) {
  444. that.pubKey = oData.responseMsg.data
  445. callback()
  446. }
  447. })
  448. },
  449. //RSA加密
  450. setEncrypt(value) {
  451. var encrypt = new JSEncrypt()
  452. encrypt.setPublicKey(this.pubKey)
  453. return encrypt.encrypt(value)
  454. },
  455. /** ----------------------------------海康摄像头预览结束------------------------------------- */
  456. }
  457. }
  458. // 推送消息
  459. function cbIntegrationCallBack(oData) {
  460. console.log(JSON.stringify(oData.responseMsg))
  461. }
  462. </script>
  463. <style rel="stylesheet/scss" lang="scss" scoped>
  464. @import '@/assets/styles/base.scss';
  465. .playWnd {
  466. margin: 4px 0 0 8px;
  467. width: 1020px; /*播放容器的宽和高设定*/
  468. height: 600px;
  469. border: 1px solid red;
  470. }
  471. </style>