wangrong
2021-11-24 130b72d6c5734f8acaac0214b6dfe5c8bfa319c3
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
421
422
423
424
425
426
427
428
429
430
431
432
433
<template>
  <div>
    <el-row>
      <el-col
        :span="24"
        style="height: 45px; text-align: left; margin-top: 20px; display: flex"
      >
        <el-radio-group v-model="type" style="margin-right: 15px">
          <el-radio-button label="时间段"></el-radio-button>
          <el-radio-button label="单日"></el-radio-button>
          <el-radio-button label="单月"></el-radio-button>
          <el-radio-button label="年度"></el-radio-button>
        </el-radio-group>
        <span style="margin-right: 15px">
          <el-date-picker
            v-model="search.valueDay"
            :type="
              type == '时间段'
                ? 'date'
                : type == '单月'
                ? 'month'
                : type == '年度'
                ? 'year'
                : 'date'
            "
            :placeholder="
              type == '时间段'
                ? '选择日期'
                : type == '单月'
                ? '选择月份'
                : type == '年度'
                ? '选择年份'
                : '选择日期'
            "
            clearable
            style="width: 130px"
          ></el-date-picker>
        </span>
        <span v-show="type == '时间段'" style="margin-right: 15px">
          <el-time-select
            v-model="search.valueTime"
            :picker-options="{
              start: '00:00',
              step: '00:30',
              end: '23:30',
            }"
            placeholder="选择时间"
            clearable
            style="width: 130px"
          ></el-time-select>
        </span>
        <el-input
          placeholder="查询广播"
          suffix-icon="el-icon-service"
          v-model="search.search_fm"
          style="margin-right: 15px; width: 130px"
        ></el-input>
        <el-select
          v-model="determine"
          placeholder="请选择"
          @change="handleChange"
          style="margin-right: 15px"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
 
        <div style="width: 30%; display: flex">
          <span style="width: 100px; line-height: 28px">录音方式:</span>
          <el-select v-model="isUnderWayValue" placeholder="请选择录音方式">
            <el-option label="定时录制" value="0"> </el-option>
            <el-option label="监听录制" value="3"> </el-option>
            <el-option label="采样录制" value="4"> </el-option>
          </el-select>
        </div>
      </el-col>
 
      <el-col :span="24" class="Device" style="margin-top: 30px">
        <el-table
          :data="tableData"
          :height="tableH"
          v-loading="loading"
          stripe
          size="small"
          class="detailTable"
        >
          <el-table-column
            label="monitorpointId"
            prop="monitorpointId"
          ></el-table-column>
          <el-table-column
            label="monitorpointName"
            prop="monitorpointName"
          ></el-table-column>
          <el-table-column label="frequency" prop="frequency"></el-table-column>
          <el-table-column label="startTime" prop="startTime">
            <template slot-scope="scope">
              {{ dateFormatter(new Date(scope.row.startTime)) }}
            </template>
          </el-table-column>
          <el-table-column label="stopTime" prop="stopTime">
            <template slot-scope="scope">
              {{ dateFormatter(new Date(scope.row.stopTime)) }}
            </template>
          </el-table-column>
          <el-table-column
            label="recordStatus"
            prop="recordStatus"
          ></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <div>
                <el-tooltip
                  class="item"
                  effect="dark"
                  content="点击回放"
                  placement="top"
                >
                  <i class="el-icon-refresh-right" @click="rePlay(scope)"></i>
                </el-tooltip>
              </div>
            </template>
          </el-table-column>
        </el-table>
      </el-col>
 
      <el-col :span="24" style="margin-top: 5px">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNo"
          :page-sizes="[10, 20, 30, 50]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="totalCount"
        >
        </el-pagination>
      </el-col>
    </el-row>
 
    <el-dialog :visible.sync="socketPlay" width="50" @close="socketReplay">
      <video
        id="socketVidoPlay"
        ref="socketVidoPlay"
        src=""
        controls
        preload
        width="100%"
        height="300"
      ></video>
    </el-dialog>
  </div>
</template>
<script>
import { originalColor } from "@/utils/chartCustomer.js";
 
