<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>招标项目信息管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
        $(function(){
            var oneSize = $(".oneTab").size();
            for(var i = 0;i < oneSize;i++){
                var hei = $(".oneTab:eq("+i+")").parent().height();
                $(".oneTab:eq("+i+")").css("height",hei-5)
                    .css("vertical-align","middle")
                    .css("line-height",hei+"px")
            }
            $("img").not(".upload_ico").each(function () {
                var num = 1 ;
                $(this).click(function () {
                    var flag = num%2;
                    if(flag == 1){
                        $(this).css("width","90%");
                        $(this).css("height","90%");
                        num++;
                    }else if(flag ==0){
                        $(this).css("width","50px");
                        $(this).css("height","50px");
                        num++;
                    }
                })
            });
        })
		var validateForm;
		function doSubmit(){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
		  if(validateForm.form()){
			  $("#inputForm").submit();
			  return true;
		  }
	
		  return false;
		}
		$(document).ready(function() {
			validateForm = $("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
            laydate.render({
                elem: '#projectStartDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            laydate.render({
                elem: '#projectEndDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
                event: 'focus' //响应事件。如果没有传入event，则按照默认的click
            });
            var isControlPrice = "${workBidingProject.isControlPrice}";
            if(isControlPrice==1){
                $("#controlPrice").show();
                $("#controlPriceVal").show();
            }
        });

        var linkManList_contract = null;
        function setContractValue(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workengineeringproject/workEngineeringProject/getContractInfo',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = linkManList_contract = JSON.parse(data);
                    $("#linkman_list").html("");
                    $(".linkman_attr").val("");
                    var defaultLinkMan = d[0];
                    if(defaultLinkMan != null && defaultLinkMan != undefined && defaultLinkMan !=""){
                        $("#contractNum").val(defaultLinkMan.contractNum);
                        $("#clientName").val(defaultLinkMan.clientName);
                        $("#clientId").val(defaultLinkMan.clientId);
                        $("#linkmanName").val(defaultLinkMan.linkmanName);
                        $("#linkmanPhone").val(defaultLinkMan.linkmanPhone);
                        $("#linkmanEmail").val(defaultLinkMan.linkmanEmail);
                        $("#linkmanPosition").val(defaultLinkMan.linkmanPosition);

                        $.each(d,function(n,value) {
                            var optionTag = '<option id="linkman_attr_'+n+'" type="text" value='+n+'>'+value.linkmanName+'</option>';
                            $("#linkman_list").append(optionTag);
                        });
                        $("#linkman_list option:first").prop("selected","selected").text(defaultLinkMan.linkmanName);
                    }
                }
            })
        }

        var linkManList = null;
        function setValuee(obj){
            $.ajax({
                type:'post',
                url:'${ctx}/workbidingproject/workBidingProject/getWorkClientInfo',
                data:{
                    "obj":obj
                },
                success:function(data){
                    var d = JSON.parse(data);
                    var defaultLinkMan = d[0];
                    linkManList = d;
                    $("#linkman_list").html("");
                    $(".linkman_attr").val("");
                    if(defaultLinkMan != null && defaultLinkMan != undefined && defaultLinkMan !=""){
                        $("#clientName").val(defaultLinkMan.clientName);
                        $("#clientId").val(defaultLinkMan.clientId);
                        //$("#linkmanName").val(defaultLinkMan.linkmanName);
                        $("#linkmanPhone").val(defaultLinkMan.linkmanPhone);
                        $("#linkmanEmail").val(defaultLinkMan.linkmanEmail);
                        $("#linkmanPosition").val(defaultLinkMan.linkmanPosition);

                        $.each(d,function(n,value) {
                            var optionTag = '<option id="linkman_attr_'+n+'" type="text" value='+n+'>'+value.linkmanName+'</option>';
                            $("#linkman_list").append(optionTag);
                        });
                        $("#linkman_list option:first").prop("selected","selected").text(defaultLinkMan.linkmanName);
                    }

                }
            })
        }
        /**
         * 查看联系人（需要用到linkManList）
         */
        function selectLinkman(index,target) {
            if(target=='linkman'){
                var manList = null ;
                if(linkManList_contract != null){
                    manList = linkManList_contract; //合同关联的
                }else{
                    manList = linkManList; //自选的
                }
                if(manList ==null){
                    manList = JSON.parse('${requestScope.linkmanList}');
                }
                var linkman = manList[index];
                $("#linkmanPosition").val(linkman.linkmanPosition==undefined?"":linkman.linkmanPosition);
                $("#linkmanPhone").val(linkman.linkmanPhone==undefined?"":linkman.linkmanPhone);
                $("#linkmanEmail").val(linkman.linkmanEmail==undefined?"":linkman.linkmanEmail);
            }
        }


        function display(n){
            if(n==1){
                $("#controlPrice").show();
                $("#controlPriceVal").show();
            }else{
                $("#controlPrice").hide();
                $("#controlPriceVal").hide();
            }
        }

        function  chooseType() {
            if($("#psort").val()==1){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
                $("#ssort11").show();$("#ssort12").show();$("#ssort13").show();
                $("#ssort21").hide();$("#ssort22").hide();$("#ssort23").hide();$("#ssort24").hide();
                $("#ssort31").hide();$("#ssort32").hide();$("#ssort33").hide();$("#ssort34").hide();$("#ssort35").hide();$("#ssort36").hide();
                $("#ssort41").hide();$("#ssort42").hide();
                $("#ssort51").hide();$("#ssort52").hide();$("#ssort53").hide();$("#ssort54").hide();$("#ssort55").hide();
                $("#ssort101").hide();$("#ssort102").hide();
            }
            else if($("#psort").val()==2){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
                $("#ssort11").hide();$("#ssort12").hide();$("#ssort13").hide();
                $("#ssort21").show();$("#ssort22").show();$("#ssort23").show();$("#ssort24").show();
                $("#ssort31").hide();$("#ssort32").hide();$("#ssort33").hide();$("#ssort34").hide();$("#ssort35").hide();$("#ssort36").hide();
                $("#ssort41").hide();$("#ssort42").hide();
                $("#ssort51").hide();$("#ssort52").hide();$("#ssort53").hide();$("#ssort54").hide();$("#ssort55").hide();
                $("#ssort101").hide();$("#ssort102").hide();
            }
            else if($("#psort").val()==3){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
                $("#ssort11").hide();$("#ssort12").hide();$("#ssort13").hide();
                $("#ssort21").hide();$("#ssort22").hide();$("#ssort23").hide();$("#ssort24").hide();
                $("#ssort31").show();$("#ssort32").show();$("#ssort33").show();$("#ssort34").show();$("#ssort35").show();$("#ssort36").show();
                $("#ssort41").hide();$("#ssort42").hide();
                $("#ssort51").hide();$("#ssort52").hide();$("#ssort53").hide();$("#ssort54").hide();$("#ssort55").hide();
                $("#ssort101").hide();$("#ssort102").hide();
            }
            else if($("#psort").val()==4){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
                $("#ssort11").hide();$("#ssort12").hide();$("#ssort13").hide();
                $("#ssort21").hide();$("#ssort22").hide();$("#ssort23").hide();$("#ssort24").hide();
                $("#ssort31").hide();$("#ssort32").hide();$("#ssort33").hide();$("#ssort34").hide();
                $("#ssort35").hide();$("#ssort36").hide();$("#ssort41").show();$("#ssort42").show();
                $("#ssort51").hide();$("#ssort52").hide();$("#ssort53").hide();$("#ssort54").hide();$("#ssort55").hide();
                $("#ssort101").hide();$("#ssort102").hide();
            }
            else if($("#psort").val()==5){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
				$("#ssort11").hide();
				$("#ssort12").hide();
				$("#ssort13").hide();
				$("#ssort21").hide();
				$("#ssort22").hide();
				$("#ssort23").hide();
				$("#ssort24").hide();
				$("#ssort31").hide();
				$("#ssort32").hide();
				$("#ssort33").hide();
				$("#ssort34").hide();
				$("#ssort35").hide();
				$("#ssort36").hide();
				$("#ssort41").hide();
				$("#ssort42").hide();
				$("#ssort51").show();
				$("#ssort52").show();
				$("#ssort53").show();
				$("#ssort54").show();
				$("#ssort55").show();
				$("#ssort101").hide();
				$("#ssort102").hide();
            }
            else if($("#psort").val()==10){
                $("#ssort ").attr("value","");
                document.getElementById( "t1").style.display= "";
                document.getElementById( "t2").style.display= "";
				$("#ssort11").hide();$("#ssort12").hide();$("#ssort13").hide();$("#ssort21").hide();
				$("#ssort22").hide();$("#ssort23").hide();$("#ssort24").hide();$("#ssort31").hide();
				$("#ssort32").hide();$("#ssort33").hide();$("#ssort34").hide();$("#ssort35").hide();
				$("#ssort36").hide();$("#ssort41").hide();$("#ssort42").hide();$("#ssort51").hide();
				$("#ssort52").hide();$("#ssort53").hide();$("#ssort54").hide();$("#ssort55").hide();
				$("#ssort101").show();$("#ssort102").show();
            }else{
                document.getElementById( "t1").style.display= "none";
                document.getElementById( "t2").style.display= "none";
            }
        }
	</script>
