|
|
@@ -0,0 +1,333 @@
|
|
|
+<template>
|
|
|
+ <div class="l-flex l-flex__fill c-camera">
|
|
|
+ <div class="l-flex--col c-camera__left">
|
|
|
+ <!-- <div class="c-camera__padding">
|
|
|
+ <search-input
|
|
|
+ v-model.trim="searchName"
|
|
|
+ class="c-camera__input"
|
|
|
+ placeholder="搜索设备"
|
|
|
+ @change="onChange"
|
|
|
+ />
|
|
|
+ </div> -->
|
|
|
+ <div
|
|
|
+ v-if="cameras.length===0"
|
|
|
+ class="u-color--info l-flex--col center"
|
|
|
+ >暂无数据</div>
|
|
|
+ <div v-else>
|
|
|
+ <div
|
|
|
+ v-for="(camera, index) in cameras"
|
|
|
+ :key="camera.id"
|
|
|
+ class="l-flex c-camera__item"
|
|
|
+ :class="{'c-camera__active': index === active }"
|
|
|
+ @click="() => onChangeCamera(camera, index)"
|
|
|
+ >
|
|
|
+ <img :src="index === active ? require('@/assets/icon_camera_white.svg') : require('@/assets/icon_camera.svg')">
|
|
|
+ <div class="l-flex__fill">
|
|
|
+ <div class="c-camera__name">{{ camera.identifier }}</div>
|
|
|
+ <div
|
|
|
+ class="c-camera__bound"
|
|
|
+ :style="{color: index === active ? '#fff':'#4293FE'}"
|
|
|
+ ><div
|
|
|
+ class="c-camera__dian"
|
|
|
+ :style="{backgroundColor: index === active ? '#fff':'#4293FE'}"
|
|
|
+ />{{ camera.bound ? '已使用' : '未使用' }}</div>
|
|
|
+ <!-- <div :style="{color: index === 2 ? '#E51414':'#8E929C'}">已下载{{ camera.totalCount }}个录像</div> -->
|
|
|
+ </div>
|
|
|
+ <div
|
|
|
+ class="c-camera__tip"
|
|
|
+ :style="{backgroundColor: camera.onlineStatus===1?'#04A681':'#E51414'}"
|
|
|
+ >{{ camera.onlineStatus===1?'在线':'离线' }}</div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="l-flex l-flex__auto c-camera__right">
|
|
|
+ <grid-table
|
|
|
+ ref="table"
|
|
|
+ :schema="recordSchema"
|
|
|
+ size="large"
|
|
|
+ >
|
|
|
+ <grid-table-item v-slot="item">
|
|
|
+ <record-player
|
|
|
+ :camera="item"
|
|
|
+ @delRecord="onDeleteRecord"
|
|
|
+ @onResumeDownloadRecord="onResumeDownloadRecord"
|
|
|
+ />
|
|
|
+ </grid-table-item>
|
|
|
+ </grid-table>
|
|
|
+ </div>
|
|
|
+ <table-dialog
|
|
|
+ ref="sdRecordTableDialog"
|
|
|
+ title="SD卡数据"
|
|
|
+ :schema="sdRecordSchema"
|
|
|
+ append-to-body
|
|
|
+ >
|
|
|
+ <template #header>
|
|
|
+ <div class="l-flex--row u-color--info">
|
|
|
+ 展示的为结束时间往前 <span class="u-color--blue u-font-size--lg">6</span> 小时内的录像
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </table-dialog>
|
|
|
+ <PlayaxisDialog
|
|
|
+ ref="PlayaxisDialog"
|
|
|
+ :camera="cameraObj"
|
|
|
+ :identifier="identifier"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { AssetType } from '@/constant'
|
|
|
+import { parseTime } from '@/utils'
|
|
|
+import {
|
|
|
+ getRecords,
|
|
|
+ getSDRecords,
|
|
|
+ downloadRecord,
|
|
|
+ stopDownloadRecord,
|
|
|
+ resumeDownloadRecord
|
|
|
+} from '@/api/external'
|
|
|
+import PlayaxisDialog from './components/PlayaxisDialog'
|
|
|
+import RecordPlayer from './components/index'
|
|
|
+
|
|
|
+export default {
|
|
|
+ components: {
|
|
|
+ RecordPlayer,
|
|
|
+ PlayaxisDialog
|
|
|
+ },
|
|
|
+ props: {
|
|
|
+ cameras: {
|
|
|
+ type: Array,
|
|
|
+ default: null
|
|
|
+ }
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ identifier: '',
|
|
|
+ searchName: '',
|
|
|
+ active: 0,
|
|
|
+ recordSchema: {
|
|
|
+ pageSize: 6,
|
|
|
+ list: this.getRecords,
|
|
|
+ buttons: [
|
|
|
+ { type: 'add', label: '新增录像', on: this.onViewSD },
|
|
|
+ { type: '', label: '实时回放', on: this.onPlayBack }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ checked: false,
|
|
|
+ // SD卡数据
|
|
|
+ sdRecordSchema: {
|
|
|
+ nonPagination: true,
|
|
|
+ list: this.getSDRecords,
|
|
|
+ filters: [
|
|
|
+ { key: 'time', type: 'datepicker', options: {
|
|
|
+ type: 'datetime',
|
|
|
+ placeholder: '结束时间',
|
|
|
+ 'picker-options': {
|
|
|
+ disabledDate: this.isDisableDate
|
|
|
+ }
|
|
|
+ } }
|
|
|
+ ],
|
|
|
+ cols: [
|
|
|
+ { type: 'refresh' },
|
|
|
+ { prop: 'recordTypeName', label: '名称' },
|
|
|
+ { prop: 'startTime', label: '开始时间' },
|
|
|
+ { prop: 'endTime', label: '结束时间' },
|
|
|
+ { type: 'invoke', render: [
|
|
|
+ { label: '下载', on: this.onStartDownload }
|
|
|
+ ] }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ cameraObj: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ pickerOptions () {
|
|
|
+ return {
|
|
|
+ disabledDate: this.isDisableDate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ cameras () {
|
|
|
+ this.cameraObj = this.cameras[this.active]
|
|
|
+ this.cameraId = this.cameras[this.active].id
|
|
|
+ this.identifier = this.cameras[this.active].identifier
|
|
|
+ this.$refs.table?.pageTo(1)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.$timer = -1
|
|
|
+ },
|
|
|
+ beforeDestroy () {
|
|
|
+ clearTimeout(this.$timer)
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ onPlayBack () {
|
|
|
+ if (this.cameras[this.active].onlineStatus === 1) {
|
|
|
+ this.$refs.PlayaxisDialog.show()
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '摄像头离线'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onChangeCamera (camera, index) {
|
|
|
+ this.cameraId = camera.id
|
|
|
+ this.identifier = camera.identifier
|
|
|
+ this.active = index
|
|
|
+ this.$refs.table?.pageTo(1)
|
|
|
+ },
|
|
|
+ onPlayRecords ({ identifier }) {
|
|
|
+ this.identifier = identifier
|
|
|
+ this.$refs.PlayaxisDialog.show()
|
|
|
+ },
|
|
|
+ isDisableDate (date) {
|
|
|
+ return date > Date.now()
|
|
|
+ },
|
|
|
+ onView (camera) {
|
|
|
+ this.$refs.cameraDialog.show(camera)
|
|
|
+ },
|
|
|
+ onViewRecords ({ identifier }) {
|
|
|
+ this.identifier = identifier
|
|
|
+ this.$refs.recordTableDialog.show()
|
|
|
+ },
|
|
|
+ // 获取录像
|
|
|
+ getRecords (params) {
|
|
|
+ clearTimeout(this.$timer)
|
|
|
+ if (params.pageNum === 1) {
|
|
|
+ this.$timer = setTimeout(() => {
|
|
|
+ this.$refs.table?.refreshCurrentPageOnBackground()
|
|
|
+ }, 5000)
|
|
|
+ }
|
|
|
+ return getRecords({
|
|
|
+ cameraId: this.cameraId,
|
|
|
+ ...params
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onDeleteRecord () {
|
|
|
+ this.$refs.table?.pageTo(1)
|
|
|
+ },
|
|
|
+ onResumeDownloadRecord (id) {
|
|
|
+ resumeDownloadRecord(id).then(() => {
|
|
|
+ this.$refs.table?.pageTo(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onStopDownloadRecord () {
|
|
|
+ stopDownloadRecord(this.identifier).then(() => {
|
|
|
+ this.$refs.recordTableDialog.getTable().pageTo(1)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onPlayRecord ({ url }) {
|
|
|
+ this.$refs.previewDialog.show({ type: AssetType.VIDEO, url })
|
|
|
+ },
|
|
|
+ onViewSD () {
|
|
|
+ if (this.cameras[this.active].onlineStatus === 1) {
|
|
|
+ this.$refs.sdRecordTableDialog.show()
|
|
|
+ } else {
|
|
|
+ this.$message({
|
|
|
+ type: 'warning',
|
|
|
+ message: '摄像头离线'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ 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.table?.pageTo(1)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+<style lang="scss" scoped>
|
|
|
+.c-camera{
|
|
|
+ border-top: 1px solid #EDF0F6;
|
|
|
+ padding: 15px 0;
|
|
|
+ &__left{
|
|
|
+ width: 224px;
|
|
|
+ border-right: 1px solid #EDF0F6;
|
|
|
+ }
|
|
|
+ &__padding{
|
|
|
+ padding: 16px;
|
|
|
+ }
|
|
|
+ &__input{
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ &__tip{
|
|
|
+ width: 32px;
|
|
|
+ height: 16px;
|
|
|
+ text-align: center;
|
|
|
+ border-radius: 2px;
|
|
|
+ color: #fff;
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ &__bound{
|
|
|
+ color: #4293FE;
|
|
|
+ margin: 5px 0;
|
|
|
+ }
|
|
|
+ &__dian{
|
|
|
+ width: 4px;
|
|
|
+ height: 4px;
|
|
|
+ border-radius: 4px;
|
|
|
+ display: inline-block;
|
|
|
+ position: relative;
|
|
|
+ top: -2px;
|
|
|
+ margin-right: 7px;
|
|
|
+ }
|
|
|
+ &__item{
|
|
|
+ padding: 16px;
|
|
|
+ cursor: pointer;
|
|
|
+ border-bottom: 1px solid #EDF0F6;
|
|
|
+ font-size: 12px;
|
|
|
+ img{
|
|
|
+ width: 23px;
|
|
|
+ height: 22px;
|
|
|
+ margin-right: 10px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ &__name{
|
|
|
+ font-size: 16px;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ }
|
|
|
+ &__active{
|
|
|
+ background-color: #1C5CB0;
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
+ &__right{
|
|
|
+ padding-left: 17px;
|
|
|
+ position: relative;
|
|
|
+ }
|
|
|
+ &__button {
|
|
|
+ position: absolute;
|
|
|
+ left: 128px;
|
|
|
+ }
|
|
|
+ &__checkbox {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|
|
|
+<style>
|
|
|
+.c-camera .el-checkbox__input.is-checked+.el-checkbox__label{
|
|
|
+ color: #1c5cb0;
|
|
|
+}
|
|
|
+.c-camera .el-checkbox__input.is-checked .el-checkbox__inner{
|
|
|
+ background-color: #1c5cb0;
|
|
|
+ border-color: #1c5cb0;
|
|
|
+}
|
|
|
+</style>
|