<%@ page import="java.util.Date" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<c:set var="path" value="${pageContext.request.contextPath}"/>
<%@ include file="/WEB-INF/jspf/common.jspf" %>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>申请列表</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv=X-UA-Compatible IE=EmulateIE7>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="${path}/static/js/html5shiv.min.js"></script>
    <script type="text/javascript" src="${path}/static/js/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${path}/static/js/respond.min.js"></script>
    <![endif]-->
    <script>
        var path = "${path}";
    </script>
    <style type="text/css">
        .mainDiv {
            background-color: #fff;
        }

        /**搜索区*/
        .searchDiv {
            padding-top: 5px;
            height: 30px;
        }

        .searchDiv1 {
            margin-top: 10px;
            height: 30px;
        }

        .tableDiv {
            width: 100%;
            background-color: #fff;
            margin-left: 1%;
            margin-top: -10px;
        }

        .dateSearchDiv {
            width: 29%;
        }

        .dateSearchInput {
            width: 30%;
            margin-left: 3%;
        }

        .dateLabelDiv {
            width: 30%;
            text-align: right;
        }

        .searchInput {
            width: 20%;
        }

        .searchElement {
            width: 40%;
        }

        .searchInputElement {
            width: 60%;
        }

        .labelDiv {
            padding-top: 4%;
            margin-left: 5px;
        }

        /**查询按钮组*/
        .btnsDiv {
            text-align: right;
            height: 30px;
            margin-right: 25px;
        }

        .btn {
            margin-left: 1%;
        }

        /**级联病案号内容*/
        .mouseOver {
            background-color: #708090;
            color: #FFFAFA;
        }

        .mouseOut {
            background-color: #FFFAFA;
            color: #000000;
        }

        /*模态框头*/
        .modal-header {
            background-color: #199ED8;
            text-align: center;
        }

        .loading {
            width: 160px;
            height: 56px;
            position: absolute;
            top: 50%;
            left: 50%;
            line-height: 56px;
            color: #fff;
            padding-left: 60px;
            font-size: 15px;
            background: #000;
            opacity: 0.7;
            z-index: 9999;
            -moz-border-radius: 20px;
            -webkit-border-radius: 20px;
            border-radius: 20px;
            filter: progid:DXImageTransform.Microsoft.Alpha(opacity=70);
        }
    </style>
</head>
<body>
<!--导入加载-->
<div id="loadingModel" class="modal fade" data-keyboard="false"
     data-backdrop="static" data-role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div id="loading" class="loading">加载中。。。</div>
