(function(){
    X.pageLogic['addproject_owner_name'] = {
        init : function(parms){
            var me = this;
            this.parms = parms;
            this.callback = parms.callback; //选择后执行的回调
            var data = parms.extData;//获取到上层弹窗传的数据
            //
            
            if(data){
                // for(let i in data.ditch){
                //     $(".datarightsedit-txt-input").html(data.main_channel);
                //     $(".datarightsedit-txt-input3").html(data.ditch);
                // }
                X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
            };

            $(document).off("click",'.datarightsedit-tj').on('click','.datarightsedit-tj',function(){
                var arr = {
                    'main_channel':'',
                    'ditch':''
                }
                data.ditch.push(arr);
                X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
            });
            
            $(document).off('click','.daxinqudao').on('blur','.daxinqudao',function(){
                var index = $(this).attr("data-index");
                data.ditch[index]['main_channel'] = $(this).val();
            });

            $(document).off('click','.qudaocanshu').on('blur','.qudaocanshu',function(){
                var index = $(this).attr("data-index");
                data.ditch[index]['ditch'] = $(this).val();
            });

            $(document).off("click",'.datarightsedit-txt-box-del').on('click','.datarightsedit-txt-box-del',function(){
                var index = $(this).attr("data-index");
                data.ditch.splice(index,1);
                X.laytpldata("#datarightsedit-con-box-dot",data.ditch,".datarightsedit-con-box");
            });
            
            $(".datarightsedit-qx").click(function(){
                layer.closeAll();
            });

            $(".datarightsedit-top-box img").click(function(){
                layer.closeAll();
            });

            $(".datarightsedit-qd").click(function(){

                X.api("project/add_project_name","post",{game:data.game,ditch:data.ditch,name: data.name},function(d){
                    if(d){
                        layer.msg("编辑成功");
                        me.callback && me.callback();
                        layer.closeAll();
                    }
                })
            });

        },

    };
})();
