
<%@ page import="com.lightinit.hsdatashow.model.admin.DicOrganizationType" %>
<%@ page import="com.lightinit.hsdatashow.dictionary.DicMedicalType" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../../../common/admin/head.jsp"></jsp:include>
    <link  rel="stylesheet" type="text/css" href="<%=basePath%>/resource/css/admin/home/index.css">
    <style type="text/css">
        #allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
    </style>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=RleRpI1DQegNo17XGsVvUUS1e3oiubUG"></script>
</head>
<body>
    <jsp:include page="../../../common/admin/body_pre.jsp"></jsp:include>
    <div class="row hidden-print">
        <div class="col-lg-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h2>医疗机构</h2>
                    <ol class="breadcrumb">
                        <li>
                            <a href="javascript:void(0);" >民生机构</a>
                        </li>
                        <li class="active">
                            <strong>医疗机构</strong>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <jsp:include page="../../../common/admin/search_pre.jsp"></jsp:include>

    <form id="formSearch" action="<%=basePath%>/admin/data_register_api/list.action" method="get" class="form-inline">
        <div class="form-group">
            <label for="searchName">机构名称</label>
            <input type="text" id="searchName" name="searchName" class="form-control" />
        </div>
        <div class="form-group">
            <button id="btnSearch" type="button" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>查询</button>
        </div>
    </form>

    <jsp:include page="../../../common/admin/search_post.jsp"></jsp:include>
    <div class="row hidden-print">
        <div class="col-lg-12 col-md-12">
            <div class="col-lg-11 col-md-11 ibox-content-noline">
                <div id="allmap" style="width: 100%;height: 655px;"></div>
                <input type="hidden" value=0 id="isFalg">
            </div>
    <div class="col-lg-1 col-md-1 ibox-content-noline">
        <div style="height: 655px">
        <div class="col-lg-12 col-md-12">
            <a title="<%=DicMedicalType.HOSPITAL%>" onclick="changeByFalg('<%=DicMedicalType.HOSPITAL%>')">
                <img id="yy" src="<%=basePath%>/resource/images/medical/yy.png">
                <img id="noyy" src="<%=basePath%>/resource/images/medical/no_yy.png" style="display: none">
            </a>
        </div>
        <div class="col-lg-12 col-md-12">
            <a title="<%=DicMedicalType.REHABILITATION%>" onclick="changeByFalg('<%=DicMedicalType.REHABILITATION%>')">
                <img id="kf" src="<%=basePath%>/resource/images/medical/kfzx.png">
                <img id="nokf" src="<%=basePath%>/resource/images/medical/no_kfzx.png" style="display: none">
            </a>
        </div>
        <div class="col-lg-12 col-md-12">
            <a title="<%=DicMedicalType.COMMUNITY_CLINICS%>" onclick="changeByFalg('<%=DicMedicalType.COMMUNITY_CLINICS%>')">
                <img id="sq" src="<%=basePath%>/resource/images/medical/sqzs.png">
                <img id="nosq" src="<%=basePath%>/resource/images/medical/no_sqzs.png" style="display: none">
            </a>
        </div>
        <div class="col-lg-12 col-md-12">
            <a title="<%=DicMedicalType.SPECIALIST_CLINIC%>" onclick="changeByFalg('<%=DicMedicalType.SPECIALIST_CLINIC%>')">
                <img id="zk" src="<%=basePath%>/resource/images/medical/zkmz.png">
                <img id="nozk" src="<%=basePath%>/resource/images/medical/no_zkmz.png" style="display: none">
            </a>
        </div>
        </div>
    </div>
    </div>
        <div class="col-lg-12 col-md-12 ">
            <div class="col-lg-12 col-md-12 ibox-content-noline">
                <div style="width: 100%;height: 220px;">
                    <table  class="table table-condensed table-hover">
                        <thead>
                        <tr>
                            <th>
                                医疗机构
                            </th>
                            <th>
                                数量
                            </th>
                        </tr>
                        </thead>
                        <tbody id="tableList">
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
    <jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
    <script type="text/javascript">
        var falg1 = 0 ;
        var falg2 = 0 ;
        var falg3 = 0 ;
        var falg4 = 0 ;

        function changeByFalg(name){
            if (name=='<%=DicMedicalType.HOSPITAL%>'){
                if (falg1==0){
                    falg1=1 ;
                    $("#yy").hide() ;
                    $("#noyy").show() ;
                }else {
                    falg1=0 ;
                    $("#yy").show() ;
                    $("#noyy").hide() ;
                }
            }
            if (name=='<%=DicMedicalType.REHABILITATION%>'){
                if (falg2==0){
                    falg2=1 ;
                    $("#kf").hide() ;
                    $("#nokf").show() ;
                }else {
                    falg2=0 ;
                    $("#kf").show() ;
                    $("#nokf").hide() ;
                }
            }
            if (name=='<%=DicMedicalType.COMMUNITY_CLINICS%>'){
                if (falg3==0){
                    falg3=1 ;
                    $("#sq").hide() ;
                    $("#nosq").show() ;
                }else {
                    falg3=0 ;
                    $("#sq").show() ;
                    $("#nosq").hide() ;
                }
            }
            if (name=='<%=DicMedicalType.SPECIALIST_CLINIC%>'){
                if (falg4==0){
                    falg4=1 ;
                    $("#zk").hide() ;
                    $("#nozk").show() ;
                }else {
                    falg4=0 ;
                    $("#zk").show() ;
                    $("#nozk").hide() ;
                }
            }
            changeByName();
        }

        changeByName(null)
        function changeByName() {
            var count1 = 0 ;
            var count2= 0 ;
            var count3 = 0 ;
            var count4 = 0 ;
            // 百度地图API功能
            var map = new BMap.Map("allmap");
            $.ajax({
                url: "<%=basePath%>/resource/json/mapStyle.json",
                dataType: "json",
                success: function (data) {
                    map.setMapStyle({
                        styleJson: data
                    });
                }
            })
            var point = new BMap.Point(115.675402, 37.745191);
            map.centerAndZoom(point, 15);

            $.post("<%=basePath%>/admin/education/getEducationOrganization.action", {
                categoryName: '<%=DicOrganizationType.MEDICAL%>',
                name:$("#searchName").val()
            }, function (datas) {
                $("#tableList").empty() ;
                if (datas.length > 0) {
                    for (var i = 0; i < datas.length; i++) {
                        (function (x) {
                            if (datas[i].orgType == '<%=DicMedicalType.HOSPITAL%>'&&falg1==0) {
                                count1++ ;
                                var fax= datas[i].fax==null?'暂无':datas[i].fax ;
                                var photo= datas[i].photo==null?'暂无':datas[i].photo ;
                                var sContent =
                                    "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + datas[i].orgName + "</h4>" +
                                    // "<img style='float:right;margin:4px' id='imgDemo' src='../img/tianAnMen.jpg' width='139' height='104' title='"+datas[i].orgName+"'/>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>地址：" + fax + "</p>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>电话：" + photo + "</p>" +
                                    "</div>";
                                var pt = new BMap.Point(datas[i].longitude, datas[i].latitude);
                                var myIcon = new BMap.Icon("<%=basePath%>/resource/images/medical/yy.png", new BMap.Size(40, 40));
                                var marker = new BMap.Marker(pt, {icon: myIcon});  // 创建标注
                                var infoWindow = new BMap.InfoWindow(sContent);
                                map.centerAndZoom(point, 15);
                                marker.addEventListener("click", function () {
                                    this.openInfoWindow(infoWindow);
                                    //图片加载完毕重绘infowindow
                                    // document.getElementById('imgDemo').onload = function (){
                                    //     infoWindow.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
                                    // }
                                });
                                map.addOverlay(marker);
                            }
                            if (datas[i].orgType == '<%=DicMedicalType.REHABILITATION%>'&&falg2==0) {
                                count2++ ;
                                var fax= datas[i].fax==null?'暂无':datas[i].fax ;
                                var photo= datas[i].photo==null?'暂无':datas[i].photo ;
                                var sContent =
                                    "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + datas[i].orgName + "</h4>" +
                                    // "<img style='float:right;margin:4px' id='imgDemo' src='../img/tianAnMen.jpg' width='139' height='104' title='"+datas[i].orgName+"'/>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>地址：" + fax + "</p>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>电话：" + photo + "</p>" +
                                    "</div>";
                                var pt = new BMap.Point(datas[i].longitude, datas[i].latitude);
                                var myIcon = new BMap.Icon("<%=basePath%>/resource/images/medical/kfzx.png", new BMap.Size(40, 40));
                                var marker = new BMap.Marker(pt, {icon: myIcon});  // 创建标注
                                var infoWindow = new BMap.InfoWindow(sContent);
                                map.centerAndZoom(point, 15);
                                marker.addEventListener("click", function () {
                                    this.openInfoWindow(infoWindow);
                                    //图片加载完毕重绘infowindow
                                    // document.getElementById('imgDemo').onload = function (){
                                    //     infoWindow.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
                                    // }
                                });
                                map.addOverlay(marker);
                            }

                            if (datas[i].orgType == '<%=DicMedicalType.COMMUNITY_CLINICS%>'&&falg3==0) {
                                count3++ ;
                                var fax= datas[i].fax==null?'暂无':datas[i].fax ;
                                var photo= datas[i].photo==null?'暂无':datas[i].photo ;
                                var sContent =
                                    "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + datas[i].orgName + "</h4>" +
                                    // "<img style='float:right;margin:4px' id='imgDemo' src='../img/tianAnMen.jpg' width='139' height='104' title='"+datas[i].orgName+"'/>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>地址：" + fax + "</p>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>电话：" + photo + "</p>" +
                                    "</div>";
                                var pt = new BMap.Point(datas[i].longitude, datas[i].latitude);
                                var myIcon = new BMap.Icon("<%=basePath%>/resource/images/medical/sqzs.png", new BMap.Size(40, 40));
                                var marker = new BMap.Marker(pt, {icon: myIcon});  // 创建标注
                                var infoWindow = new BMap.InfoWindow(sContent);
                                map.centerAndZoom(point, 15);
                                map.addOverlay(marker);
                                marker.addEventListener("click", function () {
                                    this.openInfoWindow(infoWindow);
                                    //图片加载完毕重绘infowindow
                                    // document.getElementById('imgDemo').onload = function (){
                                    //     infoWindow.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
                                    // }
                                });
                            }
                            if (datas[i].orgType == '<%=DicMedicalType.SPECIALIST_CLINIC%>'&&falg4==0) {
                                count4++ ;
                                var fax= datas[i].fax==null?'暂无':datas[i].fax ;
                                var photo= datas[i].photo==null?'暂无':datas[i].photo ;
                                var sContent =
                                    "<h4 style='margin:0 0 5px 0;padding:0.2em 0'>" + datas[i].orgName + "</h4>" +
                                    // "<img style='float:right;margin:4px' id='imgDemo' src='../img/tianAnMen.jpg' width='139' height='104' title='"+datas[i].orgName+"'/>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>地址：" + fax + "</p>" +
                                    "<p style='margin:0;line-height:1.5;font-size:13px;text-indent:2em'>电话：" + photo + "</p>" +
                                    "</div>";
                                var pt = new BMap.Point(datas[i].longitude, datas[i].latitude);
                                var myIcon = new BMap.Icon("<%=basePath%>/resource/images/medical/zkmz.png", new BMap.Size(40, 40));
                                var marker = new BMap.Marker(pt, {icon: myIcon});  // 创建标注
                                var infoWindow = new BMap.InfoWindow(sContent);
                                map.centerAndZoom(point, 15);
                                map.addOverlay(marker);
                                marker.addEventListener("click", function () {
                                    this.openInfoWindow(infoWindow);
                                    //图片加载完毕重绘infowindow
                                    // document.getElementById('imgDemo').onload = function (){
                                    //     infoWindow.redraw();   //防止在网速较慢，图片未加载时，生成的信息框高度比图片的总高度小，导致图片部分被隐藏
                                    // }
                                });
                            }
                        })(i);
                    }
                }
                var html1 = '<tr>' +
                    '<th><%=DicMedicalType.HOSPITAL%></th>' +
                    '<th>'+count1+'</th>' +
                    '</tr>' ;
                $("#tableList").append(html1) ;
                var html2 = '<tr>' +
                    '<th><%=DicMedicalType.REHABILITATION%></th>' +
                    '<th>'+count2+'</th>' +
                    '</tr>' ;
                $("#tableList").append(html2) ;
                var html3= '<tr>' +
                    '<th><%=DicMedicalType.COMMUNITY_CLINICS%></th>' +
                    '<th>'+count3+'</th>' +
                    '</tr>' ;
                $("#tableList").append(html3) ;
                var html4 = '<tr>' +
                    '<th><%=DicMedicalType.SPECIALIST_CLINIC%></th>' +
                    '<th>'+count4+'</th>' +
                    '</tr>' ;
                $("#tableList").append(html4) ;
            }, "json")
        }

        $("#btnSearch").click(function () {
            changeByName();
        });
    </script>
</body>
</html>