</div>
<input type="hidden" id="checks">
<div class="main">
    <div class="headDiv">
        <div class="headSpanDiv">
            <span class="headspan">
                申请列表
            </span>
        </div>
    </div>
    <div class="mainDiv">
        <!--搜索区-->
        <div class="searchDiv">
            <div class="searchInput left" style="margin-left: 10px;">
                <div class="searchElement left">
                    <label class="labelDiv">申请人：</label>
                </div>
                <div class="searchInputElement left">
                    <input type="test" class="form-control input-sm" id="applyerSearch" maxlength="16">
                </div>
            </div>
            <div class="dateSearchDiv left">
                <div class="dateLabelDiv left">
                    <label class="labelDiv">申请日期：</label>
                </div>
                <div class="dateSearchInput left">
                    <input type="text" class="form-control input-sm" id="startTime1" placeholder="开始时间"
                           autocomplete="off">
                </div>
                <div class="dateSearchInput left">
                    <input type="text" class="form-control input-sm" id="endTime1" placeholder="结束时间"
                           autocomplete="off">
                </div>
            </div>
            <div class="searchInput left">
                <div class="searchElement left">
                    <label class="labelDiv">姓名：</label>
                </div>
                <div class="searchInputElement left">
                    <input type="test" class="form-control input-sm" id="searchName" maxlength="16">
                </div>
            </div>
            <div class="searchInput left">
                <div class="searchElement left">
                    <label class="labelDiv">申请类型：</label>
                </div>
                <div class="searchInputElement left">
                    <select class="form-control input-sm" id="searchApplyType">
                    </select>
                </div>
            </div>
        </div>
        <div class="searchDiv1">
            <div class="searchInput left" style="margin-left: 10px;">
                <div class="searchElement left">
                    <label class="labelDiv">申请状态：</label>
                </div>
                <div class="searchInputElement left">
                    <select class="form-control input-sm" id="searchApplyState">
                        <option value="">请选择</option>
                        <option value="未提交">未提交</option>
                        <option value="已提交">已提交</option>
                        <option value="已过期">已过期</option>
                    </select>
                </div>
            </div>
            <div class="searchInput left" style="margin-left: 2%">
                <button type="button" class="btn btn-sm btn-primary" onclick="refreshTable()">查询</button>
            </div>
        </div>
        <div class="btnsDiv">
            <shiro:hasPermission name="/approve/updateReturn">
                <button class="btn btn-sm btn-warning btns" data-toggle="modal" data-target="#myModal">快速归还</button>
            </shiro:hasPermission>
            <shiro:hasPermission name="/approve/updateReturn">
                <button class="btn btn-sm btn-warning btns" data-toggle="modal" data-target="#myBorrowing">快速借阅
                </button>
            </shiro:hasPermission>
            <shiro:hasPermission name="/approve/addApplyApprove">
                <button type="button" class="btn btn-sm btn-warning btns" onclick="addApproves()" data-toggle="modal"
                        data-target="#myModal5"> + 批量申请
                </button>
            </shiro:hasPermission>
            <shiro:hasPermission name="/approve/addApplyApprove">
                <button type="button" class="btn btn-sm btn-warning btns" onclick="addApprove()" data-toggle="modal"
                        data-target="#myModal3"> + 增加
                </button>
            </shiro:hasPermission>
            <shiro:hasPermission name="/approve/deleteApproveById">
                <button type="button" class="btn btn-sm btn-primary btns" onclick="exportExcel()"><i
                        class="fa fa-reply"></i>导出
                </button>
            </shiro:hasPermission>
        </div>
        <!--数据表格-->
        <div id="tableDiv" class="tableDiv table-responsive">
            <table id="mytab" class="table text-nowrap table-bordered">
            </table>
        </div>
    </div>
</div>
<%--快速归还弹窗--%>
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title" style="font-weight: bold">
                    快速归还
                </h4>
            </div>
            <div class="modal-body">
                <form onsubmit="return false;" id="barCodeReturnTable">
                    <div class="form-group">
                        <label class="col-form-label">条形码:</label>
                        <input type="text" autofocus class="form-control" id="barCodeReturn">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="emptyForm()">取消</button>
                <button type="button" class="btn btn-primary" onclick="updateReturn()">确定</button>
            </div>
        </div>
    </div>
</div>


<%--快速借阅弹窗--%>
<div class="modal fade" id="myBorrowing" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title" style="font-weight: bold">
                    快速借阅
                </h4>
            </div>
            <div class="modal-body">
                <form onsubmit="return false;" id="borrowingTable">
                    <div class="form-group">
                        <label class="col-form-label">申请天数:</label>
                        <input type="text" autofocus class="form-control" id="effeDaysBorrowing">
                    </div>
                    <div class="form-group">
                        <label class="col-form-label">申请类型：</label>
                        <select class="form-control" id="applyTypeBorrowing" name="applyTypeBorrowing">
                        </select>
                        <div class="col-sm-1"></div>
                    </div>
                    <div class="form-group">
                        <label class="col-form-label">申请理由:</label>
                        <input type="text" autofocus class="form-control" id="applyReasonBorrowing">
                    </div>
                    <div class="form-group">
                        <label class="col-form-label">条形码:</label>
                        <input type="text" autofocus class="form-control" id="barCodeBorrowing">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="emptyBorrowingForm()">取消</button>
                <button type="button" class="btn btn-primary" onclick="fastBorrowing()">确定</button>
            </div>
        </div>
    </div>
