<template>
    <div>
        <LHeader :text="text"></LHeader>
        <!-- 内容列表 -->
        <div class="title">{{nowTime}}</div> 
        <p class="title-text">巡查发起人：{{sponsor}}</p> 
        <p class="title-text">系统提示：请依据当日任务完成当日巡查工作。</p> 
        <div class="con-list">
            <van-cell-group
                inset
                v-for="(item, index) in contentList"
                :key="index"
                @click="onClick(item)"
            >
                <div class="icon-wrap">
                    <span class="icon-img">
                        <van-image
                            width="45"
                            height="45"
                            style="margin: 0 10px;overflow: hidden; border-radius: 5px;"
                            :src="item.imgUrl"
                        />
                    </span>
                    {{ item.content }}
                </div>
            </van-cell-group>
        </div>
    </div>
</template>

<script>
import LHeader from "@/components/header.vue";
import { postWork } from "@/service/workbench";
import { timestampToTime } from "@/utils/format";
export default {
    name: "danger-patrol",
    components: {
        LHeader
    },
    data() {
        return {
            text: "隐患巡查",
            nowTime:"",
            sponsor:"", // 巡查发起人
            contentList: [
                
            ],
            contentLists:[
                {
                    title: "1",
                    imgUrl: require("@/assets/dangerPatrol/day_list.png"),
                    content: "日查清单"
                },
                {
                    title: "2",
                    imgUrl: require("@/assets/dangerPatrol/week_list.png"),
                    content: "周查清单"
                },
                {
                    title: "3",
                    imgUrl: require("@/assets/dangerPatrol/half_month_list.png"),
                    content: "半月查清单"
                },
                {
                    title: "4",
                    imgUrl: require("@/assets/dangerPatrol/month_list.png"),
                    content: "月查清单"
                },
                {
                    title: "5",
                    imgUrl: require("@/assets/dangerPatrol/quarter_list.png"),
                    content: "季查清单"
                },
                {
                    title: "6",
                    imgUrl: require("@/assets/dangerPatrol/year_list.png"),
                    content: "半年查清单"
                },
                {
                    title: "7",
                    imgUrl: require("@/assets/dangerPatrol/year_list.png"),
                    content: "年查清单"
                }
            ]
        };
    },
    mounted() {
        this.nowTime = timestampToTime(new Date(), "DT7", true);
        this.loading()
    },
    methods: {
        loading(){
            postWork("patrol/running/listCycle").then((res) => {
                this.sponsor = res.data[0].assignName
                this.contentLists.forEach((x)=>{
                    res.data.forEach((y)=>{
                        if(x.title==y.cycle){
                            this.contentList.push(x)
                        }
                    })
                })
            })
        },
        onClick(val) {
            console.log(val)
            sessionStorage.removeItem('type')
            this.$router.push({
                name: "implement",
                query:{
                    id:val.title,
                    content:val.content
                }
            });
        }
    }
};
</script>
<style lang="less" scoped>
/* @import url(); 引入css类 */
.van-cell-group--inset {
    // height: 2.266667rem;
    line-height: 2.266667rem;
    font-size: 0.42rem;
    font-weight: bolder;
    margin: 0.266667rem;
    padding-left: 0.666667rem;
    color: #646566;
    .icon-wrap {
        display: flex;
        align-items: center;
        .icon-img {
            margin-right: 0.533333rem;
            display: inherit;
        }
    }
}
.title{
    text-align: left;
    font-weight: bolder;
    margin-top: 0.5rem;
    font-size: 13px;
    padding-left: 0.666667rem;
}
.title-text{
    font-size: 13px;
    padding-left: 0.666667rem;
}
</style>
