<div id="cv-block-table-header">
    <div class="panel-title">
        <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>
    </div>
</div>
<form id="cv-block-order-form" method="post" style="width: 100%;height: 100%;">
    <table id="cv-block-table" style="height: 100%;"></table>
</form>
<script type="text/javascript">
    $(function () {
        var cvBlockTable = $('#cv-block-table');
        cvBlockTable.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:'title',title:'标签名称',width:100,align:'center'},
                {field:'tag',title:'标签标识',width:50,align:'center'},
                {field:'remark',title:'标签备注',width:100,align:'center'},
                {field:'field_type',title:'标签类型',width:80,align:'center'},
                {field:'actions',title:'可用操作',width:50,halign:'center'}
            ]],
            pagination: false,
            border:false,
            fitColumns: true,
            striped: true,
            header: '#cv-block-table-header'
        });
    });

    function reloadBlockListData() {
        $('#cv-block-table').datagrid('reload');
        updateRenderTab();
    }

    function saveBlockOrderForm(){
        $("#cv-block-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){
                    reloadBlockListData();
                }
            }
        });
    }

    function deleteBlockData(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){
                        reloadBlockListData();
                    }
                }
            });
            layer.close(confirm);
        }, function(){
            layer.close(confirm);
        });
    }

</script>
