var year = new Date().getFullYear();
$(function() {
    // 公用方法，根据当前年月动态将13个月push数组
    month_method();
    // 公用方法，月份下拉框
    // select_option();
    // 回显当前年月份
    // $(".div-month select").val(initDate);
    $.jeDate("#month_date_from", {
        isinitVal: true,
        format: 'YYYY/MM' // 分隔符可以任意定义，该例子表示只显示年月
    });
    $.jeDate("#month_date_to", {
        isinitVal: true,
        format: 'YYYY/MM' // 分隔符可以任意定义，该例子表示只显示年月
    });

    $("#month_date_from").val("2018-04");
    $("#month_date_to").val(getCurrentTimeFormat());


    $("#searchbtn").on("click", function() {
        var s_s = $("#start-score").val();
        var e_s = $("#end-score").val();
        var m_s = $("#month_number").val();
        if (!isRealNum(s_s) || !isRealNum(e_s) || !isRealNum(m_s)) {
            layer.msg('参数有错误！');
            return;
        }
        getscore($("#month_date_from").val(), $("#month_date_to").val(), m_s, s_s, e_s);
    });


    getscore("2018-04", moment(moment().format("YYYY-MM")).subtract(1, "month").format("YYYY-MM"), 3, 985, 1000);



});




function getscore(starttime, endtime, limitnumber, limitscore, limitscore2) {

    var data_p = {
        "start_date": moment(starttime + "-25 23:00:00").valueOf(),
        "end_date": moment(endtime + "-25 23:00:00").valueOf(),
        "limitnumber": limitnumber,
        "limitscore": limitscore,
        "limitscore2": limitscore2
    };

    //获取该人员排班
    var url = "f/statistics/user/score";

    post_common_service(url, data_p, function(data) {

        var table = '';
        // $("#totlapeople").html(data.length);
        for (var i in data) {
            var ss = data[i];
            var dat = "";
            for (var j in ss.fwqStatistics) {
                var po = ss.fwqStatistics[j];
                dat += po.p_str + "月、";
            }
            dat = dat.substring(0, dat.length - 1);
            table += "<tr><td width='5%;'>" + (parseInt(i) + 1) + "</td><td width='15%;'><a href='JavaScript:void(0)' onclick='jumpuser(\"" + ss.dept_id + "\")'>" + ss.dept + "</a></td><td width='60%;'>" + dat + "</td></tr>";
        }
        $(".table-tbody").html(table);
        $('[data-toggle="tooltip"]').tooltip();
        $("tr:gt(0):odd").css("background", "#EFEFEF");

    });

}

function jumpuser(deptid) {


    var param = {
        "parent_dept_id": GV("#center-manager"),
        "dept_id": GV("#fsList"),
        "start_date": $("#start-time").val(),
        "end_date": $("#end-time").val(),
        "start_num": $("#start-num").val(),
        "end_num": $("#end-num").val(),
        "start_score": $("#start-score").val(),
        "end_score": $("#end-score").val(),
        "job_select": $("#jobSelect").val()
    }
    $.zui.store.set('store_param_' + current_url, param);

    url = "/fwq/view/statistics/service_area_data_statistics.html?deptid=" + deptid + "&jump=1"

    isnew = false;
    changePage(url);

}