<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>推送日志明细查询</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="/metrics/css/layui.css">
<!--    <link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">-->
    <script src="/metrics/jquery.js"></script>
</head>
<body>

<form class="layui-form">
    <table class="layui-table">

        <thead>
        <tr>
            <th colspan="8">推送日志明细查询</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td align="right">开始时间</td>
            <td>
                <input type="text" class="layui-input" id="beginTime">

            </td>
            <td align="right">结束时间</td>
            <td>
                <input type="text" class="layui-input" id="endTime">
            </td>

            <td align="right">同步状态</td>
            <td>
                <select id="status" name="status" lay-verify="required">
                    <option value="">请选择</option>
                    <option value="2000">成功</option>
                    <option value="-1">调用失败</option>
                </select>
            </td>

            <td align="right" colspan="8">
                <button type="button" class="layui-btn layui-btn layui-btn-radius layui-btn-normal"
                        onclick="doSearch()">查询
                </button>
            </td>
        </tr>


        </tbody>
    </table>
</form>

<table class="layui-hide" id="testtable"  ></table>


<script src="/metrics/layui.js?v=20241120003"></script>

<script>

    var load = 0;
    var date = new Date();

    var option = {};
    option.appid = "<option value=''>请选择</option>";
    option.sp = "<option value=''>请选择</option>";
    option.spec = "<option value=''>请选择</option>";

    layui.use('form', function () {
        var form = layui.form;
        $(function () {
            getappid();
            getsp();
        });

        //appid列表
        function getappid() {

            var optionstr = option.appid;
            $.ajax({
                type: 'post',
                url: "/mis/log/getappId",
                dataType: "json",
                success: function (data) {

                    $.each(data.data, function (i, obj) {

                        optionstr += "<option value='" + obj.appid + "'>" + obj.remark + "</option>";

                    });
                    $('#appid').empty()
                    $('#appid').append(optionstr)
                    form.render("select");
                }
            });
        }



        //各种基于事件的操作，下面会有进一步介绍
    });




    function tableinit() {
        layui.use('table', function () {
            var table = layui.table;

            table.render({
                elem: '#testtable'
                ,
                height: 'full-250'
                ,
                url: '/mis/log/list/'
                ,
                page: true
                ,
                dataType: 'json'
                ,
                limit: 1000
                ,
                limits: [1000, 2000, 3000, 4000, 5000]
                ,
                where: {
                    appid: $('#appid').val(),
                    endTime: $('#endTime').val(),
                    beginTime: $('#beginTime').val(),
                    sendStatus: $('#status').val()
                }
                // ,cellMinWidth: 80 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
                ,
                cols: [
                    [ //标题栏
                        {title: '日志明细列表', colspan: 7}
                    ],
                    [
                        // {field:'msgid',  title: '序号', sort: true}
                        // ,
                        {field: 'orderNo', title: '微信订单号',   width: '10%'}
                        , {field: 'weiXiuOrderNo', title: '检测系统订单编号', sort: true,  width: 50}
                        , {field: 'requestparam', title: '请求内容', width: 50 }
                        , {field: 'response', title: '返回值', width: '10%'} //minWidth：局部定义当前单元格的最小宽度，layui 2.2.1 新增

                        , {field: 'step', title: '步数',   width: '10%'}
                        , {field: 'status', title: '状态',  width: '10%'}
                        , {field: 'create_time', title: '时间', sort: true, width: '10%'}


                    ]]


            });
            //工具栏事件

        });
    }


    /**
     * 设置时间
     */
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#beginTime' //指定元素
            , format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
            , type: 'datetime'
            ,change: function(value, date, endDate){
                $("#beginTime").val(value);
                if($(".layui-laydate").length){
                    $(".layui-laydate").remove();
                }
            }
            , value: new Date(new Date(new Date().toLocaleDateString()).getTime())
        }); //执行一个laydate实例
        laydate.render({
            elem: '#endTime' //指定元素
            , format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
            , type: 'datetime'
            ,change: function(value, date, endDate){
                $("#endTime").val(value);
                if($(".layui-laydate").length){
                    $(".layui-laydate").remove();
                }
            }
            , value: new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1)
        });
    });


    /**
     * 设置时间
     */
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#beginTime' //指定元素
            , format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
            , type: 'datetime'
            , value: new Date(new Date(new Date().toLocaleDateString()).getTime())
        }); //执行一个laydate实例
        laydate.render({
            elem: '#endTime' //指定元素
            , format: 'yyyy-MM-dd HH:mm:ss' //可任意组合
            , type: 'datetime'
            , value: new Date(new Date(new Date().toLocaleDateString()).getTime() + 24 * 60 * 60 * 1000 - 1)
        });
    });

    function doSearch() {


        var beginTime = $("#beginTime").val();
        var endTime = $("#endTime").val();

        if (beginTime.length == 0 || endTime.length == 0) {
            alert("开始时间和结束时间是必填项，请选择查询时间段")
            return
        }

        var d1 = new Date(beginTime);
        var d2 = new Date(endTime);
        var diffday = parseInt(d2 - d1) / 1000 / 60 / 60 / 24
        if (diffday < 0) {
            alert("结束时间不能小于开始时间，请重新选择查询时间")
            return
        }
        var table = layui.table;

        if (load == 0) {
            tableinit();
            load = 1;
        } else {
            table.reload('testtable', {
                url: '/mis/log/list/'
                ,
                page:{
                  curr:1
                },

                where: {
                    id: $('#id').val(),
                    endTime: $('#endTime').val(),
                    beginTime: $('#beginTime').val(),
                    status: $('#status').val(),
                    platenumber: $('#platenumber').val()
                }
            });
        }


    }


</script>

<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">同步</a>
</script>

</body>
</html>