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

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

    export default {
        name: "go-win-tree",
        mixins: [WinMixins],
        data() {
            return {
                treeObj:null,
            };
        },
        props: {
            treeUrl:{ type: String, default: "" },
        },
        computed: {

        },
        methods: {
            showWin(){
                let vueObj=this;
                //弹出窗口 激活一跟树
                this.$goDialog.attachTree({
                    height: this.height,
                    width: this.width,
                    closeWin: () => {
                        vueObj.$emit("input", false);
                        vueObj.$emit("close", true);
                    },
                    title: this.title,
                    config: {
                        search: true,
                        checkBox: true,
                        treeUrl: this.treeUrl,
                        backFun(treeObj) {
                            vueObj.treeObj=treeObj;
                            vueObj.$emit('backFun',{treeObj});
                        }
                    },
                    //确定按钮
                    confirmBtn() {
                        vueObj.$emit('confirmFun',{treeObj:vueObj.treeObj});
                    }
                });
            },
            hideWin(){
                this.$WinUtils.closeParentCurWin();
            },
        },
        mounted() {
            if(this.value){
                this.showWin();
            }
        },
        watch: {
            treeUrl(newVal) {
                if(this.treeObj!=null&&AssertUtils.isNotEmpty(newVal)){
                    this.treeObj.flushTreeByUrl({url:newVal});
                }
            },
            value(newVal) {
                if (newVal) {
                    this.showWin();
                } else {
                    this.hideWin();
                }

            }
        }
    };
</script>
