<%@ page contentType="text/html;charset=UTF-8" language="java" import="java.util.*" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<%
    ResourceBundle res = ResourceBundle.getBundle("config.jdbc");
%>
<html>
<head>
    <title>首次签收超期列表</title>
    <meta charset="utf-8">
    <meta name="referrer" content="never">
    <!-- 解决部分兼容性问题，如果安装了GCF，则使用GCF来渲染页面，如果未安装GCF，则使用最高版本的IE内核进行渲染。 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <!-- 页面按原比例显示 -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <%@include file="../../jspf/comm.jspf" %>
    <%@ include file="../../jspf/ztreeCommom.jsp" %>

    <style>
        .modal-header2 {
            text-align: center !important;
            vertical-align: middle !important;
            background-color: #3c8dbc !important;
            color: #fff;
            font-size: 16px;
            font-weight: bold;
            padding: 5px 5px 5px 5px !important;
        }

        .modal-dialog {
            position: fixed;
        !important;
            top: 0px;
        !important;
            left: 0px;
        !important;
        }

        .modal-footer {
            padding: 5px;
        }

        .divCss {
            margin-top: 5px;
        }

        .divCss2 {
            margin-top: 5px;
            margin-left: 20px;
        }


        .divCss8 {
            margin-top: 5px;
            margin-right: 20px;
        }

        .divCss3 {
            margin-top: 5px;
            margin-left: 20px;
            color: blue;
        }

        .modal-content {
            width: 165%; /*width: 1300px;*/
            overflow-x: hidden;
            overflow-y: auto;

        }

        .modal {
            margin-left: -39%;
            overflow-x: auto;
            /*z-index: 1049;*/
        }

        .divCss4 {
            border-top: 1px solid #e5e5e5;
            width: 97.5%;
            margin-top: 10px;
            margin-bottom: 5px;
        }

        .labCss {
            /*color: gainsboro;*/
            color: #c1c3c4;
        }

        .titleCss {
            text-align: left;
            vertical-align: middle;
            background-color: #3c8dbc;
            color: #fff;
            font-size: 19px;
            font-weight: bold;
            height: 30px;
            margin-bottom: 10px;
        }

        .treeBtn {
            margin-top: 10px;
            margin-left: 10px;
            margin-right: 10px;
        }

        .zTreeDemo {
            height: auto;
            min-height: 350px;
        }

        .divCss5 {
            border-left: 2px solid #e5e5e5;
            height: auto;
            min-height: 350px;
        }

        .btnGroupCss {
            text-align: right;
        }

        /* dataTables表头居中 */
        .table > thead:first-child > tr:first-child > th {
            text-align: center !important;
        }

        #assortModal > div > div {
            margin-top: 50%;
            margin-left: 60%;
            width: 500px;
        !important;
        }

        #exampleModal > div > div {
            margin-top: 50%;
            margin-left: 70%;
            width: 400px;
        !important;
        }

        #delPdfModal > div > div {
            margin-top: 50%;
            margin-left: 60%;
            width: 400px;
        !important;
        }

        #tsPdfModal > div > div {
            margin-top: 50%;
            margin-left: 60%;
            width: 400px;
        !important;
        }

        .imgDivCss {
            min-height: 400px !important;
        }

        .showImg {
            width: 80%;
            height: 100%
        }

        .shadeImg {
            height: 950px;
        }

        #firstModal .modal-content {
            margin-left: 20%;
            margin-top: 0%;
            width: calc(180%);
        }

        #returnModal .modal-content {
            margin-left: 3%;
            margin-top: 35%;
            width: 160%;
        }

        #returnModal2 .modal-content {
            margin-left: 30%;
            margin-top: 35%;
            width: 120%;
        }

        #backDivs {
            border-top: 1px dashed #3c8dbc;
        }

        .table th {
            text-align: center;
        }

        #tableBack td {
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        .divCss7 {
            color: blue;
        }

        #delPdfPageModal2 > div > div {
            margin-top: 20%;
            margin-left: 60%;
            width: 400px;
        !important;
        }

        .toolbarCss {
            margin-right: 20px;
            margin-bottom: 0px;
        !important;
        }

        .fixed-table-toolbar .bs-bars .pull-right {
            height: 20px;
        !important;
        }

        /*选中行颜色*/
        .fixed-table-container tbody .selected td {
            background-color: #9acfea;
        }
    </style>
</head>

<body>


<div style="margin-left:30px;margin-right:10px;height:auto">

    <!--搜索-->
    <form style="margin-top:20px;" onkeydown="enter()">
        <div class="form-inline">
            <div hidden="hidden">
                <label for="id">病案号:</label>
                <input type="text" class="input-sm form-control" id="id" placeholder="请输入病案号">
            </div>
            <div class="form-group divCss8">
                <label for="inpNo">住院号:</label>
                <input type="text" class="input-sm form-control" id="inpNo" placeholder="请输入住院号">
            </div>
            <div class="form-group divCss8">
                <label for="visitId">住院次数:</label>
                <input type="number" class="input-sm form-control" id="visitId" placeholder="请输入次数">
            </div>
            <div class="form-group divCss8">
                <label for="name">姓名:</label>
                <input type="text" class="input-sm form-control" id="name" placeholder="请输入姓名">
            </div>
            <div class="form-group divCss8" id="deptDiv" style="height: 18px;margin-top: -7px;">
                <label>入院科室 :</label>
                <select class="selectpicker bla bla bli" multiple data-live-search="true" name="deptAdmissionTo"
                        data-actions-box="true" data-deselect-all-text="取消全选" data-select-all-text="全选" data-none-results-text="没找到相应记录{0}" title="请输入入院科室"
                        id="deptAdmissionTo" title="请输入入院科室">
                    <option value="">全部</option>
                </select>
            </div>
            <div class="form-group divCss8">
                <label>出院科室 :</label>
                <select class="selectpicker bla bla bli" multiple data-live-search="true" name="deptName" id="deptName"
                        data-actions-box="true" data-deselect-all-text="取消全选" data-select-all-text="全选" data-none-results-text="没找到相应记录{0}" title="请输入出院科室">
                    <option value="">全部</option>
                </select>
            </div>
            <div class="form-group divCss8">
                <label>出院日期：</label>
                <div class="input-daterange input-group">
                    <input type="text" class="input-sm form-control" name="start" id="startDate"/>
                    <span class="input-group-addon">-</span>
                    <input type="text" class="input-sm form-control" name="end" id="endDate"/>
                </div>
            </div>
            <div class="form-group divCss8">
                <label>初审日期：</label>
                <div class="input-daterange input-group">
                    <input type="text" class="input-sm form-control" name="start" id="createTimeStart"/>
                    <span class="input-group-addon">-</span>
                    <input type="text" class="input-sm form-control" name="end" id="createTimeEnd"/>
                </div>
            </div>
            <div class="form-group divCss8">
                <label>超期天数></label>
                <input type="text" class="input-sm form-control" id="overdueDays" placeholder="请输入超期天数">
            </div>
            <%--<div class="form-group divCss">
                <label>是否死亡:</label>
                <select class="input-sm form-control" id="deathFlag">
                    <option value="">全部</option>
                    <option value="0">否</option>
                    <option value="1">是</option>
                </select>
            </div>--%>
            <button type="button" class="btn btn-primary btn-sm divCss" id="searchBtn">查询</button>
            <button type="button" class="btn btn-info btn-sm divCss" id="excelBtn">条件导出</button>

        </div>
    </form>
    <!--数据表格-->
    <table id="table" class="table  text-nowrap table-striped"></table>
    <div id="toolbar" class="btn-group pull-right toolbarCss" >
        <div class="columns columns-right btn-group pull-right" style="margin-top:0px;">
            <div class="btn-group btn-info">
                <select id="sel_exportoption" class="form-control">                
                    <option value="">导出当前页面数据</option>
                                   
                    <option value="all">导出全部数据</option>
                                 
                    <option value="selected">导出选中数据</option>
                </select>
            </div>
            <button class=" btn btn-success" style="height: 34px" type="button" id="refreshBtn" name="refresh"
                    aria-label="Refresh"
                    title="Refresh">
                <i class="glyphicon glyphicon-refresh icon-refresh"></i>
            </button>
        </div>
    </div>
</div>


<%--<div id="modal">--%>
<%--<div class="mask"></div>--%>
<%--<!-- 这里开始才是真正的内容 -->--%>
<%--<div class="dialog"></div>--%>
<%--</div>--%>

<!-- 模态框3（Modal）查看档案 -->
<div class="modal fade" id="selModal" tabindex="1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="left:20%;top:5px;">
        <div class="modal-content">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">
                    病历清单
                </h4>
            </div>
            <div class="modal-body divCss2">
                <!--通过审批且未过期的patientId集合-->
                <form class="form-horizontal" id="form1">
                    <div class="row">
                        <div class="row divCss3">病历信息</div>
                        <div class="row divCss2">
                            <div class="col-sm-5" hidden>
                                病案号：<label id="idLab" class="labCss"></label><label id="assortId" hidden></label>
                            </div>
                            <div class="col-sm-3">
                                住院号：<label id="inLab" class="labCss"></label>
                            </div>

                            <div class="col-sm-4">
                                住院次数：<label id="inTimeLab" class="labCss"></label>
                            </div>
                            <div class="col-sm-4">
                                姓名：<label id="nameLab" class="labCss"></label>
                            </div>


                        </div>
                        <div class="row divCss2">
                            <div class="col-sm-3"><input type="text" id="outDateLab" hidden/>
                                入院科室：<label id="deptToLab" class="labCss"></label>
                            </div>
                            <div class="col-sm-4">
                                入院日期：<label id="inDateLab" class="labCss"></label>
                            </div>
                            <div class="col-sm-4" id="recallDiv">
                                退回管理:
                                <button type="button" class="btn btn-danger btn-sm" id="getRecallBtn">退回查看</button>
                            </div>
                            <div class="col-sm-4"><input type="text" id="outDeptLab" hidden/>
                                出院科室：<label id="outDeptToLab" class="labCss"></label>
                            </div>
                            <div class="col-sm-4">
                                出院日期：<label id="outDeptDateLab" class="labCss"></label>
                            </div>
                            <%--<div class="col-sm-3">--%>
                            <%--完整性审核：--%>
                            <%--</div>--%>
                            <div class="col-sm-3" id="firstDiv">
                                初审管理:
                                <button type="button" class="btn btn-danger btn-sm" id="getFirstBtn">初审查看</button>
                            </div>
                        </div>
                        <div class="row divCss2">
                            <%--<div class="col-sm-4">--%>
                            <%--离院方式：<label id="outHospLab" class="labCss"></label>--%>
                            <%--</div>--%>
                            <%--<div class="col-sm-5">--%>
                            <%--主管医生：<label id="chargeLab" class="labCss"></label>--%>
                            <%--</div>--%>
                            <div class="col-sm-2">
                                完整性审核：
                            </div>
                            <div class="col-sm-10" style="margin-left: -70px" id="wzContent">
                                地三生三世所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所所
                            </div>
                        </div>
                        <%--<div class="row divCss2">--%>
                        <%--&lt;%&ndash;<div class="col-sm-4">&ndash;%&gt;--%>
                        <%--&lt;%&ndash;离院方式：<label id="outHospLab" class="labCss"></label>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;<div class="col-sm-5">&ndash;%&gt;--%>
                        <%--&lt;%&ndash;主管医生：<label id="chargeLab" class="labCss"></label>&ndash;%&gt;--%>
                        <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
                        <%----%>
                        <%--</div>--%>
                    </div>


                    <div class="divCss4"></div>
                    <div class="row">
                        <div class="row divCss3 ">病历清单</div>
                        <div class="col-sm-3 divCss2">
                            <div class="row titleCss"></div>
                            <div class="row">
                                <div class="col-sm-9">
                                    <input type="text" id="key" value="" class="input-sm form-control empty"
                                           placeholder="分段名称"/>
                                </div>
                                <button type="button" class="btn btn-primary btn-sm" id="searchBtn1">查询</button>
                            </div>
                            <div class="row">
                                <button type="button" class="btn  btn-success btn-sm treeBtn" onclick="expandAll();">
                                    全部展开
                                </button>
                                <button type="button" class="btn  btn-success btn-sm treeBtn" onclick="collapseAll();">
                                    全部收缩
                                </button>
                            </div>
                            <div class="row">
                                <!--树-->
                                <div class="zTreeDemo" id="foo">
                                    <ul id="ztree" class="ztree"></ul>
                                </div>
                            </div>
                        </div>
                        <div class="col-sm-8 divCss5">
                            <div class="row btnGroupCss">
                                <button type="button" class="btn btn-danger btn-sm" id="addPdfBtn">添加pdf</button>
                                <button type="button" class="btn btn-default btn-sm" id="uploadBtn">上传文件</button>
                                <button type="button" class="btn btn-info btn-sm" id="pdfBtn">查看分段PDF</button>
                                <button type="button" class="btn btn-success btn-sm" id="pdfBtn2">查看PDF</button>
                                <%--<button type="button" class="btn btn-primary btn-sm" id="addBtn">添加清单</button>--%>
                                <button type="button" class="btn btn-warning btn-sm" id="updateStateBtn">选中作废</button>
                                <button type="button" class="btn btn-primary btn-sm" id="updateStateBtn2">选中使用</button>
                            </div>
                            <div class="row">
                                <!--数据表格-->
                                <table id="table2" class="table  text-nowrap  table-striped"></table>
                                <div id="toolbar2" class="btn-group pull-left" style="margin-right: 20px;">
                                    <div class="columns columns-left btn-group pull-left" style="margin-top:0px;">
                                        <input type="checkbox" id="flag" value="1"
                                               style="margin-left: 20px;">只显示作废</input>
                                        <%--<button class=" btn btn-success btn-sm" style="height: 34px" type="button"--%>
                                        <%--id="refreshBtn2" name="refresh" aria-label="Refresh"--%>
                                        <%--title="Refresh">--%>
                                        <%--<i class="glyphicon glyphicon-refresh icon-refresh"></i>--%>
                                        <%--</button>--%>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<%--退回弹窗--%>