</div>


<!-- 模态框3（Modal）添加 -->
<div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabe3" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="width:80%">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title" style="font-weight: bold">
                    申请信息
                </h4>
            </div>
            <div class="modal-body" style="height:500px">
                <form class="form-horizontal" id="form3">
                    <input type="hidden" name="formToken" id="formToken">
                    <input type="hidden" id="applyState" name="applyState" value="1">
                    <input type="hidden" id="approveId" name="id">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">有效时间：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" name="effeTime" id="effeTime"
                                       maxlength="10" autocomplete="off">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请天数：</label>
                            <div class="col-sm-7">
                                <input type="number" class="form-control input-sm input" name="effeDays" id="effeDays"
                                       oninput="if(value.length>4)value=value.slice(0,4)">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请类型：</label>
                            <div class="col-sm-7">
                                <select class="form-control input-sm input" id="applyType" name="applyType">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请模板：</label>
                            <div class="col-sm-7">
                                <select class="form-control input-sm input" id="parentId" name="parentId">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请原因：</label>
                            <div class="col-sm-7">
                                <textarea class="form-control input-sm input" id="applyReason" name="applyReason"
                                          maxlength="250"></textarea>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">关闭
                        </button>
                        <button type="button" class="btn btn-sm btn-primary" onclick="save()">
                            暂时保存
                        </button>
                        <button type="button" class="btn btn-sm btn-primary" onclick="add()">
                            确认提交
                        </button>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">病案号：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" name="inpatientNo"
                                       id="inpatientNo" onkeyup="getInpatientNoContents('inpatientNo')"
                                       onfocus="getInpatientNoContents('inpatientNo')"
                                       onblur="clearContent('inpatientNo')" maxlength="16">
                                <div id="inpatientNoDiv">
                                    <table id="inpatientNoContent_table" bgcolor="#FFFAFA" border="0"
                                           cellspacing="0" cellpadding="0">
                                        <tbody id="inpatientNoContent"></tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">患者姓名：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" name="name" id="name"
                                       onkeyup="getNameContents('name')" onfocus="getNameContents('name')"
                                       onblur="clearContent('name')" maxlength="16">
                                <div id="nameDiv">
                                    <table id="nameContent_table" bgcolor="#FFFAFA" border="0"
                                           cellspacing="0" cellpadding="0">
                                        <tbody id="nameContent"></tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">住院次数：</label>
                            <div class="col-sm-7">
                                <input type="number" class="form-control input-sm input" min="1" name="admissTimes"
                                       id="admissTimes" oninput="if(value.length>4)value=value.slice(0,4)">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">出院日期：</label>
                            <div class="col-sm-7">
                                <div class="col-sm-5" style="padding: 0!important"><input type="text"
                                                                                          class="form-control input-sm input"
                                                                                          id="startTime2"
                                                                                          name="startTime2"
                                                                                          autocomplete="off"></div>
                                <div class="col-sm-1">-</div>
                                <div class="col-sm-5" style="padding: 0!important"><input type="text"
                                                                                          class="form-control input-sm input"
                                                                                          id="endTime2" name="endTime2"
                                                                                          autocomplete="off"></div>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 模态框5（Modal）批量申请 -->
