<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<c:set var="ctx" value="${pageContext.request.contextPath}"  scope="request"/>
<c:set var="resourcePath" value="${ctx}/resources"  scope="request"/>

<link rel="shortcut icon" href="${resourcePath}/images/logo.png"/>
<link rel="icon" href="${resourcePath}/images/logo.png"/>

<style>
    .layui-inline {
        margin-bottom: 10px !important;
    }
    .layui-layer-dialog{
        position: fixed;
        top: 200px !important;
    }
    .layui-table-cell {
        font-size: 13px;
        font-weight: 500;
    }
</style>

<script type="text/javascript">
	var ctx = "${ctx}";	//上下文路径
	var resourcePath = "${resourcePath}";
	//var resourcePath = resourcePath+"/manage";
	document.writeln('<script type="text/javascript" src="'+resourcePath+'/js/global.js?d=' + new Date().getTime() + '" ><\/script>');
</script>

<script>MICROANSWER_DROPDOWAN="mDropdown";</script>
<script type="text/javascript">
    // 内部包含有 box-sizing: border-box, 宽度会包含padding，导致layui的label显示异常
   	// requireCss('css/bootstrap.min.css');
   	requireCss("css/font-awesome.min.css");
   	requireCss("css/animate.css");
   	requireCss("css/reset.css");
    requireCss("layuiadmin/layui/css/layui.css");
   	requireCss("css/pagination.css");
   	require("js/bootstrap.min.js");
    require("layuiadmin/layui/layui.js");
   	require("js/jquery.serializejson.min.js");
   	require("js/ySelect.js");
   	require("js/utils/StringUtil.js");
   	require("js/utils/DialogUtil.js");
    require("js/utils/DateUtil.js");
    require("js/jquery.table2excel.js");

	function serialize(form) {
	    var serializeArray = form.serializeArray();
	    var result = [];
	    $.each(serializeArray, function(index, item) {
            result[item.name] = item.value;
        });
        return result;
    }
    function serializeObj(form) {
        var serializeArray = form.serializeArray();
        var result = {};
        $.each(serializeArray, function(index, item) {
            result[item.name] = item.value;
        });
        return result;
    }

    function null2Zero(src) {
        if (src == null) {
            return 0.0
        } else {
            return src
        }
    }

    function getDictText(value,obj,type) {
        var dictText = "";
        $.each(obj,function (k,v) {
            if (type === 'id'){
                if(v.id === value){
                    dictText = v.name;
                }
            } else if (type === 'value'){
                if(v.value === value){
                    dictText = v.name;
                }
            } else if (type === 'code'){
                if(v.code === value){
                    dictText = v.name;
                }
            } else if (type === 'roleCode'){
                if(v.roleCode === value){
                    dictText = v.roleName;
                }
            }
        })
        if(dictText == ""){
            dictText = "全部"
        }
        return dictText;
    }

    $(document).ready(function() {
        //条件搜索框点击收缩隐藏
        $(".collapse").click(function() {
            $(this).find("i").toggleClass("fa-angle-double-down");
            $($(".toolbar-body")[0]).slideToggle();
        });
    })

    $.ajaxSetup({
        beforeSend: function (xhr) {
            let token = localStorage.getItem("token");
            let userId = localStorage.getItem("userId");
            xhr.setRequestHeader("token", token);
            xhr.setRequestHeader("userId", userId);
        }
        , complete: function (xhr, textStatus) {
            try {
                let response = JSON.parse(xhr.responseText);
                if (response.code == 401) {
                    localStorage.removeItem("token");
                    localStorage.removeItem("userId");
                    window.location.href = ctx + "/login";
                }
            } catch (e) {

            }
        }
    })

</script>
<script>
    layui.config({
        base: '${resourcePath}/layuiExtension/' //假设这是你存放拓展模块的根目录
    }).extend({
        index: 'lib/index' //主入口模块
    })
</script>