var el = {
    searchForm: '#searchForm',

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


function loadGrid() {
    $('#pcnListTab').datagrid({
        iconCls: 'icon-list',
        title: '',
        height: gridheight - 23,
        width: gridwidth,
        url: g.ctx+'pc/order/purchaseOrderDetailUnlockLog/rest/queryUnlockLogPage',
        pagination: true,
        singleSelect: true,
        loadMsg: commonMsg.loadData,
        page: 1,
        pageSize: 10,
        columns: [[
            {
                field: 'ck',
                checkbox: true
            },
            {
                field: 'id',
                title: 'id',
                hidden: true
            }, {
                field: 'orderCode',
                title: "订单编号",
                align: 'center',
                width:'90px'

            },
            {
                field: 'orderRow',
                title: "订单行号",
                width:'50px',
                align: 'center'
            },
            {
                field: 'materialCode',
                title: '物料编号',
                width: '120px',
                align: 'left'
            },

            {
                field: 'materialName',
                title: "物料名称",
                width:'120px',
                align: 'center'
            },

            {
                field: 'unitName',
                title: "订单单位名称 ",
                width:'60px',
                align: 'center'
            },
            {
                field: 'num',
                width:60,
                title: "下单数量",
                align: 'center'

            },

            {
                field: 'factoryName',
                title: "工厂名称",
                align: 'center',
                width:140,
            }
            ,
            {
                field: 'createName',
                title: "创建人名称",
                align: 'center'
            },
            {
                field: 'createTime',
                title: "创建时间",
                width:150,
                align: 'center'
            },
            {
                field: 'remark',
                title: "备注",
                width:150,
                align: 'center'
            },
            {
                field: 'supplierErpCode',
                title: "供应商编码",
                width:50,
                align: 'center'
            },
            {
                field: 'supplierName',
                title: "供应商名称",
                width:180,
                align: 'center'
            },
            {
                field: 'supplierErpCode',
                title: "未清数量",
                width:80,
                align: 'center'
            },
           /* {
                field: 'unlockDate',
                title: "解锁日期",
                width:150,
                align: 'center'
            },*/
            {
                field: 'unlockFlag',
                title: "是否解锁",
                width:80,
                align: 'center',
                formatter: function (unlockFlag) {
                    if (unlockFlag) {
                        return '是';
                    } else{
                        return '否'
                    }
                }
            },
            {
                field: 'unlockRemark',
                title: "解锁原因",
                width:150,
                align: 'center'
            },
            {
                field: 'unlockNum',
                title: "解锁数量",
                width:80,
                align: 'center'
            },
            {
                field: 'operator',
                title: "操作者",
                width:150,
                align: 'center'
            },
            {
                field: 'operationTime',
                title: "操作时间",
                width:150,
                align: 'center'
            },
            {
                field: 'rowTypeCode',
                title: "项目类型",
                width:80,
                align: 'center',
                formatter: function (rowTypeCode) {
                    if (rowTypeCode == 0) {
                        return '标准';
                    } else if (rowTypeCode == 2) {
                        return '寄售';
                    } else if (rowTypeCode == 3) {
                        return '委外';
                    }else{
                        return ''
                    }
                }
            },{
                field: 'receivedNum',
                title: "已收货数量",
                width:80,
                align: 'center'
            },{
                field: 'onlineNum',
                title: "未清数量",
                width:80,
                align: 'center'
            }
        ]],
        toolbar: [{
            text: '导出', iconCls: 'icon-print', id: 'btn_unlock_export', handler: function () {
                exportExcel();
            }
        }]
    });
}
/**
 * 导出excel
 */
function exportExcel() {
    openExportDialog( "pc/order/purchaseOrderDetailUnlockLog/rest/export","pcnListTab", searchParams())
}
//查询
function searchPcn() {
    var queryParams = $('#searchForm').serializeJson();
    queryParams.supplierNo = queryParams.supplierCode;
    $('#pcnListTab').datagrid('load', queryParams);
}


// function resetSearch() {
//     debugger;
//     $("#supplierCode").val('');
//     $("#supplierName").val('');
//     $("#material").val('');
//     $("#orderCode").val('');
//     var queryParams = $('#searchForm').serializeJson();
//     $('#pcnListTab').datagrid('load', queryParams);
// };
