/*
 * The Hefei Ceshi RDC(Research and Development Centre) Group.
 * __________________
 *
 *    Copyright 2015-2019
 *    All Rights Reserved.
 *
 *    NOTICE:  All information contained herein is, and remains
 *    the property of Ceshi Company and its suppliers,
 *    if any.
 */

/**
 *
 * @author BOGON
 * @version 1.0
 */
var page = {
    dataGrid: {},
    initTable: function () {
        var columns = [[
            {
                field: 'ck',
                checkbox: true
            },
            {
                field: 'id',
                hidden: true
            }, {
                field: 'companyCode',
                title: "公司代码",
                width: '15%',
                align: 'left'

            },
            {
                field: 'costCenter',
                title: "成本中心编码",
                width: '35%',
                align: 'left'

            },
            {
                field: 'describe',
                title: "成本中心名称",
                width: '50%',
                align: 'left'

            }
        ]];
        page.dataGrid = $('#tb').datagrid({
            iconCls: 'icon-list',
            width: '100%',
            method: 'GET',
            idField: 'id',
            height: $(window).height() - $('#searchForm').outerHeight() - 20,
            url: g.ctx + 'pc/mall/shoppingPay/rest/costCenterList',
            singleSelect: true,
            pagination: true,
            loadMsg: commonMsg.loadData,
            rownumbers: true,
            fitColumns: true,
            nowrap: true,
            remoteSort: true,
            striped: true,
            page: 1,
            pageSize: 20,
            columns: columns
        });
    },
};

$(function () {
    page.initTable();
});

/**
 * 选择指定供应商
 * @param callback  选择指定供应商数据的回调
 */
function getChecked(callback) {
    let rows = $('#tb').datagrid('getChecked');
    if (rows.length !== 1) {
        topWin.layer.msg("请选中一条数据")
        return
    }
    callback(rows[0])
}