<template>
    <LayoutTable :toggleRowSelection="toggleRowSelection" ref="LayoutTable" :data="tableData" :config="tableConfig" @selection-change="handleSelectionChange">
        <div slot="table-head-left"><div>请选择窗口</div></div>
        <div slot="table-head-center"></div>
    </LayoutTable>
</template>
<script>
import table from "@/assets/mixins/table";
export default {
    props:['hallId','checkId','editId'],
    mixins: [table],
    methods:{
        handleSelectionChange(v){
            this.$emit("selection-change",v)
        },
        beforeFecth(){
            this.pageInfo.list = '/window/owner/subWindowList'
        },
        //重写
        afterRender(info){
            const {data} = info
            if(this.editId){
                // 编辑的时候回显
                const toggleRowSelection = []
                data.forEach(element => {
                    if(element.selected == 1){
                        toggleRowSelection.push(element)
                    }
                    
                });
                setTimeout(()=>{
                    this.toggleRowSelection = toggleRowSelection
                })
            }
            
        }
    },
    created(){
        this.config.search[0].enumData = this.hallId
        console.log(this.editId,"editId")
        
    },
    watch: {
        editId:{
            handler:function(v){
                if(v){
                    this.query = {staffId:v}
                }else{
                    this.query = {}
                }
                this.getData()
            },
            immediate:true
        }
    },
    data(){
        return {
            toggleRowSelection:[],
            config: {
                downloadUrl:"",
                isshowTabPane: false,
                search: [
                    {
                        name: "hallId",
                        type: "select",
                        label: "大厅",
                        enumData:{}
                    },
                    {
                        name: "deptName",
                        type: "text",
                        label: "窗口名称",
                        fuzzy: true,
                    },
                ],
                columns: [
                    { type: "selection", width: 60 },
                    // { type: "index", label: "序号", width: 50 },

                    { label: "窗口名称", prop: "name" },

                    { label: "编号", prop: "fromnum" },

                    { label: "所属楼栋", prop: "building" },

                    { label: "所属楼层", prop: "level" },
                    // {
                    //     label: "操作",
                    //     width: 240,
                    //     formatter: (row) => {
                    //     return (
                    //         <table-buttons
                    //         noAdd
                    //         row={row}
                    //         onEdit={this.toEdit}
                    //         onView={this.toView}
                    //         onDel={this.toDel}
                    //         />
                    //     );
                    //     },
                    // },
                ],
            },
        }
    },
}
</script>