张晓波
2023-09-19 164694c47c35d6654df69b533e8dbf8b5423efc5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
<template>
  <div class="main">
    <div class="main_header">
      <!-- <div class="header_item">
        <span class="header_label">视频名称:</span>
        <el-input v-model="search.videoName" :size="size" clearable placeholder="请输入视频名称"></el-input>
      </div> -->
      <div class="header_item">
        <span class="header_label">视频编码:</span>
        <el-input v-model="search.deviceNum" :size="size" clearable placeholder="请输入视频编码"></el-input>
      </div>
      <!-- <div class="header_item">
        <span class="header_label">视频类别:</span>
        <el-select v-model="search.videoType" placeholder="请选择视频类别" clearable>
            <el-option
                v-for="item in optionsType"
                :key="item.dictId"
                :label="item.dictName"
                :value="item.dictId">
            </el-option>
        </el-select>
      </div> -->
      <div class="header_item">
        <el-button icon="el-icon-search" v-if="showButton('search')" @click="searchButtonInfo(true)">查询</el-button>
        <!-- <el-button class="search_btn" icon="el-icon-plus" v-if="showButton('insert')" @click="insertProp">新增</el-button> -->
      </div>
    </div>
    <div class="main_content" style="overflow: auto;margin: 0 24px 50px;">
        <div class="video_content">
            <div :id="'video_item'+(index+1)" v-for="(item,index) in dataPath" class="video_item_style" :key="index">
                <!-- <div class="video_names_title">{{item.deviceNum}}-{{item.channelNo}}</div> -->
            </div>
        </div>
    </div>
    <!-- <div class="main_footer">
      <el-pagination
        background
        @current-change="changePageNum"
        @size-change="changePageSize"
        :current-page="pageNum"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div> -->
    <el-dialog
      class="prop_dialog"
      :title="asyncTitle ? '新增监控设备' : '修改监控设备'"
      :close-on-click-modal="false"
      :visible.sync="asyncVisible"
      width="35%">
      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" label-width="auto" class="rule_form">
        <el-form-item label="设备ID:" prop="videoSn">
          <el-input v-model="ruleForm.videoSn" :size="size" clearable placeholder="请输入设备ID"></el-input>
        </el-form-item>
        <el-form-item label="视频名称:" prop="videoName">
          <el-input v-model="ruleForm.videoName" :size="size" clearable placeholder="请输入视频名称"></el-input>
        </el-form-item>
        <el-form-item label="视频类别:" prop="videoType">
          <el-select v-model="ruleForm.videoType" placeholder="请选择视频类别">
                <el-option
                v-for="item in optionsType"
                :key="item.dictId"
                :label="item.dictName"
                :value="item.dictId">
                </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="视频地址:" prop="videoPath">
          <el-input v-model="ruleForm.videoPath" :size="size" type="textarea" :rows="2" clearable placeholder="请输入视频地址"></el-input>
        </el-form-item>
        <el-form-item label="经纬度:" required="true">
            <div style="display:flex">
                <el-input v-model="ruleForm.longitude" :size="size" clearable placeholder="请输入经度" style="width:35%;margin-right:20px"></el-input>
                <el-input v-model="ruleForm.latitude" :size="size" clearable placeholder="请输入纬度" style="width:35%;margin-right:20px"></el-input>
                <el-button  style="width:30%;display:inline-block;margin-top:5px" @click.passive="logname = true" icon="el-icon-map-location">拾取坐标</el-button>
            </div>
        </el-form-item>
      </el-form>
      <div slot="footer">
        <el-button @click="asyncVisible = false">取 消</el-button>
        <el-button class="submit_btn" @click="asyncTitle ? submitInsert() : submitUpdate()">提 交</el-button>
      </div>
    </el-dialog>
    <!-- 拾取坐标弹框 -->
    <el-dialog
      class="prop_dialog get_point"
      title="拾取坐标"
      append-to-body
      :visible.sync="logname"
      width="35%">
      <div class="rule-form map-box">
                <div class="map-search" style="background-color: rgba(57,181,254,0.3);line-height:40px;border-radius:4px">
                    <div class="search-item">
                        <span class="label">经度:</span>
                        <span style="color:#FFFFFF;">{{lng}}</span>
                    </div>
                    <div class="search-item">
                        <span class="label">纬度:</span>
                        <span style="color:#FFFFFF;">{{lat}}</span>
                    </div>
                </div>
                <div class="map-search">
                    <div class="search-item">
                        <span class="label">关键字:</span>
                        <el-input v-model="keyword" clearable size="small" placeholder="请输入关键字" />
                    </div>
                    <div class="search-item">
                        <span class="label">地区:</span>
                        <el-input v-model="location" clearable size="small" placeholder="请输入地区" />
                    </div>
                </div>
                <select-map 
                    :center="{lng: 117.041871, lat: 39.420278}" 
                    :zoom="15"
                    :longitude.sync="lng"
                    :latitude.sync="lat"
                    :location.sync="location"
                    :keyword.sync="keyword"
                    ></select-map>
            </div>
            <template #footer>
                <div class="dialog-footer">
                    <el-button  @click="submitMapInfo" class="submit_btn">提交</el-button>
                </div>
            </template>
      </el-dialog>
  </div>
