<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.lightinit.hsdataplatform.dictionary.DicRequirementState" %>
<%@ 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>
            <td>行号</td>
            <th>需求名称</th>
            <th>需求摘要</th>
            <th>需求来源</th>
            <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" varStatus="status">
                    <tr>
                        <td>${(pager.pageNo-1)*pager.pageSize+status.count}</td>
                        <td><a href="javascript:;" onclick="popDetail(this)">${item.requirementName}</a></td>
                        <td>${item.requirementSummary}</td>
                        <td>${item.requirementSource}</td>
                        <td>${item.rqrmntUserName}</td>
                        <td>${item.belongtoSectorName}</td>
                        <td><fmt:formatDate value="${item.createdAt}" pattern="yyyy-MM-dd"/></td>
                        <td>${item.rqrmntState}</td>
                        <td class="btn-table hidden-print">
                            <input type="hidden" name="id" value="${item.id}"/>
                            <c:if test="${DicRequirementState.PENDING == item.rqrmntState}">
                                <button name="btnAudit" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>审核</button>
                            </c:if>
                            <c:if test="${DicRequirementState.PENDING_FEEDBACK == item.rqrmntState}">
                                <button name="btnFeedback" class="btn btn-sm btn-info"><i class="fa fa-leaf"></i>反馈</button>
                            </c:if>
                        </td>
                    </tr>
                </c:forEach>
            </c:when>
            <c:otherwise>
                <tr>
                    <td colspan="4">无数据</td>
                </tr>
            </c:otherwise>
        </c:choose>
        </tbody>
    </table>
</div>
<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>
<script type="text/javascript">
    $("#divGrid table tbody tr td:last-child")
            .on("click", "button[name='btnFeedback']", function () {
                var id = $(this).parent().children("input[type='hidden'][name='id']").val();
                $.popBsPartial({url: "<%=basePath%>/admin/data_supply/popFeedback.action?id=" + id});
            })
            .on("click", "button[name='btnAudit']", function () {
                var id = $(this).parent().children("input[type='hidden'][name='id']").val();
                $.popBsPartial({url: "<%=basePath%>/admin/data_supply/popAudit.action?id=" + id});
            });

    function popDetail() {
        var id = $("#divGrid table tbody tr td:last-child").children("input[type='hidden'][name='id']").val();
        $.popBsPartial({url: "<%=basePath%>/admin/data_supply/popDetail.action?id=" + id});
    }
</script>