var id = helper.request.queryString("id");
$(document).ready(function () {
    //获取知识库详情
    if (id) {
        $.ajax({
            type: "get",
            url: huayi.config.callcenter_url + "Professor/GetModel",
            async: true,
            dataType: "json",
            data: {
                token: $.cookie("token"),
                id: id,
            },
            success: function (result) {
                if (result.state.toLowerCase() == "success") {
                    var data = result.data;
                    $("#name").val(data.F_XingMing);
                    $("#address").val(data.F_DiQu);
                    $("#unit").val(data.F_DanWei);
                    $("#industry").val(data.F_HangYe);
                    $("#department").val(data.F_KeShi);
                    $("#effectiveTime").val(data.F_ShengXiaoShiJian);
                    $("#job").val(data.F_ZhiWu);
                    $("#expirationTime").val(data.F_ShiXiaoShiJian);
                    $("#phoneNumber").val(data.F_ShouJi);
                    $("#publishTime").val(data.F_FaBuShiJian);
                    $("#officePhone").val(data.F_DianHua);
                    $("#publishPersonal").val(data.F_FaBuRen);
                    $("#identifyEncoding").val(data.F_BiaoShiBianMa);
                    $("#publishUnit").val(data.F_FaBuDanWei);
                    $("#introductionFieldExpertise").val(
                        data.F_ZhuanYeLingYuJianJie
                    );

                    if (data.F_TouXiang) {
                        avatarDisplay(data.F_TouXiang);
                    }
                }
            },
        });
    }
});

// 头像展示
function avatarDisplay(data) {
    $(".imgBox").empty();
    var str =
        "<div class='imgWrapper'><img class='' with='80' height='80' src=" +
        huayi.config.callcenter_url +
        data +
        " onclick='viewImage(this)' ><div class='imgMask'><i class='fa fa-remove del_file'></i></div></div>";
    $(".imgBox").append(str);
    $("#file").val(data);
}

function viewImage(file) {
    var json = {
        title: "", //相册标题
        id: 1, //相册id
        start: 0, //初始显示的图片序号，默认0
        data: [
            //相册包含的图片，数组格式
            {
                // alt: $(file).attr("alt"),
                // pid: $(file).attr("fileId"), //图片id
                src: $(file).attr("src"), //原图地址
            },
        ],
    };
    layer.photos({
        photos: json,
        anim: 5, //0-6的选择，指定弹出图片动画类型，默认随机（请注意，3.0之前的版本用shift参数）
    });
}

$(".exportWord").click(function() {
    // var url = huayi.config.callcenter_url + "home/ExportWord?token=" + $.cookie("token");

    // 正式环境
    var url = huayi.config.callcenter_url + "Professor/ExportWord?token=" + $.cookie("token");

    url += "&id=" + id

    window.location.href = url;
})
