<template>
  <div class="app-container">
    <el-form label-width="100px">
      <el-row>
        <el-col :span="3">
          <el-page-header content="分析视频管理" @back="goBack"/>
        </el-col>
        <el-col :span="8">
          <el-form-item label="关键词">
            <el-input v-model="KEYWORDS" placeholder="视频名称"/>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label-width="10px">
            <el-button v-waves type="primary" icon="el-icon-search" @click="getQuery">
              搜索
            </el-button>
            <el-button type="success" icon="el-icon-view" size="mini" @click="getReset">
              重置
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      v-loading="listLoading"
      ref="multipleTable"
      :data="varList"
      :header-cell-style="{
        'font-weight': 'bold',
        'color': '#000'
      }"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        :reserve-selection="true"
        type="selection"
        width="55"
        align="center"/>
      <el-table-column type="index" label="序号" width="50" align="center" />
      <el-table-column prop="VIDEO_NAME" label="视频名称" align="center"/>
      <el-table-column prop="VIDEO_URL" label="播放地址" align="center"/>
      <el-table-column prop="LONGITUDE" label="经纬度" align="center">
        <template slot-scope="{row}">
          {{ row.LONGITUDE ? row.LONGITUDE + '-' + row.LATITUDE : '未定位' }}
        </template>
      </el-table-column>
      <el-table-column prop="ISONLINE" label="状态" align="center">
        <template slot-scope="{row}">
          {{ row.ISONLINE === '0' ? '离线' : '在线' }}
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" width="580">
        <template slot-scope="{row}">
          <el-button type="success" icon="el-icon-caret-right" size="mini" @click="showVideo(row)">播放</el-button>
          <el-button v-if="edit" type="info" icon="el-icon-location-information" size="mini" @click="handleMap(row)">定位</el-button>
          <el-button v-if="edit" type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(row)">编辑</el-button>
          <el-button v-if="edit && row.ISONLINE === '1'" style="background-color: grey; color: white" type="Info" icon="el-icon-error" plain @click="handleOnline(row.AIBOX_RELATION_ID,0)">离线</el-button>
          <el-button v-if="edit && row.ISONLINE === '0'" style="background-color: seagreen; color: white" type="info" icon="el-icon-success" plain @click="handleOnline(row.AIBOX_RELATION_ID,1)">上线</el-button>
          <el-button v-show="edit && row.VIDEO_TYPE === '1'" type="warning" size="mini" @click="getRTSP(row)">获取rtsp地址</el-button>
          <el-button v-if="del" type="danger" icon="el-icon-delete" plain @click="handleDelete(row.AIBOX_RELATION_ID)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="page-btn-group">
      <div>
        <el-button v-if="add" v-show="$parent.CAPACITY > varList.length" type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
        <el-button type="success" icon="el-icon-caret-right" @click="showAll">播放全部</el-button>
      </div>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>

    <el-dialog :visible.sync="dialogFormMap" title="定位" width="1050px" class="dy-dialog">
      <div id="map" />
      <div slot="footer" class="dialog-footer">
        <span>经度：</span>
        <el-input v-model="addForm.info.LONGITUDE" style="width: 200px" placeholder="请输入内容" disabled />
        <span>纬度：</span>
        <el-input v-model="addForm.info.LATITUDE" style="width: 200px" placeholder="请输入内容" disabled />
        <el-button @click="dialogFormMap = false">取 消</el-button>
        <el-button type="primary" @click="setPosition()">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog :visible.sync="addForm.dialogVisible" :title="addForm.dialogType==='add'?'新增':'编辑'" width="600px">
      <el-form ref="addForm" :model="addForm.info" :rules="addForm.rules" label-width="110px" style="width: 500px;">
        <el-form-item label="视频类型">
          <el-radio-group v-model="addForm.info.VIDEO_TYPE" @change="changeType($event)">
            <el-radio :label="0">视频监控</el-radio>
            <el-radio :label="1">平台视频</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="addForm.info.VIDEO_TYPE===0" label="视频监控选择" prop="VIDEO_RESOURCES_ID">
          <el-button type="success" icon="el-icon-caret-right" size="mini" @click="selectBobileVideo()">选择</el-button>
        </el-form-item>

        <el-form-item v-if="addForm.info.VIDEO_TYPE===1" label="平台视频选择">
          <el-button type="success" icon="el-icon-caret-right" size="mini" @click="selectVideo()">选择</el-button>
        </el-form-item>

        <el-form-item label="视频名称" prop="VIDEO_NAME">
          <el-input :disabled="true" v-model="addForm.info.VIDEO_NAME" placeholder="这里输入视频名称..." />
        </el-form-item>

        <el-form-item label="摄像头编号" prop="CODE">
          <el-input :disabled="true" v-model="addForm.info.CODE" placeholder="这里输入摄像头编号..." />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="back">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>

    <el-dialog v-if="dialogVideo" :visible.sync="dialogVideo" :show-close="false" title="视频2" width="600px">
      <iframe :src="VIDEOURL" width="100%" height="380" allowfullscreen allow="autoplay; fullscreen;microphone" style="position: relative;border:none"/>
      <div slot="footer" class="dialog-footer">
        <el-button @click="back">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog v-if="dialogVideoHLS" :visible.sync="dialogVideoHLS" :before-close="handleBack" :show-close="false" title="视频" width="600px">
      <div id="aLiVideoPlayer" class="prism-player"/>
      <div slot="footer" class="dialog-footer">
        <el-button @click="back">取 消</el-button>
      </div>
    </el-dialog>

    <el-dialog v-if="dialogVideoAll" :visible.sync="dialogVideoAll" :before-close="handleBack" title="视频" width="1200px">
      <!--      <iframe src="http://192.168.192.121:10800/?menu=no/#/screen" width="100%" height="500px" allowfullscreen allow="autoplay; fullscreen" style="position: relative;border:none"/>-->
      <div style="display: flex;flex-wrap: wrap;justify-content: space-between">
        <div v-for="(video,index) in videoList" :key="index" style="margin-bottom: 10px;width: 45%">
          <div v-if="video.HLSVIDEOURL" :id="'aLiVideoPlayer'+index" class="prism-player"/>
        </div>
        <div v-for="(video2,index2) in video2List" :key="index2" style="margin-bottom: 10px;width: 45%">
          <iframe :src="video2.VIDEOURL" width="100%" height="380" allowfullscreen allow="autoplay; fullscreen;microphone" style="position: relative;border:none"/>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button @click="back">取 消</el-button>
      </div>
    </el-dialog>
    <platformvideo ref="platformvideo" @handleSelected="handleSelected"/>
    <BobileCamer ref="bobileCamer" @bobilehandleSelected="bobilehandleSelected"/>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive
