<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8" %>
<%@ page isELIgnored="false" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
    String basePath = request.getContextPath();
%>
<!DOCTYPE html>
<html>
<head>
    <jsp:include page="../../../common/admin/head.jsp"></jsp:include>
</head>
<body>
<jsp:include page="../../../common/admin/body_pre.jsp"></jsp:include>
<div class="row hidden-print">
    <div class="col-lg-12">
        <div class="ibox">
            <div class="ibox-title">
                <h2>数据需求</h2>
                <ol class="breadcrumb">
                    <li>
                        <a href="javascript:void(0);">供需管理</a>
                    </li>
                    <li class="active">
                        <strong>数据需求</strong>
                    </li>
                </ol>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../../../common/admin/search_pre.jsp"></jsp:include>
<input type="hidden" name="formSerialize"/>
<input type="hidden" name="pageNo" value="1"/>
<form id="formSearch" action="<%=basePath%>/admin/data_register/list.action" method="get" class="form-inline">
    <div class="form-group col-xs-3">
        <label for="rqrmntSectorId">数据需求单位</label>
        <input type="hidden" id="rqrmntSectorId" name="rqrmntSectorId" class="form-control input-lg"/>
        <button type="button" class="btn btn-default dropdown-toggle"
                style="min-width: 120px; text-align: right;">
            <span class="caret" style="margin-left: 10px;"></span>
        </button>
        <div id="rqrmntDivSectorTree"></div>
    </div>
    <div class="form-group col-xs-3">
        <label for="requirementState">状态</label>
        <select id="requirementState" name="requirementState" class="form-control ">
            <option>全部</option>
            <c:forEach items="${dicRequirementState}" var="item" >
                <option value="${item.key}">${item.value}</option>
            </c:forEach>
        </select>
    </div>
    <div class="form-group col-xs-3">
        <label for="requirementSource">需求来源</label>
        <select id="requirementSource" name="requirementSource" class="form-control">
            <option>全部</option>
            <c:forEach items="${dicPlatformType}" var="item" >
                <option value="${item.key}">${item.value}</option>
            </c:forEach>
        </select>
    </div>
    <div class="form-group ">
        <label for="belongtoSectorId">所属单位</label>
        <input type="hidden" id="belongtoSectorId" name="belongtoSectorId"/>
        <button type="button" class="btn btn-default dropdown-toggle"
                style="min-width: 120px; text-align: right;">
            <span class="caret" style="margin-left: 10px;"></span>
        </button>
        <div id="divSectorTree"></div>
    </div>
    <div class="form-group">
        <label for="publishDateFrom">发布日期</label>
        <div class="input-group date ">
            <input type="text" id="publishDateFrom" name="publishDateFrom" class="form-control " />
            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar"></span>
                </span>
        </div>
        至
        <div class="input-group date">
            <input type="text" id="publishDateTo" name="publishDateTo" class="form-control " />
            <span class="input-group-addon">
                    <span class="glyphicon glyphicon-calendar "></span>
                </span>
        </div>
    </div>
    <div class="form-group">
        <button id="btnSearch" type="button" class="btn btn-sm btn-primary"><i class="fa fa-search"></i>查询
        </button>
        <button id="btnReset" type="button" class="btn btn-sm btn-default"><i class="fa fa-reply"></i>重置
        </button>
    </div>
</form>
<jsp:include page="../../../common/admin/search_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/grid_pre.jsp"></jsp:include>
<a href="<%=basePath%>/admin/data_supply/publishRequirement.htm" class="btn btn-sm btn-primary btn-position"><i class="fa fa-plus">发布</i></a>
<jsp:include page="../../../common/admin/grid_middle.jsp"></jsp:include>
<div id="divGrid">
</div>
<jsp:include page="../../../common/admin/grid_post.jsp"></jsp:include>
<jsp:include page="../../../common/admin/body_post.jsp"></jsp:include>
<script type="text/javascript">
    $(".input-group.date").datetimepicker({
        format: "YYYY-MM-DD",
        locale: "zh-cn"
    });

    function search() {
        var formSerialize = $("input[type='hidden'][name='formSerialize']").val();
        var pageNo = $("input[type='hidden'][name='pageNo']").val();
        var formData = formSerialize + "&pageNo=" + pageNo;
        $("#divGrid").renderPartial({url: "<%=basePath%>/admin/data_supply/list.action", data: formData});
    }

    $("#btnSearch").click(function () {
        $("input[type='hidden'][name='pageNo']").val(1);
        $("input[type='hidden'][name='formSerialize']").val($("#formSearch").serialize());
        search();
    });

    $("#btnReset").click(function () {
        $("table input").val("");
        $("#requirementState").val("全部");
        $("#requirementSource").val("全部");
        $("#rqrmntSectorId").val('');
        $("#rqrmntSectorId").next().html('<span class="caret" style="margin-left: 10px;"></span>');
        $("#belongtoSectorId").val('');
        $("#belongtoSectorId").next().html('<span class="caret" style="margin-left: 10px;"></span>');
        $("#publishDateFrom").val('');
        $("#publishDateTo").val('');
        $("#belongtoSectorName").siblings("button").val("").html("<span class=\"caret\" style=\"margin-left: 10px;\"></span>");
        $("#rqrmntSectorName").siblings("button").val("").html("<span class=\"caret\" style=\"margin-left: 10px;\"></span>");
    });
    search();

    $("#divSectorTree").selectTree({url: "<%=basePath%>/admin/common/sector_tree_data.action"});
    $("#rqrmntDivSectorTree").selectTree({url: "<%=basePath%>/admin/common/sector_tree_data.action"});
</script>
</body>
</html>