peng
2026-03-20 8caf427556921d82c53fb1d54bcf150e79d3def7
src/views/dashboard/Analysis.vue
@@ -17,7 +17,7 @@
            placeholder="请选择终端设备"
            style="width: 200px"
            v-model="selectCameraCode"
            @change="alarmLogInit"
            @change="onCameraChange"
          >
            <a-select-option :value="''" :key="''">全部</a-select-option>
            <a-select-option :value="item.code" v-for="item in cameraList" :key="item.code">
@@ -111,7 +111,7 @@
    AnalysisDetailModal,
  },
  data() {
    data() {
    return {
      selectOrg: '',
      show: false,
@@ -122,16 +122,14 @@
      cameraList: [],
      selectCameraCode: '',
      videoConfig: {
        variable: 'player', //播放函数名称,该属性必需设置,值等于下面的new ckplayer()的对象
        // live: true,
        variable: 'player',
        backLive: false,
        track: null, //字幕
        track: null,
        crossorigin: '',
        playbackrateOpen: true,
        autoplay: true,
        loop: true, //是否需要循环播放
        video: 'https://ckplayer-video.oss-cn-shanghai.aliyuncs.com/mp4/1_640x480.mp4', //视频地址,
        // loaded: "loadedHandler", //播放器加载完成后调用该函数
        loop: true,
        video: '',
      },
      categoryOptions: [
        {
@@ -160,6 +158,8 @@
      url: {
        list: '/jyz/oilEvent/eventList',
        eventPopup: '/jyz/oilEvent/eventPopup',
        localVideoRandom: '/jyz/video/random',
        randomImages: '/jyz/video/random-images',
      },
    }
  },
@@ -176,25 +176,56 @@
  mounted() {
    // this.one_video_ckplayera()
    this.getCameraList()
    this.getLocalVideo()
    this.timer = setInterval(this.playAudio, 30000)
  },
  methods: {
    // 获取本地随机视频
    getLocalVideo() {
      getAction(this.url.localVideoRandom).then((res) => {
        if (res.code === 200 && res.result) {
          this.hasVideo = true
          this.eventVideoPlay(res.result)
        }
      })
    },
    assignRandomImages(recordList) {
      if (!recordList || !recordList.length) {
        return Promise.resolve([])
      }
      return getAction(this.url.randomImages, { count: recordList.length })
        .then((imageRes) => {
          if (imageRes.code === 200 && Array.isArray(imageRes.result) && imageRes.result.length) {
            return recordList.map((item, index) => {
              return {
                ...item,
                imgPath: imageRes.result[index % imageRes.result.length],
              }
            })
          }
          return recordList
        })
        .catch(() => recordList)
    },
    // Alarm Log 告警记录
    alarmLogInit(isFirst) {
      getAction(this.url.list, { limit: 20, cameraCode: this.selectCameraCode }).then((res) => {
        if (res.code === 200) {
          this.takeList = res.result
          if (res.result.length > 0 && isFirst) {
            if (res.result[0].videoPath) {
              this.hasVideo = true
              this.eventVideoPlay(res.result[0].videoPath)
            } else {
              this.hasVideo = false
              this.player && this.player.remove()
          const sourceList = Array.isArray(res.result) ? res.result : []
          this.assignRandomImages(sourceList).then((finalList) => {
            this.takeList = finalList
            if (finalList.length > 0 && isFirst) {
              if (finalList[0].videoPath) {
                this.hasVideo = true
                this.eventVideoPlay(finalList[0].videoPath)
              } else {
                this.hasVideo = false
                this.player && this.player.remove()
              }
            }
          }
          })
        } else {
          this.$message.error('获取失败!')
        }
@@ -230,12 +261,16 @@
      this.videoConfig.video = video
      this.player && this.player.remove()
      var videoObject = {
        ...this.videoConfig, // 通用配置
        container: '.one_video', //“#”代表容器的ID,“.”或“”代表容器的class
        ...this.videoConfig,
        container: '.one_video',
      }
      this.player = new ckplayer(videoObject) //初始化播放器
      this.player = new ckplayer(videoObject)
    },
    handleScroll() {},
    onCameraChange() {
      this.alarmLogInit(false)
      this.getLocalVideo()
    },
    onTreeNodeSelect(id, node) {
      this.selectOrg = node.selectedNodes[0].data.props.orgCode
      console.log(id, this.selectOrg)