<%@ 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>主题分类</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><a onclick="detail(${item.id})">${item.resourceName}</a></td>
                        <td>${item.resourceIdentity}</td>
                        <td>${item.resourceSummary}</td>
                        <td>${item.provider}</td>
                        <td>${item.themename}</td>
                        <td><fmt:formatDate value="${item.registerDate}" pattern="yyyy-MM-dd"/></td>
                        <td>${item.publishState}</td>
                        <td class="btn-table hidden-print">
                            <input type="hidden" name="id" value="${item.id}" />
                            <%--<button name="btnDetail" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-check"></i>详情</button>--%>
                            <c:if test="${item.publishState eq '审核不通过' || item.publishState eq '待提交' || item.publishState eq '已发布' || item.publishState eq '已下架' }">

                                <button name="btnEdit" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-edit"></i>编辑</button>
                            </c:if>
                            <c:if test="${item.publishState eq '待提交'}">
                                <button name="btnDelete" class="btn btn-sm btn-danger m-r-sm"><i class="fa fa-trash-o"></i>删除</button>
                            </c:if>
                            <c:if test="${item.publishState eq '已发布'}">
                                <button name="btnDownframe" class="btn btn-sm btn-primary m-r-sm"><i class="fa fa-check"></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='btnDelete']", function() {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.delWithConfirm({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/microapp_publish/delete.action/" + id } } });
        })
        .on("click", "button[name='btnDetail']", function () {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.popBsPartial({ url: "<%=basePath%>/admin/microapp_publish/detail.htm/" + id });
        })
        .on("click", "button[name='btnEdit']", function () {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            $.popBsPartial({ url: "<%=basePath%>/admin/microapp_publish/edit.htm/" + id });
        })
        .on("click", "button[name='btnDownframe']", function() {
            var id = $(this).parent().children("input[type='hidden'][name='id']").val();
            delDownframe({ func: $.ajaxGetRefresh, funcArgs: { ajaxGetOptions: { url: "<%=basePath%>/admin/microapp_publish/downframe.action/" + id } } });
        })


    function delDownframe(args) {
        ///<summary>带有确认取消的删除</summary>
        ///<param name="args" type="Object">参数对象</param>
        ///<param name="args.func" type="function">确认后执行的方法</param>
        ///<param name="args.funcArgs" type="function">确认后执行方法的参数</param>
        ///<param name="args.msg" type="function">自定义提示信息</param>
        var defaultArgs = {
            msg: "确认下架吗？"
        };
        var finalArgs = $.extend(true, defaultArgs, args);
        functionWithConfirm(finalArgs);
    }
    function detail(id) {
        $.popBsPartial({ url: "<%=basePath%>/admin/microapp_publish/detail.htm/" + id });
    }

</script>