</template>
 
<script>
import  EZUIKit from 'ezuikit-js';
import 'video.js/dist/video-js.min.css'
import "videojs-contrib-hls";
import { buttonPinia } from '../../../pinia/index';
import SelectMap from '@/components/selectMap/index.vue';
import { changeSize } from '../../../plugins/public'; // 导入节流、动态切换组件尺寸方法
  export default {
    components:{
        SelectMap
    },
    name:'safeVideo',
    data() {
      return {
        size: changeSize(), // 组件尺寸
        pageNum: 1,
        pageSize: 10,
        logname:false,//获取坐标弹框
        lng:"",//经度
        lat:"",//纬度
        keyword:"",//关键字
        location:"",//地区
        search:{},//查询条件
        total: 0,
        loading: false,
        dataPath:[],//地址信息
        asyncTitle: true, // 对话框title 新增:true  修改:false
        asyncVisible: false, // 添加 修改对话框
        ruleForm: {
        }, // 按钮表单
        rules: {
          videoSn: [{
            required: true,
            message: '请输入设备ID',
            trigger: 'blur'
          }],
          videoName: [{
            required: true,
            message: '请输入视频名称',
            trigger: 'blur'
          }],
          videoType: [{
            required: true,
            message: '请选择视频类别',
            trigger: 'change'
          }],
          videoPath: [{
            required: true,
            message: '请输入视频地址',
            trigger: 'blur'
          }],
        },
        optionsType:[],//设备类型
        video:null,
        videoConfig:{
            autoplay:true,
            playbackRates: [0.5, 1, 1.5, 2],
            bigPlayButton: false,
            textTrackDisplay: false,
            posterImage: true,
            errorDisplay: false,
            controls: true,
            muted: true,
            preload: 'auto'
        }
      }
    },
    watch: {
      asyncVisible(bol) {
        if(!bol) {
          this.ruleForm = {};
          this.$refs.ruleForm.resetFields();
        }
      }
    },
    mounted() {
      const that = this;
      // 根据窗口大小动态修改组件尺寸
      window.onresize = () => {
        that.size = changeSize();
      }
      that.getAllTypes()
      that.openFullScreen()
    },
    methods: {
    // 提交选择经纬度信息
    submitMapInfo() {
        this.logname = false
        this.$set(this.ruleForm, 'longitude', this.lng)
        this.$set(this.ruleForm, 'latitude', this.lat)
    },
    //获取尺寸配筋转向等信息
      getAllTypes(){
        let params = {
            pageNum: 1,
            pageSize: 100000000,
            dictType:12
        }
        this.$api.Dictionary.searchDictionary(params).then(res=>{
            if(res.statusMsg === 'ok'){
                this.optionsType = res.data.list
            }else{
                this.$message.warning(res.statusMsg)
            }
        })
      },
      //增加转圈圈
      openFullScreen() {
        const loading = this.$loading({
          lock: true,
          text: 'Loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.7)'
        });
        setTimeout(() => {
          loading.close();
        }, 3000);
      },
      // 查询按钮列表信息
      searchButtonInfo(bol) {
        if(bol) {
            this.dataPath.forEach((item, index) => {
                let div = document.getElementById(`video_show${index +1}`)
                div.remove()
            })
        }
        let params ={
          types:1,//安全:1;现场:2
        }
        this.dataPath = []
        this.loading = true;
        this.$api.Device.searchDeviceInfo(params).then((res) => {
          if(res.statusMsg === 'ok') {
            res.data.map(item=>{
                this.dataPath.push({
                    channelNo:item.channelNo,
                    deviceNum:item.deviceNum,
                    videoPath:item.videoPath,
                })
                return this.dataPath
            })
            const formData = new FormData();
            formData.set('channelNo', this.dataPath[0].channelNo);
            formData.set('deviceNum', this.dataPath[0].deviceNum);
            formData.set('types', 1);
            this.$api.Device.backVideosUrlList(formData).then(resUrl=>{
                this.dataPath.map(item=>{
                    item.accessToken = resUrl.data
                })
            })
            setTimeout(() => {
                this.showVideo()
            },3000)
          }
          this.loading = false;
          this.openFullScreen()
        })
      },
      //销毁初始化
      clearInit(){
        this.dataPath.forEach((item, index) => {
            let div = document.getElementById(`video_show${index +1}`)
            div.remove()
        })
      },
      //遍历创建视频实例
      showVideo(){
        this.dataPath.forEach((item,index)=>{
            let name = `video_item${index + 1}`
            this.createVideo(item.videoPath,name,index+1,item.accessToken)
        })
      },
      //视频初始化
      createVideo(url,name,idx,accessToken){
        this.$nextTick(()=>{
            this.createElement(url,name,idx,accessToken)
            this.video = new EZUIKit.EZUIKitPlayer({
                id: `video_show${idx}`, // 视频容器ID
                accessToken:accessToken,
                url: url,
                height:300,
                autoplay:true,
                audio:0,
                template:'standard',
                header:[],
                // footer:['fullScreen','hd']
            })
        })
      },
      //创建video标签
      createElement(url,name,idx,accessToken){
        let div = document.getElementById(name)
        let div1 = document.createElement('div')
        div1.id = `video_show${idx}`
        div1.accessToken = accessToken
        div1.url = url
        div.appendChild(div1)
      },
      // 判断按钮权限信息
      showButton(str) {
        const pinia = buttonPinia();
        return pinia.$state.buttonInfo.includes(str);
      },
    },
    // 离开页面后销毁播放器实例
    beforeDestroy() {
        this.video = null
        this.dataPath.forEach((item, index) => {
            let div = document.getElementById(`video_show${index +1}`)
            div.remove()
        })
    }
  }
