/*
 * 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: 'customerCode',
                title: "客户编号",
                width: 130,
                align: 'left'

            },
            {
                field: 'customerName1',
                title: "客户名称",
                width: 200,
                align: 'left',
                hidden:true

            },
            {
                field: 'businessPartnerGroup',
                title: "业务伙伴分组",
                width: 130,
                align: 'left'

            },
            {
                field: 'city',
                title: "城市",
                width: 80,
                align: 'left'
            },
            // {
            //     field: 'customerSort',
            //     title: "客户分类",
            //     width: 130,
            //     align: 'left'
            // },
            {
                field: 'creatDate',
                title: "创建日期",
                width: 130,
                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/supplier/customer/rest/list',
            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])
}