/**
 *  询报价模板首页JS
 *
 * Created by likui on 2019/10/29.
 */
'use strict';
var el = {
    tb: '#tb',
    fieldGroup: '#fieldGroup',
    templateName: '#templateName',
    purchaseGroupCode: '#purchaseGroupCode',
    searchForm: '#searchForm',
    moduleCode: '#moduleCode',
    userId: '#userId',
    addOrEditDialog: null,
    bodyHeight: document.documentElement.clientHeight
};


$(function () {

    loadGrid();
});


/**
 * 初始化表格
 */
function loadGrid() {
    var searchHeight = $(el.searchForm).outerHeight();
    var pager = initGridPagerNew(el.bodyHeight - searchHeight, 37, 40);

    $(el.tb).datagrid({
        loadMsg: "数据加载中......",
        url: g.ctx + 'pc/inquiry/template/field/rest/listAll',
        singleSelect: false,
        height: el.bodyHeight - searchHeight,
        pagination: false,
        fitColumns:false,
        pageSize: pager.pageSize,
        pageList: pager.pageList,
        rownumbers: true,
        queryParams: {fieldGroup:$(el.fieldGroup).val()},
        columns : [ [
            { field : 'ck', checkbox : true },
            { width : '40%', align : 'left', field : 'labelName', title : '标签名称' },
            { width : '30%', align : 'left', field : 'fieldType', title : '字段类型' },
            { width : '28%', align : 'left', field : 'groupName', title : '字段分组' }
        ] ],
    });
}

function selectField(call) {

    var rows = $(el.tb).datagrid('getSelections');
    if (rows === null || rows === undefined ) {
        layer.msg("请选中一条记录");
        return;
    }
    call(rows);
}