南昌市物联网技防平台-前端
shuishen
2021-04-08 a4e06ccd3cd976fbe4eef99e188d42ec9f3ad054
src/views/realTimePolice/real.vue
@@ -2,7 +2,7 @@
 * @Author: Morpheus
 * @Date: 2021-03-17 15:21:33
 * @Last Modified by: Morpheus
 * @Last Modified time: 2021-03-22 09:29:16
 * @Last Modified time: 2021-04-07 17:36:33
 */
<template>
  <basic-container>
@@ -19,6 +19,7 @@
      @row-save="rowSave"
      :before-open="beforeOpen"
      :row-style="rowStyle"
      row-class-name="tabFontSize"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
@@ -29,9 +30,9 @@
    >
      <template slot="menuLeft">
        <el-button
          hidden="hidden"
          type="danger"
          size="small"
          v-show="true"
          size="mini"
          icon="el-icon-delete"
          plain
          v-if="permission.real_delete"
@@ -43,7 +44,7 @@
      <template slot="menuLeft">
        <el-button
          v-bind:class="activeClass == 0 ? 'btn-color' : ''"
          size="small"
          size="mini"
          @click="getBRdata(0)"
          >本日
        </el-button>
@@ -129,7 +130,7 @@
      :visible.sync="dialogTableVisible"
      :append-to-body="true"
      :close-on-click-modal="false"
      @opened="videoConversationReal = true"
      @opened="realOpenVideoDialog"
      @close="(videoConversationReal = false), (oldVideoSatart = false)"
    >
      <el-dialog
@@ -332,6 +333,7 @@
                >视频通话
              </el-button>
              <el-button
                v-show="false"
                type="primary"
                @click.stop="
                  (oldVideoSatart = true), (videoConversationReal = false)
@@ -432,15 +434,17 @@
        calcHeight: 30,
        labelWidth: "100",
        size: "mini",
        border: false,
        stripe: true,
        menuWidth: 240,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 3,
        border: true,
        align: "center",
        index: true,
        viewBtn: true,
        selection: false,
        selection: true,
        dialogClickModal: false,
        column: [
          {
@@ -448,7 +452,7 @@
            prop: "waringType",
            search: false,
            searchSpan: 3,
            width: 130,
            width: 85,
            className: "waringTypeClass",
            searchPlaceholder: "请选择",
            type: "select",
@@ -463,7 +467,7 @@
          {
            label: "报警时间",
            type: "datetime",
            width: 130,
            width: 160,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            prop: "alarmTime",
@@ -497,11 +501,12 @@
          {
            label: "负责人电话",
            prop: "onePhone",
            width: 96,
            width: 110,
          },
          {
            label: "报警人",
            prop: "galarmPeople",
            width: 90,
          },
          {
            label: "报警人电话",
@@ -510,7 +515,6 @@
          },
          {
            label: "事发地址",
            width: 200,
            prop: "place",
          },
          {
@@ -560,6 +564,10 @@
            dicUrl: "/api/blade-system/region/select",
            span: 6,
            className: "cityClass1",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "地市",
@@ -578,6 +586,10 @@
            span: 3,
            labelWidth: "0",
            className: "cityClass2",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "区县",
@@ -596,10 +608,15 @@
            span: 3,
            labelWidth: "0",
            className: "cityClass3",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "接警人",
            prop: "alarmPeople",
            width: 90,
          },
          {
            label: "接警时间",
@@ -608,6 +625,10 @@
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            width: 130,
            prop: "jjTime",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
        ],
      },
@@ -690,14 +711,6 @@
  },
  created() {
    this.dateTime = this.getDate();
    Recorder.getPermission().then(() => {});
    this.recorder = new Recorder({
      sampleBits: 16, // 采样位数,支持 8 或 16,默认是16
      sampleRate: 8000, // 采样率,支持 11025、16000、22050、24000、44100、48000,根据浏览器默认值,我的chrome是48000
      numChannels: 1, // 声道,支持 1 或 2, 默认是1
      // compiling: false,(0.x版本中生效,1.x增加中)  // 是否边录边转换,默认是false
    });
  },
  methods: {
    rowSave(row, done, loading) {
@@ -812,7 +825,7 @@
      };
      if (
        this.$route.query.waringType &&
        this.$route.query.waringType &&
        this.$route.query != undefined &&
        this.$route.query != null &&
        this.$route.query != ""
@@ -850,6 +863,18 @@
            waringType: this.$route.query.waringType,
            beginTime: this.dateTime.day.beginTime,
            endTime: this.dateTime.day.endTime,
          };
        }
        if (
          this.$route.query.startTime != undefined &&
          this.$route.query.startTime != null &&
          this.$route.query.startTime != ""
        ) {
          params = {
            waringType: this.$route.query.waringType,
            beginTime: this.$route.query.startTime,
            endTime: this.$route.query.endTime,
          };
        }
      }
