<%@ 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>
<html>
    <head>
        <jsp:include page="../common/head.jsp"></jsp:include>
        <meta charset="utf-8">
        <title>API发布需求</title>
        <link rel="stylesheet" href="<%=basePath%>/resource/css/open/base.css" type="text/css">
    </head>
    <body>
    <jsp:include page="../common/body_header.jsp"></jsp:include>
                  <div class="line0"></div>
                  <div class="mid-fabu1">
                      <div class="form-fabu1">
                          <div class="fabufont">发布您的需求</div>
                          <div class="line-fabu"></div>
                          <div class="clearfix"></div>
                          <div class="fabu00">
                              <form class="form-horizontal" id="settingFrom" role="form" method="post"
                                    >
                                  <div class="fabu-01">
                                      <span class="fabufont1"><span class="xinghao">*</span>需求名称</span>
                                      <span class="ff1">
                                      <input type="text" class="fabuinput" name="rqrmntName" placeholder="请输入需求名称">
                                      <div class="tishi4"></div>
                                      </span>
                                  </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1"><span class="xinghao">*</span>需求说明</span>
                                        <span class="ff1">
                                        <input type="text" class="fabuinput" name="rqrmntSummary" placeholder="请输入需求说明">
                                        <div class="tishi4"></div>
                                        </span>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1"><span class="xinghao">*</span>系统名称</span>
                                        <span class="ff1">
                                        <input type="text" class="fabuinput" name="systemName" placeholder="请输入系统名称">
                                        <div class="tishi4"></div>
                                        </span>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">系统类型</span>
                                        <input type="text" class="fabuinput" name="systemType" placeholder="请输入系统类型">
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">系统描述</span>
                                        <textarea name="systemDesc" id="systemDesc"  cols="30" rows="2" class="fabuinput1" placeholder="请输入系统描述" ></textarea>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1"><span class="xinghao">*</span>所属单位</span>
                                        <span class="ff1">
                                        <input type="text" class="fabuinput" name="belongTo" placeholder="请输入需求说明">
                                        <div class="tishi4"></div>
                                        </span>
                                    </div>
                                    <div class="fabu-02">
                                        <span class="fabufont2"><span class="xinghao">*</span>所有权</span>
                                        <span class="radio0">
                                            <input type="radio" name="hasOwnership" value="0" checked  class="radio">是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="radio" name="hasOwnership" value="1" class="radio">否
                                        </span>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">访问网址</span>
                                        <input type="text" class="fabuinput" name="url" placeholder="http://">
                                    </div>
                                    <div class="fabu-03">
                                        <span class="fabufont2"><span class="xinghao">*</span>网络性质</span>
                                        <span class="radio0">
                                              <span class="ff1">
                                            <input type="radio" name="networkType" checked value="内网系统" class="radio">内网系统&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="radio" name="networkType" value="公网系统" class="radio">公网系统
                                            <div class="tishi4"></div>
                                              </span>
                                        </span>
                                    </div>
                                    <div class="fabu-04">
                                        <span class="fabufont2">开发语言</span>
                                        <span class="radio0">
                                            <input type="checkbox" name="devLanguage" value="java" class="radio">java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="C/C++" class="radio">C/C++&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="C#" class="radio">C#&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="JS" class="radio">JS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="CSS" class="radio">CSS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="html" class="radio">html&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="PHP" class="radio">PHP&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="checkbox" name="devLanguage" value="其他" class="radio">其他&nbsp;&nbsp;&nbsp;&nbsp;
                                            <span class="checkbox1 "></span>
                                        </span>
                                    </div>
                                    <div class="fabu-05">
                                        <span class="fabufont1"><span class="xinghao">*</span>接口个数</span>
                                        <span class="fabu-button0"><input type="text" id="interfaceCount" name="interfaceCount" value=0 class="input-01" placeholder="1"></span>
                                        <span class="fabu-button1" onclick="subInterfaceCount()"></span>
                                        <span class="fabu-button2" onclick="addInterfaceCount()"></span>
                                        <span class="ff1">
                                        <div class="tishi4"></div>
                                        </span>
                                    </div>
                                    <div class="clearfix"></div>
                                    <div class="fabu-05">
                                            <span class="fabufont1">截止日期</span>
                                            <span class="fabu-button0">
                                                <input type="text" name="deadline" id="datetimepicker" class="input-02" placeholder="选择截止日期">
                                            </span>
                                            <span class="fabu-button3"></span>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">主联系人</span>
                                        <input type="text" name="contact1" class="fabuinput" placeholder="请输入主联系人">
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">主联系人电话</span>
                                        <input type="text" class="fabuinput" name="phone1" placeholder="主联系人电话">
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">备用联系人</span>
                                        <input type="text" class="fabuinput" name="contact2" placeholder="备用联系人">
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">备用联系人电话</span>
                                        <input type="text" class="fabuinput" name="phone2" placeholder="备用联系人电话">
                                    </div>
                                    <div class="fabu-02">
                                        <span class="fabufont2"><span class="xinghao">*</span>是否需要平台撮合交易</span>
                                        <span class="radio0">
                                            <input type="radio" checked name="needPlatformSupport"  value="是" class="radio">是&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="radio" name="needPlatformSupport" value="否" class="radio">否
                                            <div class="tishi4"></div>
                                        </span>
                                    </div>
                                    <div class="fabu-06">
                                        <span class="fabufont2"><span class="xinghao">*</span>分类</span>
                                        <span class="radio0">
                                            <input type="radio" checked name="categoryId" value="1" class="radio">数据APi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="radio" name="categoryId" value="2" class="radio">模型API&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <input type="radio" name="categoryId" value="3" class="radio">工具APi&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                            <div class="tishi4"></div>
                                        </span>
                                        <span class="fabu-button0" style="visibility: hidden"><input type="text" name="categoryId" class="input-03" style="visibility: hidden"></span>
                                        <span class="fabu-button4" style="visibility: hidden"></span>
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">预期报价</span>
                                        <input type="text" name="expectedQuote" class="fabuinput" placeholder="请输入预期报价">
                                    </div>
                                    <div class="clearfix"></div>
                                    <div class="fabu-07">
                                        <span class="fabufont1">附件</span>
                                        <input type="file" name="attachment" class="file" >
                                    </div>
                                    <div class="fabu-01">
                                        <span class="fabufont1">说明</span>
                                        <textarea name="description" id="description" cols="30" rows="2" class="fabuinput1" placeholder="请输入其他说明" ></textarea>
                                    </div>
                                    <div class="clearfix"></div>
                                    <button type="button" class="fabu-but"  onclick="publish()">发布</button>
                                </form>
                          </div>

                      </div>
                    </div>

                  </div>
            <jsp:include page="../common/body_footer.jsp"></jsp:include>
            <script type="text/javascript">
                function publish() {
                    var msg = "您真的确定要发布吗？";
                    if (confirm(msg)){
                        $('.tishi4').text('');//清空验证
                        $.post("<%=basePath%>/open/apiDemand/release.action",$('#settingFrom').serialize(),function(result){
                            if(result.stateCode==200){
                                window.location.href="<%=basePath%>/open/apiDemand/list.htm";
                            }else{
                                if(result.data ==null){
                                    alert(result.msg);//弹出发布失败提示
                                }else{
                                    for(var item in result.data){
                                        $("[name='"+item+"']").next().text("! "+result.data[item]);
                                        $("[name='"+item+"']").next().show();
                                    }
                                }
                            }
                        })
                    }
                    <%--$('#settingFrom').ajaxValSubmit({--%>
                        <%--ajaxSubmitOptions: {--%>
                            <%--onSuccessFront:function () {--%>
                                <%----%>
                            <%--},--%>
                            <%--onSuccess: function () {--%>
                                <%--window.location.href="<%=basePath%>/open/apiDemand/list.htm";--%>
                            <%--}--%>
                        <%--}--%>
                    <%--});--%>
                }
                $.datetimepicker.setLocale('zh');
                $("#datetimepicker").datetimepicker({
                    format: 'Y-m-d'
                });

                function addInterfaceCount(){
                    var interfanceCount = $("#interfaceCount").val() ;
                    interfanceCount = interfanceCount*1 + 1 ;
                    $("#interfaceCount").val(interfanceCount)
                }
                function subInterfaceCount(){
                    var interfanceCount = $("#interfaceCount").val() ;
                    if (interfanceCount!=0){
                    interfanceCount = interfanceCount*1 - 1 ;
                    $("#interfaceCount").val(interfanceCount) ;
                    }
                }
            </script>
    </body>
</html>