(function(){
    X.pageLogic['apiadmin'] = {
        init : function(parms){
            var me = this;
            me.updataapilist();
            $(document).off('click','.eventattradmin-actions___141YT').on('click','.eventattradmin-actions___141YT',function(){
                X.parametersopen('','apiadmin_add','auto',function(){
                    me.updataapilist();
                })
            });

            layui.table.on('tool(apiadminntest)', function(obj){
                var data = obj.data;
                if(obj.event === 'edit'){
                    X.parametersopen(data,"apiadmin_add",'auto',function(){
                      me.updataapilist();
                    })
                }else if(obj.event === 'del'){
                    layer.confirm('确认删除当前api吗？该操作不可恢复', {
                        btn: ['取消','删除 '] //按钮
                      }, function(){
                        //取消
                        layer.close(layer.index);
                      }, function(){
                        //删除
                        var arr = [];
                        arr.push(data._id);
                        X.api("authz/del_api",'post',{ids:arr},function(d){
                            layer.msg('删除成功');
                            layer.close(layer.index);
                            me.updataapilist();
                        })
                    });
                }
            })
        
        },
        updataapilist:function(){
            X.laytabledata("#apiadmin-table","authz/api_list",[[
                {field:'name', title: '标题', width: '10%', sort: true}
                ,{field:'path', title: '路径'}
                ,{field:'desc', title: '简介',width: '60%'}
                ,{fixed: 'right', title:'操作', toolbar: '#apiadminbarDemo', width:117}
            ]],null,'685');
        }
    };
})();