/**
 * 物料样品申请单列表
 * src/main/resources/view/supplier/product/demo/index.ftl
 */
var el = {
    id: '#id',
    table: '#tb',
    searchForm: '#searchForm',
    code: '#code',
    //purchaseCode: '#purchaseCode',
    startTime: '#startTime',
    endTime: "#endTime",
    materialNameOrCode: '#materialNameOrCode',
    supplierlNameOrCode: '#supplierlNameOrCode',

    bodyHeight: document.documentElement.clientHeight
}

$(function () {
    loadData();

});


/**
 * 初始化页面数据
 */
function loadData() {
    var searchHeight = $(el.searchForm).outerHeight();
    var pager = initGridPagerNew(el.bodyHeight - searchHeight, 37, 40);
    var columns = [[
        {
            field: 'ck',
            checkbox: true
        },
        {field: 'id', hidden: true},
        {
            field: 'code',
            title: "申请单号",
            align: 'left',
            width: 160
        },
        {
            field: 'state',
            title: "状态",
            align: 'left',
            width: 120,
            formatter: function (value) {
                switch (value) {
                    case 1:
                        return '<font color="red">' + "新建" + '</font>';
                    case 2:
                        return '<font color="#FF5722">' + "待供应商处理" + '</font>';
                    case 3:
                        return '<font color="green">' + "待采购处理" + '</font>';
                    case 4:
                        return '<font color="green">' + "待审核" + '</font>';
                    case 5:
                        return '<font color="green">' + "审核通过" + '</font>';
                    case 6:
                        return '<font color="red">' + "审核不通过" + '</font>';
                }
            }
        },
        {
            field: 'materialCode',
            title: "物料编码",
            align: 'left',
            width: 120
        },
        {
            field: 'materialName',
            title: "物料名称",
            align: 'left',
            width: 120
        },
        {
            field: 'sampleType',
            title: "送样类型",
            align: 'left',
            width: 80,
            formatter:function(value){
                return getDicName("sample_type",value)
            }
        },
        {
            field: 'sendTarget',
            title: "验证目的",
            align: 'left',
            width: 80,
            formatter:function(value){
                return getDicName("send_target",value)
            }
        },
        {
            field: 'sampleCount',
            title: "送货数量",
            align: 'left',
            width: 80
        },
        {
            field: 'sampleUnit',
            title: "样品单位",
            align: 'left',
            width: 80
        },
        {
            field: 'materialGroupCode',
            title: '物料组编码',
            align: 'left',
            width: 120
        },
        {
            field: 'materialGroupName',
            title: '物料组描述',
            align: 'left',
            width: 300
        },

        {
            field: "supplierCode",
            title: "供应商编码",
            align: 'left',
            width: 120
        },
        {
            field: "supplierName",
            title: "供应商名称",
            align: 'left',
            width: 120
        },
        {
            field: "supplierBatch",
            title: "供方批号",
            align: 'left',
            width: 100
        },
        {
            field: "supplierModel",
            title: "供方规格型号",
            align: 'left',
            width: 160
        },
        {
            field: "remark",
            title: "备注",
            align: 'left',
            width: 300
        },
        {
            field: "createTime",
            title: "创建时间",
            align: 'left',
            width: 120
        }
    ]];
    $(el.table).datagrid({
        iconCls: 'icon-list',
        height: el.bodyHeight - searchHeight,
        singleSelect: false,
        method: "GET",
        url: g.ctx + 'pc/supplier/materialDemo/rest/listBySupplierId?supplierId=' + supplierId,
        pageSize: pager.pageSize,
        pageList: pager.pageList,
        pagination: true,
        loadMsg: commonMsg.loadData,
        rownumbers: true,
        fitColumns: false,
        page: 1,
        queryParams: {},
        columns: columns
    });
}

function getChecked() {
    let rows = $(el.table).datagrid("getChecked")
    if (rows.length <= 0) {
        topWin.layer.msg("请选中至少一条数据!")
        return
    }
    return rows
}








