南昌市物联网技防平台-前端
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-19 18:47:03
 * @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"
@@ -30,7 +31,8 @@
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          v-show="true"
          size="mini"
          icon="el-icon-delete"
          plain
          v-if="permission.real_delete"
@@ -41,20 +43,26 @@
      <template slot="menuLeft">
        <el-button
          v-bind:class="activeClass == 0 ? 'btn-color' : ''"
          size="mini"
          @click="getBRdata(0)"
          >本日
        </el-button>
        <el-button
          v-bind:class="activeClass == 1 ? 'btn-color' : ''"
          size="small"
          size="mini"
          @click="getBZdata(1)"
          >本周
        </el-button>
        <el-button
          v-bind:class="activeClass == 2 ? 'btn-color' : ''"
          size="small"
          size="mini"
          @click="getBYdata(2)"
          >本月
        </el-button>
        <el-button
          v-bind:class="activeClass == 3 ? 'btn-color' : ''"
          size="small"
          size="mini"
          @click="getQBdata(3)"
          >全部
        </el-button>
@@ -63,9 +71,7 @@
      <template slot-scope="{ row }" slot="jtype">
        <el-tag
          >{{
            row.jtype == "0"
              ? "未处理"
              : "已处理"
            row.jtype == "0" ? "未处理" : row.jtype == "1" ? "处理中" : "已处理"
          }}
        </el-tag>
      </template>
@@ -101,7 +107,7 @@
          >核实
        </el-button>
        <el-button
          v-if="row.jtype == 1 || row.jtype == 2 || row.jtype == 3"
          v-if="row.jtype != 0 && row.jtype != ''"
          icon="el-icon-s-order"
          :size="size"
          :type="type"
@@ -124,7 +130,8 @@
      :visible.sync="dialogTableVisible"
      :append-to-body="true"
      :close-on-click-modal="false"
      @close="innerVisibleVideo = false"
      @opened="realOpenVideoDialog"
      @close="(videoConversationReal = false), (oldVideoSatart = false)"
    >
      <el-dialog
        class="ss-video-dialog"
@@ -139,7 +146,7 @@
      >
        <video
          src=""
          id="video_conversation"
          id="real_video_conversation"
          style="width: 100%; height: 100%; object-fit: fill"
          controls
        ></video>
@@ -161,7 +168,7 @@
          muted="muted"
          autoplay="autoplay"
          loop
          id="old_video"
          id="real_old_video"
          style="width: 100%; height: 100%; object-fit: fill"
          controls
        ></video>
@@ -255,7 +262,7 @@
        </el-row>
        <el-row>
          <el-col span="12">
            <el-form-item label="警情类别">
            <el-form-item label="警情类型">
              <el-input
                disabled="true"
                v-model="form.waringType"
@@ -283,11 +290,20 @@
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col span="12">
          <!-- <el-col span="12">
            <el-form-item label="接警时间">
              <el-input
                disabled="true"
                v-model="form.jjTime"
                autocomplete="off"
              ></el-input>
            </el-form-item>
          </el-col> -->
          <el-col span="12">
            <el-form-item label="报警内容">
              <el-input
                disabled="true"
                v-model="form.content"
                autocomplete="off"
              ></el-input>
            </el-form-item>
@@ -310,13 +326,14 @@
                :class="{ active: isActive }"
                type="success"
                @click.stop="
                  (videoConversationReal = !videoConversationReal),
                    (oldVideoSatart = fasle),
                    aKeyToCall(form)
                  (videoConversationReal = true), (oldVideoSatart = false)
                "
                @mousedown.native="aKeyToCall"
                @mouseup.native="aKeyStopCall"
                >视频通话
              </el-button>
              <el-button
                v-show="false"
                type="primary"
                @click.stop="
                  (oldVideoSatart = true), (videoConversationReal = false)
@@ -328,15 +345,6 @@
        </el-row>
        <el-row>
          <el-col span="12">
            <el-form-item label="报警内容">
              <el-input
                disabled="true"
                v-model="form.content"
                autocomplete="off"
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col span="12">
            <el-form-item label="备注">
              <el-input v-model="form.bz" autocomplete="off"></el-input>
