/**
 *
 * @author BOGON
 * @version 1.0
 */

var page = {
    initData: function () {
        $("#tb").datagrid({
            height: document.documentElement.clientHeight,
            url: g.ctx + 'pc/supplier/template/rest/fields/listAll',
            method: "GET",
            singleSelect: false,
            pagination: false,
            autoHeight: true,
            loadMsg: "数据加载中......",
            rownumbers: true,
            fitColumns: false,
            nowrap: true,
            remoteSort: true,
            striped: true,
            queryParams: {},
            columns: [[
                {field: 'ck', checkbox: true},
                {width: '200', align: 'left', field: 'labelName', title: '标签名称'},
                {
                    width: '120', align: 'left', field: 'fieldType', title: '字段类型',
                    formatter: function (a) {
                        let result = ''
                        switch (a) {
                            case 'bigint':
                                result = '数字';
                                break;
                            case 'date':
                                result = '日期';
                                break;
                            case 'dict':
                                result = '字典';
                                break;
                            case 'int':
                                result = '数字';
                                break;
                            case 'table':
                                result = '表格';
                                break;
                            case 'varchar':
                                result = '字符串';
                                break;
                            default:
                                result = '未知类型';
                                break;
                        }
                        return result
                    }
                }
            ]]
        });
    },
    getChecked: function (call) {
        var rows = $('#tb').datagrid('getChecked');
        if (rows.length <= 0) {
            topWin.layer.msg("请选中至少一条记录");
            return;
        }
        call(rows)
    }
}
$(function () {
        page.initData()
    }
)