(function(){
    X.pageLogic['apiadmin_add'] = {
        init : function(parms){
            var me = this;
            this.parms = parms;
            this.callback = parms.callback; //选择后执行的回调
            var data = parms.extData;//获取到上层弹窗传的数据
            console.log(data);
            if(data){
                $("#path").val(data.path);
                $("#name").val(data.name);
                $("#desc").val(data.desc);
            }
            $(document).off('click','.newwenjian-qd').on('click','.newwenjian-qd',function(){
                if($("#path").val() == "" && $("#name").val() == ""){
                    layer.msg('标题，路径为必填项');
                    return;
                }
                var arr = {
                    "path": $("#path").val(),
                    "name": $("#name").val(),
                    "desc": $("#desc").val()
                }
                if(!data){
                    X.api('authz/add_api','post',arr,function(d){
                        layer.closeAll();
                        X.pageLogic.apiadmin.updataapilist();
                    });
                }else {
                    arr['id'] = data['_id'];
                    X.api('authz/edit_api','post',arr,function(d){
                        layer.closeAll();
                        X.pageLogic.apiadmin.updataapilist();
                    });
                }
                
            });

            $(document).off('click','.newwenjian-qx').on('click','.newwenjian-qx',function(){
                layer.closeAll();
                
            });

            $(document).off('click','.newwenjian-cha').on('click','.newwenjian-cha',function(){
                layer.closeAll();
               
            });
            
        
        }
    };
})();