<div class="modal fade" id="returnModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">退回信息</h4>
            </div>
            <div class="modal-body divCss2">
                <div class="row" id="backDiv" style="margin-right: 2px">
                    <!--数据表格-->
                    <table id="tableBack" class="table text-nowrap table-striped" style="table-layout:fixed"></table>
                </div>
                <div class="row" id="backDivs">
                    <span style="color: blue;">退回信息</span>
                    <!--通过审批且未过期的patientId集合-->
                    <form class="form-horizontal " id="form2">
                        <div class="row"><input id="backArchiveId" hidden>
                            <%--<div class="row divCss3 ">退回信息</div>--%>
                            <div class="row" style="margin-left: 30px;">
                                <div class="row " hidden>
                                    <span style="vertical-align:center;">病案评分：</span>
                                    <input id="score" type="number" class="input-sm "/> 分
                                </div>
                                <div class="row ">
                                    <span style="vertical-align:top;">退回内容：</span>
                                    <textarea id="backContent" rows="6" style="width:80%;"></textarea>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="row" id="backDivsStaff">
                    <span style="color: blue;">备注信息</span>
                    <!--通过审批且未过期的patientId集合-->
                    <form class="form-horizontal " id="formStaff" style="margin-left: 13px;">
                        <div class="row ">
                            <span style="vertical-align:top;">护士备注：</span>
                            <textarea id="nuresText" rows="6" style="width:82.5%;" readonly></textarea>
                        </div>
                        <div class="row ">
                            <span style="vertical-align:top;">医生备注：</span>
                            <textarea id="doctorText" rows="6" style="width:82.5%;" readonly></textarea>
                        </div>
                    </form>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <%--<button type="button" class="btn btn-primary btn-sm" id="returnBtn">确认</button>--%>
            </div>
        </div>
    </div>
</div>

<%--缺陷详情弹窗--%>
<div class="modal fade" id="qxModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">缺陷信息</h4>
            </div>
            <div class="modal-body">
                <div class="row" style="margin-left:5px;">
                    <div class="col-sm-4"><input id="qxId" hidden/>
                        病案退回：<label id="backPerson" class="labCss"></label>
                    </div>
                    <div class="col-sm-4">
                        处理否：<label id="dealFlag" class="labCss"></label>
                    </div>
                    <div class="col-sm-3">
                        处理人：<label id="dealPerson" class="labCss"></label>
                    </div>

                </div>
                <div class="row" style="margin-left:5px;margin-top:5px;">
                    <div class="col-sm-4">
                        处理日期：<label id="dealTime" class="labCss"></label>
                    </div>
                </div>
                <%--<div class="row divCss2">--%>
                <%--<span style="vertical-align:top;">缺陷类型：</span>--%>
                <%--<input type="text" id="assortName" readonly/>--%>
                <%--</div>--%>
                <div class="row" style="margin-left:5px;margin-top:5px;">
                    <div class="col-sm-8">
                        选项：<select class="input-sm " disabled style="min-width: 500px" id="faultType">
                        <%--<option value="非类型">非类型</option>--%>
                        <%--<option value="">全部</option>--%>
                    </select>
                    </div>
                </div>
                <%--<div class="row divCss2">--%>
                <%--<span class="divCss7">选项：</span>--%>
                <%--<div class="divCss4" id="faultTypeDiv">--%>
                <%--&lt;%&ndash;<div class="row " style="width:600px">&ndash;%&gt;--%>
                <%--&lt;%&ndash;<label class="col-xs-6"><input name="Fruit" type="checkbox" value=""/>苹果 </label>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<label class="col-xs-6"><input name="Fruit" type="checkbox" value=""/>桃子 </label>&ndash;%&gt;--%>
                <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<div class="row " style="width:600px">&ndash;%&gt;--%>
                <%--&lt;%&ndash;<label class="col-xs-6"><input name="Fruit" type="checkbox" value=""/>苹果水电费是否是的范德萨</label>&ndash;%&gt;--%>
                <%--&lt;%&ndash;<label class="col-xs-6"><input name="Fruit" type="checkbox" value=""/>桃子</label>&ndash;%&gt;--%>
                <%--&lt;%&ndash;</div>&ndash;%&gt;--%>
                <%--</div>--%>
                <%--</div>--%>
                <div class="row divCss2">
                    <span style="vertical-align:top;">内容：</span>
                    <textarea id="content" rows="10" style="width:90%;" readonly></textarea>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info btn-sm" id="dealBtn" hiddendata-dismiss="modal">已处理</button>
                <button type="button" class="btn btn-warning btn-sm" id="dealNoBtn" data-dismiss="modal">未处理</button>
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>

<!-- 模态框3（Modal）分段信息 -->
<div class="modal fade" id="assortModal" tabindex="2" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title">
                    病历清单详情
                </h4>
            </div>
            <div class="modal-body">
                <!--通过审批且未过期的patientId集合-->
                <%--<form class="form-horizontal" id="logForm">--%>
                <input type="hidden" id="inpId" name="inpId">
                <div class="row divCss8">
                    <div class="form-group"><input id="fileUrlInp" hidden/>
                        <label class="col-sm-3 control-label">标题：</label>
                        <div class="col-sm-7">
                            <input type="text" class="input-sm form-control" id="inpTitle" name="inpTitle">
                        </div>
                    </div>
                </div>
                <div class="row divCss8">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">类型：</label>
                        <div class="col-sm-6">
                            <%--<input type="text" class="input-sm form-control"  id="inpType" name="inpType">--%>
                            <select class="input-sm form-control" id="inpType">

                            </select>
                        </div>
                    </div>
                </div>
                <div class="row divCss8">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">页码：</label>
                        <div class="col-sm-6">
                            <input type="number" class="input-sm form-control" id="pageNumber" name="pageNumber">
                        </div>
                    </div>
                </div>
                <div class="row divCss8">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">来源：</label>
                        <div class="col-sm-6">
                            <input type="text" class="input-sm form-control" readonly id="inpSource" name="inpSource">
                        </div>
                    </div>
                </div>
                <div class="row divCss8">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">状态：</label>
                        <div class="col-sm-3">
                            <select class="input-sm form-control" id="inpFlag">
                                <option value="0">使用</option>
                                <option value="1">作废</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="row divCss8">
                    <div class="form-group">
                        <label class="col-sm-3 control-label">上传pdf：</label>
                        <div class="col-sm-9">
                            <input type="text" id="pdfPathVal" readonly
                                   style="width:100%;background-color: #eee"></input>
                            <%--<a href="javascript:void(0);" target="_self" id="previewFile" style="display:none">预览</a>--%>
                            <div id="upPdfDiv">
                                <form action="path/uploadPDF1" id="formUpload" enctype="multipart/form-data"
                                      method="post">
                                    <input id="addFile" class="inp_file" type="file" accept="application/pdf"
                                           name="addFile"
                                           size="chars">
                                    <%--<iframe id="pdf_page" name="pdf_page" style="width:1500px;height:640px">--%>
                                    <%--</iframe>--%>
                                </form>
                            </div>

                        </div>
                        <%--<div class="col-sm-1"></div>--%>
                    </div>
                </div>
                <%--</form>--%>
            </div>
            <div class="modal-footer">

                <button type="button" class="btn btn-primary btn-sm" id="saveBtn">保存</button>
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">关闭</button>

            </div>
        </div>
    </div>
</div>
<%--多图片框--%>
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog"
     aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content enterCss">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">手动上传扫描病历（图片上传）</h4>
            </div>
            <div class="modal-body">
                <form id="filesUpload" style="margin-top:20px;" method="POST" enctype="multipart/form-data">
                    <div class="imgDivCss" id="divImg">
                        <%--<form>--%>

                        <%--<p class="form-group">--%>
                        <%--<h3>Bootstrap File Input Demo1</h3>--%>
                        <%--</p>--%>


                        <%--<input name="uploadFile" type="file" id="uploadFile" multiple class="file-loading"/>--%>

                        <%--</form>--%>

                        <div class="form-inline">
                            <div class="form-group divCss">
                                <label for="inpGl">归类 :</label>
                                <select class="input-sm form-control" id="inpGl">
                                    <option value="非类型">非类型</option>
                                    <option value="">全部</option>
                                    <%--<option value="在院">在院</option>--%>
                                    <%--<option value="未归档">未归档</option>--%>
                                    <%--<option value="归档中">归档中</option>--%>
                                    <%--<option value="初审">初审</option>--%>
                                    <%--<option value="已认证">已认证</option>--%>
                                    <%--<option value="已归档">已归档</option>--%>
                                </select>
                            </div>
                            <button type="button" class="btn btn-primary btn-sm divCss" id="imgBtn">查询</button>
                            <%--<button type="button" class="btn btn-info btn-sm divCss" id="imgsBtn">批量上传</button>--%>
                            <%--<button type="button" class="btn btn-danger btn-sm divCss" id="imgsDelBtn">批量删除</button>--%>
                            <button type="button" class="btn btn-warning btn-sm divCss" id="imgsSaveBtn">保存</button>
                            <a href="javascript:;" class="a-upload btn btn-info btn-sm">
                                <input type="file" name="myFile" id="myFile" multiple="multiple" accept="image/*"
                                       hidden/>选择文件
                            </a>

                        </div>

                        <div class="img_div"></div>

                        <div class="shade" onclick="javascript:closeShade()">
                            <div class=""><span class="text_span"></span>
                            </div>
                        </div>
                        <%--<div class="shadeImg"  onclick="javascript:closeShadeImg()">--%>
                        <%--<div class="">--%>
                        <%--<img class="showImg" src=""/>--%>
                        <%--</div>--%>
                        <%--</div>--%>

                    </div>
                </form>
                <%--<div id="handout_wrap_inner"><input id="tsInfo" type="text" style="border:none" size="100" readonly/></div>--%>
                <%--<iframe id="pdf_page" name="pdf_page" data-target="_bank" style="width:100%;height:100%"></iframe>--%>
            </div>
            <%--<div class="modal-footer">--%>
            <%--<button type="button" class="btn btn-default btn-sm"--%>
            <%--data-dismiss="modal">返回--%>
            <%--</button>--%>
            <%--</div>--%>
        </div>
    </div>
</div>
<%--发大弹窗--%>
<div class="modal fade" id="maxImg" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
            </div>
            <div class="modal-body" STYLE="height: 950px">
                <div class="shadeImg" onclick="javascript:closeShadeImg()">
                    <div class="">
                        <img class="showImg" src=""/>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
            </div>
        </div>
    </div>
