<%@ 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">
    <jsp:include page="../common/user_center_header.jsp"></jsp:include>
    <div class="user-mid2">
        <div class="xinxi0">
            <div class="user-mid0">
                <%--<div class="if">--%>
                    <%--<span onclick="showAndHiddenApi1()" class="xx0" id="tagShenqing"><a>申请的API</a></span>--%>
                    <%--<span class="xx" onclick="showAndHiddenApi2()" id="tagGuanzhu"><a>关注的API</a></span>--%>
                <%--</div>--%>
                <div class="if">
                    <span onclick="showAndHiddenApi1()" class="xx0 xx01" id="tagShenqing"><a>我的数据需求</a></span>
                    <span class="xx" onclick="showAndHiddenApi2()" id="tagGuanzhu"><a>我关注的需求</a></span>
                </div>
                <div class="clearfix"></div>
                <div class="xx-main" id="data">
                    <table >
                        <tr bgcolor="#f2f2f2" class="biaotou1">
                            <td class="td5">需求名称</td>
                            <td >需求描述</td>
                            <td class="td4">发布日期</td>
                            <td class="td4">状态</td>
                            <td class="td7">操作</td>
                        </tr>
                        <c:if test="${dataList !=null}">
                            <c:forEach items="${dataList}" var="item" >
                                <tr>
                                    <td><a class="qxbm" href="<%=basePath%>/share/dataRequirement/detail.htm/${item.rqrmntId}">${item.rqrmntName}</a></td>
                                    <td>${item.rqrmntSummary}</td>
                                    <td><fmt:formatDate value="${item.publishAt}" pattern="yyyy-MM-dd"></fmt:formatDate></td>
                                    <td>${item.rqrmntState}</td>
                                    <td>
                                        <a class="qxbm" onclick="offLine(${item.rqrmntId})"><c:if test="${item.rqrmntState eq '已反馈' || item.rqrmntState eq '待反馈'}">下架</c:if></a>
                                        <a class="qxbm" onclick="edit(${item.rqrmntId})"><c:if test="${item.rqrmntState eq '审核不通过' || item.rqrmntState eq '待提交'}">编辑</c:if></a>
                                        <a class="qxbm" onclick="del(${item.rqrmntId})"><c:if test="${item.rqrmntState eq '待提交'}">删除</c:if></a>
                                        <a class="qxbm" onclick="publish(${item.rqrmntId})"><c:if test="${item.rqrmntState eq '待提交'}">发布</c:if></a>

                                    </td>
                                </tr>
                            </c:forEach>
                        </c:if>
                    </table>
                </div>
                <div class="xx-main" id="follow" style="display: none">
                    <table >
                        <tr bgcolor="#f2f2f2" class="biaotou1">
                            <td class="td5">需求名称</td>
                            <td >需求类型</td>
                            <td class="td4">发布人</td>
                            <td class="td4">关注日期</td>
                            <td class="td7">操作</td>
                        </tr>
                        <c:if test="${followList !=null}">
                            <c:forEach items="${followList}" var="item" >
                                <tr>
                                    <td>${item.rqrmntName}</td>
                                    <td>${item.rqrmntType}</td>
                                    <td>${item.publishBy}</td>
                                    <td><fmt:formatDate value="${item.createdAt}" pattern="yyyy-MM-dd"></fmt:formatDate> </td>
                                    <td><a onclick="delfollow(${item.followId})" class="qxbm">取消关注</a></td>
                                </tr>
                            </c:forEach>
                        </c:if>
                    </table>
                </div>



            </div>
        </div>
    </div>
</div>


<div class="clearfix"></div>
<jsp:include page="../common/body_footer.jsp"></jsp:include>
</body>
<script>
    function showAndHiddenApi1() {
        $("#data").show();
        $("#follow").hide();
        $("#tagShenqing").addClass("xx01");
        $("#tagGuanzhu").removeClass("xx01");

    }

    function showAndHiddenApi2() {
        $("#data").hide();
        $("#follow").show();
        $("#tagGuanzhu").addClass("xx01");
        $("#tagShenqing").removeClass("xx01");
    }
    function delfollow(id) {
        $.ajax({
            url:"<%=basePath%>/share/MyShareFollow/delfollow.action/"+id,
            type:"post",
            success:function (msg) {
                if(msg.stateCode==200) {
                    window.location.href="<%=basePath%>/share/MyShareDataRequirement/list.action"
                    alert("取消关注成功");
                }
            }
        })

    }
    function offLine(id) {
        $.ajax({
            url:"<%=basePath%>/share/MyShareDataRequirement/offLine.action/"+id,
            type:"post",
            success:function (msg) {
                if(msg.stateCode==200) {
                    window.location.href="<%=basePath%>/share/MyShareDataRequirement/list.action"
                    alert("下架成功");
                }else{
                    alert("下架失败");
                }
            }
        })

    }
    function del(id) {
        $.ajax({
            url:"<%=basePath%>/share/MyShareDataRequirement/del.action/"+id,
            type:"post",
            success:function (msg) {
                if(msg.stateCode==200) {
                    window.location.href="<%=basePath%>/share/MyShareDataRequirement/list.action"
                    alert("删除成功");
                }else{
                    alert("删除失败");
                }
            }
        })

    }
    function publish(id) {
        $.ajax({
            url:"<%=basePath%>/share/MyShareDataRequirement/publish.action/"+id,
            type:"post",
            success:function (msg) {
                if(msg.stateCode==200) {
                    window.location.href="<%=basePath%>/share/MyShareDataRequirement/list.action"
                    alert("发布成功");
                }else{
                    alert("发布失败");
                }
            }
        })

    }


    function edit(id) {
    window.location.href="<%=basePath%>/share/MyShareDataRequirement/edit.htm/"+id;
    }

</script>
</html>