</script>
 
<style lang="scss" scoped>
@import '../../../style/layout-main.scss';
 
.video_content{
    display: flex;
    flex-wrap: wrap;
 
    .video_item_style{
        width: 23.2%;
        height: 300px;
        margin: 0.5%;
        position: relative;
 
        .video_names_title{
            padding-left: 40px;
            position: absolute;
            top: 15px;
            left: 0px;
            z-index: 999;
            color: rgba(255, 255, 255, 1);
            overflow: hidden;
            white-space: nowrap;
            text-overflow: ellipsis;
            width: 150px!important;
            display: inline-block;
            &::before{
                content: '';
                width: 18px;
                height: 17px;
                background: url("../../../assets/video_icons.png") no-repeat;
                position: absolute;
                top: 0px;
                left: 10px;
                z-index: 999;
            }
        }
    }
}
 
 
.map-box {
    height: 500px;
    
    .map-search {
        display: flex;
        margin: 10px;
        justify-content: space-between;
        padding: 0 15px;
        
        .label {
            // width: 100px;
            text-align: right;
            color: #fff;
            flex-grow: 0;
            flex-shrink: 0;
        }
        
        .search-item {
            display: flex;
            align-items: center;
        }
    }
}
.get_point{
  /deep/.el-dialog__body{
      overflow: hidden;
  }  
}
::v-deep .el-input .el-input__inner{
  background-color: transparent!important;
  border: 1px solid rgba(49, 105, 215, 0.5)!important;
  color: #fff;
}
</style>