

layui.use(['table', 'jquery','laydate'], function () {
    var table = layui.table;
    var form = layui.form,
       layer = parent.layer === undefined ? layui.layer : parent.layer,
       $ = layui.jquery;
  
    var laydate = layui.laydate;
    //日期时间范围
    laydate.render({
        elem: '#test10'
        // , type: 'datetime'
      , range: true

    });
    //查询按钮
    $(".bthSearch").click(function () {
        LoadData($(".dayParty").val());
    });

    //今天
    $("#oneDay").click(function () {
        var dataParty = formatDate(now) + ' - ' + formatDate(now);
        $(".dayParty").val(dataParty);
        LoadData(dataParty);
    });
    //本周
    $("#oneWeek").click(function () {
        var dataParty = getWeekStartDate() + ' - ' + formatDate(now);
        $(".dayParty").val(dataParty);
        LoadData(dataParty);
    });
    //本月
    $("#oneMonth").click(function () {
        var dataParty = getMonthStartDate() + ' - ' + formatDate(now);
        $(".dayParty").val(dataParty);
        LoadData(dataParty);
    });
    //本季度
    $("#onePrient").click(function () {
        var dataParty = getQuarterStartDate() + ' - ' + formatDate(now);
        $(".dayParty").val(dataParty);
        LoadData(dataParty);
    });
    //本年
    $("#oneYear").click(function () {
        var dataParty = getYearStartDate() + ' - ' + formatDate(now);
        $(".dayParty").val(dataParty);
        LoadData(dataParty);
    });

    //加载数据
    function LoadData(dateParty) {
        $.ajax({
            url: "/Report/WorkOrderDate",
            type: "get",
            contentType: "application/json",
            dataType: "text",
            cache: false,
            data: { "NowDateTime": new Date(), "dateParty": dateParty },
            success: function (result, status) {
                if (status == "success") {
                    //  var productModelList = eval("(" + result + ")");

                    $(".layui-tab-content").empty();
                    $(".layui-tab-content").append(result);

                }
            }
        });
    }
    
    //查询按钮
    // $("#ExToExcel").click(function () {
    //     var tableName = $(".dayParty").val() + "综合报表"
    //     $('.layui-tab-content').tableExport({ type: 'excel', escape: 'false', tableName: tableName });

    // });

    LoadData($(".dayParty").val());

});