showallDialog.vue 3.62 KB
<template>
    <el-dialog
      :visible.sync="isShow"
      class="manage-dialog xy-dialog track-dialog"
      :close-on-click-modal="false"
      :title="$t('dialog.showAllPic')"
      :before-close="closeDialog">
        <div>
            <el-scrollbar class="track-list-scrollbar" wrap-class="list-scrollbar" :native="false" style="height: 100%; height: 600px; max-height: 600px;">
                <ul class="img-container">
                    <li v-for="(item, index) in imgList" :key="index" class="catch-item">
                        <img :src="item.catchpic" class="catch-img" :onerror="defaultImg" />
                        <p>{{ item.catchtime }}</p>
                    </li>
                    <li v-if="imgList.length == 0" class="nodata-item">{{ noData }}</li>
                </ul>
            </el-scrollbar>
        </div>
    </el-dialog>
</template>

<script>
import defaultImg from '@/assets/img/behavior/default.png'
export default {
    data() {
        return {
            isShow: false,
            imgList: [],
            noData: '',
            defaultImg: 'this.src="' + defaultImg + '"',
        }
    },
    methods: {
    
        dialogInit(personUnid, param) {
            this.isShow = true;
            this.noData = 'loading...';
            this.imgList = [];
            this.$api.flowReport.captureRecord({
                mallId: param.asis_org,// param.asis_org
                // orgType: 'mall',
                personUnid: personUnid,
                countdate: param.asis_time
            })
                .then(res => {
                    let result = res.data;
                    result.data.forEach(item => {
                        const dateStr = item.counttime.replace(/^(\d{4})-(\d{2})-(\d{2}).*$/, '$1$2$3')
                        this.imgList.unshift({
                            catchtime: item.counttime,
                            catchpic: this.dealImg(item)
                        })
                    })
                    this.noData = this.imgList.length === 0 ? '已开启隐私模式,无图片' : '';
                })
                .catch(err => {
                    this.catchErrorHandle(err)
                })
        },
        dealDate(counttime, fmt = "$1$2$3") {
        return counttime.replace(/^(\d{4})-(\d{2})-(\d{2}).*/, fmt);
        },
        dealImg(item) {
            const { dealDate } = this;
            let imageUrl = "";
            if (item.bodyPic) {
                imageUrl = item.bodyPath && item.bodyPic
                ? item.bodyPath + item.bodyPic
                : `body/${dealDate(item.counttime)}/${item.channelSerialnum}/${item.bodyPic}`
            } else {
                // if (item.facePath && item.facePic) {
                imageUrl = item.facePath && item.facePic
                    ? item.facePath + item.facePic
                    : `/face/${dealDate(item.counttime)}/${item.channelSerialnum}/${item.facePic}`
            }
            return window._vionConfig.picUrl + "/picture/" + imageUrl;
        },
        closeDialog() {
            this.isShow = false;
            this.imgList = [];
        }
    }
}
</script>

<style scoped>
    .img-container:after
    .img-container:before {
        content: '';
        display: table;
    }
    
    .img-container:after {
        clear: both;
    }

    .img-container {
        /* max-height: 400px;
        overflow-x: hidden;
        overflow-y: auto; */
    }

    .catch-item {
        float: left;
        padding: 14px;
        text-align: center;
    }

    .nodata-item {
        text-align: center;
        font-size: 16px;
    }

    .catch-img {
        height: 150px;
        width: 105px;
    }
</style>