let form, layer;
$(function () {
    let obj = localStorage.getItem("downEvaluateInfo");
    setParams(obj);
})


function setParams(obj) {
    objParam = JSON.parse(obj);
    $('#title').html(objParam.proName + objParam.subName + objParam.teamName + "评价表");
    $('#subName').html(objParam.subName);
    $('#teamName').html(objParam.teamName);
    $('#userName').html(objParam.userName);
    layui.use(['form', 'layer'], function () {
        form = layui.form;
        layer = layui.layer;
        form.verify();
        form.on('submit(formData)', function (data) {
            submitApply(data);
        });
        form.render();
        getDataDetails();
    });
}
// 评价详情
function getDataDetails() {
    $.ajax({
        url: `${ctxPath}` + '/backstage/teamEvaluate/getEvaluateData?id=' + objParam.id,
        type: 'GET',
        dataType: "JSON",
        success: function (result) {
            console.error(result)
            if (result.res === 1) {
                setFormData(result.obj);
            }
        }
    });

    // 表单赋值
    function setFormData(obj) {
        let mark = obj.mark;
        let markArr = mark.split('@@');
        for (let i = 0; i < markArr.length; i++) {
            $('#mark' + (i + 1)).html(markArr[i]);
        }
        $('.level').html("");
        $('#level1').html("");
        $('#level2').html("");
        $('#level3').html("");
        $('#level4').html("");
        $('#level' + obj.level).html("✔");
        $('#manager').html(obj.manager);
        $('#evaluateTime').html(obj.evaluateTime);
    }
}

function print() {
    Print('#main-box', {
        onStart: function () {
            console.log('onStart', new Date())
        },
        onEnd: function () {
            console.log('onEnd', new Date())
        }
    })
}

// 下载
function download() {
    let token = localStorage.getItem("token");
    window.location.href = `${ctxPath}` + '/backstage/teamEvaluate/exportByDoc?id=' + objParam.id + '&token=' + token;
}

// 关闭页面
function closePage(type) {
    let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
    if (type === 1) {
        window.parent.reloadTreeTable();
    }
    parent.layer.close(index); // 再执行关闭
}