<%@ 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 uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%
    String basePath = request.getContextPath();
%>
<div class="table-responsive">
    <table class="table table-striped table-bordered table-hover " >
        <thead>
        <tr>
            <th>资源名称</th>
            <th>所属单位</th>
            <th>发布时间</th>
            <th>排序值</th>
            <th class="hidden-print">操 作</th>
        </tr>
        </thead>
        <tbody>
        <c:choose>
            <c:when test="${list!=null}">
                <c:forEach items="${list}" var="item" >
                    <tr>
                        <td>${item.resourceName}</td>
                        <td>${item.provider}</td>
                        <td><fmt:formatDate value="${item.auditedAt}" pattern="yyyy-MM-dd"></fmt:formatDate> </td>
                        <td>${item.sortValue}</td>
                        <td class="btn-table hidden-print">
                            <input type="hidden" name="id" value="${item.id}" />
                            <input type="hidden" name="resourceId" value="${item.resourceId}" />


                                <button name="btnUp" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>上移</button>
                                <button name="btnDown" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>下移</button>
                        </td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
        <input type="hidden" id="sortCategory" value="${sortCategory}"/>
    </table>
</div>
<script type="text/javascript">
    $("#divGrid table tbody tr td:last-child")
        .on("click", "button[name='btnUp']", function () {
            debugger;
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            var resourceId = $(this).parent().children("input[type='hidden'][name='resourceId']").val();
            if(id!="") {
                $.popBsPartial({ url: "<%=basePath%>/admin/DataRecommendation/move.htm/" + id});
            }else {
                var sortCategory = $("#sortCategory").val();
                var resourceId = $(this).parent().children("input[type='hidden'][name='resourceId']").val();
                $.popBsPartial({ url: "<%=basePath%>/admin/DataRecommendation/add1.htm/"+resourceId+"/"+sortCategory});
            }
        })
        .on("click", "button[name='btnDown']", function () {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            var resourceId = $(this).parent().children("input[type='hidden'][name='resourceId']").val();
            if(id!="") {
                $.popBsPartial({ url: "<%=basePath%>/admin/DataRecommendation/move.htm/" + id});
            }else {
                var sortCategory = $("#sortCategory").val();
                var resourceId = $(this).parent().children("input[type='hidden'][name='resourceId']").val();
                $.popBsPartial({ url: "<%=basePath%>/admin/DataRecommendation/add1.htm/"+resourceId+"/"+sortCategory});
            }
        })


</script>
<jsp:include page="../../../common/admin/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>
