<%@ page import="com.lightinit.hsdataportal.dictionary.DicResourceShareType" %>
<%@ page language="java" pageEncoding="UTF-8"
         contentType="text/html; charset=UTF-8"%>
<%@ page isELIgnored="false"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<!DOCTYPE html>
<head>
    <title>数据-列表</title>
    <jsp:include page="../common/head.jsp"></jsp:include>
</head>
<body>
    <jsp:include page="../common/body_header.jsp"></jsp:include>
    <div class="mid-0">
        <div class="mid">
            <div class="mid-top0">
                <div class="sjst"><a href="<%=basePath%>/share/data/dataview.htm">数据视图</a></div>
                <div class="mid-top00">
                    <div class="mid-top000">
                        <div class="mid-top1">
                            <div class="xuanzeimg">
                                <div class="img1"><a href="<%=basePath%>/share/data/index.htm">数据</a></div>
                                <div class="img2" onclick="fnAPI()"><a href="<%=basePath%>/share/api/list.htm">API</a></div>
                                <div class="img2" onclick="fnMric()"><a href="<%=basePath%>/share/microapp/shareList.action">微应用</a></div>
                            </div>
                            <div class="js">
                                <img src="<%=resourcePath%>/images/share/icon_shuju.png" alt="">
                                <div class="jsfont">数据提供交通、教育、医疗、旅游等资源，方便民众快速的了解自己想知道的。</div>
                            </div>

                        </div>
                        <div class="mid-top2">
                        <div id="themeItem" class="xx1">
                            <span>主题：</span>
                            <ul>
                                <li><a onclick="themeSearch('')" <c:if test="${ empty searchModel.catelogThemeCode}">class="li-active"</c:if>>不限</a></li>
                                <c:if test="${themes.size()>0}">
                                    <c:forEach items="${themes}" var="theme">
                                        <li><a onclick="themeSearch('${theme.catelogCode}')" <c:if test="${searchModel.catelogThemeCode eq theme.catelogCode}">class="li-active"</c:if>>${theme.cateLogName}</a></li>
                                    </c:forEach>
                                </c:if>
                            </ul>
                            <div id="themeDown" class="icon2"><a onclick="showThemeTag()"><img src="<%=resourcePath%>/images/share/icon_down.png"></a></div>
                            <div id="themeTop" class="icon2"><a onclick="hiddenThemeTag()"><img src="<%=resourcePath%>/images/share/icon_top.png"></a></div>
                        </div>
                        <div class="clearfix"></div>
                        <div id="sectorItem" class="xx1">
                            <span>部门：</span>
                            <ul>
                                <li><a onclick="sectorSearch('')" <c:if test="${empty searchModel.sectorCode}">class="li-active"</c:if>>不限</a></li>
                                <c:if test="${sectors.size()>0}">
                                    <c:forEach items="${sectors}" var="sector">
                                        <li><a onclick="sectorSearch('${sector.sectorCode}')" <c:if test="${searchModel.sectorCode==sector.sectorCode}">class="li-active"</c:if>>${sector.sectorName}</a></li>
                                    </c:forEach>
                                </c:if>
                            </ul>
                            <div id="sectorDown" class="icon2"><a onclick="showSectorShow()"><img src="<%=resourcePath%>/images/share/icon_down.png"></a></div>
                            <div id="sectorTop" class="icon2"><a onclick="hiddenSectorHidden()"><img src="<%=resourcePath%>/images/share/icon_top.png"></a></div>
                        </div>
                        <div class="clearfix"></div>
                        <div class="xx2">
                            <span>属性：</span>
                            <ul>
                                <li><a onclick="shareTypeSearch('')" <c:if test="${empty searchModel.moreCondition}">class="li-active"</c:if>>不限</a></li>
                                <li><a onclick="shareTypeSearch('<%=DicResourceShareType.CONDITIONAL%>')" <c:if test="${searchModel.moreCondition eq '有条件共享'}">class="li-active"</c:if>><%=DicResourceShareType.CONDITIONAL%></a></li>
                                <li><a onclick="shareTypeSearch('<%=DicResourceShareType.UNCONDITIONAL%>')" <c:if test="${searchModel.moreCondition eq '无条件共享'}">class="li-active"</c:if>><%=DicResourceShareType.UNCONDITIONAL%></a></li>
                            </ul>

                        </div>
                    </div>
                    </div>
                </div>
                <div class="mid0">
                    <div class="mid00">
                        <div class="mid00-top">
                            <div class="mid00-top1">符合条件的数据（共<span>${pager.total}</span>项）</div>
                            <div class="mid00-top2" id="sortType">
                                <span>排序方式：</span>
                                <a ${searchModel.sortType == 0 ? 'class="li-active"' : ''}>默认排序</a>
                                <a ${searchModel.sortType == 1 ? 'class="li-active"' : ''}>最新开放</a>
                                <a ${searchModel.sortType == 2 ? 'class="li-active"' : ''}>访问数量</a>
                                <a ${searchModel.sortType == 3 ? 'class="li-active"' : ''}>申请数量</a>
                            </div>
                        </div>
                        <div class="mid1">
                            <c:if test="${outputModel !=null}">
                                <c:forEach items="${outputModel}" var="item" varStatus="status">
                                    <c:if test="${status.index % 5 ==0}"><div class="shuju01"> </c:if>
                                        <div class="div">
                                            <div class="h" title="${item.resourceName}"><a href="<%=basePath%>/share/data/detail.htm/${item.publishSettingId}">${item.resourceName}</a></div>
                                            <div class="div_icon" title="${item.resourceName}">
                                                <a href="<%=basePath%>/share/data/detail.htm/${item.publishSettingId}"><img src="${item.resourceImg}"></a>
                                            </div>
                                            <p>${item.shareType}</p>
                                            <div class="api-foot">
                                                    <span class="liulan" title="浏览量：(${item.viewTimes})">
                                                        <img src="<%=resourcePath%>/images/share/icon_chakan.png" class="liulan-icon">(${item.viewTimes})
                                                    </span>
                                                <span class="xiazai" title="下载量：0">
                                                        <img src="<%=resourcePath%>/images/share/icon_xiazai.png" class="xiazai-icon">0
                                                    </span>
                                                <div class="line-w"></div>
                                                <div class="line-h"></div>
                                            </div>
                                            <img src="<%=resourcePath%>/images/share/icon_youhui.png" class="icon">
                                        </div>
                                    <c:if test="${status.index % 5 ==4}"></div></c:if>
                                    <c:if test="${status.last}"></div></c:if>
                                </c:forEach>
                            </c:if>
                        </div>
                        <c:if test="${pager.total ==0}">
                            <div class="text" style=" text-align:center;"><span >暂无数据</span></div>
                        </c:if>
                        <c:if test="${pager.total >0}">
                            <jsp:include page="../common/pager.jsp">
                                <jsp:param name="pageNo" value="${pager.pageNo}"/>
                                <jsp:param name="pageSize" value="${pager.pageSize}"/>
                                <jsp:param name="total" value="${pager.total}"/>
                            </jsp:include>
                        </c:if>
                    </div>
                </div>
                <input type="hidden" name="theme" id="theme" value="${searchModel.catelogThemeCode}">
                <input type="hidden" name="sector" id="sector" value="${searchModel.sectorCode}">
                <input type="hidden" name="shareType" id="shareType" value="${searchModel.moreCondition}">
            </div>
        </div>
    <jsp:include page="../common/body_footer.jsp"></jsp:include>
