<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RetrospectSearch.aspx.cs" Inherits="MESWebSite.Manage.RetrospectSearch" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/CSS/Basics.css" rel="stylesheet" />
    <link href="/Scripts/jquery-easyui-1.4.3/themes/metro/easyui.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/jquery-easyui-1.4.3/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="/Scripts/jquery-easyui-1.4.3/themes/color.css" rel="stylesheet" type="text/css" />
    <script src="/Scripts/jquery-easyui-1.4.3/jquery.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-easyui-1.4.3/jquery.easyui.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js" type="text/javascript"></script>
    <script src="/Scripts/MyJs.js" type="text/javascript"></script>
    <style>
        #w td {
            padding: 5px 5px;
            text-align: left;
            vertical-align: middle;
        }

        #w .title {
            vertical-align: middle;
            text-align: right;
            width: 80px;
            height: 40px;
        }

        p {
            padding: 5px;
            font-size: small;
            font-family: 微软雅黑;
        }

        .datagrid {
            text-align: center;
        }
        .datagrid-body{
            overflow:auto;
        }
        .datagrid-header-row > td {
            border-bottom: 5px solid #DFDFDF !important;
        }
    </style>
    <title>条码信息查询</title>
</head>
<body>
    <form id="form1" runat="server">
        <div class="top">
            <table style="width: 100%">
                <tr style="display: flex ;flex-direction: row; flex-wrap: wrap;">
                    <td><span class="title">条码信息查询</span>
                    </td>
                    <td style="width: 260px;">条码:
                        <input type="text" id="barcode" style="width: 140px;" /></td>
                    <td style="width: 500px;">时间:
                        <input id="StartTime_s"class="easyui-datetimebox" data-options="onShowPanel:function(){ $(this).datetimebox('spinner').timespinner('setValue','00:00:00');}" />&nbsp;至&nbsp;
                        <input id="EndTime_s" class="easyui-datetimebox" data-options="onShowPanel:function(){ $(this).datetimebox('spinner').timespinner('setValue','23:59:59');}" />
                    </td>
                    <td style="width: 80px;"><a class="topsearchBtn" id="searchBtn">查询</a></td>
                    <td style="width: 80px">
                        <a class="topexcelBtn" id="exportbtn">导出</a>
                    </td>
                </tr>
            </table>
        </div>
        <table id="tb" title="条码记录" style="width: 99%;">
        </table>
        <input id="UserID" type="text" hidden="hidden" runat="server" />
        <script>
            /****************       全局变量          ***************/
            var PrimaryID;               //要编辑的id
            var dg = $('#tb');      //表格
            var isEdit = false;     //是否为编辑状态

            /****************       DOM加载          ***************/
            $(function() {
                $.ajaxSetup({
                    cache: false //关闭AJAX缓存
                });

                var curr_time = new Date();
                var str = curr_time.getFullYear() + "-";
                str += curr_time.getMonth() + 1 + "-";
                str += curr_time.getDate();
                $('#StartTime_s').datetimebox('setValue', str + " 08:00:00");
                $('#EndTime_s').datetimebox('setValue', str + " 20:00:00");

                //查询
                $('#searchBtn').first().click(function () {
                    SearchInfo();
                });


                dg = $('#tb').datagrid({
                    fitColumns: false,
                    nowrap: false,
                    striped: true,
                    collapsible: false,
                    url: "/HttpHandlers/RetrospectSearchHandler.ashx?method=QueryList",
                    remoteSort: false,
                    frozenColumns: [[
                        { field: 'OneBarCode', title: '塑件条码', width: 150 },
                        { field: 'PrintType', title: '打印方式', width: 100 },
                        { field: 'CreateTime', title: '打印时间', width: 150 }
                    ]],
                    columns: [[
                        {
                            field: 'InspectionResult1', title: '塑件质检结果', width: 150,
                            //formatter: function (value) {
                            //    if (value == null) {
                            //        return "合格";
                            //    }  else {
                            //        return value;
                            //    }
                            //}
                        },
                        { field: 'BadPosition1', title: '塑件缺陷位置', width: 150 },
                        { field: 'BadReason1', title: '塑件缺陷原因', width: 150 },
                        {
                            field: 'CreateTime1', title: '塑件质检时间', width: 150,
                            formatter: function (value) {
                                if (value == "0001-01-01 00:00:00") {
                                    return "";
                                } else if (value == null) {
                                    return "";
                                } else {
                                    return value;
                                }
                            }
                        },
                        {
                            field: 'OpenDoorResult', title: '开门扫描结果', width: 150 
                        },
                        {
                            field: 'CreateTime2', title: '开门扫描时间', width: 150,
                            formatter: function (value) {
                                if (value == "0001-01-01 00:00:00") {
                                    return "";
                                } else if (value == null) {
                                    return "";
                                } else {
                                    return value;
                                }
                            }
                        },
                        {
                            field: 'InspectionResult2', title: '总成质检结果', width: 150,
                            //formatter: function (value) {
                            //    if (value == null) {
                            //        return "合格";
                            //    } else {
                            //        return value;
                            //    }
                            //}
                        },
                        { field: 'BadPosition2', title: '总成缺陷位置', width: 150 },
                        { field: 'BadReason2', title: '总成缺陷原因', width: 150 },
                        {
                            field: 'CreateTime3', title: '总成质检时间', width: 150, formatter: function (value) {
                                if (value == "0001-01-01 00:00:00") {
                                    return "";
                                } else if (value == null) {
                                    return "";
                                } else {
                                    return value;
                                }
                            }
                        },
                        {
                            field: 'ZcCode', title: '总成条码', width: 150
                            
                        },
                        {
                            field: 'CreateTime4', title: '总成条码打印时间', width: 150,
                            formatter: function (value) {
                                if (value == "0001-01-01 00:00:00") {
                                    return "";
                                } else if (value == null) {
                                    return "";
                                } else {
                                    return value;
                                }
                            }
                            
                        }
                    ]],

                    pagination: true,//表示在datagrid设置分页              
                    rownumbers: true,
                    singleSelect: true
                });

                dg.datagrid('getPager').pagination({
                    pageSize: 10,
                    pageNumber: 1,
                    pageList: [10, 20, 30, 40, 50],
                    beforePageText: '第',//页数文本框前显示的汉字   
                    afterPageText: '页    共 {pages} 页',
                    displayMsg: '当前显示 {from} - {to} 条记录   共 {total} 条记录',
                });

            });

            /****************       主要业务程序          ***************/
            //查询方法
            function SearchInfo() {

                var barcode = $('#barcode').val();
                var startTime = $('#StartTime_s').datetimebox('getValue');
                var endTime = $('#EndTime_s').datetimebox('getValue');

                var queryParams = {
                    barcode: barcode,
                    startTime: startTime,
                    endTime: endTime
                };

                dg.datagrid({
                    queryParams: queryParams
                });

                dg.datagrid('reload');

            }
        </script>
    </form>
</body>
</html>