<template>
    <span></span>
</template>

<script>
    import WinMixins from "../ctlMixins/WinMixins";
    import {AssertUtils} from 'goingutils';


    export default {
        name: "go-win-grid",
        mixins: [WinMixins],
        data() {
            return {
                treeObj:null,
            };
        },
        props: {
            //是否存在列选择
            colSelBox:{ type: Boolean, default: true },
            //是否存在序号
            colOrderNum:{ type: Boolean, default: true },
            //是否可以多选
            moreSel:{ type: Boolean, default: true },
            //是否可以查询
            hasSearch:{ type: Boolean, default: false },
            //查询url地址
            queryUrl:{ type: String, default: "" },
            //列表 列信息
            fieldAry:{ type: Array, default: ()=>[] },
            //列表 的查询列信息
            searchFieldAry:{ type: Array, default: ()=>[] },
        },
        computed: {

        },
        methods: {
            showWin(){
                let vueObj=this;
                this.$goDialog.attachGrid(
                    {
                        width: this.width,
                        height: this.height,
                        title: this.title,
                        closeWin: () => {
                            vueObj.$emit("input", false);
                            vueObj.$emit("close", true);
                        },
                        hasSearch: this.hasSearch,
                        searchFieldAry:this.searchFieldAry,
                        searchFun() {},
                        config: {
                            queryUrl: vueObj.queryUrl,
                            colOrderNum: this.colOrderNum,
                            moreSel: this.moreSel,
                            colSelBox: this.colSelBox,
                            fieldAry: this.fieldAry
                        },
                        confirmBtn: function(gridObj, vueObj) {
                            //授权的主题id
                            let principalIds = gridObj.getSelectedRowIds();
                            vueObj.$emit("confirmBtn", { principalIds });
                        }
                    },
                    this
                );
            },
            hideWin(){},
        },
        mounted() {
            if(this.value){
                this.showWin();
            }
        },
        watch: {
            queryUrl(newVal) {
                if(this.treeObj!=null&&AssertUtils.isNotEmpty(newVal)){
                    this.treeObj.flushTreeByUrl({url:newVal});
                }
            },
            value(newVal) {
                if (newVal) {
                    this.showWin();
                } else {
                    this.hideWin();
                }

            }
        }
    };
</script>

