<template>
    <div>
        <LHeader :text="text"></LHeader>
        <van-search
            v-model="value"
            show-action
            placeholder="请输入搜索内容"
            @search="onSearch" 
            >
            <template #action>
                <div @click="onSearch" >搜索</div>
            </template>
        </van-search>
        <van-cell-group inset v-if="dangerList.length > 0">
            <van-grid :column-num="4">
                <van-grid-item
                    @click="dangerJump(item.path)"
                    v-for="item in dangerList"
                    :key="item.key"
                    :icon="item.imgUrl"
                    :text="item.text"
                />
            </van-grid>
        </van-cell-group>
        <!-- 内容列表 -->
        <!-- <div class="title">2022年4月26日</div> 
        <p class="title-text">系统提示：请依据当日任务完成当日巡查工作。</p> 
        <div class="con-list">
            <van-cell-group
                inset
                v-for="(item, index) in contentList"
                :key="index"
                @click="onClick(item.content)"
            >
                <div class="icon-wrap">
                    <span class="icon-img">
                        <van-image
                            width="35"
                            height="35"
                            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";
export default {
    name: "danger-patrol",
    components: {
        LHeader
    },
    data() {
        return {
            text: "隐患巡查",
            finalDangerList:[],
            value:"",
            dangerList:[
                {
                    key: "1",
                    imgUrl: require("@/assets/workbench/danger-report.png"),
                    text: "执行巡查",
                    path: "/danger-Patrol-Time",
                },
                {
                    key: "2",
                    imgUrl: require("@/assets/workbench/risk-confirm.png"),
                    text: "取消巡查",
                    path: "/cancel-patrol",
                },
                {
                    key: "3",
                    imgUrl: require("@/assets/workbench/danger-confirm.png"),
                    text: "巡查记录",
                    path: "/record-Patrol-Time",
                },
                {
                    key: "4",
                    imgUrl: require("@/assets/workbench/danger-rectification.png"),
                    text: "巡查审批",
                    path: "/approval-patrol",
                },
                {
                    key: "5",
                    imgUrl: require("@/assets/workbench/danger-acceptance.png"),
                    text: "巡查统计",
                    path: "/statistics",
                }
            ],
            contentList: [
                // {
                //     title: "A1",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "执行巡查"
                // },
                // {
                //     title: "A2",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "取消巡查"
                // },
                // {
                //     title: "A1",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "巡查记录"
                // },
                // {
                //     title: "A2",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "巡查统计"
                // }
                // {
                //     title: "A1",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "日查清单"
                // },
                // {
                //     title: "A2",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "周查清单"
                // },
                // {
                //     title: "A3",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "月查清单"
                // },
                // {
                //     title: "A4",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "季查清单"
                // },
                // {
                //     title: "A5",
                //     imgUrl: require("@/assets/dangerPatrol/patrol-icon.png"),
                //     content: "年查清单"
                // }
            ]
        };
    },
    created() {
        //  根据权限显示对应的图标
        // this.getWorkList();
    },
    mounted() {},
    methods: {
        onSearch(){
    
        },
        dangerJump(path) {
            if (path) {
                this.$router.push(path);
            }
        },
        // 请求工作台列表
        getWorkList() {
            postWork("mobile/menu2").then((res) => {
                if (res.code == 0) {
                    this.powerObj = res.data;
                    console.log(this.powerObj,'sss')
                    // 隐患排查治理
                    if (this.powerObj.隐患巡查) {
                        this.finalDangerList = [...this.dangerList].filter(
                            (x) =>
                                [...this.powerObj.隐患巡查].some(
                                    (y) => y.menuName === x.text
                                )
                        );
                    } else {
                        this.finalDangerList = [];
                    }
                } else {
                    this.powerObj = [];
                }
            });
        },
        // onClick(val) {
        //     if (val == "执行巡查") {
        //         this.$router.push({
        //             name: "implement"
        //         });
        //     } else if (val == "取消巡查") {
        //         this.$router.push({
        //             name: "cancel-patrol"
        //         });
        //     } else if (val == "巡查记录") {
        //         this.$router.push({
        //             name: "record-patrol"
        //         });
        //     } else if (val == "巡查统计") {
        //         this.$router.push({
        //             name: "statistics"
        //         });
        //     }
        // }
    }
};
</script>
<style lang="less" scoped>
/* @import url(); 引入css类 */
.van-cell-group--inset {
    // height: 2.266667rem;
    line-height: 2.266667rem;
    font-size: 0.4rem;
    font-weight: bolder;
    margin: 0.266667rem;
    // padding-left: 0.666667rem;
    color: #3499ff;
    .icon-wrap {
        display: flex;
        align-items: center;
        .icon-img {
            margin-right: 0.533333rem;
            display: inherit;
        }
    }
}
/deep/ .van-cell::after {
    border: none;
}
/deep/ [class*="van-hairline"]::after {
    border: none;
}
.title{
    text-align: center;
    font-weight: bolder;
    margin-top: 0.5rem;
}
.title-text{
    padding-left: 0.666667rem;
}
</style>
