<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('产品码查询')" />
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list col-md-offset-4">
                    <ul>
                        <li>
                            <label class="required">产品码：</label>
                            <input type="text" name="semiBarcode" id="semiBarcode" required/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="searc()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <!--                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;查询全部</a>-->
                            <!--                            <a class="btn btn-info btn-rounded btn-sm" onclick="celexport()" shiro:hasPermission="nanjing:ParaAllShow:export"><i class="fa fa-download"></i> 导出</a>-->
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table1"></table>

        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table2"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-table-export-js" />
<script th:inline="javascript">
    var prefix = ctx + "nanjing/selectParaAll";
    function searc() {
        var formData = new FormData();
        formData.append("semiBarcode",$("#semiBarcode").val());
        $.ajax({
            type: "post",
            url: prefix + "/paraAllShow",
            data: formData,
            // contentType: "application/json;charset=utf-8",
            dataType: "json",
            json: 'callback',
            processData: false,
            contentType: false,
            modalName: "产品码查询",
            success: function (json) {
                console.log(json);

                var columnsArray2 = [];
                columnsArray2.push({field : "semiBarcode",title : "产品码",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "部件码",title : "部件码",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "工位代码",title : "工位代码",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "记录时间",title : "记录时间",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "参数名称",title : "参数名称",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "实测值",title : "实测值",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "最小值",title : "最小值",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "最大值",title : "最大值",colspan: 1,rowspan: 1});
                columnsArray2.push({field : "参数状态",title : "参数状态",colspan: 1,rowspan: 1});

                var columnsArray1 = [];
                columnsArray1.push({field : "系统条码",title : "系统条码",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "semiBarcode" ,title : "产品码",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "机种类型",title : "机种类型",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "返修Y/N",title : "返修Y/N",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "合格状态",title : "合格状态",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "完成状态",title : "完成状态",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "当前工位",title : "当前工位",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "NG工位",title : "NG工位",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "标签Y/N",title : "标签Y/N",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "开始时间",title : "开始时间",colspan: 1,rowspan: 1});
                columnsArray1.push({field : "结束时间",title : "结束时间",colspan: 1,rowspan: 1});

                $('#bootstrap-table1').bootstrapTable('destroy').bootstrapTable({
                    id: "bootstrap-table1",
                    data:json.rows[1],
                    toolbar: "#toolbar",
                    singleSelect: false,
                    clickToSelect: true,
                    sortName: "recordTime",
                    sortOrder: "desc",
                    pageSize: 50,
                    pageNumber: 1,
                    pageList: "[10, 15,25, 50, All]",
                    showToggle: false,
                    showRefresh: false,
                    showColumns: false,
                    search: false,
                    pagination: true,
                    showExport: true,//工具栏上显示导出按钮
                    exportOptions: {
                        ignoreColumn: false  //忽略第一列和最后一列
                    },
                    // exportDataType: 'all',
                    columns: columnsArray1
                });

                $('#bootstrap-table2').bootstrapTable('destroy').bootstrapTable({
                    id: "bootstrap-table2",
                    data:json.rows[0],
                    toolbar: "#toolbar",
                    singleSelect: false,
                    clickToSelect: true,
                    sortName: "insertTime",
                    sortOrder: "desc",
                    pageSize: 50,
                    pageNumber: 1,
                    pageList: "[10, 15,25, 50, All]",
                    showToggle: false,
                    showRefresh: false,
                    showExport:true,
                    showColumns: false,
                    search: false,
                    pagination: true,
                    exportOptions: {
                        ignoreColumn: false  //忽略第一列和最后一列
                    },
                    // exportDataType: 'all',
                    columns: columnsArray2
                });
            },
            error: function () {
                alert("查询失败!");
            }
        });
    }

    function celexport(formId) {
        table.set();
        var formData = new FormData();
        $.modal.confirm("确定导出所有数据吗？", function() {
            // var currentId = $.common.isEmpty(formId) ? $('form').attr('id') : formId;
            // var params = $("#" + table.options.id).bootstrapTable('getOptions');
            // var dataParam = $("#" + currentId).serializeArray();
            // dataParam.push({ "name": "orderByColumn", "value": params.sortName });
            // dataParam.push({ "name": "isAsc", "value": params.sortOrder });
            formData.append("semiBarcode",$("#semiBarcode").val());
            console.log(formData.get("semiBarcode"));
            $.modal.loading("正在导出数据，请稍后...");
            $.ajax({
                type: "post",
                url: prefix + "/export",
                data: formData,
                // contentType: "application/json;charset=utf-8",
                dataType: "json",
                json: 'callback',
                processData: false,
                contentType: false,
                success: function(result) {
                    if (result.code == web_status.SUCCESS) {
                        window.location.href = ctx + "common/download?fileName=" + encodeURI(result.msg) + "&delete=" + true;
                    } else if (result.code == web_status.WARNING) {
                        $.modal.alertWarning(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                }
            });
        });
    }

</script>
</body>
</html>