@@ -426,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: [
          {
@@ -442,7 +452,7 @@
            prop: "waringType",
            search: false,
            searchSpan: 3,
            width: 130,
            width: 85,
            className: "waringTypeClass",
            searchPlaceholder: "请选择",
            type: "select",
@@ -457,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",
@@ -484,21 +494,27 @@
            ],
          },
          {
            label: "报警内容",
            prop: "content",
            label: "主要负责人",
            prop: "oneContacts",
            width: 90,
          },
          {
            label: "负责人电话",
            prop: "onePhone",
            width: 110,
          },
          {
            label: "报警人",
            prop: "galarmPeople",
            width: 90,
          },
          {
            label: "联系电话",
            label: "报警人电话",
            prop: "phoneNumber",
            width: 130,
          },
          {
            label: "事发地址",
            width: 200,
            prop: "place",
          },
          {
@@ -523,9 +539,13 @@
                value: "0",
              },
              {
                label: "已处理",
                label: "处理中",
                value: "1",
              }
              },
              {
                label: "已处理",
                value: "2",
              },
            ],
          },
          {
@@ -544,6 +564,10 @@
            dicUrl: "/api/blade-system/region/select",
            span: 6,
            className: "cityClass1",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "地市",
@@ -562,6 +586,10 @@
            span: 3,
            labelWidth: "0",
            className: "cityClass2",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "区县",
@@ -580,10 +608,15 @@
            span: 3,
            labelWidth: "0",
            className: "cityClass3",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
          {
            label: "接警人",
            prop: "alarmPeople",
            width: 90,
          },
          {
            label: "接警时间",
@@ -592,6 +625,10 @@
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            width: 130,
            prop: "jjTime",
            hide: true,
            addDisplay: true,
            editDisplay: true,
            viewDisplay: true,
          },
        ],
      },