<div class="modal fade" id="myModal5" tabindex="-1" role="dialog" aria-labelledby="myModalLabe5" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="width:80%">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title" style="font-weight: bold">
                    批量申请信息
                </h4>
            </div>
            <div class="modal-body" style="height:500px">
                <form class="form-horizontal" id="form5" method="POST" enctype="multipart/form-data">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">有效时间：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" name="effeTime" id="effeTime5"
                                       maxlength="10" autocomplete="off">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请天数：</label>
                            <div class="col-sm-7">
                                <input type="number" class="form-control input-sm input" name="effeDays" id="effeDays5"
                                       oninput="if(value.length>4)value=value.slice(0,4)">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请类型：</label>
                            <div class="col-sm-7">
                                <select class="form-control input-sm input" id="applyType5" name="applyType">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请模板：</label>
                            <div class="col-sm-7">
                                <select class="form-control input-sm input" id="parentId5" name="parentId">
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请原因：</label>
                            <div class="col-sm-7">
                                <textarea class="form-control input-sm input" id="applyReason5" name="applyReason"
                                          maxlength="250"></textarea>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-sm btn-default" data-dismiss="modal">关闭
                        </button>
                        <button type="button" class="btn btn-sm btn-primary" onclick="addSimple()">
                            确认提交
                        </button>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">下载模板：</label>
                            <div class="col-sm-7">
                                <button type="button" class="btn btn-sm btn-primary"
                                        onclick="window.open('${path }/static/js/template/借阅申请模板.xls');">下载模板
                                </button>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">上传模板：</label>
                            <div class="col-sm-7">
                                <input type="file" id="upfile" name="upfile">选择模板</input>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<!-- 模态框4（Modal）查看 -->
<div class="modal fade" id="myModal4" tabindex="-1" role="dialog" aria-labelledby="myModalLabe4" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="width:80%">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    <font size="30">&times;</font>
                </button>
                <h4 class="modal-title" style="font-weight: bold">
                    申请信息
                </h4>
            </div>
            <div class="modal-body" style="height:500px">
                <form class="form-horizontal" id="form4">
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">有效时间：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" readonly id="effeTime1"
                                       maxlength="10" autocomplete="off">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请天数：</label>
                            <div class="col-sm-7">
                                <input type="number" class="form-control input-sm input" readonly id="effeDays1">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请类型：</label>
                            <div class="col-sm-7">
                                <select class="form-control input input-sm" id="applyType1" readonly>
                                    <c:forEach items="${applyTypes}" var="applyType">
                                        <option value="${applyType.code}">${applyType.name}</option>
                                    </c:forEach>
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请模板：</label>
                            <div class="col-sm-7">
                                <select class="form-control input input-sm" id="parentId1" disabled>
                                    <option value="">请选择</option>
                                    <c:forEach items="${models}" var="model">
                                        <option value="${model.id}">${model.typeName}</option>
                                    </c:forEach>
                                </select>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">申请原因：</label>
                            <div class="col-sm-7">
                                <textarea class="form-control input input-sm" id="applyReason1" readonly></textarea>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">病案号：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" id="inpatientNo1" readonly>
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">患者姓名：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" readonly id="name1">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">住院次数：</label>
                            <div class="col-sm-7">
                                <input type="number" class="form-control input-sm input" min="1" readonly
                                       id="admissTimes1">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group">
                            <label class="col-sm-4 control-label collectLabel">出院日期：</label>
                            <div class="col-sm-7">
                                <input type="text" class="form-control input-sm input" readonly id="startTime3">
                            </div>
                            <div class="col-sm-1"></div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script>
    var time = new Date().getTime();
    document.write('<script src="${path}/static/js/approveManage/approveList/approveList174.js?t=' + time + '"><\/script>')
    document.write('<script src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js?t=' + time + '"><\/script>')
    document.write('<script src="${path}/static/js/approveManage/approveList/approveSaveCommomMethod.js?t=' + time + '"><\/script>')
    document.write('<script src="${path}/static/js/recordManage/templateSearch/searchCommomMethodqf.js?t=' + time + '"><\/script>')
    document.write('<script src="${path}/static/js/dateUtil.js?t=' + time + '"><\/script>')
    document.write('<script src="${path}/static/js/commom.js?t=' + time + '"><\/script>')
</script>

<%--<script src="${path}/static/js/approveManage/approveList/approveList.js?t=" +<%=new Date().getTime() %> type="text/javascript"></script>
<script src="${path}/static/js/approveManage/approveList/approveDateCommmomMethod.js"></script>
<script src="${path}/static/js/approveManage/approveList/approveSaveCommomMethod.js?t=2"></script>
<script src="${path}/static/js/dateUtil.js"></script>--%>
</body>
</html>

