<%@ 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"%>
<%
    String basePath = request.getContextPath();
    String resourcePath = basePath + "/resource";
%>
<!DOCTYPE html>
<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="datalistbanner">
        <div class="banner"></div>
    </div>
    <div class="liebiao">
        <div class="liebiao1">
            <span class="liebiao02"><a href="<%=basePath%>/open/data/index.htm" class="xuanxiangfont xuanxiangfont-active">数据</a></span>
            <span class="liebiao01"><a href="<%=basePath%>/open/api/list.htm" class="xuanxiangfont">API</a> </span>
            <span class="liebiao01"><a href="<%=basePath%>/open/microapp/openList.action" class="xuanxiangfont">微应用</a></span>
        </div>
    </div>
    <div class="mid">

        <div class="main">

            <div class="shuju">
                <div class="sjst"><a href="<%=basePath%>/open/data/dataview.htm">数据视图</a></div>
                <div class="clearfix"></div>
                <div class="filter">
                    <div class="item">
                        <div class="zhuti" id="zhuti">主题：</div>
                        <ul style="height: 60px" id="themeItem" class="item1">
                            <li class="li">
                                <a href="##" onclick="themeSearch('')" class="a<c:if test="${ empty searchModel.catelogThemeCode}">0</c:if>4">不限</a>
                            </li>
                            <c:if test="${themes.size()>0}">
                                <c:forEach items="${themes}" var="theme">
                                    <li class="li">
                                        <a href="##" onclick="themeSearch('${theme.catelogCode}')" class="a<c:if test="${searchModel.catelogThemeCode eq theme.catelogCode}">0</c:if>4"
                                        >${theme.cateLogName}</a>
                                    </li>
                                </c:forEach>
                            </c:if>
                        </ul>
                        <div id="themeDown" class="icon2"><a onclick="showThemeTag()"><img src="<%=resourcePath%>/images/icon_down.png"></a></div>
                        <div id="themeTop" class="icon2"><a onclick="hiddenThemeTag()"><img src="<%=resourcePath%>/images/icon_top.png"></a></div>
                    </div>
                    <div class="item" id="sectorItem" style="height: 60px">
                        <div class="zhuti">部门：</div>
                        <ul class="item1">
                            <li class="li">
                                <a href="##" onclick="sectorSearch('')" class="a<c:if test="${empty searchModel.sectorCode}">0</c:if>4">不限</a>
                            </li>
                            <c:if test="${sectors.size()>0}">
                                <c:forEach items="${sectors}" var="sector">
                                    <li class="li">
                                        <a href="##" onclick="sectorSearch('${sector.sectorCode}')" class="a<c:if test="${searchModel.sectorCode==sector.sectorCode}">0</c:if>4"
                                        >${sector.sectorName}</a>
                                    </li>
                                </c:forEach>
                            </c:if>
                        </ul>
                        <div id="sectorDown" class="icon2"><a onclick="showSectorShow()"><img src="<%=resourcePath%>/images/icon_down.png"></a></div>
                        <div id="sectorTop" class="icon2"><a onclick="hiddenSectorHidden()"><img src="<%=resourcePath%>/images/icon_top.png"></a></div>
                    </div>
                    <div  class="item">
                        <div class="zhuti">类型：</div>
                        <ul class="item1">
                            <li class="li">
                                <a href="##" onclick="chargeMethodSearch('')" class="a<c:if test="${empty searchModel.chargeMethod}">0</c:if>4">不限</a>
                            </li>
                            <c:if test="${chargeMethods.size()>0}">
                                <c:forEach items="${chargeMethods}" var="chargeMethod">
                                    <li class="li">
                                        <a href="##" onclick="chargeMethodSearch('${chargeMethod.key}')" class="a<c:if test="${searchModel.chargeMethod eq chargeMethod.key}">0</c:if>4"
                                           class="a4">${chargeMethod.key}</a>
                                    </li>
                                </c:forEach>
                            </c:if>
                        </ul>
                    </div>
                </div>
                <div class="shuju0">
                    <div id="sortType">
                        <span ${searchModel.sortType == 0 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>默认排序</a></span>
                        <span ${searchModel.sortType == 1 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>最新开放</a></span>
                        <span ${searchModel.sortType == 2 ? 'class="paixu paixu-active"' : "class='paixu'"}<a>访问数量</a></span>
                        <span ${searchModel.sortType == 3 ? 'class="paixu paixu-active"' : "class='paixu'"}><a>申请数量</a></span>
                        <span class="xiangshu">(共${pager.total}项)</span>
                    </div>
                    <c:forEach items="${list}" var="item" varStatus="status">
                        <c:if test="${status.index % 5 ==0}"><div class="shuju01" onclick="fnToDetail()"> </c:if>
                            <div class="div1">
                                <div class="div_icon1">
                                    <a href="<%=basePath%>/open/data/detail.htm/${item.publishSettingId}"><img src="${item.resourceImg}"/></a>
                                </div>
                                <div class="h1" title="${item.resourceName}"><a   class="qxbm" href="<%=basePath%>/open/data/detail.htm/${item.publishSettingId}">${item.resourceName}</a></div>
                                <div ${item.chargeMethod eq '免费'?'class="mianfei"':'class="shoufei"'}>${item.chargeMethod}</div>
                                <div class="api-foot1">
                                            <span class="liulan" id="liulan" title="浏览量：${item.viewTimes}">
                                                <img src="<%=resourcePath%>/images/icon_chakan.png" class="liulan-icon">(${item.viewTimes})
                                            </span>
                                    <span class="xiazai" title="下载量：">
                                                <img src="<%=resourcePath%>/images/icon_xiazai.png" class="xiazai-icon">()
                                            </span>
                                    <div class="line-w"></div>
                                    <div class="line-h"></div>
                                </div>
                            </div>
                        <c:if test="${status.index % 5 ==4}"></div></c:if>
                        <c:if test="${status.last}"></div></c:if>
                    </c:forEach>
                    <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>
                    <%--<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>--%>
                    <input type="hidden" name="theme" id="theme" value="${searchModel.catelogThemeCode}">
                    <input type="hidden" name="sector" id="sector" value="${searchModel.sectorCode}">
                    <input type="hidden" name="chargeMethod" id="chargeMethod" value="${searchModel.chargeMethod}">
                </div>
            </div>
        </div>
    </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 ($("#chargeMethod").val() != null && $("#chargeMethod").val() != '' && $("#chargeMethod").val() != undefined) {
            str3 = "&chargeMethod=" + $("#chargeMethod").val();
        }
        window.location.href = "<%=basePath%>/open/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 ($("#chargeMethod").val() != null && $("#chargeMethod").val() != '' && $("#chargeMethod").val() != undefined) {
            str3 = "&chargeMethod=" + $("#chargeMethod").val();
        }
        window.location.href = "<%=basePath%>/open/data/index.htm?" + str2 + str1 + str3 ;
    }

    function chargeMethodSearch(str) {
        if (str != null && str != '' && str != undefined) {
            str2 = "chargeMethod="+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%>/open/data/index.htm?" + str2 +str3+str1;
    }


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

    hiddenThemeTag() ;

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

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

    hiddenSectorHidden() ;

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

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

    //分页
    $('#pager a').not(".disabled").click(function(){
        var pageNo=$(this).attr("page");
        pageSearch(pageNo);
    })
    function pageSearch(pageNo) {
            window.location.href = "<%=basePath%>/open/data/index.htm?sortType=${searchModel.sortType}&catelogThemeCode=${searchModel.catelogThemeCode}"+
                "&sectorCode=${searchModel.sectorCode}&chargeMethod=${searchModel.chargeMethod}&pageNo="+pageNo+"";
    }

    // 根据选中项展开
    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>
