<template>
    <div class="container" style="padding-top: 13vw">
        <TopNav :navTitle="title" />
        <van-list v-model:loading="loading" :finished='finished' finished-text='沒有更多了' @load="onLoad">
            <van-cell v-for="(item,index) in list" :key="index+'rygj'">
                <div v-if="title==='人员轨迹'" class="item_main item_box">
                    <div style="color:#027db4">{{item.pcsj}}</div>
                    <div>姓名：{{item.xm}} <span style="color:f00">{{item.bqxxsj}}</span></div>
                    <div>性别：{{item.xbdm==1?'男':'女'}}</div>
                    <div>身份证号：{{item.sfzh}}</div>
                    <div>所属单位：{{item.ssbm}}</div>
                    <div>所乘车辆：暂无</div>
                    <div @click="preview(item.tpList)">照片数量：{{item.tpList.length}}</div>
                    <div>盘查特征：{{item.tzList==null?'暂无':item.tzList.join(',')}}</div>
                    <div>盘查物品：
                        <span v-for="(e,index) in item.wpVoList"
                            :key="index+'pctp'">{{setDict(e.wplx,D_BZ_WPLX)+'*'+e.wpsl}}</span>
                        <span v-show="item.wpVoList.length===0">暂无</span>

                    </div>
                    <div>处理结果：
                        <span v-show="item.pcclJg==1">放行</span>
                        <span v-show="item.pcclJg==2">移交</span>
                        <span v-show="item.pcclJg==9">盘查</span>
                    </div>
                </div>
                <div v-else class="item_main item_box">
                    <div style="color:#027db4">{{item.pcsj}}</div>
                    <div>车牌号：{{item.hphm}}</div>
                    <div>车主姓名：{{item.jdcsyr}}</div>
                    <div>身份证号：{{item.jdcsyrsfzh}}</div>
                    <div>号牌种类：{{setDict(item.hpzl,D_BZ_HPZL)}}</div>
                    <div>盘查结果：{{item.pcclJg==1?'放行':'移交'}}</div>
                    <div>盘查方式：{{item.pcfs=='01'?'车牌设备自动':'民警手动'}}</div>
                    <div>盘查物品：
                        <span v-for="(e,index) in item.wpVoList"
                            :key="index+'pctp'">{{setDict(e.wplx,D_BZ_WPLX)+'*'+e.wpsl}}</span>
                        <span v-show="item.wpVoList.length===0">暂无</span>
                    </div>
                    <div>处理结果：
                        <span v-show="item.pcclJg==1">放行</span>
                        <span v-show="item.pcclJg==2">移交</span>
                        <span v-show="item.pcclJg==9">盘查</span>
                    </div>
                </div>
            </van-cell>
        </van-list>
    </div>
</template>

<script setup>
import { ref,onMounted } from 'vue'
import { useRouter } from "vue-router";
import TopNav from "../../../components/topNav.vue";
import {getDictList,setDict} from '../../../utils/dict'
import { getRypcList,getClpcList } from '../../../api/common'
import { ImagePreview } from 'vant'
const { D_BZ_WPLX,D_BZ_HPZL } = getDictList('D_BZ_WPLX','D_BZ_HPZL')
const router = useRouter();
const loading = ref(false)
const finished = ref(false)
const total=ref(0)
const title = router.currentRoute.value.query.sfzh?'人员轨迹':"车辆轨迹"
const url = '/mosty-api/mosty-base/minio/image/download/'
const queryList = ref({
    pageCurrent:1,
    pageSize:10,
    sfzh:router.currentRoute.value.query.sfzh,
    hphm:router.currentRoute.value.query.hphm
})
const list = ref([])
function preview(e){
    const imgIdList = e.map(e=>url+e.id)
    if(imgIdList.length>0){
        ImagePreview({imgIdList,closeable:true})
    }
}

function onLoad(){
    if(router.currentRoute.value.query.sfzh){
     getRypcList(queryList.value).then(res=>{
        list.value.push(...res.records)
        total.value = res.total
        loading.value = false
        queryList.value.pageCurrent++
        if(list.value.length>=res.total){
            finished.value = true
        }
        })   
    }else{
        getClpcList(queryList.value).then(res=>{
            list.value.push(...res.records)
            total.value = res.total
            loading.value = false
            queryList.value.pageCurrent++
            if(list.value.length>=res.total){
                finished.value = true
            }
        })   
    }
    
}
onMounted(()=>{})
</script>

<style lang="scss" scoped>
@import "../../../assets/styles/mixin.scss";

.item_main {
    box-sizing: border-box;
    padding: 2.5vw;
    border-radius: 4px;
    margin: 16px 2.5vw;
}

.van-cell {
    background-color: rgba(0, 0, 0, 0);
}</style>