</div>
<%--确认框--%>
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title" id="exampleModalLabel">确认作废</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <input type="hidden" id="idT" name="idT" value=""/>
                        <label class="control-label">作废该分段记录吗？</label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary btn-sm" id="stateBtn">确认</button>
            </div>
        </div>
    </div>
</div>


<%--初审核弹窗--%>
<div class="modal fade" id="firstModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">初审信息</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group ">
                        <input id="archiveId2" hidden/>
                        <span style="vertical-align:top;">初审内容：</span>
                        <textarea rows="8" style="width:90%;" readonly="readonly" maxlength="255"
                                  id="firstTrial"></textarea>
                    </div>
                    <div class="form-group  ">
                        <span style="vertical-align:top;">护士备注：</span>
                        <textarea id="nuresText2" rows="8" style="width:90%;" readonly></textarea>
                    </div>
                    <div class="form-group  ">
                        <span style="vertical-align:top;">医生备注：</span>
                        <textarea id="doctorText2" rows="8" style="width:90%;" readonly></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <%--<button type="button" class="btn btn-primary btn-sm" id="verifyBtn">通过</button>--%>
            </div>
        </div>
    </div>
</div>

<%--确认框--%>
<div class="modal fade" id="delPdfModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">确认</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <input type="hidden" id="idPdfT" name="idPdfT" value=""/>
                        <label class="control-label">是否删除该记录？</label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary btn-sm" id="statePdfBtn">确认</button>
            </div>
        </div>
    </div>
</div>

<%--确认框--%>
<div class="modal fade" id="tsPdfModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">确认</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label class="control-label">是否替换原有的PDF文件？</label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary btn-sm" id="thPdfBtn">确认</button>
            </div>
        </div>
    </div>
</div>


<%--删除pdf某页弹窗--%>
<div class="modal fade" id="delPdfPageModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
                <h4 class="modal-title">PDF页信息</h4>
            </div>
            <div class="modal-body divCss2">
                <form>
                    <div class="form-group ">
                        <input id="pdfId" hidden/>
                        <span style="vertical-align:top;">pdf路径：</span>
                        <textarea rows="6" style="width:85%;" readonly id="pathPdf"></textarea>
                    </div>
                    <div class="form-group ">
                        <span style="vertical-align:top;">删除页码：</span>
                        <input type="number" id="pagePdf"/>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary btn-sm" id="delPageBtn">确认</button>
            </div>
        </div>
    </div>
</div>


<%--删除pdf某页确认框--%>
<div class="modal fade" id="delPdfPageModal2" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content ">
            <div class="modal-header2">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">×</span></button>
                <h4 class="modal-title">确认</h4>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label class="control-label">如果删除将不可恢复,是否删除？</label>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default btn-sm" data-dismiss="modal">返回</button>
                <button type="button" class="btn btn-primary btn-sm" id="delPageBtn2">确认</button>
            </div>
        </div>
    </div>
</div>

</body>