</body>
<script type="text/javascript">
    var str1 = "";
    var str2 = "";
    var str3 = "";
    function themeSearch(code) {
        if (code != null&& code != '' && code != undefined ) {
            str2 = "catelogThemeCode=" + code;
        }
        if ($("#sector").val() != null && $("#sector").val() != '' && $("#sector").val() != undefined) {
            str1 = "&sectorCode=" + $("#sector").val();
        }
        if ($("#shareType").val() != null && $("#shareType").val() != '' && $("#shareType").val() != undefined) {
            str3 = "&shareType=" + $("#shareType").val();
        }
        window.location.href = "<%=basePath%>/share/data/index.htm?" + str2 + str1+str3 ;
    }

    function sectorSearch(code) {
        if (code != null&& code != '' && code != undefined ) {
            str2 = "sectorCode=" + code;
        }
        if ($("#theme").val() != null && $("#theme").val() != '' && $("#theme").val() != undefined) {
            str1 = "&catelogThemeCode=" + $("#theme").val();
        }
        if ($("#shareType").val() != null && $("#shareType").val() != '' && $("#shareType").val() != undefined) {
            str3 = "&shareType=" + $("#shareType").val();
        }
        window.location.href = "<%=basePath%>/share/data/index.htm?" + str2 + str1 + str3 ;
    }

    function shareTypeSearch(str) {
        if (str != null && str != '' && str != undefined) {
            str2 = "shareType="+str ;
        }
        if ($("#theme").val() != null && $("#theme").val() != '' && $("#theme").val() != undefined) {
            str3 = "&catelogThemeCode=" + $("#theme").val();
        }
        if ($("#sector").val() != null && $("#sector").val() != '' && $("#sector").val() != undefined) {
            str1 = "&sectorCode=" + $("#sector").val();
        }
        window.location.href = "<%=basePath%>/share/data/index.htm?" + str2 +str3+str1;
    }

    function showThemeTag() {
        $("#themeItem").removeAttr("style");
        $("#themeDown").hide() ;
        $("#themeTop").show() ;
    }

    hiddenThemeTag() ;

    function hiddenThemeTag() {
        $("#themeItem").attr("style","height:70px");
        $("#themeDown").show() ;
        $("#themeTop").hide() ;
    }

    function showSectorShow() {
        $("#sectorItem").removeAttr("style");
        $("#sectorDown").hide() ;
        $("#sectorTop").show() ;
    }

    hiddenSectorHidden() ;

    function hiddenSectorHidden() {
        $("#sectorItem").attr("style","height:70px");
        $("#sectorDown").show() ;
        $("#sectorTop").hide() ;
    }

    //排序
    sort();
    function sort(){
            var spans = $('#sortType').children("a");
            for(var i=0;i<spans.length;i++){
                (function(j){
                    spans[j].onclick=function() {
                        window.location.href = "<%=basePath%>/share/data/index.htm?sortType="+j+"&catelogThemeCode=${searchModel.catelogThemeCode}"+
                            "&sectorCode=${searchModel.sectorCode}&shareType=${searchModel.moreCondition}";
                    };
                })(i)
            }
        }


    //分页
    $('#pager button').not(".disabled").click(function(){
        var pageNo=$(this).attr("page");
        pageSearch(pageNo);
    })
    function pageSearch(pageNo) {
        window.location.href = "<%=basePath%>/share/data/index.htm?sortType=${searchModel.sortType}&catelogThemeCode=${searchModel.catelogThemeCode}"+
            "&sectorCode=${searchModel.sectorCode}&shareType=${searchModel.moreCondition}&pageNo="+pageNo+"";
    }
    //主题切换
    function fnMric() {
        window.location.href="<%=basePath%>/share/microapp/shareList.action"
    }
    function fnAPI() {
        window.location.href="<%=basePath%>/share/api/list.htm"
    }


    // 根据选中项展开
    function expandCriteria(parentDiv, selectedValue, expandFunction){
        var selectedLi;
        $(parentDiv + " ul li a").each(function (index, element) {
            if (selectedValue && selectedValue != "" && $(element).attr("onclick").indexOf(selectedValue) > -1){
                selectedLi = $(element).parent();
            }
        });
        if (selectedLi && selectedLi.position().top > 0){
            expandFunction();
        }
    }

    $(function () {
        expandCriteria("#themeItem", "${searchModel.catelogThemeCode}", showThemeTag);
        expandCriteria("#sectorItem", "${searchModel.sectorCode}", showSectorShow);
    });
</script>
</html>