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

<script>
    import WinMixins from "../ctlMixins/WinMixins";

    export default {
        name: "go-win-form",
        mixins: [WinMixins],
        data() {
            return {
                treeObj:null,
                winIdStr:'',
            };
        },
        props: {
            labelWidth:{ type: Number, default: 150 },
            inputWidth:{ type: Number, default: 200 },
            fieldAry:{ type: Array, default: ()=>[] }
        },
        computed: {

        },
        methods: {
            showWin(){
                let vueObj=this;
                //弹出窗口
                this.winIdStr=this.$goDialog.attachForm(
                    {
                        height: this.height,
                        width: this.width,
                        title: this.title,
                        closeWin: () => {
                            vueObj.$emit("input", false);
                            vueObj.$emit("close", true);
                        },
                        config: {
                            labelWidth: this.labelWidth,
                            inputWidth: this.inputWidth,
                            fieldAry:this.fieldAry
                        },
                        //初始化form里面的对象值
                        initFun:(formObj)=>{
                            vueObj.$emit("initFun", {formObj});
                        },
                        //确定按钮
                        confirmBtn(goingForm) {
                            vueObj.$emit('confirmFun',{goingForm});
                        }
                    },
                    this
                );
            },
            hideWin(){
                //    关闭窗口
                this.$WinUtils.closeParentCurWin(true,this.winIdStr);
            },
        },
        mounted() {
            if(this.value){
                this.showWin();
            }
        },
        watch: {
            value(newVal) {
                if (newVal) {
                    this.showWin();
                } else {
                    this.hideWin();
                }

            }
        }
    };
</script>

