/*
 * 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: 'billCode',
                title: "采购申请单号",
                width: '20%',
                align: 'left'

            },
            {
                field: 'purchaseOrderNumber',
                title: "OA流程单号",
                width: '10%',
                align: 'left'

            },
            {
                field: 'itemCode',
                title: "行号",
                width: '8%',
                align: 'left'

            },
            {
                field: 'materialName',
                title: "物料描述",
                width: '20%',
                align: 'left'

            },
            {
                field: 'materialSpec',
                title: "规格",
                width: '10%',
                align: 'left'

            },
            {
                field: 'requireNum',
                title: "需求数量",
                width: '5%',
                align: 'left'

            },
            {
                field: 'remainQuantity',
                title: "剩余数量",
                width: '5%',
                align: 'left'

            },
            {
                field: 'urgency',
                title: "紧急程度",
                width: '5%',
                align: 'left'

            },
            {
                field: 'materialGroupName',
                title: "物料组名称",
                width: '15%',
                align: 'left'

            },
            {
                field: 'requireName',
                title: "申请人",
                width: '8%',
                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/inquiry/purchase/apply/bill/detail/rest/list?shangCFlag='+ 1,
            // url: g.ctx + 'pc/inquiry/purchase/apply/bill/detail/rest/list?transferStatus=1',
            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])
}