(function(){
    X.pageLogic['yidong-pop'] = {
        init : function(parms){
            var me = this;
            this.parms = parms;
            this.callback = parms.callback; //选择后执行的回调
            var data = parms.extData;//获取到上层弹窗传的数据
            var comboTree1,comboTree2
            comboTree1 = $('.yidong-txt-box .justAnotherInputBox1').comboTree({
                source : X.DATA.KanBanData,
                isMultiple: false
            });
            comboTree2 = $('.yidong-txt-box .justAnotherInputBox2').comboTree({
                source : X.DATA.ProjectData,
                isMultiple: false
            });
            
            //叉图标关闭弹窗
            $(".yidong-top .yidong-cha").click(function(){
                console.log(layer.index)
                parent.layer.closeAll(layer.index);
            });
            //取消按钮
            $(".yidong-but-box .yidong-qx").click(function(){
                layer.closeAll(layer.index);
            });
            //我的看板，空间切换实践
            $(".yidong-tab-box .yidong-tab div").click(function(){
                $(".yidong-tab-box .yidong-tab div").removeClass('tabdata');
                $(this).addClass('tabdata');
                if($(this).html() == "我的看板"){
                    $(".yidong-txt-box .justAnotherInputBox1").show();
                    $(".yidong-txt-box .justAnotherInputBox2").hide();
                }else {
                    $(".yidong-txt-box .justAnotherInputBox1").hide();
                    $(".yidong-txt-box .justAnotherInputBox2").show();
                }
                $(".yidong-txt-box .justAnotherInputBox1").val("");
                $(".yidong-txt-box .justAnotherInputBox2").val("");
            })

            //确定按钮
            $(".yidong-but-box .yidong-qd").click(function(){
                var type ='kanban';
                var id = '';//没有默认传看板
                if($('#yidongjustAnotherInputBox2').val() != ""){
                    var Addlocation = $('#yidongjustAnotherInputBox2').val();
                    type = "space"
                }else {
                    var Addlocation = $('#yidongjustAnotherInputBox1').val();
                }
                // console.log(Addlocation);
                if(Addlocation){
                   id = X.pageLogic.newkanban.matchingid(Addlocation,type);
                }else {
                    alert('请选择添加的位置');
                    return;
                }
                // var source_id = data['mykanban'].concat(data['kongjian']);
                var dataArr = {
                    'source_ids':data,
                    'dest_pid': id,
                    'cat':type
                };
                console.log(dataArr);
                X.api('dashboard/move','post',dataArr,function(d){
                    // if(d.code == "ok"){
                        X.pageLogic.dashboard.freshMenu(X.DATA.projectid);//刷新侧边栏
                        X.pageLogic.adminkanban.updata(X.DATA.projectid);//刷新数据
                        console.log(me.parms.layIndex);
                        layer.closeAll(0);
                    // }
                })
            });


        }
    };
})();