/**
 * 数据管理-采购组管理首页JS
 *
 * Created by li.kui on 20203/17.
 */
'use strict';
var el = {
    searchForm: '#searchForm',
    pgCode: '#pgCode',
    pgName: '#pgName',
    poCode: '#poCode',
    orgCodeOrName: '#orgCodeOrName',
    tb: '#tb',
    addOrEditDialog: null,
    lookDialog: null,
    bodyHeight: document.documentElement.clientHeight
};


$(function () {
    loadGrid();
});


function loadGrid() {
    var searchHeight = $(el.searchForm).outerHeight();
    var pager = initGridPagerNew(el.bodyHeight - searchHeight, 40, 30);

    $(el.tb).datagrid({
        loadMsg: '数据加载中......',
        url: g.ctx + 'pc/sys/purchaseGroup/rest/list',
        singleSelect: true,
        height: el.bodyHeight - searchHeight,
        pagination: true,
        pageSize: pager.pageSize,
        pageList: pager.pageList,
        rownumbers: true,
        queryParams: {},
        columns: [
            [
                {
                    field: 'ck',
                    checkbox: true
                },
                {
                    field: 'purchaseGroupCode',
                    title: '采购组编码',
                    width: 120
                },
                {
                    field: 'purchaseGroupName',
                    title: '采购组名称',
                    width: 200
                },
                {
                    field: 'orgName',
                    title: '所属组织',
                    width: 200
                },
                {
                    field: 'createTime',
                    title: '创建日期',
                    width: 140,
                    formatter: function (value) {
                        return moment(value).format('YYYY-MM-DD HH:mm');
                    }
                }
            ]
        ]
    });
}

/**
 * 选择采购组
 * @param call  选择采购组数据的回调
 */
function chooseRow(call) {

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