import Platformvideo from './platformvideo.vue'
import BobileCamer from './bobileCamer.vue'
import TiandiMap from '../../../../components/TianMap/TiandiMap'

export default {
  components: { Platformvideo, Pagination, TiandiMap, BobileCamer },
  directives: { waves },
  data() {
    return {
      map: null,
      marker: null,
      BMap: '',
      clientHeight: 500,
      inputLocation: '',
      msg: 'add',
      video2List: [],
      config: config,
      listLoading: true,
      dialogForm: false,
      dialogImageUrl: '',
      dialogVisible: false,
      dialogSelect: false,
      add: '',
      del: '',
      edit: '',
      dialogFormMap: false,
      listQuery: {
        page: 1,
        limit: 20
      },
      total: 0,
      KEYWORDS: '',
      dates: [],
      videoList: [],
      varList: [],
      LATITUDE: '',
      LONGITUDE: '',
      form: {
        GATEVIDEO_ID: '',
        VIDEONAME: '', //
        CODE: '', //
        PLATFORMVIDEOMANAGEMENT_ID: '',
        LATITUDE: '',
        LONGITUDE: ''
      },
      zoom: 10,
      rules: {
        VIDEONAME: [{ required: true, message: '视频名称不能为空', trigger: 'blur' }],
        CODE: [{ required: true, message: '摄像头编号不能为空', trigger: 'blur' }]
      },
      dialogVideo: false,
      dialogVideoHLS: false,
      dialogVideoBack: false,
      dialogVideoAll: false,
      player: {},
      playerList: [],
      VIDEOURL: '',
      corpinfoAllList: [],
      capacityList: [{ name: '4', value: 4 }, { name: '8', value: 8 }, { name: '12', value: 12 }],
      AIBOX_RELATION_ID: '',
      addForm: {
        dialogType: 'add', // 增or改
        dialogVisible: false,
        rules: {
          VIDEO_NAME: [{ required: true, message: '不可为空', trigger: 'blur' }],
          CODE: [{ required: true, message: '不可为空', trigger: 'blur' }]
        },
        info: {
          AIBOX_ID: this.$parent.AIBOX_ID,
          VIDEO_TYPE: 0,
          VIDEO_NAME: '', //
          VIDEO_URL: '',
          CODE: '',
          LATITUDE: '',
          LONGITUDE: '',
          ALGO_LIMIT: ''
        }
      }
    }
  },
  created() {
    this.getCoroInfoAll()
    this.getList()
    this.hasButton()
  },
  beforeDestroy() {
    console.log('定时器关闭')
    clearInterval(this.timer)
    this.map && this.map.removeEventListener('click', this.MapClick)
  },
  methods: {
    handleOnline(AIBOX_RELATION_ID, ISONLINE) {
      requestFN(
        '/aiboxVideo/edit',
        {
          AIBOX_RELATION_ID: AIBOX_RELATION_ID,
          ISONLINE: ISONLINE
        }
      ).then((data) => {
        this.$message.success('保存成功')
        this.getList()
        this.addForm.dialogVisible = false
      }).catch((e) => {
      })
    },

    handleSelected(row) {
      this.$set(this.addForm.info, 'VIDEO_NAME', row.NAME)
      this.$set(this.addForm.info, 'VIDEO_URL', row.REGIONPATH)
      this.$set(this.addForm.info, 'CODE', row.INDEXCODE)
      this.$set(this.addForm.info, 'VIDEO_ID', row.PLATFORMVIDEOMANAGEMENT_ID)
    },

    bobilehandleSelected(row) {
      this.$set(this.addForm.info, 'VIDEO_URL', row.VIDEOURL)
      this.$set(this.addForm.info, 'VIDEO_NAME', row.VIDEONAME)
      this.$set(this.addForm.info, 'CODE', row.CODE)
      this.$set(this.addForm.info, 'VIDEO_ID', row.VIDEO_RESOURCES_ID)
      this.$forceUpdate()
    },
    getCoroInfoAll() {
      requestFN(
        '/corpinfo/listSelect',
        { }
      ).then((data) => {
        this.corpinfoAllList = data.list
      }).catch((e) => {
      })
    },
    selectBobileVideo() {
      this.$refs.bobileCamer.init()
    },
    // 搜索
    getReset() {
      this.KEYWORDS = ''
      this.listQuery = {
        page: 1,
        limit: 20
      }
      this.total = 0
      this.getQuery()
    },
    /**
     * 初始化天地图对象
     */
    initTDT() {
      return new Promise((resolve, reject) => {
        if (window.T) {
          console.log('天地图初始化成功...')
          resolve(window.T)
          reject('error')
        }
      }).then(T => {
        window.T = T
      })
    },
    /**
     * 初始化地图
     * @param {*} lng 经度
     * @param {*} lat 纬度
     * @param {*} zoom 缩放比例(1~18)
     */
    initMap(lng, lat, zoom) {
      this.initTDT().then((T) => {
        const imageURL = 'http://t0.tianditu.gov.cn/img_w/wmts?' + 'SERVICE=WMTS&REQUEST=GetTile&VERSION=1.0.0&LAYER=img&STYLE=default&TILEMATRIXSET=w&FORMAT=tiles' + '&TILEMATRIX={z}&TILEROW={y}&TILECOL={x}&tk=e8a16137fd226a62a23cc7ba5c9c78ce'
        // 创建自定义图层对象
        this.lay = new window.T.TileLayer(imageURL, { minZoom: 1, maxZoom: 18 })
        // 初始化地图对象
        this.map = new window.T.Map('map')
        this.initCenter(lng, lat, zoom)
      })
    },
    initCenter(lng, lat, zoom) {
      // 设置显示地图的中心点和级别
      if (!this.addForm.info.LONGITUDE && !this.addForm.info.LATITUDE) {
        this.map.centerAndZoom(new window.T.LngLat(119.58, 39.94), zoom)
        this.marker && this.map.removeOverLay(this.marker)
      } else {
        this.map.centerAndZoom(new window.T.LngLat(lng, lat), zoom)
        this.marker && this.map.removeOverLay(this.marker)
        this.addForm.info.LONGITUDE = lng
        this.addForm.info.LATITUDE = lat
        this.marker = new window.T.Marker(new window.T.LngLat(lng, lat))
        // 向地图上添加标注
        this.map.addOverLay(this.marker)
      }
      // 创建卫星和路网的混合视图
      this.map.setMapType(window.TMAP_HYBRID_MAP)
      // 允许鼠标滚轮缩放地图
      this.map.enableScrollWheelZoom()
      // 允许鼠标移动地图
      this.map.enableInertia()
      // 向地图上添加标注
      this.map.addEventListener('click', this.MapClick)
    },
    MapClick(event) {
      console.log(1111)
      this.marker && this.map.removeOverLay(this.marker)
      this.addForm.info.LONGITUDE = event.lnglat.getLng()
      this.addForm.info.LATITUDE = event.lnglat.getLat()
      this.marker = new window.T.Marker(new window.T.LngLat(event.lnglat.getLng(), event.lnglat.getLat()))
      // 向地图上添加标注
      this.map.addOverLay(this.marker)
    },
    handleMap(row) {
      this.dialogFormMap = true
      this.AIBOX_RELATION_ID = row.AIBOX_RELATION_ID
      this.addForm.info = {
        ...this.addForm.info,
        LATITUDE: row.LATITUDE,
        LONGITUDE: row.LONGITUDE
      }
      this.$nextTick(() => {
        if (!this.map) this.initMap(this.addForm.info.LONGITUDE, this.addForm.info.LATITUDE, 16)
        else this.initCenter(this.addForm.info.LONGITUDE, this.addForm.info.LATITUDE, 16)
      })
    },
    getRowKey(row) {
      return row.GATEVIDEO_ID
    },
    // 搜索
    getQuery() {
      this.$refs.multipleTable.clearSelection()
      this.getList()
    },
    // 五分钟关闭视频播放页面定时任务
    start() {
      console.log('定时器开启')
      this.timer = setInterval(this.closeVideoStart, (5 * 60 * 1000)) // 5分钟
    },
    over() {
      // 定时器手动关闭
      console.log('定时器自动关闭')
      this.$message.warning('单次播放时长已到5分钟自动关闭')
      clearInterval(this.timer)
    },
    closeVideoStart() {
      this.dialogVideo = false
      this.dialogVideoHLS = false
      this.dialogVideoBack = false
      this.dialogVideoAll = false
      this.over()
    },
    // 播放
    handleBack() {
      if (this.dialogVideoAll) {
        for (let i = 0; i < this.playerList.length; i++) {
          this.playerList[i].dispose()
        }
        this.dialogVideoAll = false
      }
      if (this.dialogVideoHLS) {
        this.player.dispose()
        this.dialogVideoHLS = false
      }
    },
    showVideo(row) {
      this.$message.warning('单次播放最多五分钟')
      this.start()
      if (row.VIDEO_TYPE === '0') {
        this.VIDEOURL = row.VIDEO_URL
        this.dialogVideo = true
      } else {
        requestFN(
          '/platformvideomanagement/getHlsPath',
          {
            INDEXCODE: row.CODE
          }
        ).then((res) => {
          this.dialogVideoHLS = true
          this.$nextTick(() => {
            // eslint-disable-next-line no-undef
            this.player = new Aliplayer({
              'id': 'aLiVideoPlayer',
              'source': res.data.url,
              'width': '100%',
              'height': '500px',
              'autoplay': true,
              'isLive': true,
              'rePlay': false,
              'playsinline': true,
              'preload': true,
              'controlBarVisibility': 'hover',
              'useH5Prism': true
            }, function(player) {
              console.log('The player is created')
            })
          })
        }).catch((e) => {
          this.over()
          this.listLoading = false
        })
      }
    },
    setPosition() {
      this.dialogFormMap = false
      this.listLoading = true
      requestFN(
        '/aiboxVideo/edit',
        {
          LATITUDE: this.addForm.info.LATITUDE,
          LONGITUDE: this.addForm.info.LONGITUDE,
          AIBOX_RELATION_ID: this.AIBOX_RELATION_ID
        }
      ).then((data) => {
        this.$message.success('定位成功')
        this.listLoading = false
        this.dialogForm = false
        this.getList()
      }).catch((e) => {
        this.listLoading = false
      })
    },
    getRTSP(row) {
      requestFN(
        '/platformvideomanagement/getRtspPath',
        {
          INDEXCODE: row.CODE
        }
      ).then((res) => {
        this.notify(res.data.url)
      }).catch((e) => {
        this.listLoading = false
      })
    },
    showAll() {
      const _selectData = this.$refs.multipleTable.selection
      if (_selectData == null || _selectData.length == 0) {
        this.$message({
          message: '请选中要播放的视频...',
          type: 'error'
        })
        return false
      }
      this.video2List = []
      const ids = _selectData.map((item, index) => {
        if (item.VIDEO_TYPE === '1') {
          return item.VIDEO_ID
        } else if (item.VIDEO_TYPE === '0') {
          this.video2List.push({ 'VIDEOURL': item.VIDEO_URL })
        }
      }).join(',')
      this.videoList = []
      this.listLoading = true
      requestFN(
        '/gateVideo/goAllVideoForAlarm',
        {
          DATA_IDS: ids
        }
      ).then((data) => {
        this.videoList = data.videoList
        this.listLoading = false
        this.dialogVideoAll = true
        this.playerList = []
        this.$nextTick(() => {
          for (let i = 0; i < this.videoList.length; i++) {
            if (!this.videoList[i].HLSVIDEOURL) continue
            console.log(this.videoList[i].HLSVIDEOURL.data.url)
            // eslint-disable-next-line no-undef
            const player = new Aliplayer({
              'id': 'aLiVideoPlayer' + i,
              'source': this.videoList[i].HLSVIDEOURL.data.url,
              'width': '100%',
              'height': '500px',
              'autoplay': true,
              'isLive': true,
              'rePlay': false,
              'playsinline': true,
              'preload': true,
              'controlBarVisibility': 'hover',
              'useH5Prism': true
            }, function(player) {
              console.log('The player is created')
            })
            this.playerList.push(player)
            console.log(this.playerList)
          }
        })
      }).catch((e) => {
        this.listLoading = false
      })
    },

    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/aiboxVideo/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          KEYWORDS: this.KEYWORDS,
          AIBOX_ID: this.$parent.AIBOX_ID
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
      }).catch((e) => {
        this.listLoading = false
      })
    },

    // 添加
    handleAdd() {
      this.resetAddForm()
      this.addForm.dialogType = 'add'
      this.addForm.dialogVisible = true
    },

    handleEdit(row) {
      this.resetAddForm()
      this.AIBOX_RELATION_ID = row.AIBOX_RELATION_ID
      this.addForm.info.VIDEO_ID = row.VIDEO_ID
      this.addForm.info.VIDEO_NAME = row.VIDEO_NAME
      this.addForm.info.VIDEO_URL = row.VIDEO_URL
      this.addForm.info.CODE = row.CODE
      this.addForm.info.VIDEO_TYPE = parseInt(row.VIDEO_TYPE)
      this.addForm.dialogType = 'edit'
      this.addForm.dialogVisible = true
    },

    selectVideo(row) {
      this.$refs.platformvideo.init()
    },

    // 获取详情
    getData() {
      this.listLoading = true
      requestFN(
        '/gateVideo/goEdit',
        {
          GATEVIDEO_ID: this.form.GATEVIDEO_ID
        }
      ).then((data) => {
        this.form = data.pd
        this.listLoading = false
      }).catch((e) => {
        this.listLoading = false
      })
    },

    // 保存
    save() {
      this.$refs.form.validate(valid => {
        if (valid) {
          this.listLoading = true
          requestFN(
            '/gateVideo/' + this.msg,
            {
              VIDEONAME: this.form.VIDEONAME,
              CODE: this.form.CODE,
              GATEVIDEO_ID: this.form.GATEVIDEO_ID,
              GATE_AREA_ID: this.$parent.GATE_AREA_ID,
              PLATFORMVIDEOMANAGEMENT_ID: this.form.PLATFORMVIDEOMANAGEMENT_ID
            }
          ).then((data) => {
            this.listLoading = false
            this.dialogForm = false
            this.getList()
          }).catch((e) => {
            this.listLoading = false
          })
        } else {
          return false
        }
      })
    },
    resetAddForm() {
      this.AIBOX_RELATION_ID = ''
      this.addForm.info = {
        VIDEO_TYPE: '',
        VIDEO_NAME: '',
        VIDEO_URL: '',
        CODE: '',
        LATITUDE: '',
        LONGITUDE: '',
        ALGO_LIMIT: ''
      }
      this.addForm.dialogType = ''
    },
    changeType(e) {
      if (e === 1) {
        this.addForm.info.VIDEO_TYPE = 1
      } else {
        this.addForm.info.VIDEO_TYPE = 0
      }
      this.addForm.info.VIDEO_NAME = ''
      this.addForm.info.VIDEO_URL = ''
      this.addForm.info.CODE = ''
      this.addForm.info.LATITUDE = ''
      this.addForm.info.LONGITUDE = ''
      this.addForm.info.ALGO_LIMIT = ''
      this.$forceUpdate()
    },
    confirm() {
      this.$refs.addForm.validate(valid => {
        if (valid) {
          requestFN(
            '/aiboxVideo/' + this.addForm.dialogType,
            {
              ...this.addForm.info,
              AIBOX_ID: this.$parent.AIBOX_ID,
              AIBOX_RELATION_ID: this.AIBOX_RELATION_ID
            }
          ).then((data) => {
            this.$message.success('保存成功')
            this.getList()
            this.addForm.dialogVisible = false
          }).catch((e) => {
          })
        } else {
          return false
        }
      })
    },
    handleDelete(id) {
      this.$confirm('确定要删除吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/aiboxVideo/delete',
          {
            AIBOX_RELATION_ID: id
          }
        ).then((data) => {
          if (data.result === 'success') {
            this.$message({
              message: '删除成功',
              type: 'success'
            })
          } else {
            this.$message.error(data.msg)
          }
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },
    batchDel() {
      const _selectData = this.$refs.multipleTable.selection
      if (_selectData == null || _selectData.length == 0) {
        this.$message({
          message: '请选中要删除的项...',
          type: 'error'
        })
        return false
      }
      const ids = _selectData.map((item, index) => {
        return item.GATEVIDEO_ID
      }).join(',')

      this.$confirm('确定要删除选中的数据吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/gateVideo/deleteAll',
          {
            DATA_IDS: ids
          }
        ).then(() => {
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.$refs.multipleTable.clearSelection()
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },
    goKeyReset() {
      this.KEYWORDS = ''
      this.getList()
    },

    back() {
      if (this.addForm.dialogVisible) this.addForm.dialogVisible = false
      if (this.dialogVideo) this.dialogVideo = false
      if (this.dialogVideoBack) this.dialogVideoBack = false
      if (this.dialogVideoAll) {
        this.dialogVideoAll = false
        for (let i = 0; i < this.playerList.length; i++) {
          this.playerList[i].dispose()
        }
      }
      if (this.dialogForm) this.dialogForm = false
      if (this.dialogVideoHLS) {
        this.dialogVideoHLS = false
        this.player.dispose()
      }
    },

    resetForm() {
      this.form = {
        GATEVIDEO_ID: '',
        VIDEONAME: '', //
        PLATFORMVIDEOMANAGEMENT_ID: ''
      }
    },
    goBack() {
      this.$parent.activeName = 'List'
      this.$parent.GATE_MACHINE_ID = ''
    },
    // 判断按钮权限，用于是否显示按钮
    hasButton: function() {
      var keys = 'aiboxVideo:add,aiboxVideo:del,aiboxVideo:edit'
      requestFN(
        '/head/hasButton',
        {
          keys: keys
        }
      ).then((data) => {
        this.add = data.aiboxVideofhadminadd		// 新增权限
        this.del = data.aiboxVideofhadmindel		// 删除权限
        this.edit = data.aiboxVideofhadminedit	// 修改权限
      }).catch((e) => {
        this.listLoading = false
      })
    }
  }

}

</script>
<style>
.ui-foot-xuan {
  width: 100%;
  margin-top: 10px;
  position: inherit;
  height: 60px;
  line-height: 60px;
  background-color: #f1f1f1;
  text-align: center;
}
#map{
  width: 1000px;
  height: 500px;
}
</style>
