<%@ 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";
%>
<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="mid11">
    <div class="nr">
        <div class="form-fabu1">
            <div class="fabufont">发布您的需求</div>
            <div class="line-fabu"></div>
            <div class="clearfix"></div>
            <div class="fabu001">
                <form id="publishFormId" >
                    <input type="hidden" name="subOrTem" />
                    <input type="hidden" name="delIds" id="delIds" />
                    <input type="hidden" name="id" value="${requirement.id}" />
                    <input type="hidden" name="platformType" value="${requirement.platformType}" />
                    <input type="hidden" name="publishBy" value="${requirement.publishBy}" />
                    <input type="hidden" name="publishAt" value="${requirement.publishAt}" />
                    <input type="hidden" name="rqrmntType" value="${requirement.rqrmntType}" />
                    <input type="hidden" id="rqrmntState" name="rqrmntState" value="${requirement.rqrmntState}" />

                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>需求名称</span>
                        <span class="ff1">
                        <input type="text" class="fabuinput" name="rqrmntName" value="${requirement.rqrmntName}" placeholder="请输入需求名称">
                        <div class="tishi4"></div>
                        </span>
                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1"><span class="xinghao">*</span>需求摘要</span>
                        <span class="ff1">
                        <textarea  cols="30" rows="2" class="fabuinput1"  name="rqrmntSummary" placeholder="请输入需求摘要" >${requirement.rqrmntSummary}</textarea>
                        <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="dataUses" value="${requirementData.dataUses}" placeholder="请输入需求用途">
                        <div class="tishi4"></div>
                        </span>
                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1">数据需求部门</span>
                        <select name="rqrmntSectorId" id="rqrmntSectorId" class="fabuinput5">
                            <option></option>
                            <c:forEach items="${sectorNames}" var="item">
                                <option value="${item.sectorId}" ${item.sectorId == requirementData.sectorId ? "selected=\"selected\"" : ""}>${item.sectorName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <div class="fabu-01">
                        <span class="fabufont1">数据所属部门</span>
                        <select name="sectorId" id="sectorId" class="fabuinput5">
                            <option></option>
                            <c:forEach items="${sectorNames}" var="item">
                                <option value="${item.sectorId}" ${item.sectorId == requirementData.rqrmntSectorId ? "selected=\"selected\"" : ""}>${item.sectorName}</option>
                            </c:forEach>
                        </select>
                    </div>
                    <%--///////////////暂时隐藏112--%>
                    <%-- <div class="fabu-01">
                         <div  class="fabufont1"><span class="xinghao">*</span>数据添加类型</div>
                         <div class="xz00" >
                             <span class="xz0"><input type="radio" class="xz" name="choice" placeholder="选择数据" value="0" checked="checked">&nbsp;选择数据</span>
                             <span class="xz1"><input type="radio" class="xz" name="choice" placeholder="选择数据" value="1">&nbsp;自定义数据</span>
                         </div>
                     </div>--%>
                    <%--//////////////////////--%>
                    <div class="fabu-028" id="zidingyiId">
                            <span class="fabufont1">数据资源</span>
                            <div class="fb" id="DataRequirementDataDemoId">

                                <c:if test="${dataRequirementData.size()>0}">
                                <c:forEach var="item" items="${dataRequirementData}" varStatus="status">
                                    <div class="fabuinput4" >
                                    <input type="hidden" id="ids"   name='dataRequirementDataList[${status.index}].id' value="${item.id}"/>

                                        <div class="fabu-010">
                                            <span class="fabufont1">数据名称</span>
                                            <input type="text" class="fabuinput6" name="dataRequirementDataList[${status.index}].dataName" value="${item.dataName}" placeholder="请输入数据名称">
                                        </div>
                                        <div class="fabu-010">
                                            <span class="fabufont1">数据项</span>
                                            <input type="text" class="fabuinput6" name="dataRequirementDataList[${status.index}].dataItem" value="${item.dataItem}" placeholder="请输入数据项">
                                        </div>
                                        <div class="clearfix"></div>
                                        <div><div class="jia-1" id="jiaOrJian"><c:if test="${status.last}"><span  onclick="fnAdd()">+</span></c:if><span  onclick="fnDec(this)">-</span></div></div>
                                    </div>
                                </c:forEach>
                                </c:if>
                                <c:if test="${dataRequirementData.size()<1}">
                                <div class="fb" id="DataRequirementDataDemoId1">
                                    <div class="fabuinput4" >
                                        <div class="fabu-010">
                                            <span class="fabufont1">数据名称</span>
                                            <input type="text" class="fabuinput6" name="dataRequirementDataList[0].dataName" value="${item.dataName}" placeholder="请输入数据名称">
                                        </div>
                                        <div class="fabu-010">
                                            <span class="fabufont1">数据项</span>
                                            <input type="text" class="fabuinput6" name="dataRequirementDataList[0].dataItem" value="${item.dataItem}" placeholder="请输入数据项">
                                        </div>
                                        <div class="clearfix"></div>
                                        <div><div class="jia-1" id="jiaOrJian1"><span   onclick="fnAdd1()">+</span></div></div>
                                    </div>
                                </div>
                                </c:if>
                            </div>
                        </div>


                    <%--/////////暂时隐藏112/////////--%>
                    <%-- <div class="fabu-01" id="xuanzeId">
                         <div class="fabufont1">添加数据</div>
                         <div class="xz00">
                             <table>
                                 <tr bgcolor="#f2f2f2">
                                     <td>部门名称</td>
                                     <td>资源名称</td>
                                     <td>数据项名称</td>
                                 </tr>
                                 <tr>
                                     <td>市人力资源和社会保障局</td>
                                     <td>职业技能鉴定机构许可证</td>
                                     <td>odd</td>
                                 </tr>
                                 <tr>
                                     <td colspan="3" ><img src="<%=resourcePath%>/images/fabu.png" alt="美哟了" class="zjimg" onclick="fnAdd()"></td>
                                 </tr>
                             </table>
                         </div>
                     </div>--%>
                    <%--//////////////////--%>
                    <div class="clearfix"></div>

                    <div class="clearfix"></div>
                    <div class="fbbut">
                        <button class="tjbut" type="button" onclick="fnPublish()">提交</button>
                        <button class="zcbut"  type="button" onclick="fnTemporaryStorage()">暂存</button>
                        <button class="fhbut">返回</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<jsp:include page="../common/body_footer.jsp"></jsp:include>

<%--///////////////////添加数据项/////暂时隐藏112/////////--%>
<%--<div id="tianjiaId" style="display: none">
    <div class="fade"></div>
    <div class="window1">
        <div class="top01">
            <span class="p">选择待组装数据和数据项</span>
            <img src="<%=resourcePath%>/images/icon_guanbi.png" alt="" class="guanbi" onclick="closeAdd()">
        </div>
        <div class="ss1">
            <div class="xz2">
                <span class="mc">机构名称：</span>
                <input type="text" placeholder="请输入机构名称" class="mcinput">
            </div>
            <div class="xz3">
                <span class="mc">资源名称：</span>
                <input type="text" placeholder="请输入机构名称" class="mcinput">
            </div>
            <div class="xz3">
                <span class="mc">资源类型：</span>
                <input type="text" placeholder="请输入机构名称" class="mcinput">
            </div>
            <div class="cx">
                <button class="chaxun">查询</button>
            </div>
        </div>
        <div class="clearfix"></div>
        <div class="cxsj">
            <table>
                <tr bgcolor="#f2f2f2">
                    <td>资源名称</td>
                    <td>资源编码</td>
                    <td>资源类型</td>
                    <td>所属部门</td>
                    <td>选择</td>
                </tr>
                <tr>
                    <td>民办职业培训机构招生广告</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr>
                    <td>职业技能鉴定机构许可证</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr>
                    <td>民办职业培训机构招生广告</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr>
                    <td>职业技能鉴定机构许可证</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr>
                    <td>民办职业培训机构招生广告</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
                <tr>
                    <td>职业技能鉴定机构许可证</td>
                    <td>11000/A00003V42F32</td>
                    <td>ODS</td>
                    <td>市人力资源和社会保障局</td>
                    <td><input type="checkbox"></td>
                </tr>
            </table>
            <div class="ys00">
                <button class="ys"></button>
                <button class="ys1">1</button>
                <button class="ys1">2</button>
                <button class="ys1">3</button>
                <button class="ys1">4</button>
                <button class="ys1">5</button>
                <button class="ys1">6</button>
                <button class="ys1">7</button>
                <span class="ys2">···</span>
                <button class="ys1">18</button>
                <button class="ys3"></button>

            </div>
            <button class="xiayibu">下一步</button>
        </div>
    </div>
</div>--%>
<%--///////////////////////////--%>
</body>
<script type="text/javascript">
    var ss = $("#delIds").val();
    //加
    var count=${dataRequirementData.size()};
    function fnAdd(){
        count++;
         var v=$('#DataRequirementDataDemoId').children('div:last-child').html();
        $('#DataRequirementDataDemoId').children('div:last-child').after("<div class='fabuinput4'>"+v+"</div>")
        $('#DataRequirementDataDemoId').children('div:last-child').find('input').attr('value','');
        $('#DataRequirementDataDemoId').children('div:last-child').prev().children('div:last-child').html('<div class="jian-1" id="jiaOrJian"><span onclick="fnDec(this)">-</span></div>');
        ////
        var d=$('#DataRequirementDataDemoId').children('div:last-child').find('input:eq(1)').attr('name',"dataRequirementDataList["+count+"].dataName");
        var d=$('#DataRequirementDataDemoId').children('div:last-child').find('input:eq(2)').attr('name',"dataRequirementDataList["+count+"].dataItem");
    }
    function fnAdd1(){
        count++;
        var v=$('#DataRequirementDataDemoId1').children('div:last-child').html();
        $('#DataRequirementDataDemoId1').children('div:last-child').after("<div class='fabuinput4'>"+v+"</div>");
        $('#DataRequirementDataDemoId1').children('div:last-child').prev().children('div:last-child').html('<div class="jian-1" id="jiaOrJian"><span onclick="fnDec1(this)">-</span></div>');
        var d=$('#DataRequirementDataDemoId1').children('div:last-child').find('input:eq(0)').attr('name',"dataRequirementDataList["+count+"].dataName");
        var d=$('#DataRequirementDataDemoId1').children('div:last-child').find('input:eq(1)').attr('name',"dataRequirementDataList["+count+"].dataItem");
    }

    //减
    function fnDec(tr){
        //alert($(tr).parent().parent().parent().children("input[type='hidden'][id='ids']").val());
        if($(tr).parent().parent().parent().children("input[type='hidden'][id='ids']").val()!=""){
            ss+=$(tr).parent().parent().parent().children("input[type='hidden'][id='ids']").val()+",";
            $("#delIds").val(ss);
        }
        $(tr).parent().parent().parent().remove();
    }
    function fnDec1(tr){
        $(tr).parent().parent().parent().remove();
    }

    //简单发布验证
    var isSubmit=false;
    //发布
    function fnPublish(){
        $("#rqrmntState").val("待审核");
        //$('#publishFormId').append('<input type="hidden" name="rqrmntState" value="待审核">')
        // $("#publishFormId input[type='hidden']").val(1)
        pt();
    }
    //暂存
    function fnTemporaryStorage(){
        //$('#publishFormId').append('<input type="hidden" name="rqrmntState" value="待提交">')
        //$("#publishFormId input[type='hidden']").val(2)
        pt();
    }
    //提交/暂存代码提取
    function pt(){
        if(isSubmit){
            alert("你已经提交过表单了！")
            return;
        }
        var msg = "您真的确定要发布吗？";
        if (confirm(msg)){
            $.post("<%=basePath%>/share/MyShareDataRequirement/doEdit.action",$('#publishFormId').serialize(),function(result){
                if(result.stateCode==200){
                    alert(result.msg)
                    window.location.href="<%=basePath%>/share/MyShareDataRequirement/list.action";
                }else{
                    for(var item in msg.data){
                        $("[name='"+item+"']").next().text("! "+msg.data[item]);
                        $("[name='"+item+"']").next().show();
                    }
                }
                isSubmit=true;
            })
        }
    }

    //需求选择
    //暂时关闭112
    /* $("input[type='radio'][name='choice']").change(function(){
         //alert($(this).val());
         var choiceNum = $(this).val();
         if(choiceNum !=0){
             $('#zidingyiId').show();
             $('#xuanzeId').hide();
         }else{
             $('#zidingyiId').hide();
             $('#xuanzeId').show();
         }
     })

     //弹框添加数据
     function fnAdd(){
         $.get('<%=basePath%>/share/dataRequirement/addData.action',function (data) {
            alert(data);
            $('#tianjiaId').show();
        })
    }
    //关闭
    function closeAdd(){
        $('#tianjiaId').hide();
    }*/


</script>
</html>