export default {
  watch: {
    isUnderWayValue: {
      handler(n, o) {
        if (this.timer) {
          clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
          this.getData();
        }, 300);
      },
      deep: true,
    },
    search: {
      handler(n, o) {
        if (this.timer) {
          clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
          this.getData();
        }, 300);
      },
      deep: true,
    },
    determine: {
      handler(n, o) {
        if (this.timer) {
          clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
          this.getData();
        }, 500);
      },
      deep: true,
    },
    type: {
      handler(n, o) {
        if (this.timer) {
          clearTimeout(this.timer);
        }
        this.timer = setTimeout(() => {
          this.getData();
        }, 500);
      },
      deep: true,
    },
  },
  data() {
    return {
      isUnderWayValue: "0",
      playVideo: null,
      socketPlay: false,
      tableH: 0,
      timer: null,
      totalCount: 100,
      pageNo: 1,
      pageSize: 10,
      tableData: [],
      tableH: null,
      otherAct: [{ item: "查看所有", id: "", type: "primary" }],
      type: "年度",
      options: [],
 
      queryParams: {
        page: 1,
        size: 10,
        VF: "",
        table: "t_fm_scan_timestamp",
      },
      determine: "",
      search: {
        valueTime: new Date().getHours() + ":00",
        valueDay: new Date(),
        search_fm: "",
      },
      loading: false,
      colors: originalColor,
      color: [
        { color: "#9D96F5", percentage: 10 },
        { color: "#FF9F7F", percentage: 20 },
        { color: "#FB7293", percentage: 30 },
        { color: "#37A2DA", percentage: 40 },
        { color: "#67E0E3", percentage: 50 },
        { color: "#9FE6B8", percentage: 60 },
        { color: "#E690D1", percentage: 80 },
        { color: "#E7BCF3", percentage: 100 },
      ],
    };
  },
  mounted() {
    this.tableH = window.innerHeight - 135;
    this.getData();
  },
  methods: {
    dateFormatter(time) {
      if (time) {
        var year = time.getFullYear();
        var month = time.getMonth() + 1;
        var date = time.getDate();
        var hour = time.getHours();
        var minute = time.getMinutes();
        var second = time.getSeconds();
        return (
          this.add0(year) +
          "-" +
          this.add0(month) +
          "-" +
          this.add0(date) +
          " " +
          this.add0(hour) +
          ":" +
          this.add0(minute) +
          ":" +
          this.add0(second)
        );
      } else {
        return 0;
      }
    },
    socketReplay() {
      if (this.playVideo) {
        this.playVideo.pause();
        this.playVideo = null;
      }
    },
    rePlay(scope) {
      this.loading = true;
      if (scope.row.stopTime) {
        let startTime = this.dateFormatter(
          new Date(new Date(scope.row.startTime).getTime())
        );
        let endTime = this.dateFormatter(
          new Date(new Date(scope.row.stopTime).getTime() + 1000 * 60 * 180)
        );
 
        let param = new URLSearchParams();
        param.append("method", "mutipleReview");
        param.append("instruct", 1);
        param.append("playType", 1);
        param.append("hls", 1);
        param.append("key", 123456);
        param.append("monitorpointId", scope.row.monitorpointId);
        param.append("frequencyValue", scope.row.frequency);
        param.append("startTime", startTime);
        param.append("endTime", endTime);
 
        this.$post(window.equipmentURL + "FRP/NetRequest.do", param).then(
          (res) => {
            if (res.success == "true") {
              this.socketPlay = true;
              this.playVideo = this.$refs.socketVidoPlay;
              if (Hls.isSupported()) {
                var hls = new Hls();
                hls.loadSource(res.url);
                hls.attachMedia(this.playVideo);
                hls.on(Hls.Events.MANIFEST_PARSED, function () {
                  this.playVideo.play();
                });
                this.loading = false;
              } else if (
                this.playVideo.canPlayType("application/vnd.apple.mpegurl")
              ) {
                this.playVideo.src = res.url;
                this.playVideo.addEventListener("loadedmetadata", function () {
                  this.playVideo.play();
                });
                this.loading = false;
              }
            } else {
              this.$message.error(res.msg);
              this.loading = false;
            }
          }
        );
      } else {
        this.$message.warning("尚未有回放");
        this.loading = false;
      }
    },
    handleSizeChange(size) {
      this.pageSize = size;
      this.getData();
    },
    handleCurrentChange(page) {
      this.pageNo = page;
      this.getData();
    },
    getOptions() {
      this.$getJSON(
        window.backstageURL +
          "dataservice/getNoTokenData?bid=getChannelSettingB"
      ).then((res) => {
        this.options = [];
        let tmpArr = res.data.data[0];
        tmpArr.forEach((item) => {
          let oneOption = {
            value: item.monitorpointId,
            label: item.monitorpointName,
          };
          this.options.push(oneOption);
        });
      });
    },
    handleChange(value) {
      this.queryParams.determine = value;
    },
    getData() {
      this.loading = true;
      let typeValue = this.formatType(this.type);
 
      let dateValue =
        this.search.valueDay == ""
          ? "2021"
          : this.formatDate(this.search.valueDay);
 
      let tmeValue =
        this.type == "时间段" ? this.search.valueTime.split(":")[0] : "";
 
      this.$getJSON(window.backstageURL + "dataservice/getNoTokenData", {
        bid: "getRecordHistory",
        isUnderWay: this.isUnderWayValue,
        querymode: typeValue,
        timevalue1: dateValue,
        timevalue2: tmeValue,
        monitorpointid: this.determine,
        frequency: this.search.search_fm,
        pageno: this.pageNo,
        pagesize: this.pageSize,
      }).then((res) => {
        this.loading = false;
        this.tableData = res.data.data[0];
        this.totalCount = Number(res.data.data[1][0].counter);
      });
    },
 
    formatType(type) {
      if (type == "时间段") {
        return "time";
      } else if (type == "单日") {
        return "day";
      } else if (type == "单月") {
        return "month";
      } else if (type == "年度") {
        return "year";
      }
    },
 
    formatDate(date) {
      if (date) {
        let year = date.getFullYear();
        let month = date.getMonth() + 1;
        let day = date.getDate();
 
        if (this.type == "年度") {
          return year;
        } else if (this.type == "单月") {
          return year + "-" + this.add0(month);
        } else if (this.type == "单日" || this.type == "时间段") {
          return year + "-" + this.add0(month) + "-" + this.add0(day);
        } else {
          return "";
        }
      }
    },
 
    add0(val) {
      return val < 10 ? "0" + val : val;
    },
  },
};
</script>
<style lang="scss" scope>
</style>