<script type="text/javascript">
    var tipLoad = 1;
    //创建数组保存图片
    var files = new Array();
    var id = 0;
    var backFlagVal;

    function getFaultType() {
        //获取科室列表
        $.ajax({
            url: "${path}/lastVerify/getFaultType",
            type: "POST",
            data: {effective: 1},
            success: function (result) {
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        $("#faultType").append("<option value=" + result[i].id + ">" + result[i].typeName + "(" + result[i].price + "分)" + "</option>");
                    }
                    // var html = '';
                    // var num = 0;
                    // for (var i = 0; i < result.length; i++) {
                    //     if (num == 0) {
                    //         html += '<div class="row" ><label class="col-xs-4"><input name="Fruit" type="checkbox" disabled="disabled" value="' + result[i].id + '">' + result[i].typeName + '</label>';
                    //         num = 1;
                    //     } else if (num == 1) {
                    //         html += '<label class="col-xs-4"><input name="Fruit" type="checkbox" disabled="disabled" value="' + result[i].id + '">' + result[i].typeName + '</label>';
                    //         num = 2;
                    //     } else if (num == 2) {
                    //         html += '<label class="col-xs-3"><input name="Fruit" disabled="disabled" type="checkbox" value="' + result[i].id + '">' + result[i].typeName + '</label></div>';
                    //         num = 0;
                    //     }
                    // }
                    // $("#faultTypeDiv").append(html);
                }
            }
        });
    }

    getFaultType();

    function dealFun(id) {
        //处理信息
        $.ajax({
            url: "${path}/fault/dealFault",
            type: "POST",
            data: {id: id},
            success: function (result) {
                if (result.indexOf("成功") != -1) {
                    toastr.success(result);
                } else if (result.indexOf("失败") != -1) {
                    toastr.error(result);
                } else {
                    toastr.warning(result);
                }
                $("#qxModal").modal('hide');
                //刷新
                $('#tableBack').bootstrapTable('refresh');

            }
        });
    }

    $(function () {
        var objUrl;
        var img_html;

        $("#myFile").change(function () {
            var img_div = $(".img_div");
            var filepath = $("input[name='myFile']").val();
            //获取所有图片
            var fileALL = this.files;
            for (var i = 0; i < fileALL.length; i++) {
                //把图片存到数组中
                files[id] = fileALL[i];
                id++;
                //获取图片路径
                objUrl = getObjectURL(fileALL[i]);
                var extStart = filepath.lastIndexOf(".");
                var ext = filepath.substring(extStart, filepath.length).toUpperCase();
                /**
                 *描述：鉴定每个图片上传尾椎限制
                 */

                if (ext != ".BMP" && ext != ".PNG" && ext != ".GIF" && ext != ".JPG" && ext != ".JPEG") {
                    toastr.warning("图片限于png,gif,jpeg,jpg格式");
                    //$(".shade").fadeIn(500000000);//500
                    //$(".text_span").text("图片限于bmp,png,gif,jpeg,jpg格式");
                    // this.value = "";
                    //$(".img_div").html("");
                    return false;
                } else {
                    /**
                     *若规则全部通过则在此提交url到后台数据库
                     */
                    // if (objUrl.indexOf(".") != -1) {
                    //     img_html = "<div class='isImg' id='-1'><img src='require(" + objUrl + ")' id='" + fileALL[i].name + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' />"
                    // } else {
                    img_html = "<div class='isImg' id='-1'><img src='" + objUrl + "' id='" + fileALL[i].name + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' />"
                    //}
                    img_html += selectStr
                        + " <button class='removeBtn' onclick='javascript:removeImg(this)'>x</button></div>";
                    img_div.append(img_html);
                    // img_html = "<div class='isImg' id='-1'><img src='" + objUrl + "' id='" + fileALL[i].name + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' />"
                    //     + selectStr
                    //     + " <button class='removeBtn' onclick='javascript:removeImg(this)'>x</button></div>";
                    // img_div.append(img_html);
                }
            }
            /**
             *描述：鉴定每个图片大小总和
             */
            var file_size = 0;
            var all_size = 0;
            for (j = 0; j < fileALL.length; j++) {
                file_size = fileALL[j].size;
                all_size = all_size + fileALL[j].size;
                var size = all_size / 1024;
                if (size > 500000000) {//500
                    //$(".shade").fadeIn(500);
                    //$(".text_span").text("上传的图片大小不能超过100k!");
                    toastr.warning("上传的图片大小不能超过10000000k!");
                    this.value = "";
                    $(".img_div").html("");
                    return false;
                }
            }
            /**
             *描述：鉴定每个图片宽高 以后会做优化 多个图片的宽高 暂时隐藏掉 想看效果可以取消注释就行
             */
            // var img = new Image();
            // img.src = objUrl;
            // img.onload = function() {
            // 	if (img.width > 100 && img.height > 100) {
            //      toastr.warning("图片宽高不能大于一百!");
            // 		$("#myFile").val("");
            // 		$(".img_div").html("");
            // 		return false;
            // 	}
            // }
            return true;
        });

        /**
         *描述：鉴定每个浏览器上传图片url 目前没有合并到Ie,返回值为blob的url
         */
        function getObjectURL(file) {
            var url = null;
            if (window.createObjectURL != undefined) { // basic
                url = window.createObjectURL(file);
            } else if (window.URL != undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file);
            } else if (window.webkitURL != undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file);
            }
            //console.log(url);
            return url;
        }

        //blob转base64
        function blobToDataURL(blob) {
            var a = new FileReader();
            a.readAsDataURL(blob);//读取文件保存在result中
            a.onload = function (e) {
                var getRes = e.target.result;//读取的结果在result中
            }

        }
    });

    /**
     * 描述：上传图片附带删除 再次地方可以加上一个ajax进行提交到后台进行删除
     */
    function removeImg(r) {
        //获取data中的图片名
        var filename = $(r).siblings("img").attr('id');

        //删除父节点
        $(r).parent().remove();
        var fileList = Array.from(files);
        //遍历数组
        for (var j = 0; j < fileList.length; j++) {
            //通过图片名判断图片在数组中的位置然后删除
            // console.log(fileList[j].name + "111");
            if (fileList[j].name == filename) {
                fileList.splice(j, 1);
                id--;
                break;
            }
        }
        files = fileList;
        var id = $(r).parent().attr('id');
        var maxPicture = $(r).siblings("img").attr('src');


        if ($(r).parent().attr('id') != -1) {
            var target = document.getElementById('filesUpload');
            spinner.spin(target);//给id为foo的div 中绑上spinner
            $.ajax({
                url: "${path}/inHosp/delImg",
                type: "POST",
                data: {id: id, maxPicture: maxPicture},
                success: function (result) {
                    spinner.spin();
                    if (result.indexOf("成功") != -1) {
                        //刷新
                        $('#table2').bootstrapTable('refresh');
                        initTree($("#idLab").html());
                        toastr.success(result);
                    } else {
                        toastr.error(result);
                    }
                }, error: function () {
                    //toastr.error("加载失败!");
                }
            });
        }
    }

    /**
     * 描述：上传图片附带放大查看处理
     */
    function lookBigImg(b) {
        $('#maxImg').modal({
            backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
            keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
            show: true//弹出对话框
        });

        $(".shadeImg").fadeIn(500);
        $(".showImg").attr("src", $(b).attr("src"));

    }

    /**
     * 描述：关闭弹出层
     */
    function closeShade() {
        // $(".shade").fadeOut(500);
    }

    /**
     *描述：关闭弹出层
     */
    function closeShadeImg() {
        // $(".shadeImg").fadeOut(500);
    }

    //初始化类别
    var selectStr = "";

    function getAssortFun() {
        $.ajax({
            url: "${path}/zdAssort/getAssort",
            type: "POST",
            //data: {patientId: $("#idLab").html()},
            async: true,
            success: function (result) {
                if (result.length > 0) {
                    if (result != null) {
                        selectStr = "<select class='selectB'>";
                        for (i = 0; i < result.length; i++) {
                            selectStr += "<option value=" + result[i].assortId + ">" + result[i].assortName + "</option>";
                            $("#inpGl").append("<option value=" + result[i].assortId + ">" + result[i].assortName + "</option>");
                            $("#inpType").append("<option value=" + result[i].assortId + ">" + result[i].assortName + "</option>");
                        }
                        selectStr += " </select>";
                    }
                }
            }, error: function () {
                //toastr.error("加载失败!");
            }
        });


    }

    getAssortFun();

    var opts = {
        lines: 13, // The number of lines to draw |小长条的数量
        length: 20, // The length of each line |小长条的长度
        width: 5, // The line thickness |小长条的宽度
        // left: "50%",
        radius: 15, // The radius of the inner circle |内环的半径长
        corners: 1, // Corner roundness (0..1)
        rotate: 0, // The rotation offset |旋转角度
        direction: 1, // 1: clockwise, -1: counterclockwise |1：顺时针方向 -1：逆时针方向
        color: '#000', // #rgb or #rrggbb or array of colors |颜色
        speed: 1, // Rounds per second |每秒转多少圈
        trail: 60, // Afterglow percentage |余晖效果百分比
        shadow: false, // Whether to render a shadow |渲染阴影
        hwaccel: false, // Whether to use hardware acceleration |加速
        className: 'spinner', // The CSS class to assign to the spinner |类名spinner
        zIndex: 2e9, // The z-index (defaults to 2000000000) |显示在最顶层
        top: '70%', // Top position relative to parent in px |相对父元素的top
        //left: '90' // Left position relative to parent in px |相对父元素的left ，默认情况spinner是显示于父元素居中位置

    };
    var spinner = new Spinner(opts);

    var url = "";

    function uploadFileAndDate() {
        var formData = new FormData();
        formData.append('file', $('#addFile')[0].files[0]);
        formData.append('fileName', $("#outDateLab").val());
        formData.append('id', $("#inpId").val());
        formData.append('masterID', $("#idLab").html());
        formData.append('assortID', $("#inpType").val());
        formData.append('title', $("#inpTitle").val());
        if ($("#pageNumber").val() < 1) {
            $("#pageNumber").val(1);
        }
        formData.append('pageNumber', $("#pageNumber").val());
        formData.append('source', $("#inpSource").val());
        formData.append('flag', $("#inpFlag").val());
        formData.append('sys', "emr_medical_record");
        $.ajax({
            url: "${path}/inHosp/uploadPdf2",
            scriptCharset: "UTF-8",
            contentType: "application/x-www-form-urlencoded; charset=UTF-8",
            type: 'POST',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            success: function (result) {
                if (result.indexOf("文件") == -1) {
                    toastr.success("操作成功!");
                    $('#addFile').attr("src", result);
                    url = result;
                    $('#previewFile').css("display", "block");//显示预览按钮
                } else {
                    toastr.warning(result);
                }
                $('#assortModal').modal('hide');  //手动关闭
                //刷新
                $('#table2').bootstrapTable('refresh');
                initTree($("#idLab").html());

            }, error: function (result) {
                $('#assortModal').modal('hide');  //手动关闭
                toastr.success("操作成功!");
                //$('#addFile').attr("src", $("#outDateLab").val() + ".pdf");//.val($("#outDateLab").val()+".pdf");
                //toastr.error("上传PDF失败!");
                //刷新
                $('#table2').bootstrapTable('refresh');
                initTree($("#idLab").html());
            }
        });
    }

    function uploadFileFun() {
        if ($('#addFile')[0].files[0] != undefined) {
            if ($('#addFile')[0].files[0].size > 0) {
                //新增或修改
                uploadFileAndDate();
            } else {
                toastr.warning("文件为空!");
            }
        } else {
            if ($('#pdfPathVal').val() == null || $('#pdfPathVal').val() == "") {
                toastr.warning("请选择文件!");
            } else {
                //修改
                uploadFileAndDate();
            }
        }
    }

    function blobToDataURL(blob, callback) {

        var a = new FileReader();

        a.onload = function (e) {

            callback(e.target.result);

        }

        a.readAsDataURL(blob);

    }

    function blobToFile(blob, fileName) {
        blob.lastModifiedDate = new Date();
        blob.name = fileName;
        return blob;
    }

    function imgSelectFun() {
        var img_div = $(".img_div");
        if ($("#inpGl").val() != "非类型") {
            var target = document.getElementById('divImg');
            spinner.spin(target);//给id为foo的div 中绑上spinner
            var data = {};
            data.relationId = $("#idLab").html();
            data.assortId = $("#inpGl").val();
            $.ajax({
                url: "${path}/inHosp/getPicList",
                type: "post",
                data: data,
                success: function (result) {
                    if (result != null) {
                        img_div.empty();
                        for (var i = 0; i < result.length; i++) {
                            /**
                             *若规则全部通过则在此提交url到后台数据库
                             */
                                //selectStr= selectStr.replace(result[i].assortId+'\"','\" selected');
                            var fileName = result[i].maxPicture.split("\\");
                            if (result[i].maxPicture.indexOf("..") != -1) {
                                img_html = "<div class='isImg' id='" + result[i].id + "'><img src='" + result[i].maxPicture + "' id='" + fileName[fileName.length - 1] + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' />"
                                    + selectStr//+"<label  class='oldSel' id='oldSel"+i+"' value='"+result[i].assortId+"' hidden></label>"
                                    + " <button class='removeBtn' onclick='javascript:removeImg(this)'>x</button></div>";
                            } else {
                                var reg = /\\/g;
                                var path = "getImg2?path=" + (result[i].maxPicture).replace(reg, "/");
                                //path= "getImg2?path=C:/Users/Administrator/Desktop/测试/lunfan4.jpg";
                                //console.log((result[i].maxPicture).replace(reg, "/"));
                                img_html = "<div class='isImg' id='" + result[i].id + "'><img src='" + path + "' id='" + fileName[fileName.length - 1] + "' onclick='javascript:lookBigImg(this)' style='height: 100%; width: 100%;' />"
                                    + selectStr//+"<label  class='oldSel' id='oldSel"+i+"' value='"+result[i].assortId+"' hidden></label>"
                                    + " <button class='removeBtn' onclick='javascript:removeImg(this)'>x</button></div>";

                            }
                            img_div.append(img_html);
                            img_div.find("select").eq(i).val(result[i].assortId);
                        }
                    } else {
                        toastr.success("暂无数据!");
                    }
                    spinner.spin();

                },
                error: function () {
                    toastr.error("获取图片列表失败!");
                }
            });
        } else {
            img_div.empty();
        }

    }

    $("#imgBtn").click(function () {
        //console.log("===查询图片列表===");
        //var target = document.getElementById('filesUpload');
        imgSelectFun();

    });

    $("#imgsSaveBtn").click(function () {
        //console.log("===保存图片===");

        var fileArr = [];
        var b = 0;
        //获取图片src和下拉框值
        var div_p = $(".img_div").children();
        var div_data = div_p.children();
        if (div_data != null)
            for (var i = 0; i < div_data.length; i++) {
                if (div_data[i].getAttribute('src') != null && div_data[i].getAttribute('src') != "") {
                    // console.log("第" + (i + 1) + "个的src=" + div_data[i].getAttribute('src'));
                    //obj.fileSrc= div_data[i].getAttribute('src');
                    //obj.fileSrc = obj.fileSrc;
                    //var s=new File([obj.fileSrc], "a"+i+".jpg");
                    //files.push(s);
                    //console.log(obj.fileSrc);
                }
                if (div_data[i].value != null && div_data[i].value != "") {
                    var obj = {};
                    //console.log("第select" + (i + 1) + "个的value=" + div_data[i].value);
                    obj.selectVal = div_data[i].value;
                    if (b < div_data.length / 2) {
                        obj.id = div_p[b].id;
                        b++;
                    }
                    fileArr.push(obj);

                }

                // if (div_data[i].id.indexOf("oldSel")!=-1) {
                //     console.log("第Lable" + (i + 1) + "html=" + div_data[i].getAttribute('value'));
                // }

            }

        if (fileArr.length > 0) {
            //创建FormData根据form
            var uploadFile = new FormData($("#filesUpload")[0]);
            uploadFile.append('fileName', $("#outDateLab").val());
            uploadFile.append('masterID', $("#idLab").html());
            uploadFile.append("list", JSON.stringify(fileArr));
            //console.log(fileArr);
            //遍历图片数组把图片添加到FormData中
            for (var i = 0; i < files.length; i++) {
                uploadFile.append("imgs", files[i]);
            }
            if ("undefined" != typeof (uploadFile) && uploadFile != null && uploadFile != "") {
                var target = document.getElementById('filesUpload');
                spinner.spin(target);//给id为foo的div 中绑上spinner
                //通过ajax上传
                $.ajax({
                    url: "${path}/inHosp/uploadImgS",
                    type: "post",
                    data: uploadFile, //把FormData作为参数
                    contentType: false, //不设置内容类型
                    processData: false, //不处理数据
                    success: function (data) {
                        //刷新当前类别
                        imgSelectFun();

                        initTree($("#idLab").html());

                        if (data.indexOf("成功") != -1) {
                            toastr.success(data);
                        } else if (data.indexOf("成功") != -1) {
                            toastr.error(data);
                        } else {
                            toastr.warning(data);
                        }
                        files = new Array();
                    },
                    error: function () {
                        toastr.error("批量上传失败!");
                    }
                });

                spinner.spin();
            }
        } else {
            toastr.warning("请选择上传的图片!");
        }


    });

    $("#pdfBtn").click(function () {
        //上传后预览pdf文件
        //生成pdf返回url
        var masterId = $("#idLab").html();
        if (masterId != "" && masterId != null) {
            var imgStr = "";
            var zTree = $.fn.zTree.getZTreeObj("ztree");//换成实际的图层的id
            var changedNodes = zTree.getChangeCheckedNodes(); //获取改变的全部结点
            for (var i = 0; i < changedNodes.length; i++) {
                var treeNode = changedNodes[i];
                if (treeNode.id != 0) {
                    imgStr += treeNode.id + ",";
                }
            }
            //判断id
            if (imgStr == null || imgStr == '') {
                toastr.warning("请选择分段类别!");
                return;
            }
            //打开一个不被拦截的新窗口
            var newWindow = window.open();
            var titleName=document.getElementById("nameLab").innerText;
            $.ajax({
                url: "${path}/inHosp/getPdfToPdf",
                type: "POST",
                data: {masterId: masterId, imgStr: imgStr},
                success: function (result) {
                    if (result != "") {
                        //绝对路径
                        var pdfPath = result;
                        newWindow.location.href = "${path}/static/pdfjs/web/viewer.html?file=" + encodeURIComponent("${path}/inHosp/pdfStreamHandeler?url=" + pdfPath+"?titleName="+titleName);
                        //相对路径
                        <%--var pdfUrl = "${path}/static/pdfjs/web/viewer.html?file=../../../static/img/pdfFiles/" + result;//+ result;--%>
                        <%--newWindow.location.href = pdfUrl;--%>
                    } else {
                        newWindow.close();//此处为ajax失败方法，自动关闭刚才会打开的页面
                        toastr.warning("勾选的PDF文件不存在或破损!");
                    }
                }, error: function (result) {
                    newWindow.close();//此处为ajax失败方法，自动关闭刚才会打开的页面
                    toastr.error("操作失败!");
                }
            });
        } else {
            toastr.warning("病案不存在!");
        }
    });


    $("#pdfBtn2").click(function () {
        //选中批量使用
        var idStr = "";
        var getSelectRows = $("#table2").bootstrapTable('getSelections');
        if (getSelectRows.length > 0) {
            for (var i = 0; i < getSelectRows.length; i++) {
                idStr += getSelectRows[i].id + ",";
            }
        } else {
            toastr.warning("请选择记录!");
            return;
        }
        //上传后预览pdf文件,根据id直接获取pdf并合成
        //打开一个不被拦截的新窗口
        var newWindow = window.open();
        var titleName=document.getElementById("nameLab").innerText;
        $.ajax({
            url: "${path}/inHosp/getPdfById",
            type: "POST",
            data: {idStr: idStr},
            success: function (result) {
                if (result != "") {
                    //绝对路径
                    var pdfPath = result;
                    newWindow.location.href = "${path}/static/pdfjs/web/viewer.html?file=" + encodeURIComponent("${path}/inHosp/pdfStreamHandeler?url=" + pdfPath+"?titleName="+titleName);
                    //相对路径
                    <%--var pdfUrl = "${path}/static/pdfjs/web/viewer.html?file=../../../static/img/pdfFiles/typesPdf/" + result;//+ result;--%>
                    <%--newWindow.location.href = pdfUrl;--%>

                } else {
                    newWindow.close();//此处为ajax失败方法，自动关闭刚才会打开的页面
                    toastr.warning("勾选的PDF文件不存在或破损!");
                }
            }, error: function (result) {
                newWindow.close();//此处为ajax失败方法，自动关闭刚才会打开的页面
                toastr.error("操作失败!");
            }
        });
    });


    $("#uploadBtn").click(function () {
        $("#inpGl").val("非类型");
        $(".img_div").html("");
        files = new Array();
        // console.log("批量上传图片模态框");
        $('#pdfModal').modal({
            backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
            keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
            show: true//弹出对话框
        });
    });


    $('#addFile').on('change', function () {
        //判断文件类型，并上传pdf
        //uploadFileFun();
    });

    $("#previewFile").on('click', function () {
        //上传后预览pdf文件
        var fileUrl = $("#fileUrlInp").val();
        //console.log(fileUrl);
        var pdfUrl = "${path}/static/pdfjs/web/viewer.html?file=" + fileUrl;
        if (fileUrl != null && fileUrl != "") {
            window.open(pdfUrl, 'PDF', 'width:50%;height:50%;top:100;left:100;');

        }
    });
    $(function () {
        //日期控件
        $(".input-daterange").datepicker({
            format: "yyyy-mm-dd",
            language: "zh-CN"
        });

        var url = window.location.href;
        var index = url.substring(url.lastIndexOf('?') + 1).replace("num=", "");

        if (index != null && index != "" && index.indexOf("excel") != -1) {
            $("#excelBtn").show();
            $("#toolbar").show();
        } else {
            $("#excelBtn").hide();
            $(".columns-right").hide();
        }
        if (index != null && index != "" && index.indexOf("upload") != -1) {
            $("#uploadBtn").show();
        } else {
            $("#uploadBtn").hide();
        }
        if (index != null && index != "" && index.indexOf("addPdf") != -1) {
            $("#addPdfBtn").show();
        } else {
            $("#addPdfBtn").hide();
        }
        if (index != null && index != "" && index.indexOf("pdf") != -1) {
            $("#pdfBtn").show();
        } else {
            $("#pdfBtn").hide();
        }
        if (index != null && index != "" && index.indexOf("pdf2") != -1) {
            $("#pdfBtn2").show();
        } else {
            $("#pdfBtn2").hide();
        }
        if (index != null && index != "" && index.indexOf("cancelAll") != -1) {
            $("#updateStateBtn").show();
        } else {
            $("#updateStateBtn").hide();
        }
        if (index != null && index != "" && index.indexOf("useAll") != -1) {
            $("#updateStateBtn2").show();
        } else {
            $("#updateStateBtn2").hide();
        }

        // var deptAdmissionTo = url.substring(url.lastIndexOf('&') + 1).replace("depts=", "");
        // if (deptAdmissionTo == null || deptAdmissionTo == '') {
        //     $('#deptDiv').show();
        // } else {
        //     $('#deptDiv').hide();
        // }

    });


    function getDept() {
        //获取科室列表
        $.ajax({
            url: "${path}/inHosp/getDept",
            type: "POST",
            data: {effective: 1, typecode: "dept_code"},
            success: function (result) {
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        $("#deptName").append("<option value=" + result[i].code + ">" + result[i].name + "</option>");
                        $("#deptAdmissionTo").append("<option value=" + result[i].code + ">" + result[i].name + "</option>");

                    }
                }
                $(".selectpicker").selectpicker('refresh');
            }
        });
    }

    getDept();

    //处理导出内容,这个方法可以自定义某一行、某一列、甚至某个单元格的内容,也就是将其值设置为自己想要的内容
    function DoOnCellHtmlData(cell, row, col, data) {
        if (row == 0) {
            return data;
        }

        //由于备注列超过6个字的话,通过span标签处理只显示前面6个字,如果直接导出的话会导致内容不完整,因此要将携带完整内容的span标签中title属性的值替换
        if (col == 4 || col == 11 || col == 7) {
            var spanObj = $(data);//将带 <span title="val"></span> 标签的字符串转换为jQuery对象
            var title = spanObj.attr("title");//读取<span title="val"></span>中title属性的值
            //var span = cell[0].firstElementChild;//读取cell数组中的第一个值下的第一个元素
            if (typeof (title) != 'undefined') {
                return title;
            }
        }

        return data;
    }

    /**
     * 根据两个日期，判断相差天数
     * @param sDate1 开始日期 如：2016-11-01
     * @param sDate2 结束日期 如：2016-11-02
     * @returns {number} 返回相差天数
     */
    function daysBetween(sDate1, sDate2) {
        //Date.parse() 解析一个日期时间字符串，并返回1970/1/1 午夜距离该日期时间的毫秒数
        var time1 = Date.parse(new Date(sDate1));
        var time2 = Date.parse(new Date(sDate2));
        var nDays = Math.abs(parseInt((time2 - time1) / 1000 / 3600 / 24));
        return nDays;
    };

    function show() {
        var mydate = new Date();
        var str = "" + mydate.getFullYear() + "-";
        str += (mydate.getMonth() + 1) + "-";
        str += mydate.getDate() + "";
        return str;
    }

    function initTable() {
        if (tipLoad == 1) {
            $("#table").bootstrapTable({ // 对应table标签的id
                //method: 'POST',
                url: "${path}/medicalOverdue/medicalOverdueList", // 获取表格数据的url
                contentType: "application/x-www-form-urlencoded",//一种编码。好像在post请求的时候需要用到。这里用的get请求，注释掉这句话也能拿到数据
                //dataField: "data",//这是返回的json数组的key.默认是"rows".这里只有前后端约定好就行
                cache: false, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
                striped: true,  //是否显示行间隔色
                pagination: true, // 在表格底部显示分页组件，默认false
                paginationShowPageGo: true,
                pageList: [10, 20, 50, 100], // 如果设置了分页，设置可供选择的页面数据条数。设置为All 则显示所有记录。
                smartDisplay: false,
                pageSize: 2, // 页面数据条数
                pageNumber: 1, // 初始化加载第一页，默认第一页
                sidePagination: 'server', // 设置为服务器端分页     客户端：client
                search: false,
                showColumns: true,
                // sortable: true,
                // sortOrder: "asc",
                toolbar: '#toolbar',//指定工具栏
                searchOnEnterKey: true, //设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
                undefinedText: '---', //当数据为 undefined 时显示的字符
                singleSelect: false,//设置True 将禁止多选
                clickToSelect: true,//设置true 将在点击行时，自动选择rediobox 和 checkbox
                //height: 560,     //定义表格的高度。
                searchTimeOut: 500,// 默认500  设置搜索超时时间。
                toolbarAlign: 'right',// 指定 toolbar 水平方向的位置。'left' 或 'right'
                paginationDetailHAlign: 'left',//指定 分页详细信息 在水平方向的位置。'left' 或 'right'。
                showHeader: true,//是否显示列头。
                trimOnSearch: true,//设置为 true 将自动去掉搜索字符的前后空格。
                //是否显示导出按钮
                showExport: true,
                //导出表格方式（默认basic：只导出当前页的表格数据；all：导出所有数据；selected：导出选中的数据）
                exportDataType: "basic",
                //导出文件类型
                exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
                exportOptions: {
                    fileName: document.title
                },
                // showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
                // cardView: false,                    //是否显示详细视图
                // detailView: false,                   //是否显示父子表
                queryParams: function (params) {
                    var currPageSize = this.pageSize;
                    if (currPageSize == 2) {
                        currPageSize = 10;
                    }
                    var limit = null;
                    var offset = params.offset;
                    //判断是否导出全部all
                    if ($("#sel_exportoption").val() == "all") {
                        offset = 0;
                        limit = this.totalRows;
                        this.pageSize = limit;
                    } else {
                        limit = currPageSize;
                        this.pageSize = currPageSize;
                    }

                    var deptName = $("#deptName").val().toString();
                    if (deptName.indexOf("") != -1 && deptName.length<=0) {
                        deptName = "";
                    }

                    var deptAdmissionTo = $("#deptAdmissionTo").val().toString();
                    if (deptAdmissionTo.indexOf("") != -1 && deptAdmissionTo.length<=0) {
                        deptAdmissionTo = "";
                    }


                    var temp = {
                        limit: limit,     //页面大小
                        offset: offset,   //页码
                        // order: params.order,      //排位命令（desc，asc）
                        // id: $("#id").val(),
                        // idNo: $("#idNo").val(),
                        inpNo: "" + $("#inpNo").val(),
                        visitId: "" + $("#visitId").val(),
                        name: "" + $("#name").val(),
                        deptName: deptName.toString(),
                        deptAdmissionTo: deptAdmissionTo.toString(),
                        startDate: $("#startDate").val(),
                        endDate: $("#endDate").val(),
                        createTimeStart: $("#createTimeStart").val(),
                        createTimeEnd: $("#createTimeEnd").val(),
                        deathFlag: $("#deathFlag").val(),
                        overdueDays: $("#overdueDays").val()
                    };

                    return temp;
                },
                sortName: 'id', // 要排序的字段
                sortOrder: 'desc', // 排序规则
                columns: [{
                    title: '全选',
                    field: 'select',   //复选框
                    checkbox: true,
                    width: 25,
                    align: 'center',
                    valign: 'middle',

                }, {
                    title: '病案清单id',
                    field: 'id',
                    align: 'left',
                    valign: 'middle',
                    visible: false
                },
                    {
                        title: '住院号',
                        field: 'inpNo',
                        align: 'left',
                        valign: 'middle',
                    },
                    {
                        title: '住院次数',
                        field: 'visitId',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '姓名',
                        field: 'name',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '入院科室',
                        field: 'deptAdmissionTo',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '入院日期',
                        field: 'admissionDateTime',
                        align: 'center',
                        visible: false,
                        formatter: function (value, row, index) {
                            var result = "";
                            if (value != null && value != "") {
                                result = value.substring(0, 10);
                            }
                            return result;
                        }
                    },
                    {
                        title: '出院科室',
                        field: 'deptName',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '出院日期',
                        field: 'dischargeDateTime',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var result = "";
                            if (value != null && value != "") {
                                result = value.substring(0, 19);
                            }
                            return result;
                        }
                    },
                    {
                        title: '科室提交',
                        field: 'createTime',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var result = "";
                            if (value != null && value != "") {
                                result = value.substring(0, 19);
                            }
                            return result;
                        }
                    },
                    {
                        title: '初审人',
                        field: 'firstInstance',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '主管医生',
                        field: 'doctorInCharge',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '是否死亡',
                        field: 'deathFlag',
                        align: 'center',
                        formatter: function (value, row, index) {
                            var result = "";
                            var days;//当天-出院-7
                            if (row.dischargeDateTime != null && row.dischargeDateTime != "") {
                                days = daysBetween(show(), row.dischargeDateTime.split(" ")[0]);
                            }
                            //死亡否
                            var deathExpired = <%=res.getString("deathExpired")%>;
                            if (value != null && value != "" && value == 0) {
                                result = '<span style="color:green;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>否</span>'
                            } else {
                                if (days > deathExpired) {
                                    var day = days - deathExpired;
                                    result = '<span style="color:red;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>是</span>';
                                } else {
                                    result = '<span style="color:red;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>是</span>';
                                }
                            }
                            return result
                        }
                    },
                    {
                        title: '间隔天数',
                        field: 'overdue',
                        align: 'center',
                        valign: 'middle',
                    },
                    {
                        title: '超期天数',
                        field: 'overdue',
                        align: 'center',
                        valign: 'middle',
                        formatter: function (value, row, index) {
                            var overdueDays=$("#overdueDays").val();
                            if(overdueDays!=null && overdueDays>0){
                                return row.overdue-overdueDays;
                            }else{
                                return row.overdue;
                            }
                        }
                    },
                ],
                onLoadSuccess: function (result) {  //加载成功时执行
                    // console.info("加载成功");
                    tipLoad = 0;
                },
                onLoadError: function () {  //加载失败时执行
                    //console.info("加载数据失败");
                    tipLoad = 0;
                }

            });
        }
    }

    var idArr = [];
    var flag = 0;

    function initTable2() {
        idArr = [];
        $("#table2").bootstrapTable({ // 对应table标签的id
            //method: 'POST',
            url: "${path}/inHosp/getAssortdetail", // 获取表格数据的url
            contentType: "application/x-www-form-urlencoded",//一种编码。好像在post请求的时候需要用到。这里用的get请求，注释掉这句话也能拿到数据
            //dataField: "data",//这是返回的json数组的key.默认是"rows".这里只有前后端约定好就行
            cache: false, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //表格显示条纹，默认为false
            pagination: true, // 在表格底部显示分页组件，默认false
            paginationShowPageGo: true,
            pageList: [10, 20, 50, 100], // 如果设置了分页，设置可供选择的页面数据条数。设置为All 则显示所有记录。
            smartDisplay: false,
            pageSize: 2, // 页面数据条数
            pageNumber: 1, // 初始化加载第一页，默认第一页
            sidePagination: 'server', // 设置为服务器端分页     客户端：client
            search: false,
            toolbar: '#toolbar2',//指定工具栏
            showColumns: true,
            searchOnEnterKey: true, //设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
            undefinedText: '---', //当数据为 undefined 时显示的字符
            singleSelect: false,//设置True 将禁止多选
            clickToSelect: true,//设置true 将在点击行时，自动选择rediobox 和 checkbox
            //height: 560,     //定义表格的高度。
            searchTimeOut: 500,// 默认500  设置搜索超时时间。
            toolbarAlign: 'left',// 指定 toolbar 水平方向的位置。'left' 或 'right'
            paginationDetailHAlign: 'left',//指定 分页详细信息 在水平方向的位置。'left' 或 'right'。
            showHeader: true,//是否显示列头。
            trimOnSearch: true,//设置为 true 将自动去掉搜索字符的前后空格。
            queryParams: function (params) {
                var currPageSize = this.pageSize;
                if (currPageSize == 2) {
                    currPageSize = 10;
                }
                var limit = null;
                var offset = params.offset;
                var patientId = $("#idLab").html();
                var assortId = $("#assortId").html();
                if (assortId == 0) assortId = null;
                //判断是否导出全部all
                if ($("#sel_exportoption").val() == "all") {
                    offset = 0;
                    limit = this.totalRows;
                    this.pageSize = limit;
                } else {
                    limit = currPageSize;
                    this.pageSize = currPageSize;
                }

                var temp = {
                    limit: limit,     //页面大小
                    offset: offset,   //页码
                    order: params.order,      //排位命令（desc，asc）
                    patientId: patientId,
                    assortId: assortId,
                    flag: flag
                };
                return temp;
            },
            sortName: 'assortSort', // 要排序的字段
            sortOrder: 'desc', // 排序规则
            columns: [{
                title: '全选',
                field: 'select',   //复选框
                checkbox: true,
                width: 25,
                align: 'center',
                hidden: true,
            }, {
                title: '序',
                field: 'id',
                align: 'left',
                visible: false
            },

                {
                    title: '分段类id',
                    field: 'assortId',
                    align: 'left',
                    valign: 'middle',
                    visible: false
                },

                {
                    title: '标题',
                    field: 'title',
                    align: 'left',
                    valign: 'middle',
                },
                {
                    title: '上传时间',
                    field: 'uploaddatetime',
                    align: 'left',
                    valign: 'middle',
                    width: 150, // 定义列的宽度，单位为像素px
                },
                {
                    title: '来源',
                    field: 'source',
                    align: 'center',
                    valign: 'middle',
                    width: 50, // 定义列的宽度，单位为像素px
                },
                {
                    title: '状态',
                    field: 'flag',
                    align: 'center',
                    valign: 'middle',
                    width: 80, // 定义列的宽度，单位为像素px
                    formatter: function (value, row, index) {
                        //在院  未归档  归档中  初审 已归档 已认证
                        var a = '';
                        if (value == "1") {
                            a = '<span style="color:red;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>作废</span>';
                        } else if (value == "0") {
                            a = '<span style="color:green"><i class="fa fa-check-circle-o" aria-hidden="true"></i>使用</span>';
                        }
                        return a;
                    }
                },
                {
                    title: "操作",
                    align: 'left',
                    valign: 'middle',
                    width: 120, // 定义列的宽度，单位为像素px
                    formatter: function (value, row, index) {
                        //return '<button class="btn btn-danger btn-sm" onclick="selectFun(\'' + row + '\')">查看 </button>';
                        var url = window.location.href;
                        var index = url.substring(url.lastIndexOf('?') + 1).replace("num=", "");

                        var html = "";

                        if (index != null && index != "" && index.indexOf("edit") != -1) {
                            //addFile
                            //return '<button class="btn btn-danger btn-sm" onclick="selectFun(\'' + row + '\')">查看 </button>';
                            html = html + '<button type="button" class="btn btn-info btn-sm editInfo" >编辑 </button>';// '<a href="javascript:;" class="delete">删除</a>';


                        }

                        if (index != null && index != "" && index.indexOf("cancel") != -1) {
                            if (row.flag == "0") {
                                html = html + '<button type="button" class="btn btn-danger btn-sm stateInfo" >作废 </button>';
                            }
                        }

                        if (index != null && index != "" && index.indexOf("delPdf") != -1) {
                            //console.log("===:" + row.pdfPath + "====" + row.source);
                            //删除
                            if (row.pdfPath != null && row.pdfPath != "") {
                                //console.log("===:" + row.pdfPath.indexOf(row.assortId + ".pdf") != -1);
                                if (row.pdfPath.indexOf(row.assortId + ".pdf") == -1) {
                                    if (row.source != null && row.source != "") {
                                        if (row.source.indexOf("后台") != -1) {
                                            html = html + '<button type="button" class="btn btn-warning btn-sm delPdfInfo" >删除 </button>';
                                        }
                                    }
                                }
                            } else {

                                if (row.source != null && row.source != "") {
                                    if (row.source.indexOf("后台") != -1) {
                                        html = html + '<button type="button" class="btn btn-warning btn-sm delPdfInfo" >删除 </button>';
                                    }
                                }
                            }
                        }


                        if (row.source != null && row.source != "") {
                            if (row.source.indexOf("后台") != -1) {
                                if (index != null && index != "" && index.indexOf("delPage") != -1) {
                                    //return '<button class="btn btn-danger btn-sm" onclick="selectFun(\'' + row + '\')">查看 </button>';
                                    html = html + '<button type="button" class="btn btn-primary btn-sm delPdfPage" >删除页 </button>';// '<a href="javascript:;" class="delete">删除</a>';
                                }
                            }
                        }


                        return html;
                    }, events: {
                        'click .editInfo': function (e, value, row, index) {
                            //console.log(row);
                            if (row.pdfPath != null && row.pdfPath != "") {
                                //console.log("===:" + row.pdfPath.indexOf(row.assortId + ".pdf") != -1);
                                if (row.pdfPath.indexOf(row.assortId + ".pdf") != -1) {
                                    $("#upPdfDiv").hide();
                                    $("#inpType").attr("disabled", "true");

                                } else {
                                    $("#upPdfDiv").show();
                                    $("#inpType").removeAttr("disabled");
                                }
                            } else {
                                $("#upPdfDiv").show();
                                $("#inpType").removeAttr("disabled");
                            }
                            if (row.source.indexOf("后台") != -1) {
                                $("#addFile").show();
                            } else {
                                $("#addFile").hide();
                                $("#inpType").attr("disabled", "true");
                            }


                            //同步
                            $("#inpId").val(row.id);
                            $("#inpTitle").val(row.title);
                            $("#inpType").val(row.assortId);
                            $("#inpSource").val(row.source);
                            $("#inpFlag").val(row.flag);
                            $("#pageNumber").val(row.pageNumber);
                            //console.log("===="+ row.pdfPath);
                            $("#pdfPathVal").val(row.pdfPath);
                            if (row.pdfPath != "" && row.pdfPath != null) {
                                $("#pdfPathVal").show();

                                //..\..\..\static\img\pdfFiles\980bda8d-18e3-4deb-bb25-9d2b3784e9f3\HC3SL2HENH348M8X619PMCA7GC5R3125\HC3SL2HENH348M8X619PMCA7GC5R3125.pdf
                                var pdfUrl = "../../" + (row.pdfPath).replace(/\\/g, "/");

                                $("#fileUrlInp").val(pdfUrl);
                                // var pdfUrl = "${path}/static/pdfjs/web/viewer.html?file=../../../static/img/pdfFiles/typesPdf/" + result;//+ result;

                                $('#previewFile').css("display", "block");//显示预览按钮
                                $('#addFile').attr("src", row.pdfPath);
                                //$("#addFile").val("ssss");
                                $('.inp_file').val(null);
                            } else {
                                $("#pdfPathVal").hide();
                                $('#addFile').attr("src", "");
                                $('.inp_file').val(null);
                            }

                            $('#assortModal').modal({
                                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                                keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                                show: true//弹出对话框
                            });
                        }, 'click .stateInfo': function (e, value, row, index) {
                            $('#exampleModal').modal({
                                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                                keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                                show: true//弹出对话框
                            });

                            //同步
                            $("#idT").val(row.id);

                        }, 'click .delPdfInfo': function (e, value, row, index) {
                            $('#delPdfModal').modal({
                                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                                keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                                show: true//弹出对话框
                            });
                            //同步
                            $("#idPdfT").val(row.id);
                        }, 'click .delPdfPage': function (e, value, row, index) {
                            //删除pdf某一页
                            $('#delPdfPageModal').modal({
                                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                                keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                                show: true//弹出对话框
                            });
                            // //同步
                            $("#pdfId").val(row.id);
                            $("#pathPdf").val(row.pdfPath);
                        }
                    },
                    cellStyle: function (value, row, index) {
                        return {classes: 'success'}

                    }
                }
            ],
            onLoadSuccess: function (result) {  //加载成功时执行
                idArr = [];
                // console.info("加载成功");
            },
            onLoadError: function () {  //加载失败时执行
                //console.info("加载数据失败");
                //toastr.warning("用户长时间未操作，请重新登录!");
            }, onCheckAll: function (rows) { //点击全选框时触发的操作
                if (rows != null && rows.length) {
                    for (var i = 0; i < rows.length; i++) {
                        idArr.push(rows[i].id)
                    }
                }
            }, onCheck: function (row) {//点击每一个单选框时触发的操作
                idArr.push(row.id)
            }, onUncheck: function (row) {//取消每一个单选框时对应的操作；
                var index = idArr.indexOf(row.id);
                if (index > -1) {
                    idArr.splice(index, 1);
                }
            }, onUncheckAll: function (row) {//取消每一个单选框时对应的操作；
                idArr = [];
            }

        });
    }

    initTable2();

    $("#flag").click(function () {
        if ($("#flag").is(":checked") == true) {
            //选中触发事件
            flag = 1;
            $('#table2').bootstrapTable('refreshOptions', {limit: 1, offset: 10});
        } else {
            flag = 0;
            //取消选中触发事件
            $('#table2').bootstrapTable('refreshOptions', {limit: 1, offset: 10});
        }
        initTree($("#idLab").html());
        idArr = [];

    });

    $("#selModal").keydown(function (e) {
        if (e.keyCode == 13) {
            event.preventDefault();//禁用默认回车事件
        }
    });


    //查询
    $('#searchBtn').click(function () {
        if (tipLoad == 0) {
            $("#table").bootstrapTable("refreshOptions", {pageNumber: 1});
        } else {
            toastr.warning("正在查询，请稍等...");
        }
    });

    //添加pdf记录
    $("#addPdfBtn").click(function () {
        if ($('#inpType').val() != null && $('#inpType').val() != "") {
            $("#inpId").val("");
            $("#inpTitle").val("");
            $("#pageNumber").val(1);
            $("#inpSource").val("后台");
            $('#addFile').attr("src", "");
            $('.inp_file').val(null);
            $('#upPdfDiv').show();
            $("#pdfPathVal").hide();
            $('#addFile').show();
            $("#inpType").removeAttr("disabled");
            $('#assortModal').modal({
                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                show: true//弹出对话框
            });
            $('#pdfPathVal').val("");

        } else {
            toastr.warning("请选择分段类别!");
        }

    });

    //获取table的高度
    function getHeight() {
        return $(window).height() - 100;
    }

    initTable();


    //2.初始化select的change事件
    $("#sel_exportoption").change(function () {
        $('#table').bootstrapTable('refreshOptions', {
            exportDataType: $(this).val()
        });
    });
    $("#refreshBtn").click(function () {
        //刷新
        $('#table').bootstrapTable('refresh');
    });

    //导出excel功能
    $("#excelBtn").click(function () {
        var inpNo = "" + $("#inpNo").val();
        var visitId = "" + $("#visitId").val();
        var name = "" + $("#name").val();

        var deptName = $("#deptName").val();
        if (deptName.indexOf("") != -1) {
            deptName = "";
        } else {
            deptName = $("#deptName").val().toString();
        }

        var deptAdmissionTo = $("#deptAdmissionTo").val();
        if (deptAdmissionTo.indexOf("") != -1) {
            deptAdmissionTo = "";
        } else {
            deptAdmissionTo = $("#deptAdmissionTo").val().toString();
        }

        var startDate= $("#startDate").val();
        var endDate= $("#endDate").val();
        var createTimeStart= $("#createTimeStart").val();
        var createTimeEnd= $("#createTimeEnd").val();
        var deathFlag= $("#deathFlag").val();
        var overdueDays= $("#overdueDays").val();
        window.location.href = "${path}/medicalOverdue/exportExcel?inpNo=" + inpNo + "&visitId=" + visitId +
            "&name=" + name + "&deptName=" + deptName + "&deptAdmissionTo=" + deptAdmissionTo
            //+ "&archivestate=" + archivestate
            + "&createTimeStart=" + createTimeStart + "&createTimeEnd=" + createTimeEnd+ "&startDate=" + startDate
            + "&endDate=" + endDate+ "&deathFlag=" + deathFlag + "&overdueDays=" + overdueDays;
    });

    var zNodes = [];
    var nodeList = [];
    function initTree(patientId) {
        var target = document.getElementById('foo');
        spinner.spin(target);//给id为foo的div 中绑上spinner
        zNodes = [];
        //获取所有分段列表
        $.ajax({
            url: "${path}/inHosp/getAssort",
            type: "POST",
            data: {patientId: patientId, flag: flag},
            async: true,
            success: function (result) {
                zNodes.push({id: 0, pId: 0, name: "分段列表", open: true});
                if (result.length > 0) {
                    for (var i = 0; i < result.length; i++) {
                        //下拉类别
                        //$("#inpType").append("<option value=" + result[i].assortId + ">" + result[i].assortName + "</option>");
                        //树列表
                        var obj = {};
                        obj.id = result[i].assortId;
                        obj.pId = 0;
                        obj.name = "" + result[i].assortName + "(" + (result[i].pageNum) + ")";
                        obj.assortSort = result[i].assortSort;
                        obj.patientId = result[i].patientId;
                        obj.printFlag = result[i].printFlag;
                        zNodes.push(obj);
                    }
                }
                //$.fn.zTree.init($("#ztree"), setting, zNodes);
                var treeObj = $.fn.zTree.init($("#ztree"), setting, zNodes);
                var node;
                var currId = $("#assortId").html();
                if (currId != "" && currId != null) {
                    //修改选中已选节点
                    node = treeObj.getNodeByParam("id", currId);
                } else {
                    //添加选中父节点
                    var node = treeObj.getNodeByParam("id", 0);
                }
                treeObj.selectNode(node, true);//将指定ID的节点选中
                $('#table2').bootstrapTable('refresh');
                spinner.spin();
            }, error: function () {
                // toastr.error("加载失败!");
            }
        });


    }

    var setting = {
        view: {
            addHoverDom: false,
            removeHoverDom: false,
            selectedMulti: false,
            autoCancelSelected: false
        },
        check: {
            enable: true
        },
        data: {
            simpleData: {
                enable: true,
                idKey: "id",
                pIdKey: "pId",
                rootPId: "0"
            }
        },
        edit: {
            enable: false
        },
        callback: {
            beforeClick: function (treeId, treeNode) {
                $("#assortId").html(treeNode.id);
                //查询之后重新从第一页算起
                $('#table2').bootstrapTable('refreshOptions', {limit: 1, offset: 10});
                //刷新
                $('#table2').bootstrapTable('refresh');
                idArr = [];
            }

        }
    };

    function searchNode() {
        var zTree = $.fn.zTree.getZTreeObj("ztree");
        var value = $("#key").val();
        if (value == "") {
            var nodes = zTree.getNodesByParam("isHidden", true);
            zTree.showNodes(nodes);
        } else {
            nodeList = zTree.getNodesByParamFuzzy("name", value);
            var nodes = zTree.getNodes();
            zTree.hideNodes(nodes[0].children);
            updateNodes(true);
        }
        zTree.expandAll(true);
    }

    function updateNodes(highlight) {
        var zTree = $.fn.zTree.getZTreeObj("ztree");
        for (var i = 0, l = nodeList.length; i < l; i++) {
            zTree.showNode(nodeList[i]);
        }
    }

    $(document).keydown(function (event) {
        if (event.keyCode == 13) {
            searchNode();
        }
    });

    //展开
    function expandAll() {
        var treeObj = $.fn.zTree.getZTreeObj("ztree");
        treeObj.expandAll(true);
    }

    //收缩
    function collapseAll() {
        var treeObj = $.fn.zTree.getZTreeObj("ztree");
        treeObj.expandAll(false);
    }

    $("#searchBtn1").click(function () {
        searchNode();
    });

    $("#updateStateBtn").click(function () {
        //选中批量作废
        var id = idArr.toString();
        //判断id
        if (id == null || id == '') {
            toastr.warning("请选择记录!");
            return;
        }
        $.ajax({
            url: "${path}/inHosp/updateStateAll",
            type: "POST",
            data: {"id": id, flag: "1"},
            success: function (result) {
                if (result == 1) {
                    //刷新
                    $('#table2').bootstrapTable('refresh');
                    toastr.success("批量作废成功!");
                } else {
                    toastr.error("批量作废失败，无记录!");
                }
            }, error: function () {
                toastr.error("操作失败!");
            }
        });
    });

    $("#updateStateBtn2").click(function () {
        //选中批量使用
        var id = idArr.toString();
        //判断id
        if (id == null || id == '') {
            toastr.warning("请选择记录!");
            return;
        }
        $.ajax({
            url: "${path}/inHosp/updateStateAll",
            type: "POST",
            data: {"id": id, flag: "0"},
            success: function (result) {
                if (result == 1) {
                    //刷新
                    $('#table2').bootstrapTable('refresh');
                    toastr.success("批量使用成功!");
                } else {
                    toastr.error("批量使用失败，无记录!");
                }
            }, error: function () {
                toastr.error("操作失败!");
            }
        });
    });

    $("#stateBtn").click(function () {
        $('#exampleModal').modal('hide');  //手动关闭
        var id = $("#idT").val();
        //console.log("===作废事件=======" + id);
        $.ajax({
            url: "${path}/inHosp/updateState",
            type: "POST",
            data: {"id": id, flag: "1"},
            success: function (result) {
                if (result == 1) {
                    //刷新
                    $('#table2').bootstrapTable('refresh');
                    toastr.success("作废成功!");
                } else {
                    toastr.error("作废失败，无该条记录!");
                }
            }, error: function () {
                toastr.error("操作失败!");
            }
        });

    });

    function submitForm(i) {
        var formDate = new FormData($("#form2")[0]);
        $.ajax({
            url: 'upload_importFile.do?ccqoid=' + i,
            type: 'POST',
            data: formDate,
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (data) {
                if (data.success) {
                    //$.messager.alert('提示', '导入成功!');
                }
            },
            error: function (returndata) {

            }
        });
    };

    $("#getFirstBtn").on('click', function () {
        //退回信息保存
        $('#firstModal').modal({
            backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
            keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
            show: true//弹出对话框
        });
        //console.log($("#idLab").html());
        getStaffFun(2);
        //获取初审
        $.ajax({
            url: "${path}/lastVerify/getDetailByArchId", // 获取表格数据的url
            type: "POST",
            data: {archiveDetailId: $("#idLab").html()},
            success: function (result) {
                //console.log(result);
                if (result != null) {
                    $("#firstTrial").val(result.firstTrial);
                }
            }, error: function () {
                // toastr.error("失败!")
            }
        });
    });

    function getQxList() {
        $("#tableBack").bootstrapTable({ // 对应table标签的id
            //method: 'POST',
            url: "${path}/fault/getFaultPage", // 获取表格数据的url
            contentType: "application/x-www-form-urlencoded",//一种编码。好像在post请求的时候需要用到。这里用的get请求，注释掉这句话也能拿到数据
            //dataField: "data",//这是返回的json数组的key.默认是"rows".这里只有前后端约定好就行
            cache: false, // 设置为 false 禁用 AJAX 数据缓存， 默认为true
            striped: true,  //是否显示行间隔色
            pagination: true, // 在表格底部显示分页组件，默认false
            paginationShowPageGo: true,
            pageList: [10, 20, 50, 100], // 如果设置了分页，设置可供选择的页面数据条数。设置为All 则显示所有记录。
            smartDisplay: false,
            pageSize: 2, // 页面数据条数
            pageNumber: 1, // 初始化加载第一页，默认第一页
            sidePagination: 'server', // 设置为服务器端分页     客户端：client
            search: false,
            //showColumns: true,
            //sortable: true,
            // sortOrder: "asc",
            //toolbar: '#toolbar',//指定工具栏
            searchOnEnterKey: false, //设置为 true时，按回车触发搜索方法，否则自动触发搜索方法
            undefinedText: '---', //当数据为 undefined 时显示的字符
            singleSelect: true,//设置True 将禁止多选
            clickToSelect: true,//设置true 将在点击行时，自动选择rediobox 和 checkbox
            height: 350,     //定义表格的高度。
            searchTimeOut: 500,// 默认500  设置搜索超时时间。
            paginationDetailHAlign: 'left',//指定 分页详细信息 在水平方向的位置。'left' 或 'right'。
            showHeader: true,//是否显示列头。
            trimOnSearch: true,//设置为 true 将自动去掉搜索字符的前后空格。
            //是否显示导出按钮
            showExport: false,
            //导出表格方式（默认basic：只导出当前页的表格数据；all：导出所有数据；selected：导出选中的数据）
            //exportDataType: "basic",
            //导出文件类型
            //exportTypes: ['json', 'xml', 'csv', 'txt', 'sql', 'excel'],
            exportOptions: {
                fileName: document.title
            },
            // showToggle: false,                    //是否显示详细视图和列表视图的切换按钮
            // cardView: false,                    //是否显示详细视图
            // detailView: false,                   //是否显示父子表
            queryParams: function (params) {
                var currPageSize = this.pageSize;
                if (currPageSize == 2) {
                    currPageSize = 10;
                }
                var limit = null;
                var offset = params.offset;
                //判断是否导出全部all
                if ($("#sel_exportoption").val() == "all") {
                    offset = 0;
                    limit = this.totalRows;
                    this.pageSize = limit;
                } else {
                    limit = currPageSize;
                    this.pageSize = currPageSize;
                }
                var temp = {
                    limit: limit,     //页面大小
                    offset: offset,   //页码
                    //order: params.order,      //排位命令（desc，asc）
                    archiveDetailId: $("#idLab").html(),
                    backFlag: 1
                };
                return temp;
            },
            sortName: 'id', // 要排序的字段
            sortOrder: 'desc', // 排序规则
            columns: [{
                field: 'archiveDetailId',
                title: 'id',
                visible: false
            }, {
                field: 'assortId',
                title: '缺陷类型ID',
                width: 150,
                visible: false
            }, {
                field: 'assortName',
                title: '缺陷类型',
                width: 150
            }, {
                field: 'price',
                title: '类型分',
                width: 60,
                visible: false,
                formatter: function (value, row, index) {
                    var result = '<span style="color:blue;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>' + value + '分</span>';
                    return result
                }
            }, {
                title: '退回',
                field: 'backFlag',
                align: 'center',
                width: 130,
                formatter: function (value, row, index) {
                    var result = "";
                    if (value == 1) {
                        result = '<span style="color:green;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>科主任退回医生</span>'
                    } else if (value == 2) {
                        result = '<span style="color:red;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>科主任退回护士</span>'
                    } else if (value == 5) {
                        result = '<span style="color:orange;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>病案室退回医生</span>'
                    } else if (value == 6) {
                        result = '<span style="color:dodgerblue;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>病案室退回护士</span>'
                    }
                    return result
                }
            }, {
                field: 'dealFlag',
                title: '处理否',
                align: 'center',
                width: 80,
                formatter: function (value, row, index) {
                    var result = "";
                    if (value == "1") {
                        result = '<span style="color:green;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>已处理</span>';
                    } else {
                        result = '<span style="color:blue;"><i class="fa fa-times-circle-o" aria-hidden="true"></i>未处理</span>';
                    }
                    return result
                }
            }, {
                field: 'dealPerson',
                title: '处理人',
                width: 80

            }, {
                field: 'dealTime',
                title: '处理时间',
                width: 150

            },
                // {
                //     field: 'content',
                //     title: '内容',
                //     width: 300
                // },
                {
                    title: "操作",
                    align: 'left',
                    valign: 'middle',
                    width: 100, // 定义列的宽度，单位为像素px
                    formatter: function (value, row, index) {
                        var url = window.location.href;
                        var index = url.substring(url.lastIndexOf('?') + 1).replace("num=", "");
                        var html = "";

                        if (row.dealFlag == 1) {
                            if (index != null && index != "" && index.indexOf("dealNO") != -1) {
                                html += '<button type="button" class="btn btn-warning btn-sm dealInfo" >未处理 </button>';
                            }
                        } else {
                            if (index != null && index != "" && index.indexOf("dealOk") != -1) {
                                html += '<button type="button" class="btn btn-info btn-sm dealInfo" >已处理 </button>';
                            }
                        }
                        if (index != null && index != "" && index.indexOf("select") != -1) {
                            //return '<button class="btn btn-danger btn-sm" onclick="selectFun(\'' + row + '\')">查看 </button>';
                            html += '<button type="button" class="btn btn-danger btn-sm qxInfo" >查看 </button>';// '<a href="javascript:;" class="delete">删除</a>';
                        }
                        return html;

                    }, events: {
                        'click .qxInfo': function (e, value, row, index) {
                            var url = window.location.href;
                            var index = url.substring(url.lastIndexOf('?') + 1).replace("num=", "");
                            var html = "";

                            $('#qxModal').modal({
                                backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                                keyboard: true,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                                show: true//弹出对话框
                            });
                            var backPerson = "";
                            if (row.backFlag == 1) {
                                backPerson = "主任退回医生";
                            } else if (row.backFlag == 2) {
                                backPerson = "主任退回护士";
                            } else if (row.backFlag == 5) {
                                backPerson = "病案室退回医生";
                            } else if (row.backFlag == 6) {
                                backPerson = "病案室退回护士";
                            }
                            var backPerson = "";
                            if (row.backFlag == 1) {
                                backPerson = "主任退回医生";
                            } else if (row.backFlag == 2) {
                                backPerson = "主任退回护士";
                            } else if (row.backFlag == 5) {
                                backPerson = "病案室退回医生";
                            } else if (row.backFlag == 6) {
                                backPerson = "病案室退回护士";
                            }
                            var dealFlag = "";
                            if (row.dealFlag == 1) {
                                dealFlag = "已处理";
                                if (index != null && index != "" && index.indexOf("dealNO") != -1) {
                                    $("#dealNoBtn").show();
                                } else {
                                    $("#dealNoBtn").hide();
                                }
                                if (index != null && index != "" && index.indexOf("dealOk") != -1) {
                                    $("#dealBtn").hide();
                                } else {
                                    $("#dealBtn").hide();
                                }
                            } else {
                                dealFlag = "未处理";
                                if (index != null && index != "" && index.indexOf("dealNO") != -1) {
                                    $("#dealNoBtn").hide();
                                } else {
                                    $("#dealNoBtn").hide();
                                }
                                if (index != null && index != "" && index.indexOf("dealOk") != -1) {
                                    $("#dealBtn").show();
                                } else {
                                    $("#dealBtn").hide();
                                }
                            }
                            var dealPerson = "";
                            if (dealPerson == null || dealPerson == "") {
                                dealPerson = "暂无";
                            } else {
                                dealPerson = row.dealPerson;
                            }

                            var dealTime = "";
                            if (dealTime == null || dealTime == "") {
                                dealTime = "暂无";
                            } else {
                                dealTime = row.dealTime;
                            }
                            //同步dealFlag
                            $("#backPerson").html(backPerson);
                            $("#dealFlag").html(dealFlag);
                            $("#dealPerson").html(dealPerson);
                            $("#dealTime").html(dealTime);
                            $("#assortName").val(row.assortName);
                            $("#content").val(row.content);
                            $("#qxId").val(row.id);
                            $("#faultType").val(row.assortId);
                            // $('input[name="Fruit"]').each(function () {//遍历每一个名字为interest的复选框，其中选中的执行函数
                            //     if ($(this).val() == row.assortId) {
                            //         $(this)[0].checked = true;
                            //     } else {
                            //         $(this)[0].checked = false;
                            //     }
                            // });
                        },
                        'click .dealInfo': function (e, value, row, index) {
                            //处理操作
                            dealFun(row.id);
                        }
                    },
                    cellStyle: function (value, row, index) {
                        return {classes: 'success'}
                    }
                }
            ],
            onLoadSuccess: function (result) {  //加载成功时执行
                // console.info("加载成功");
            },
            onLoadError: function () {  //加载失败时执行
                //console.info("加载数据失败");
            },
            onPostBody: function () {
                //重点就在这里，获取渲染后的数据列td的宽度赋值给对应头部的th,这样就表头和列就对齐了
                var header = $(".fixed-table-header table thead tr th");
                var body = $(".fixed-table-header table tbody tr td");
                var footer = $(".fixed-table-header table tr td");
                body.each(function () {
                    header.width((this).width());
                    footer.width((this).width());
                });
            }

        });
    }

    getQxList();

    function getStaffFun(flag) {
        $.ajax({
            url: "${path}/staffRemark/staffRemarkList",
            type: "POST",
            data: {masterId: $("#idLab").html(), effective: 1},
            success: function (result) {
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        if (result[i].typeFlag == 1) {
                            //1护士
                            if (flag == 1) {
                                $("#nuresText").val(result[i].content);
                            } else if (flag == 2) {
                                $("#nuresText2").val(result[i].content);
                            }
                        } else if (result[i].typeFlag == 0) {
                            //0医生
                            if (flag == 1) {
                                $("#doctorText").val(result[i].content);
                            } else if (flag == 2) {
                                $("#doctorText2").val(result[i].content);
                            }
                        }
                    }
                }
            }
        });
    }

    $("#getRecallBtn").on('click', function () {
        $('#form2').find('input,textarea').prop('readonly', true);
        $('#returnBtn').hide();
        //根据病案号获取缺陷信息
        $("#tableBack").bootstrapTable('refresh');
        //根据病案号获取缺陷信息
        $.ajax({
            url: "${path}/lastVerify/getDetailByArchId",
            type: "POST",
            data: {archiveDetailId: $("#idLab").html(), backFlag: backFlagVal},
            success: function (result) {
                if (result != null && result != "") {
                    $("#backContent").val(result.backContent);
                    $("#score").val(result.score);
                } else {
                    toastr.warning("数据不存在!");
                }
            }
        });
        getStaffFun(1);

        //退回信息保存
        $('#returnModal').modal({
            backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
            keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
            show: true//弹出对话框
        });
    });

    $("#dealBtn").on('click', function () {
        //处理操作
        var id = $("#qxId").val();
        if (id != null && id != "") {
            dealFun(id);
        }
    });

    $("#dealNoBtn").on('click', function () {
        //处理操作
        var id = $("#qxId").val();
        if (id != null && id != "") {
            dealFun(id);
        }
    });


    //删除pdf
    $("#statePdfBtn").click(function () {
        $('#delPdfModal').modal('hide');  //手动关闭
        var id = $("#idPdfT").val();
        //console.log("===作废事件=======" + id);
        $.ajax({
            url: "${path}/inHosp/delPdfInfo",
            type: "POST",
            data: {"id": id},
            success: function (result) {
                if (result == 1) {
                    //刷新
                    $('#table2').bootstrapTable('refresh');
                    initTree($("#idLab").html());
                    toastr.success("删除成功!");
                } else {
                    toastr.error("删除失败，无该条记录!");
                }
            }, error: function () {
                toastr.error("操作失败!");
            }
        });

    });

    //删除pdf页码
    $("#delPageBtn").click(function () {
        $('#delPdfPageModal2').modal({
            backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
            keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
            show: true//弹出对话框
        });
    });

    //确认删除pdf页码
    $("#delPageBtn2").click(function () {
        var entity = {};
        entity.id = $("#pdfId").val();
        entity.title = "" + $("#pagePdf").val();
        entity.pdfPath = $("#pathPdf").val();
        if (entity.id == null || entity.id == "") {
            toastr.warning("id不为空!");
            return;
        }
        if (entity.title == null || entity.title == "") {
            toastr.warning("页码必填!");
            return;
        }
        if (entity.title != null && entity.title != "") {
            if (entity.title <= 0) {
                toastr.warning("页码大于0必填!");
                return;
            }
        }
        if (entity.pdfPath == null || entity.pdfPath == "") {
            toastr.warning("PDF不存在!");
            return;
        }

        $.ajax({
            url: "${path}/inHosp/delPdfPage",
            type: "POST",
            data: entity,
            success: function (result) {
                $("#pagePdf").val("");
                $('#delPdfPageModal').modal('hide');  //手动关闭
                $('#delPdfPageModal2').modal('hide');  //手动关闭
                if (result == 1) {
                    //刷新
                    $('#table2').bootstrapTable('refresh');
                    initTree($("#idLab").html());
                    toastr.success("删除pdf页数,第" + entity.title + "页成功!");

                } else if (result == 0) {
                    toastr.error("删除pdf页数,第" + entity.title + "页失败!");
                } else if (result == 2) {
                    toastr.error("pdf文件不存在!");
                }
            }, error: function () {
                toastr.error("操作失败!");
            }
        });
    });

    // $("#addBtn").click(function () {
    //     $("#inpId").val("");
    //     $("#inpTitle").val("");
    //     $("#inpSource").val("后台");
    //     $("#inpFlag").val("0");
    //     $('#assortModal').modal({
    //         backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
    //         keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
    //         show: true//弹出对话框
    //     });
    // });

    function inpFun() {
        var temp = {};
        temp.id = $("#inpId").val();
        temp.title = $("#inpTitle").val();
        temp.assortid = $("#inpType").val();
        temp.source = $("#inpSource").val();
        temp.flag = $("#inpFlag").val();
        temp.masterid = $("#idLab").html();
        temp.sys = "emr_medical_record";
        return temp
    }

    $("#saveBtn").click(function () {
        if ($("#inpTitle").val().length > 100) {
            toastr.warning("内容长度不超过100!");
            return;
        }
        //判断file是否为空，如果不是弹出提示框标识该文件已经存在是否替换
        //console.log($("#addFile").attr("src")=="");
        if ($("#addFile").attr("src") == "") {
            //判断文件类型，并上传pdf
            uploadFileFun();
        } else {
            //提示是否替换已有的pdf文件且判断file是否为空
            //console.log($('#addFile')[0].files[0]);
            if ($('#addFile')[0].files[0] != undefined) {
                $('#tsPdfModal').modal({
                    backdrop: 'static',//backdrop 为 static 时，点击模态对话框的外部区域不会将其关闭。
                    keyboard: false,//keyboard 为 false 时，按下 Esc 键不会关闭 Modal。
                    show: true//弹出对话框
                });
            } else {
                //判断文件类型，并上传pdf
                uploadFileFun();
            }
        }
        idArr = [];
    });
    $("#thPdfBtn").click(function () {
        $('#tsPdfModal').modal('hide');  //手动关闭
        //判断文件类型，并上传pdf
        uploadFileFun();
    });

    jQuery(function ($) {
        //解决模态框背景色越来越深的问题
        $(document).on('show.bs.modal', '.modal', function (event) {
            $(this).appendTo($('body'));
        }).on('shown.bs.modal', '.modal.in', function (event) {
            setModalsAndBackdropsOrder();
        }).on('hidden.bs.modal', '.modal', function (event) {
            setModalsAndBackdropsOrder();
        });

        function setModalsAndBackdropsOrder() {
            var modalZIndex = 1040;
            $('.modal.in').each(function (index) {
                var $modal = $(this);
                modalZIndex++;
                $modal.css('zIndex', modalZIndex);
                $modal.next('.modal-backdrop.in').addClass('hidden').css('zIndex', modalZIndex - 1);
            });
            $('.modal.in:visible:last').focus().next('.modal-backdrop.in').removeClass('hidden');
        }

        //覆盖Modal.prototype的hideModal方法
        $.fn.modal.Constructor.prototype.hideModal = function () {
            var that = this
            this.$element.hide()
            this.backdrop(function () {
                //判断当前页面所有的模态框都已经隐藏了之后body移除.modal-open，即body出现滚动条。
                $('.modal.fade.in').length === 0 && that.$body.removeClass('modal-open')
                that.resetAdjustments()
                that.resetScrollbar()
                that.$element.trigger('hidden.bs.modal')
            })
        }
    });

    function enter() {
        if (event.keyCode == 13) {
            document.getElementById('searchBtn').click();
        }
    }
</script>

</html>