video.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. <template>
  2. <div class="video-page">
  3. <header>
  4. <div :class="activeId===item.id?'active item':'item'" v-for="item in items" :key="item.id" @click="changeHead(item)">{{ item.name }}</div>
  5. </header>
  6. <div class="tab">
  7. <el-select v-model="conditions.goafOrebelt" placeholder="矿带" @change="changeArea(1)" style="width:120px" clearable>
  8. <el-option v-for="(item,index) in goafOrebelts" :key="index" :value="item" :label="item" />
  9. </el-select>
  10. <el-select v-model="conditions.goafOrebody" placeholder="矿体" @change="changeArea(2)" style="width:120px;margin:0 12px;">
  11. <el-option v-for="(item,index) in goafOrebodys" :key="index" :value="item.goafOrebody" :label="item.goafOrebody" />
  12. </el-select>
  13. <el-select v-model="conditions.goafOreheight" placeholder="中段" @change="changeArea(3)" style="width:120px">
  14. <el-option v-for="(item,index) in goafOreheights" :key="index" :value="item.goafOreheight" :label="item.goafOreheight" />
  15. </el-select>
  16. </div>
  17. <div class="container">
  18. <div class="lf">
  19. <div class="search-container">
  20. <el-select v-model="conditions.goafId" placeholder="采空区编号" @change="changeArea(4)" style="width:210px;margin:0 12px;">
  21. <el-option v-for="item in goafNames" :key="item.goafId" :value="item.goafId" :label="item.goafName" />
  22. </el-select>
  23. <div class="bt search" @click="searchSubmit">查询</div>
  24. <div class="bt" @click="resetSubmit">重置</div>
  25. </div>
  26. <div class="lf-container">
  27. <div class="video-container">
  28. <div class="item" v-for="(item,index) in dataList" :key="index" @click="showVideo(item)" :data="item">
  29. <img src="./images/video.png">
  30. <p style="cursor:pointer;">{{NumConvertLM(item.goafOrebelt)}}-{{item.goafOrebody}}-{{item.goafOreheight}}-{{item.goafName}}</p>
  31. </div>
  32. </div>
  33. <div class="el-pagination-wrap">
  34. <el-pagination small layout="prev, pager, next" :total="total" />
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="video-dialog" v-if="videoDialogVisible">
  40. <div class="video-dialog-container">
  41. <div class="header">
  42. <div class="name">{{ video.goafDevName }}</div>
  43. <div class="close" @click="videoDialogVisible=false"><el-icon><Close /></el-icon></div>
  44. </div>
  45. <!-- <HkwsVideo ref="HkwsVideo"></HkwsVideo> -->
  46. <iframe id="video" :src="video.src" frameborder="0" style="height: 80%;" />
  47. </div>
  48. </div>
  49. </div>
  50. </template>
  51. <script>
  52. import HkwsVideo from '@/components/HkwsVideo/iframe'
  53. import { getGoafBaseInfo } from '@/api/goaf/info'
  54. import { getSensor } from '@/api/goaf/sensor'
  55. import { NumConvertLM } from '@/utils'
  56. import axios from 'axios'
  57. export default {
  58. name:"particulars_video",
  59. components:{
  60. HkwsVideo
  61. },
  62. data(){
  63. return{
  64. activeId:'5',
  65. activetab:'1',
  66. items:[
  67. {name:"首页",id:"1",path:"/particulars/sensor"},
  68. {name:"压力传感器",id:"2",path:"/particulars/check"},
  69. {name:"位移传感器",id:"3",path:"/particulars/goaf-info"},
  70. {name:"有害气体传感器",id:"4",path:"/particulars/goaf-info"},
  71. {name:"视频监控",id:"5",path:"/particulars/goaf-info"},
  72. ],
  73. video:{
  74. src:"",
  75. name:""
  76. },
  77. videoDialogVisible:false,
  78. tabs:[
  79. {name:"Ⅲ号",id:"1"},
  80. {name:"770",id:"2"},
  81. {name:"32001",id:"3"},
  82. ],
  83. conditions: {
  84. page: 1,
  85. limit: 10,
  86. goafId: '',
  87. goafOrebelt: '',
  88. goafOrebody: '',
  89. goafOreheight: '',
  90. goafName:"",
  91. goafDevName:""
  92. },
  93. goafList: [],
  94. goafOrebelts: [],
  95. goafOrebodys: [],
  96. goafOreheights: [],
  97. goafNames: [],
  98. dataList:[]
  99. }
  100. },
  101. created(){
  102. this.init()
  103. },
  104. methods:{
  105. NumConvertLM,
  106. init(){
  107. getGoafBaseInfo().then((res) => {
  108. const goafOrebelts = res.data.map(item => item.goafOrebelt)
  109. this.goafOrebelts = [...new Set(goafOrebelts)]
  110. this.goafList = res.data
  111. })
  112. this.getData()
  113. },
  114. changeHead(item){
  115. this.activeId=item.id
  116. if(item.id!=='5'){
  117. this.$router.push(`/particulars/sensor?id=${item.id}`)
  118. }else{
  119. this.init()
  120. }
  121. },
  122. searchSubmit(){
  123. this.conditions.page=1
  124. this.getData()
  125. },
  126. resetSubmit(){
  127. this.conditions={
  128. page: 1,
  129. limit: 10,
  130. goafId: '',
  131. goafOrebelt: '',
  132. goafOrebody: '',
  133. goafOreheight: '',
  134. goafName:"",
  135. goafDevName:""
  136. }
  137. this.goafOrebodys=[]
  138. this.goafOreheights=[]
  139. this.goafNames=[]
  140. this.getData()
  141. },
  142. getData() {
  143. for(let key in this.conditions){
  144. if(this.conditions[key]===undefined||this.conditions[key]===''||this.conditions[key]==='undefined'){
  145. delete this.conditions[key]
  146. }
  147. }
  148. getSensor(this.conditions).then((resp) => {
  149. this.listLoading = false
  150. const { data } = resp
  151. const start = (this.conditions.page - 1) * this.conditions.limit
  152. const end = this.conditions.page * this.conditions.limit
  153. const dataList = data.filter((item) => item.goafDevTypename.includes('摄像头'))
  154. this.dataList = dataList.filter((item, index) => index >= start && index < end)
  155. this.total = dataList.length
  156. this.$nextTick(()=>{
  157. this.dataList.forEach((item)=>{
  158. if(this.$refs['HkwsVideo'+item.goafDevId]){
  159. this.$refs['HkwsVideo'+item.goafDevId][0].loadData({
  160. streamServeUrl:item.goafDevSocketAddr,
  161. szIP: item.goafDevIp, // protocol ip
  162. szPort: item.goafDevPort, // protocol port
  163. szUsername:item.goafDevAccount, // device username
  164. szPassword: item.goafDevPwd, // device password
  165. state:false
  166. })
  167. }
  168. })
  169. })
  170. })
  171. },
  172. showVideo(item) {
  173. axios({
  174. url: 'https://open.ys7.com/api/lapp/token/get',
  175. method: 'POST',
  176. params: {
  177. appKey: item.appKey,
  178. appSecret: item.appSecret
  179. }
  180. }).then((res) => {
  181. const accessToken = res.data.data.accessToken
  182. if (!accessToken) {
  183. this.$message.error('获取监控token失败!')
  184. return
  185. }
  186. this.videoDialogVisible = true
  187. this.video = {
  188. ...item,
  189. src: `https://open.ys7.com/ezopen/h5/iframe?url=ezopen://open.ys7.com/${item.deviceSerial}/1.live&autoplay=1&accessToken=${accessToken}`
  190. }
  191. }).catch((res) => {
  192. console.error(res)
  193. this.$message.error('获取监控失败!')
  194. })
  195. },
  196. showLocalVideo(item){
  197. if(this.isNull(item.goafDevSocketAddr)){
  198. console.error('未配置推流地址')
  199. return
  200. }
  201. if(this.isNull(item.goafDevIp)){
  202. console.error('未配置设备IP')
  203. return
  204. }
  205. if(this.isNull(item.goafDevPort)){
  206. console.error('未配置设备端口')
  207. return
  208. }
  209. if(this.isNull(item.goafDevAccount)){
  210. console.error('未配置设备账号')
  211. return
  212. }
  213. if(this.isNull(item.goafDevPwd)){
  214. console.error('未配置设备密码')
  215. return
  216. }
  217. this.videoDialogVisible=true;
  218. this.$nextTick(()=>{
  219. this.$refs.HkwsVideo.loadData({
  220. streamServeUrl:item.goafDevSocketAddr,
  221. szIP: item.goafDevIp, // protocol ip
  222. szPort: item.goafDevPort, // protocol port
  223. szUsername:item.goafDevAccount, // device username
  224. szPassword: item.goafDevPwd, // device password
  225. })
  226. })
  227. },
  228. changeArea(type) {
  229. const goafs = this.deeepClone(this.goafList)
  230. let goafOrebodys = this.deeepClone(this.goafOrebodys)
  231. let goafOreheights = this.deeepClone(this.goafOreheights)
  232. let goafNames = this.deeepClone(this.goafNames)
  233. if (type === 1) {
  234. goafOrebodys = goafs.filter(item => item.goafOrebelt === this.conditions.goafOrebelt)
  235. goafOrebodys = this.unique(goafOrebodys, 'goafOrebody')
  236. this.goafOrebodys = goafOrebodys
  237. this.goafOreheights = []
  238. this.goafNames = []
  239. this.conditions.goafOrebody = ''
  240. this.conditions.goafOreheight = ''
  241. this.conditions.goafName = ''
  242. this.conditions.goafId = ''
  243. } else if (type === 2) {
  244. goafOreheights = goafs.filter(item => (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  245. goafOreheights = this.unique(goafOreheights, 'goafOreheight')
  246. this.goafOreheights = goafOreheights
  247. this.goafNames = []
  248. this.conditions.goafOreheight = ''
  249. this.conditions.goafName = ''
  250. this.conditions.goafId = ''
  251. } else if (type === 3) {
  252. goafNames = goafs.filter(item => (item.goafOreheight === this.conditions.goafOreheight) && (item.goafOrebody === this.conditions.goafOrebody) && (item.goafOrebelt === this.conditions.goafOrebelt))
  253. this.goafNames = goafNames
  254. this.conditions.goafName = ''
  255. this.conditions.goafId = ''
  256. } else {
  257. for (let i = 0; i < goafNames.length; i++) {
  258. if (this.conditions.goafId === goafNames[i].goafId) {
  259. this.conditions.goafName = goafNames[i].goafName
  260. }
  261. }
  262. }
  263. this.$forceUpdate()
  264. },
  265. isNull(val){
  266. if(val===undefined||val==="undefined"&&val===null&&val===""){
  267. return true
  268. }
  269. return false
  270. },
  271. unique(arr = [], name = 'name') {
  272. const res = new Map()
  273. return arr.filter((item) => !res.has(item[name]) && res.set(item[name], 1))
  274. },
  275. deeepClone(params) {
  276. return JSON.parse(JSON.stringify(params))
  277. }
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .video-page{
  283. .search-item{
  284. display: flex;
  285. justify-content: center;
  286. align-items: center;
  287. margin-bottom: 14px;
  288. span{
  289. font-family: 'Ping Hei';
  290. font-size: 14px;
  291. line-height: 1;
  292. color: rgba(255, 255, 255, 0.7);
  293. }
  294. }
  295. .input,.select,.el-date-editor{
  296. width: 180px;
  297. margin-right:16px;
  298. color: #fff;
  299. }
  300. ::v-deep{
  301. .el-input__wrapper{
  302. background-color: rgba(8, 128, 255, 0.2);
  303. border: 0;
  304. box-shadow: none;
  305. }
  306. .el-input__inner{
  307. color: #fff;
  308. }
  309. }
  310. .video-dialog{
  311. position: fixed;
  312. z-index: 9999;
  313. left: 10px;
  314. top: 0;
  315. right: 10px;
  316. bottom: 0;
  317. background-color: rgba(222, 229, 236, 0.45);
  318. .video-dialog-container{
  319. width: 860px;
  320. height: 70%;
  321. max-width: 80%;
  322. background-color: #051933;
  323. border-radius: 20px;
  324. margin: 20px auto;
  325. }
  326. .name{
  327. color: #fff;
  328. font-size: 20px;
  329. line-height:1 ;
  330. text-indent: 20px;
  331. }
  332. .header{
  333. display: flex;
  334. justify-content: space-between;
  335. align-items: center;
  336. .close{
  337. height: 50px;
  338. line-height: 50px;
  339. display: inline-block;
  340. padding: 10px 20px;
  341. cursor: pointer;
  342. color: #fff;
  343. font-size: 36px;
  344. }
  345. }
  346. #video{
  347. display: block;
  348. width: 80%;
  349. max-height: 80vh;
  350. box-shadow: 2px 2px 4px rgba(0,0,0,0.6);
  351. margin: 10px auto;
  352. }
  353. }
  354. header{
  355. display: flex;
  356. justify-content: center;
  357. align-items: center;
  358. padding-top: 0.5vh;
  359. .item{
  360. width: 188px;
  361. height: 36px;
  362. line-height: 36px;
  363. text-align: center;
  364. background-image: url(@/assets/sensor/head.png);
  365. background-size: 100% 100%;
  366. background-repeat: no-repeat;
  367. margin-right: 12px;
  368. max-width: 20%;
  369. color: #7FCFF4;
  370. cursor: pointer;
  371. &.active{
  372. background-image: url(@/assets/sensor/head_active.png);
  373. color: #2AFFFF;
  374. }
  375. }
  376. }
  377. .tab{
  378. padding-top: 1.5vh;
  379. .item{
  380. display: inline-block;
  381. padding: 5px 10px;
  382. color: #fff;
  383. font-size: 16px;
  384. background: #003B7A;
  385. border: 1px solid #004EA2;
  386. letter-spacing: 0.6px;
  387. margin-right: 24px;
  388. border-radius: 4px 15px 8px 4px;
  389. cursor: pointer;
  390. &.active{
  391. background: #0083CF;
  392. border: 1px solid #0097DD;
  393. }
  394. }
  395. }
  396. .container{
  397. display: flex;
  398. .lf{
  399. width: 100%;
  400. padding-left: 100px;
  401. .search-container{
  402. padding:4.4vh 0 5vh 0;
  403. box-sizing: border-box;
  404. display: flex;
  405. flex-wrap: wrap;
  406. .input,.select,.el-date-editor{
  407. width: 220px;
  408. height: 36px;
  409. margin-right:16px;
  410. color: #fff;
  411. }
  412. ::v-deep{
  413. .el-input__wrapper{
  414. background-color: rgba(8, 128, 255, 0.2);
  415. border: 0;
  416. box-shadow: none;
  417. }
  418. .el-input__inner{
  419. color: #fff;
  420. }
  421. }
  422. .bt{
  423. width: 100px;
  424. height: 36px;
  425. line-height: 36px;
  426. text-align: center;
  427. color: #fff;
  428. font-size: 14px;
  429. background: rgba(8, 128, 255, 0.2);
  430. border-radius: 4px;
  431. cursor: pointer;
  432. &.search{
  433. background: linear-gradient(rgba(94, 226, 255, 1),rgba(79, 175, 255, 1));
  434. margin-right:14px;
  435. }
  436. }
  437. }
  438. .lf-container{
  439. .video-container{
  440. display: flex;
  441. justify-content: flex-start;
  442. align-items: center;
  443. flex-wrap: wrap;
  444. margin-top: 3vh;
  445. .item{
  446. width: 20%;
  447. display: flex;
  448. justify-content: center;
  449. align-items: center;
  450. flex-direction: column;
  451. padding: 20px;
  452. box-sizing: border-box;
  453. color: #fff;
  454. font-size: 14px;
  455. video{
  456. display: block;
  457. width: 100%;
  458. cursor: pointer;
  459. }
  460. p{
  461. padding-top: 10px;
  462. }
  463. }
  464. }
  465. .el-pagination-wrap{
  466. float: right;
  467. margin-top: 3vh;
  468. ::v-deep{
  469. .el-pager li,button{
  470. background-color: #00539F;
  471. margin-left: 10px;
  472. color: rgba(255, 255, 255, 0.75);
  473. &.is-active{
  474. background-color: rgba(0, 131, 207, 1);
  475. }
  476. }
  477. }
  478. }
  479. }
  480. }
  481. }
  482. }
  483. </style>