<%--
  Created by IntelliJ IDEA.
  User: 56827
  Date: 2021/3/4
  Time: 20:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<c:set value="${pageContext.request.contextPath}" var="path" scope="page"/>
<html>
<head>
    <title>测试用的完整性信息校验</title>
    <meta http-equiv="Content-Type"  content="text/html;charset=utf-8">
    <%--<meta name="referrer" content="no-referrer">--%>
    <%--<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" %>
    <script src="${path}/static/js/loadAssortDetailCommom.js"></script>
</head>
<style>
    body{
        scroll-x:hidden;
    }

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

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

    .divCss5{
        margin-top: 5px;
        margin-right: 2px;
    }

    .divW{
        margin-left: 20px;
        scroll-x:hidden;
        width: 95%;
    }

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

<body>
<div class="row form-inline divCss" style="scroll-x:hidden;">
    <div class="form-group divCss8"><input type="text" id="masterId2" hidden/>
        <label for="inpNo">住院号:</label>
        <input type="text" class="input-sm form-control" id="inpNo2" placeholder="请输入住院号">
    </div>
    <div class="form-group divCss8">
        <label >住院次数:</label>
        <input type="number" class="input-sm form-control" id="visitId2" placeholder="请输入次数">
    </div>
    <div class="form-group divCss5">
        <label>出院日期：</label>
        <div class="input-daterange input-group" id="datepicker">
            <input type="text" class="input-sm form-control" name="start" id="startDateTo"/>
            <span class="input-group-addon">-</span>
            <input type="text" class="input-sm form-control" name="end" id="endDateTo"/>
        </div>
    </div>


    <button type="button" class="btn btn-primary btn-sm divCss5" id="searchBtn2">查询</button>
    <button type="button" class="btn btn-info btn-sm divCss5" id="excelBtn2">条件导出</button>
    <button type="button" class="btn btn-danger btn-sm divCss5" id="wzCheckBtn">重置校验</button>
    <div class="row divW">
        <table id="table2" class="table  text-nowrap  table-striped"></table>
    </div>

</div>

<script>
    $(function () {

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

        var opts = {
            lines: 13, // 花瓣数目
            length: 20, // 花瓣长度
            width: 10, // 花瓣宽度
            radius: 30, // 花瓣距中心半径
            corners: 1, // 花瓣圆滑度 (0-1)
            rotate: 0, // 花瓣旋转角度
            direction: 1, // 花瓣旋转方向 1: 顺时针, -1: 逆时针
            color: '#000', // 花瓣颜色
            speed: 1, // 花瓣旋转速度
            trail: 60, // 花瓣旋转时的拖影(百分比)
            shadow: false, // 花瓣是否显示阴影
            hwaccel: false, //spinner 是否启用硬件加速及高速旋转
            className: 'spinner', // spinner css 样式名称
            zIndex: 2e9, // spinner的z轴 (默认是2000000000)
            top: '50%', // spinner 相对父容器Top定位 单位 px
            //left: '900%'// spinner 相对父容器Left定位 单位 px
        };
        var spinner = new Spinner(opts);

        //导出excel功能
        $("#excelBtn2").click(function () {
            var inpNo = $("#inpNo2").val();
            var visitId = $("#visitId2").val();
            var checkDatetime = $("#startDateTo").val();
            var checkedDatetime = $("#endDateTo").val();
            window.location.href = "${path}/exportExcel?inpNo=" + inpNo+ "&visitId=" + visitId + "&checkDatetime=" + checkDatetime
                + "&checkedDatetime=" + checkedDatetime
        });

       function wzCheckFun(){
           var target = document.getElementById('table2');
           spinner.spin(target);//给id为foo的div 中绑上spinner
            var entity={};
            var inpNo = $("#inpNo2").val();
            var visitId = $("#visitId2").val();
            var checkDatetime = $("#startDateTo").val();
            var checkedDatetime = $("#endDateTo").val();
            var masterId = $("#masterId2").val();
            entity.masterId=masterId;
            entity.inpNo=inpNo;
            entity.visitId=visitId;
            entity.checkDatetime=checkDatetime;
            entity.checkedDatetime=checkedDatetime;
           // console.log(entity);
            $.ajax({
                url: "${path}/wzByArchivId",
                type: "POST",
                data: entity,
                success: function (result) {
                    //console.log(result);
                    if(result=="已重置完成!"){
                        $('#table2').bootstrapTable('refresh');
                        toastr.success(result);
                    }else{
                        toastr.warning(result);
                    }
                   // spinner.spin();
                }
            });
           spinner.spin();
       }

       //更新校验
        $("#wzCheckBtn").on('click', function () {
            $("#masterId2").val("");
            wzCheckFun();
        });


        //刷新
        $("#searchBtn2").on('click', function () {
            $("#masterId2").val("");
            $('#table2').bootstrapTable('refresh');
        });

        //查询缺陷列表
        var scollPostion2 = null;
        var idArr=[];
        //var eidtSelRow2=[];
        initTable2();
    });
</script>












<div>==================================保留原有的===========================================</div>
    <div style="margin-left:30px;margin-right:10px;height:auto">
        <%--<form id="form" name="form" method="post" action="${pageContext.request.contextPath }/selectByInpNoAndVisitId">--%>
        <form>
            <div>
                <label for="inpNo">住院号:</label>
                <input type="text" id="inpNo" placeholder="请输入住院号">
            </div>
            <div>
                <label for="visitId">住院次数:</label>
                <input type="number" id="visitId" placeholder="请输入次数">
            </div>
            <button type="button" id="searchBtn">查询</button>
            <button type="button" id="reloadWz">重新校验完整性</button>
            <button type="button" id="reloadWzAll">重新校验完整性（缺失清单）</button>
        </form>
    </div>
    <div>
        <label>患者id:</label>
        <textarea id="masterId" style="height: 200px;width: 400px">

        </textarea>
        <label>完整性信息:</label>
        <textarea id="wzContent" style="height: 200px;width: 400px">

        </textarea>
    </div>

<script>
    $(function () {
        //======================================wzq===============================
        $("#searchBtn").on('click', function () {
            var inpNo = $("#inpNo").val();
            var visitId = $("#visitId").val();
            $.ajax({
                url: "${pageContext.request.contextPath }/selectByInpNoAndVisitId",
                type: "POST",
                data: {inpNo: inpNo, visitId: visitId},
                success: function (result) {
                    console.log(result);
                    if (result.length > 0) {
                        $("#masterId").val(result[0].id);
                        $("#wzContent").val(result[0].lockinfo);
                    }else {
                        alert("不存在该患者");
                    }
                }
            });
        });

        $("#reloadWz").on('click', function () {
            var masterId = $("#masterId").val();
            $.ajax({
                url: "${pageContext.request.contextPath }/reloadWz",
                type: "POST",
                data: {masterId: masterId},
                success: function (result) {
                    //console.log(result);
                    if (result > 0) {
                        alert("重新校验成功");
                    }else {
                        alert("重新校验失败");
                    }
                }
            });
        });

        $("#reloadWzAll").on('click', function () {
            //var masterId = $("#masterId").val();
            $.ajax({
                url: "${pageContext.request.contextPath }/reloadWzAll",
                type: "GET",
                data: null,
                success: function (result) {
                    // console.log(result.length);
                    // console.log(result);
                    if (result > 0) {
                        alert("重新校验成功");
                    }else {
                        alert("重新校验失败");
                    }
                }
            });
        });
    });

</script>
</body>
</html>