@@ -1110,8 +1135,21 @@
          }
        )
        .then(function () {
          that.onLoad(that.page, that.query);
          that.dialogTableVisible = false;
          axios({
            method: "post",
            url: `/api/blade-jfpts/rvideo/stop`,
            params: {
              jid: row.id,
            },
          }).then((resdata) => {});
          that.onLoad(that.page, that.query);
          that.$router.push({
            path: "/policeTracking/track",
            query: that.form,
          });
        });
    },
    beginTimeOrEndTime(time) {
@@ -1175,6 +1213,7 @@
    },
    // 视频通话打开关闭事件
    openRealVideoBox() {
      var that = this;
      var newAxios = axios.create({
        baseURL: "https://web.byisf.com:18000",
        withCredentials: false,
@@ -1197,24 +1236,49 @@
        .then((res) => {
          newAxios
            .get(
              `https://web.byisf.com:18000/GetPlayUrl?deviceCode=${this.form.serialNumber}&chl=${this.form.channelNumber}`
              `https://web.byisf.com:18000/GetPlayUrl?deviceCode=${that.form.serialNumber}&chl=${this.form.channelNumber}`
            )
            .then((result) => {
              this.videoSource = result.data.data.m3u8;
              that.videoSource = result.data.data.m3u8;
              if (Hls.isSupported()) {
                var dom = document.getElementById("real_video_conversation");
                this.hls = new Hls();
                that.hls = new Hls();
                var m3u8Url = decodeURIComponent(this.videoSource);
                var m3u8Url = decodeURIComponent(that.videoSource);
                this.hls.loadSource(m3u8Url);
                that.hls.loadSource(m3u8Url);
                this.hls.attachMedia(dom);
                that.hls.attachMedia(dom);
                this.hls.on(Hls.Events.MANIFEST_PARSED, function () {
                that.hls.on(Hls.Events.MANIFEST_PARSED, function () {
                  dom.play();
                });
                that.hls.on(Hls.Events.ERROR, function (event, data) {
                  console.log(data, 4566824159, "视频播放有问题!!!");
                  if (data.fatal) {
                    switch (data.type) {
                      case Hls.ErrorTypes.NETWORK_ERROR:
                        // try to recover network error
                        console.log(
                          "fatal network error encountered, try to recover"
                        );
                        that.hls.startLoad();
                        break;
                      case Hls.ErrorTypes.MEDIA_ERROR:
                        console.log(
                          "fatal media error encountered, try to recover"
                        );
                        that.hls.recoverMediaError();
                        break;
                      default:
                        // cannot recover
                        that.hls.destroy();
                        break;
                    }
                  }
                });
              }
            });
@@ -1243,6 +1307,7 @@
    },
    aKeyToCall() {
      this.isActive = true;
      var that = this;
      if (this.recorder == null) {
        this.recorder = new Recorder({
@@ -1252,7 +1317,6 @@
          // compiling: false,(0.x版本中生效,1.x增加中)  // 是否边录边转换,默认是false
        });
      }
      this.isActive = true;
      // 一键呼叫相关函数
      that.recorder.start().then(
@@ -1268,6 +1332,7 @@
    // 序列号后期待修改
    aKeyStopCall() {
      this.isActive = false;
      var newCallAxios = axios.create({
        baseURL: "https://web.byisf.com:18000",
        withCredentials: false,
@@ -1276,7 +1341,6 @@
        },
      });
      var that = this;
      that.isActive = false;
      newCallAxios
        .post(
@@ -1290,6 +1354,8 @@
        )
        .then((result) => {
          var formData = new FormData();
          // that.recorder.downloadWAV("新文件");
          var blob = that.recorder.getPCMBlob(); //获取pcm格式音频数据
          //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
          var newbolb = new Blob([blob], { type: "audio/pcm" });
@@ -1323,6 +1389,10 @@
    PoliceTracking(row) {
      //警情追踪
      this.$router.push({ path: "/policeTracking/track", query: row });
    },
    realOpenVideoDialog() {
      Recorder.getPermission().then(() => {});
      this.videoConversationReal = true;
    },
  },
};
@@ -1430,7 +1500,7 @@
}
.el-button.active {
  background: #ff0000;
  background: #ff0000 !important;
}
.el-button.btn-color {
@@ -1438,4 +1508,8 @@
  background-color: rgb(64, 158, 255);
  border-color: rgb(64, 158, 255);
}
.tabFontSize {
  font-size: 15px;
}
</style>