<template>
    <el-form v-if="list.length">
        <select-item
            :label="item.label"
            :data="item.data"
            v-for="(item,index) in list"
            :key="item.id"
            v-show="item.show"
        ></select-item>
    </el-form>
</template>

<script>
import selectItem from "./selectItem";
import ChildItem from "./ChildItem";

export default {
    name: "seFiltrate03",
    components: {
        selectItem
    },
    data() {
        return {
            value: "",
            list: []
        };
    },
    props: {
        filtrates: {//筛选项目
            type: Array,
            default: () => [
                {
                    label: "label",
                    getData() {
                        return [{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"3"}]
                    }
                },
                {
                    label: "label",
                    getData() {
                        return [{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"1"},{label:"4"},{label:"3"}]
                    }
                }
            ]
        },
        defSubmit: {
            type: Boolean,
            default: true,
        },
    },
    created() {

    },
    async mounted() {
        await this.initList();
        this.defSubmit && this.submit();
    },
    methods: {
        /**
         * 提交按钮事件
         */
        submit() {
            this.$emit("submit", this.value);
        },
        async initList() {
            let list = [];
            for (const item of this.filtrates) {
                list.push(await new ChildItem(item).init())
            }
            this.list = list;
        }
    }
};
</script>
