|
|
@@ -0,0 +1,195 @@
|
|
|
+<template>
|
|
|
+ <wrapper
|
|
|
+ fill
|
|
|
+ margin
|
|
|
+ padding
|
|
|
+ background
|
|
|
+ >
|
|
|
+ <schema-table
|
|
|
+ ref="table"
|
|
|
+ :schema="schema"
|
|
|
+ highlight-current-row
|
|
|
+ />
|
|
|
+ <table-dialog
|
|
|
+ ref="recordTableDialog"
|
|
|
+ title="录像"
|
|
|
+ :schema="recordSchema"
|
|
|
+ />
|
|
|
+ <table-dialog
|
|
|
+ ref="sdRecordTableDialog"
|
|
|
+ title="SD卡数据"
|
|
|
+ :schema="sdRecordSchema"
|
|
|
+ >
|
|
|
+ <template #header>
|
|
|
+ <div class="u-color--error">
|
|
|
+ 展示的为结束时间往前一小时内的录像,默认为当前时间
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </table-dialog>
|
|
|
+ <preview-dialog ref="previewDialog" />
|
|
|
+ <camera-dialog ref="cameraDialog" />
|
|
|
+ </wrapper>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import {
|
|
|
+ Camera,
|
|
|
+ AssetType
|
|
|
+} from '@/constant'
|
|
|
+import { parseTime } from '@/utils'
|
|
|
+import {
|
|
|
+ getCameras,
|
|
|
+ getRecords,
|
|
|
+ getSDRecords,
|
|
|
+ downloadRecord,
|
|
|
+ stopDownloadRecord,
|
|
|
+ deleteRecord,
|
|
|
+ resumeDownloadRecord
|
|
|
+} from '@/api/external'
|
|
|
+
|
|
|
+export default {
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ schema: {
|
|
|
+ list: this.getCameras,
|
|
|
+ filters: [
|
|
|
+ { key: 'boundFlag', type: 'select', placeholder: '使用情况', options: [
|
|
|
+ { value: 1, label: '已使用' },
|
|
|
+ { value: 0, label: '未使用' }
|
|
|
+ ] },
|
|
|
+ { key: 'identifier', type: 'search', placeholder: '唯一标识' },
|
|
|
+ { key: 'remark', type: 'search', placeholder: '备注' }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { prop: 'identifier', label: '唯一标识' },
|
|
|
+ { prop: 'remark', label: '备注' },
|
|
|
+ { type: 'tag', render: ({ onlineStatus }) => onlineStatus === 1
|
|
|
+ ? { type: 'success', label: '在线' }
|
|
|
+ : { type: 'danger', label: '离线' } },
|
|
|
+ { label: '使用情况', type: 'tag', render: ({ bound }) => bound
|
|
|
+ ? { type: 'success', label: '已使用' }
|
|
|
+ : { type: 'primary', label: '未使用' } },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '录像信息', on: this.onViewRecords },
|
|
|
+ { label: '摄像头实时查看', allow: ({ onlineStatus }) => onlineStatus, on: this.onView }
|
|
|
+ ], width: 240 }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ // 录像
|
|
|
+ recordSchema: {
|
|
|
+ list: this.getRecords,
|
|
|
+ buttons: [
|
|
|
+ { type: 'add', label: '新增录像', on: this.onViewSD }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { label: '时间', render: ({ startTime, endTime }) => `${startTime} - ${endTime}` },
|
|
|
+ { type: 'tag', prop: 'status', render: ({ status }) => status === 0
|
|
|
+ ? { type: 'primary', label: '下载中' }
|
|
|
+ : status === 1
|
|
|
+ ? { type: 'success', label: '完成' }
|
|
|
+ : status === 2
|
|
|
+ ? { type: 'danger', label: '失败' }
|
|
|
+ : { type: 'warning', label: '停止' } },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '停止', render: ({ status }) => status === 0, on: this.onStopDownloadRecord },
|
|
|
+ { label: '恢复', render: ({ status }) => status === 2 || status === 3, on: this.onResumeDownloadRecord },
|
|
|
+ { label: '播放', allow: ({ url }) => url, on: this.onPlayRecord },
|
|
|
+ { label: '删除', allow: ({ status }) => status !== 0, on: this.onDeleteRecord }
|
|
|
+ ], width: 200 }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ // SD卡数据
|
|
|
+ sdRecordSchema: {
|
|
|
+ nonPagination: true,
|
|
|
+ list: this.getSDRecords,
|
|
|
+ filters: [
|
|
|
+ { key: 'time', type: 'datetime', placeholder: '结束时间' }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { prop: 'recordTypeName', label: '名称' },
|
|
|
+ { prop: 'startTime', label: '开始时间' },
|
|
|
+ { prop: 'endTime', label: '结束时间' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '下载', on: this.onStartDownload }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ pickerOptions () {
|
|
|
+ return {
|
|
|
+ disabledDate: this.isDisableDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ isDisableDate (date) {
|
|
|
+ return date > Date.now()
|
|
|
+ },
|
|
|
+ getCameras (params) {
|
|
|
+ return getCameras({
|
|
|
+ cameraType: Camera.LED,
|
|
|
+ ...params
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onView (camera) {
|
|
|
+ this.$refs.cameraDialog.show(camera)
|
|
|
+ },
|
|
|
+ onViewRecords ({ identifier }) {
|
|
|
+ this.identifier = identifier
|
|
|
+ this.$refs.recordTableDialog.show()
|
|
|
+ },
|
|
|
+ getRecords (params) {
|
|
|
+ return getRecords({
|
|
|
+ identifier: this.identifier,
|
|
|
+ ...params
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onDeleteRecord ({ id }) {
|
|
|
+ deleteRecord(id).then(() => {
|
|
|
+ this.$refs.recordTableDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onResumeDownloadRecord ({ id }) {
|
|
|
+ resumeDownloadRecord(id).then(() => {
|
|
|
+ this.$refs.recordTableDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onStopDownloadRecord () {
|
|
|
+ stopDownloadRecord(this.identifier).then(() => {
|
|
|
+ this.$refs.recordTableDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onPlayRecord ({ url }) {
|
|
|
+ this.$refs.previewDialog.show({ type: AssetType.VIDEO, url })
|
|
|
+ },
|
|
|
+ onViewSD () {
|
|
|
+ this.$refs.sdRecordTableDialog.show()
|
|
|
+ },
|
|
|
+ getSDRecords ({ time }) {
|
|
|
+ time = time ? new Date(time) : new Date()
|
|
|
+ const startTime = new Date(time.getTime())
|
|
|
+ startTime.setHours(startTime.getHours() - 1)
|
|
|
+ return getSDRecords({
|
|
|
+ identifier: this.identifier,
|
|
|
+ startTime: parseTime(startTime, '{y}-{m}-{d} {h}:{i}:{s}'),
|
|
|
+ endTime: parseTime(time, '{y}-{m}-{d} {h}:{i}:{s}')
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onStartDownload ({ startTime, endTime }) {
|
|
|
+ downloadRecord({
|
|
|
+ identifier: this.identifier,
|
|
|
+ startTime,
|
|
|
+ endTime
|
|
|
+ }).then(() => {
|
|
|
+ this.$refs.sdRecordTableDialog.hide()
|
|
|
+ this.$refs.recordTableDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|