<div id="cv-manager-table-header">
    <div class="panel-title">
		<?php if ($is_peak):?>
        <a href="javascript:openDialog('添加管理员','<?= url('new'); ?>','520px','330px')" class="easyui-linkbutton">+ 添加</a>
        <a href="javascript:saveManagerOrderForm();" class="easyui-linkbutton"><i class="sui-icon icon-tb-delete cv-f-14"></i> 排序</a>
		<?php endif;?>
    </div>
</div>
<form id="cv-manager-order-form" method="post" style="width: 100%;height: 100%;">
    <table id="cv-manager-table" style="height: 100%;"></table>
</form>
<script type="text/javascript">
    $(function () {
        var cvManagerTable = $('#cv-manager-table');
        cvManagerTable.datagrid({
            url:'<?= url('index'); ?>',
            columns:[[
                {field:'ck',checkbox:true,width:10},
                {field:'id',title:'ID',width:15,align:'center'},
                {field:'order',title:'权重',width:20,align:'center'},
                {field:'username',title:'用户名',width:100,align:'center'},
                {field:'true_name',title:'真实姓名',width:50,align:'center'},
                {field:'email',title:'邮箱',width:100,align:'center'},
                {field:'actions',title:'可用操作',width:50,halign:'center'}
            ]],
            pagination: false,
            border:false,
            fitColumns: true,
            striped: true,
            header: '#cv-manager-table-header'
        });
    });

    function reloadManagerListData() {
        $('#cv-manager-table').datagrid('reload');
    }

    function saveManagerOrderForm(){
        $("#cv-manager-order-form").form('submit',{
            url: '<?= url('order'); ?>',
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                var response = JSON.parse(result);
                message(response.message);
                if (response.success){
                    reloadManagerListData();
                }
            }
        });
    }

    function deleteManagerData(url){
        var confirm = layer.confirm('确认删除吗？删除后将无法恢复', {
            btn: ['删除','取消'],
            btnAlign: 'c',
            anim:4
        }, function(){
            $.ajax({
                url: url,
                type:'POST',
                success: function (response) {
                    message(response.message);
                    if (response.success){
                        reloadManagerListData();
                    }
                }
            });
            layer.close(confirm);
        }, function(){
            layer.close(confirm);
        });
    }

</script>