</head>
<body class="hideScroll">
<div class="wrapper wrapper-content">
	<div class="ibox">
		<form:form id="inputForm" modelAttribute="workBidingProject" action="${ctx}/workbidingproject/workBidingProject/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>	
		   <div class="col-sm-12 m-t-xs">
			   <div class="col-sm-2 gray-bg text-center oneTab">
				   <label>基本信息</label>
			   </div>
			   <div class="col-sm-10 " >
				   <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
					   <tbody>
						    <tr>
							   <td class="width-15 active"><label class="pull-right"><font color="red">*</font>合同名称：</label></td>
							   <td class="width-35">
								   <sys:gridselectContract url="${ctx}/workengineeringproject/workEngineeringProject/selectcontractId" id="contractId" name="contract.id" type="3" isTotal="" value="${workBidingProject.contract.id}"  title="选择合同名称" labelName="contract.name"
														   labelValue="${workBidingProject.contract.name}" cssClass="form-control required" fieldLabels="合同信息" fieldKeys="name" searchLabel="合同名称" searchKey="name" ></sys:gridselectContract>
							   </td>
							   <td class="width-15 active"><label class="pull-right">合同编号：<font color="red">*</font></label></td>
							   <td class="width-35">
								   <form:input path="contract.contractNum" id="contractNum" htmlEscape="false"  readonly="true"   class="form-control required"/>
							   </td>
						    </tr>
							<tr>
								<td class="width-15 active"><label class="pull-right"><font color="red">*</font>客户：</label></td>
								<td class="width-35">
									<sys:gridselect url="${ctx}/workbidproject/workBidProject/selectbidCompany" id="client" name="client.id"  value="${workBidingProject.client.id}"  title="选择客户单位" labelName="client.name"
													labelValue="${workBidingProject.client.name}" cssClass="form-control required" fieldLabels="客户" fieldKeys="name" searchLabel="客户名称" searchKey="name"  ></sys:gridselect>
								</td>
								<td class="width-15 active"><label class="pull-right">投资额(元)：</label></td>
								<td class="width-35">
									<form:input path="investmentAmount" htmlEscape="false"    class="form-control  number"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">招标方式：</label></td>
								<td class="width-35">
									<form:select path="biddingType" class="form-control ">
										<form:option value="" label=""/>
										<form:options items="${fns:getMainDictList('bidding_type')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</td>
								<td class="width-15 active"><label class="pull-right">批次：</label></td>
								<td class="width-35">
									<form:select path="batch" class="form-control ">
										<form:option value="" label=""/>
										<form:options items="${fns:getDictList('bidding_batch')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">行业分类：</label></td>
								<td class="width-35">
									<form:select id="psort" path="psort" class="form-control" onChange="chooseType()"><%--onChange="changeTypeExplain(this)"--%>
										<form:option value="" label=""/>
										<form:options items="${fns:getDictList('psort')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</td>
								<td class="width-15 active" id="t1" style="display:none"><label class="pull-right">详细分类：</label></td>
								<td class="width-35" id="t2" style="display:none">
									<form:select path="ssort" class="form-control" onChange="changeTypeExplain(this)">
										<form:option value="" label=""/>
										<form:options id="ssort1" items="${fns:getDictList('ssort1')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										<form:options id="ssort2" items="${fns:getDictList('ssort2')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										<form:options id="ssort3" items="${fns:getDictList('ssort3')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										<form:options id="ssort4" items="${fns:getDictList('ssort4')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										<form:options id="ssort5" items="${fns:getDictList('ssort5')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
										<form:options id="ssort10" items="${fns:getDictList('ssort10')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">项目编号：</label></td>
								<td class="width-35">
									<form:input path="projectNumber" htmlEscape="false"    class="form-control "/>
								</td>
								<td class="width-15 active"><label class="pull-right">项目名称：</label></td>
								<td class="width-35">
									<form:input path="projectName" htmlEscape="false"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">联系人姓名：</label></td>
								<td class="width-35">
									<select id="linkman_list" onchange="selectLinkman(this.value,'linkman')" class="linkman_list max-width-250 form-control" />
								</td>
								<td class="width-15 active"><label class="pull-right">职务：</label></td>
								<td class="width-35">
									<form:input path="client.workClientLinkmanList[0].position" id="linkmanPosition" readonly="true" class="form-control linkman_attr"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right"> 联系方式：</label></td>
								<td class="width-35">
									<form:input path="client.workClientLinkmanList[0].linkPhone" id="linkmanPhone" readonly="true" class="form-control linkman_attr"/>
								</td>
								<td class="width-15 active"><label class="pull-right">E-mail：</label></td>
								<td class="width-35">
									<form:input path="client.workClientLinkmanList[0].email" id="linkmanEmail" readonly="true" class="form-control linkman_attr"/>
								</td>
							</tr>
					   </tbody>
				   </table>
			   </div>
		   </div>
		   <div class="col-sm-12 m-t-xs">
			   <div class="col-sm-2 gray-bg text-center oneTab">
				   <label>项目概况</label>
			   </div>
			   <div class="col-sm-10 " >
				   <table class="table table-bordered  table-condensed dataTables-example dataTable no-footer">
					   <tbody>
							<tr>
								<td class="width-15 active"><label class="pull-right">标底或招标控制价：</label></td>
								<td class="width-35">
									<c:choose>
										<c:when test="${workBidingProject.isControlPrice eq '1'}">
											<input type="radio" value="0" id="isExt" name="isControlPrice" onclick="display(this.value)">无
											<input type="radio" value="1" id="isExt" name="isControlPrice" onclick="display(this.value)" checked="checked">有
										</c:when>
										<c:otherwise>
											<input type="radio" value="0" id="isExt" name="isControlPrice" onclick="display(this.value)" checked="checked">无
											<input type="radio" value="1" id="isExt" name="isControlPrice" onclick="display(this.value)">有
										</c:otherwise>
									</c:choose>
								</td>
								<td class="width-15 active" id ="controlPrice" style="display:none"><label class="pull-right"><font color="red">*</font>标底或招标控制价(元)：</label></td>
								<td class="width-35" colspan="3" id ="controlPriceVal" style="display:none">
									<form:input path="controlPrice" htmlEscape="false"    class="form-control required"/>
								</td>


							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right"><font color="red">*</font>需求部门：</label></td>
								<td class="width-35">
									<sys:treeselect id="demandOffice" name="demandOffice.id" value="${workBidingProject.demandOffice.id}" labelName="demandOffice.name" labelValue="${workBidingProject.demandOffice.name}"
													title="部门" url="/sys/office/treeDataAll?type=2" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
								</td>
								<td class="width-15 active"><label class="pull-right"><font color="red">*</font>施工地点/交货地：</label></td>
								<td class="width-35">
									<sys:treeselect id="area" name="area.id" value="${workBidingProject.area.id}" labelName="area.name" labelValue="${workBidingProject.area.name}"
													title="区域" url="/sys/area/treeData" cssClass="form-control required" allowClear="true" notAllowSelectParent="true"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">监督单位：</label></td>
								<td class="width-35">
									<form:input path="supervisoryOffice" htmlEscape="false"    class="form-control "/>
								</td>
								<td class="width-15 active"><label class="pull-right">资金属性：</label></td>
								<td class="width-35">
									<form:select path="capitalAttribute" class="form-control ">
										<form:option value="" label=""/>
										<form:options items="${fns:getDictList('biding_capital_attribute')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
									</form:select>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">工期/交货期：</label></td>
								<td class="width-35" >
									<input id="projectStartDate" name="projectStartDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
										   value="<fmt:formatDate value="${workBidingProject.projectStartDate}" pattern="yyyy-MM-dd"/>"/>
								</td>
								<td class="width-15 active">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;至</td>
								</td>
								<td class="width-35" >
									<input id="projectEndDate" name="projectEndDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
										   value="<fmt:formatDate value="${workBidingProject.projectEndDate}" pattern="yyyy-MM-dd"/>"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">招标范围：</label></td>
								<td class="width-35" colspan="3">
									<form:textarea path="scopeOfBidding" htmlEscape="false" rows="4"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">评标办法：</label></td>
								<td class="width-35" colspan="3">
									<form:textarea path="bidEvaluationMethod" htmlEscape="false" rows="4"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">投资人资质要求：</label></td>
								<td class="width-35" colspan="3">
									<form:textarea path="investorQualification" htmlEscape="false" rows="4"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">项目负责人资质要求：</label></td>
								<td class="width-35" colspan="3">
									<form:textarea path="hostProjectQualification" htmlEscape="false" rows="4"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">其他要求：</label></td>
								<td class="width-35" colspan="3">
									<form:textarea path="otherRequirement" htmlEscape="false" rows="4"    class="form-control "/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">项目组负责人：</label></td>
								<td class="width-35" colspan="3">
										<sys:treeselect id="projectMaster" name="projectMasterIds" value="${workBidingProject.projectMasterIds}" labelName="projectMasterNames" labelValue="${workBidingProject.projectMasterName}"
																	  title="选择负责人" url="/sys/office/treeData?type=3&isAll=false" cssClass="form-control" notAllowSelectParent="true" checked="true"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">项目组成员：</label></td>
								<td class="width-35" colspan="3">
										<sys:treeselect id="projectMember" name="projectMemberIds" value="${workBidingProject.projectMemberIds}" labelName="projectMemberNames" labelValue="${workBidingProject.projectMemberName}"
														title="选择成员" url="/sys/office/treeData?type=3&isAll=false" cssClass="form-control" notAllowSelectParent="true" checked="true"/>
								</td>
							</tr>
							<tr>
								<td class="width-15 active"><label class="pull-right">清单编制人员：</label></td>
								<td class="width-35" colspan="3">
									<sys:treeselect id="inventorUser" name="inventorUserIds" value="${workBidingProject.inventorUserIds}" labelName="inventorUserNames" labelValue="${workBidingProject.inventorUserName}"
													title="清单编制人员" url="/sys/office/treeDataAll?type=3&isAll=false" cssClass="form-control" notAllowSelectParent="true" checked="true"/>
								</td>
							</tr>
					   </tbody>
				   </table>
			   </div>
		   </div>
	</form:form>
	</div>
</div>
</body>
</html>