@@ -660,8 +697,8 @@
      return {
        addBtn: this.vaildData(this.permission.real_add, false),
        viewBtn: this.vaildData(null, false),
        delBtn: this.vaildData(this.permission.real_delete, false),
        editBtn: this.vaildData(this.permission.real_edit, false),
        delBtn: this.vaildData(null, false),
        editBtn: this.vaildData(null, false),
      };
    },
    ids() {
@@ -674,13 +711,6 @@
  },
  created() {
    this.dateTime = this.getDate();
    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) {
@@ -795,13 +825,58 @@
      };
      if (
        this.$router.query &&
        this.$router.query != null &&
        this.$router.query != ""
        this.$route.query.waringType &&
        this.$route.query != undefined &&
        this.$route.query != null &&
        this.$route.query != ""
      ) {
        params = {
          alarmType: this.$router.query.alarmType,
        };
        if (
          this.$route.query.status != undefined &&
          this.$route.query.status != null &&
          this.$route.query.status == ""
        ) {
          this.activeClass = this.$route.query.status;
          this.page.currentPage = 1;
          if (this.$route.query.status == 0) {
            params = {
              waringType: this.$route.query.waringType,
              beginTime: this.dateTime.day.beginTime,
              endTime: this.dateTime.day.endTime,
            };
          } else if (this.$route.query.status == 1) {
            params = {
              waringType: this.$route.query.waringType,
              beginTime: this.dateTime.week.beginTime,
              endTime: this.dateTime.week.endTime,
            };
          } else if (this.$route.query.status == 2) {
            params = {
              waringType: this.$route.query.waringType,
              beginTime: this.dateTime.month.beginTime,
              endTime: this.dateTime.month.endTime,
            };
          }
        } else {
          this.activeClass = 0;
          this.page.currentPage = 1;
          params = {
            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,
          };
        }
      }
      if (releaseTimeRange) {
@@ -818,13 +893,13 @@
          ...this.query,
        };
      }
      this.loading = true;
      getList(page.currentPage, page.pageSize, values).then((res) => {
        const data = res.data.data;
        console.log(data.records);
        data.records.forEach(item => {
          item.waringType == "紧急求救" ? item.waringType = "一键求助" : '';
        })
        data.records.forEach((item) => {
          item.waringType == "紧急求救" ? (item.waringType = "一键求助") : "";
        });
        this.page.total = data.total;
        data.records.sort((a, b) => {
@@ -832,7 +907,7 @@
        });
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
@@ -889,6 +964,20 @@
          : currentData.getSeconds();
      return {
        day: {
          beginTime: currentY + "-" + currentM + "-" + currentD + " 00:00:00",
          endTime:
            currentY +
            "-" +
            currentM +
            "-" +
            currentD +
            " " +
            currenH +
            ":" +
            currenM +
            ":00",
        },
        week: {
          beginTime: mondayY + "-" + mondayM + "-" + mondayD + " 00:00:00",
          endTime:
@@ -931,6 +1020,16 @@
          currenS,
      };
    },
    getBRdata(e) {
      this.activeClass = e;
      var params = {
        beginTime: this.dateTime.day.beginTime,
        endTime: this.dateTime.day.endTime,
      };
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
    },
    getBZdata(e) {
      this.activeClass = e;
      var params = {
@@ -959,13 +1058,17 @@
      this.onLoad(this.page, params);
    },
    rowStyle({ row, column, rowIndex }) {
      if (row.jtype == "1") {
      if (row.jtype == "0") {
        return {
          color: "#ff2727",
        };
      } else if (row.jtype == "1") {
        return {
          color: "#15a2fe",
        };
      } else {
        return {
          color: "#ff2727",
          color: "#000000",
        };
      }
    },
@@ -1024,15 +1127,29 @@
              jtype: jtype,
              rid: row.alarmId,
              bz: row.bz,
              snumber: row.alarmPeople,
              sname: row.alarmId,
              snumber: row.alarmId,
              sname: row.alarmPeople,
              zc: t,
              zctime: that.getDate().current,
            },
          }
        )
        .then(function () {
          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) {
@@ -1119,58 +1236,56 @@
        .then((res) => {
          newAxios
            .get(
              `https://web.byisf.com:18000/GetPlayUrl?deviceCode=001241945990&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("video_conversation");
                var dom = document.getElementById("real_video_conversation");
                // if (dom.volume) dom.volume = 1.0;
                that.hls = new Hls();
                this.hls = new Hls();
                var m3u8Url = decodeURIComponent(that.videoSource);
                var m3u8Url = decodeURIComponent(this.videoSource);
                that.hls.loadSource(m3u8Url);
                this.hls.loadSource(m3u8Url);
                that.hls.attachMedia(dom);
                this.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;
                    }
                  }
                });
              }
            });
          //   newAxios
          //     .post(
          //       "/api_control",
          //       {},
          //       {
          //         params: {
          //           param: JSON.stringify({
          //             PktType: "RemotePlayback",
          //             accessToken: res.data.data.accessToken,
          //             deviceCode: "001231409472",
          //             startTime: "20210130150000",
          //             endTime: "20210130160000",
          //             chl: data.serialNumber
          //           })
          //         }
          //       }
          //     )
          //     .then(result => {
          //       this.videoConversationReal = true;
          //       this.videoSource = result.data.data.m3u8;
          //     });
        });
    },
    closeRealVideoBox() {
      var dom = document.getElementById("video_conversation");
      var dom = document.getElementById("real_video_conversation");
      if (dom.getAttribute("src") != "") {
        dom.pause();
@@ -1180,20 +1295,44 @@
        this.hls.destroy();
      }
    },
    // 历史视频打开关闭事件
    openOldVideoBox() {
      var dom = document.getElementById("old_video");
      var dom = document.getElementById("real_old_video");
      dom.currentTime = 0;
      dom.play();
    },
    closeOldVideoBox() {
      var dom = document.getElementById("old_video");
      var dom = document.getElementById("real_old_video");
      dom.pause();
    },
    aKeyToCall(e, form) {
    aKeyToCall() {
      this.isActive = true;
      var that = this;
      if (this.recorder == null) {
        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
        });
      }
      // 一键呼叫相关函数
      that.recorder.start().then(
        () => {
          // 开始录音
        },
        (error) => {
          // 出错了
          console.log(`${error.name} : ${error.message}`);
        }
      );
    },
    // 序列号后期待修改
    aKeyStopCall() {
      this.isActive = false;
      var newCallAxios = axios.create({
        baseURL: "https://web.byisf.com:18000",
        withCredentials: false,
@@ -1203,121 +1342,43 @@
      });
      var that = this;
      Recorder.getPermission().then(() => {
        // 一键呼叫相关函数
        setInterval(() => {
          that.recorder.start().then(
            () => {
              // 开始录音
              setTimeout(() => {
                newCallAxios
                  .post(
                    `/api_control`,
                    {},
                    {
                      params: {
                        param: { PktType: "GetAccessToken" },
                      },
                    }
                  )
                  .then((result) => {
                    var formData = new FormData();
                    var blob = that.recorder.getPCMBlob(); //获取pcm格式音频数据
                    //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
                    var newbolb = new Blob([blob], { type: "audio/pcm" });
                    var fileOfBlob = new File(
                      [newbolb],
                      new Date().getTime() + ".pcm"
                    );
                    formData.append("file", fileOfBlob);
                    // var dom = document.getElementById("real_audio");
                    // dom.setAttribute("src", URL.createObjectURL(blob));
                    // this.recorder.play();
                    newCallAxios
                      .post(`/api_control`, blob, {
                        params: {
                          param: {
                            PktType: "Talk",
                            accessToken: result.data.data.accessToken,
                            // deviceCode: form.channelNumber,
                            deviceCode: "001241945990",
                          },
                        },
                      })
                      .then((result) => {});
                  });
              }, 5000);
      newCallAxios
        .post(
          `/api_control`,
          {},
          {
            params: {
              param: { PktType: "GetAccessToken" },
            },
            (error) => {
              // 出错了
              console.log(`${error.name} : ${error.message}`);
            }
          );
        }, 6000);
      });
    },
          }
        )
        .then((result) => {
          var formData = new FormData();
          // that.recorder.downloadWAV("新文件");
    aKeyToCall111(e, form) {
      var newCallAxios = axios.create({
        baseURL: "https://web.byisf.com:18000",
        withCredentials: false,
        headers: {
          "Content-Type": "application/json;",
        },
      });
      setInterval(() => {
        Recorder.getPermission().then(() => {
          this.recorder.start().then(() => {
            // 开始录音
            newCallAxios
              .post(
                `/api_control`,
                {},
                {
                  params: {
                    param: { PktType: "GetAccessToken" },
                  },
                }
              )
              .then((result) => {
                var formData = new FormData();
                var blob = this.recorder.getPCMBlob(); //获取pcm格式音频数据
                //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
                var newbolb = new Blob([blob], { type: "audio/pcm" });
                var fileOfBlob = new File(
                  [newbolb],
                  new Date().getTime() + ".pcm"
                );
                formData.append("file", fileOfBlob);
                // var dom = document.getElementById("real_audio");
                // dom.setAttribute("src", URL.createObjectURL(blob));
                // this.recorder.play();
                newCallAxios
                  .post(`/api_control`, blob, {
                    params: {
                      param: {
                        PktType: "Talk",
                        accessToken: result.data.data.accessToken,
                        // deviceCode: form.channelNumber,
                        deviceCode: "001241945990",
                      },
                    },
                  })
                  .then((result) => {});
          var blob = that.recorder.getPCMBlob(); //获取pcm格式音频数据
          //此处获取到blob对象后需要设置fileName满足当前项目上传需求,其它项目可直接传把blob作为file塞入formData
          var newbolb = new Blob([blob], { type: "audio/pcm" });
          var fileOfBlob = new File([newbolb], new Date().getTime() + ".pcm");
          formData.append("file", fileOfBlob);
          newCallAxios
            .post(`/api_control`, blob, {
              params: {
                param: {
                  PktType: "Talk",
                  accessToken: result.data.data.accessToken,
                  deviceCode: this.form.serialNumber,
                },
              },
            })
            .then(() => {
              that.recorder.destroy().then(function () {
                that.recorder = null;
              });
          });
            });
        });
        // 一键呼叫相关函数
      }, 200000);
    },
    peopleOrPhone(e) {
      this.peopleList.forEach((item) => {
        if (item.label == e) {
@@ -1328,6 +1389,10 @@
    PoliceTracking(row) {
      //警情追踪
      this.$router.push({ path: "/policeTracking/track", query: row });
    },
    realOpenVideoDialog() {
      Recorder.getPermission().then(() => {});
      this.videoConversationReal = true;
    },
  },
};
@@ -1435,7 +1500,7 @@
}
.el-button.active {
  background: #ff0000;
  background: #ff0000 !important;
}
.el-button.btn-color {
@@ -1443,4 +1508,8 @@
  background-color: rgb(64, 158, 255);
  border-color: rgb(64, 158, 255);
}
.tabFontSize {
  font-size: 15px;
}
</style>