detail.vue 5.26 KB
<template>
    <el-dialog
      class="manage-dialog shot-detail-dialog"
      :visible.sync="detailVisible"
      :close-on-click-modal="false"
      @close="detailDialogClose"
      :title="$t('button.historicalShot')">
        <el-row style="padding-bottom:5px">
            <el-col :span="22">
                <el-select v-model="channelValue" filterable :placeholder="$t('pholder.deviceNumber')" style="width:230px">
                    <el-option v-for="item in channelList" :key="item.id" :label="item.serialnum" :value="item.serialnum">
                    </el-option>
                </el-select>
                <el-date-picker
                    v-model="date"
                    type="date"
                    :placeholder="$t('pholder.date')"
                    :picker-options="pickerOptions"
                    style="width:160px"
                    value-format="yyyy-MM-dd">
                </el-date-picker>
            </el-col>
            <el-col :span="2">
                 <el-button type="primary" class="search-btn" style="float:right;margin-right:10px" plain size="mini" @click="getSnapshotHisory">{{$t('button.search')}}</el-button>
            </el-col>
        </el-row>
        <div class="">
            <ul class="screenshot-ul shot-ul">
                <p v-if="shotHistoryData.length == 0" style="text-align:center"><span>{{$t('echartsTitle.noData')}}</span></p>
                <li v-for="item in shotHistoryData" :key="item.id" :class="screenshotLi" :style="liWidth">
                    <div class="label-box">
                        <!-- <p>{{ $t('table.deviceNum') + ': ' + item.serialnum }}</p>
                        <p>{{ $t('table.monitorSiteName') + ': ' +  item.gate.name }}</p>
                        <p>{{ $t('table.localIP') + ': ' +  item.device.localIp }}</p> -->
                        <p>{{ $t('table.time') + ': ' +  item.counttime}}</p>
                    </div>
                    <div v-lazy-container="{ selector: 'img' }">
                        <img class="screenshot-img"  :data-src="dealImg(item.snapshot)" :data-error="defaultImage"> 
                    </div>
                    <!-- <img class="screenshot-img" v-lazy="dealImg(item.snapshot)" :onerror="defaultImage"><img> -->
                </li>
            </ul>
        </div>
    <div slot="footer" class="dialog-footer">
        <el-button @click="detailDialogClose" class="dialog-btn">{{$t('button.closed')}}</el-button>
    </div>
    </el-dialog>
</template>

<script>
import defaultImg from "@/assets/img/manage/screenshot.png";
export default {
    data() {
        return {
             pickerOptions: {
                disabledDate(time) {
                    return time.getTime() > Date.now();
                }
            },
            defaultImage: require('../../../assets/img/manage/screenshot.png'),
            detailVisible: false,
            screenshotLi: 'screenshot-li screenshot3n',
            channelList: [],
            channelValue: '',
            shotHistoryData: [],
            date: dateUnit.dateFormat(new Date(),'yyyy-MM-dd')
        }
    },
    methods: {
        dialogInit(data,list) {
            this.detailVisible = true;
            this.channelList = list;
            this.channelValue = data.serialnum;
            this.getSnapshotHisory();
        },
        getSnapshotHisory(serialnum,date) {
			let params = {
				channelSerialnum: this.channelValue,
				countdate: this.date,
			}
			this.$api.management.channelSnapshots(params)
			.then(res => {
                let result = res.data.data;
                this.shotHistoryData = result;
				this.liWidth = this.computedW()
			})
			.catch(err => {})
        },
        computedW() {
            let imgLen = this.shotHistoryData.length;
            if(imgLen == 1) {
                return 'width: 100%';
            } else if(imgLen > 1 && imgLen < 5) {
				this.screenshotLi = 'screenshot-li screenshot2n'
                return 'width: 48.5%;';
            } else {
				this.screenshotLi = 'screenshot-li screenshot3n'
                return 'width: 32.5%;';
            }
        },
        dealImg(snapshot){
			if(snapshot){
                var zoomImgUrl = this.getWindowHost() + '/' + snapshot;
				return zoomImgUrl; 
			}else{
                return defaultImage;
            }
		},
		getWindowHost() {
            return window._vionConfig.picUrl;
            if(window._vionConfig.apiUrl.indexOf('http') != -1){
				var apiUrl = window._vionConfig.apiUrl.match(/^http(s)?:\/\/\w+(\.\w+)*/)
                return apiUrl[0]
            }else{
				return ""
			}
		},
        detailDialogClose() {
            this.shotHistoryData = [];
            this.detailVisible = false;
		},
    },
}
</script>

<style scoped>
    .shot-ul {
        max-height: 720px;
    }
    .label-box {
        position: absolute;
        left: 5px;
        bottom: 5%;
        color: #f00;
    }
    @media (max-width: 1680px){
        .shot-ul {
            max-height: 700px;
        }
    }
    @media (max-width: 1440px){
        .shot-ul {
            max-height: 565px;
        }
    }
    @media (max-width: 1366px){
        .shot-ul {
            max-height: 440px;
        }
        .label-box {
            font-size: 12px	
        }
    }
    @media (max-width: 1280px){
        .shot-ul {
            max-height: 390px;
        }
    }
</style>