<%@ 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">
		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: '#registrationDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
					});
					laydate.render({
			            elem: '#bidDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			         });
					laydate.render({
			            elem: '#trialDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
					laydate.render({
			            elem: '#purchaseDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
					laydate.render({
			            elem: '#refundDate', //目标元素。由于laydate.js封装了一个轻量级的选择器引擎，因此elem还允许你传入class、tag但必须按照这种方式 '#id .class'
			            event: 'focus' //响应事件。如果没有传入event，则按照默认的click
			        });
					var isExt = "${workBidProject.isExt}";
				    if(isExt==0){
				        $("#contact").show();
				        $("#btnAdd1").hide();
				        $("#btnAdd2").show();
				        $("#extContact").hide();
				    }else{
				        $("#extContact").show();
				        $("#btnAdd1").show();
				        $("#btnAdd2").hide();
				        $("#contact").hide();
				    }

		});

		function addRow(list, idx, workClientLinkmanTpl, row) {
            if (idx < 1) {
				$(list).append(Mustache.render(workClientLinkmanTpl, {
					idx: idx, delBtn: true, row: row
				}));
				$(list + idx).find("select").each(function () {
					$(this).val($(this).attr("data-value"));
				});
				$(list + idx).find("input[type='checkbox'], input[type='radio']").each(function () {
					var ss = $(this).attr("data-value").split(',');
					for (var i = 0; i < ss.length; i++) {
						if ($(this).val() == ss[i]) {
							$(this).attr("checked", "checked");
						}
					}
				});
        	}
		}
		function delRow(obj, prefix){
			var id = $(prefix+"_id");
			var delFlag = $(prefix+"_delFlag");
			if (id.val() == ""){
				$(obj).parent().parent().remove();
			}else if(delFlag.val() == "0"){
				delFlag.val("1");
				$(obj).parent().parent().hide();
				$(obj).html("&divide;").attr("title", "撤回删除");
				$(obj).parent().parent().addClass("error");
			}else if(delFlag.val() == "1"){
				delFlag.val("0");
				$(obj).html("&times;").attr("title", "删除");
				$(obj).parent().parent().removeClass("error");
			}
		}

		function display(n){
		    if(n==0){
		        $("#contact").show();
		        $("#btnAdd1").hide();
		        $("#btnAdd2").show();
		        $("#extContact").hide();
		    }else{
		        $("#extContact").show();
		        $("#btnAdd1").show();
		        $("#btnAdd2").hide();
		        $("#contact").hide();
		    }
		}
		function display1(){
       		var id =$("#bidCompanyId")[0].defaultValue;
 			$.get("${ctx}/workclientinfo/workClientInfo/selectLinkman", { clientId: id},
					  function(data,textStatus){
 						data = data.body.list;
			 		    if(data !=null){
							for (var i=0; i<data.length; i++){
								addRow('#workClientLinkmanList', workClientLinkmanRowIdx, workClientLinkmanTpl, data[i]);
                                workClientLinkmanRowIdx = workClientLinkmanRowIdx + 1;
							}
						}
					  });
		}
	</script>
	<script type="text/template" id="workClientLinkmanTpl">
	</script>
	<script type="text/javascript">
		var workClientLinkmanRowIdx = 0, workClientLinkmanTpl = $("#workClientLinkmanTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
		$(document).ready(function() {
			var data = ${fns:toJson(workBidProject.workClientLinkmanList)};
			if(data !=null){
				for (var i=0; i<data.length; i++){
					addRow('#workClientLinkmanList', workClientLinkmanRowIdx, workClientLinkmanTpl, data[i]);
					workClientLinkmanRowIdx = workClientLinkmanRowIdx + 1;
				}
			}
		});
	</script>
</head>
<body class="hideScroll">
		<form:form id="inputForm" modelAttribute="workBidProject" action="${ctx}/workbidingdocument/workBidingDocument/confirmSave?workBidProjectId=${workBidProject.id}" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<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" colspan="3">
						<form:input path="projectName" 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" colspan="3">
						<form:input path="projectNumber" htmlEscape="false" readonly="true" class="form-control required"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">项目类型：</label></td>
					<td class="width-35">
						<form:select path="projectType" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('contract_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:input path="typeExplain" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">项目来源：</label></td>
					<td class="width-35">
						<form:select path="projectSource" class="form-control">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('bidProjectSource')}" 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:input path="sourceExplain" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"> 是否外部联系人  ：</label></td>
					<td class="width-35">
					<c:choose>
					<c:when test="${workBidProject.isExt == 1}">
						<input type="radio" value="1" id="isExt" name="isExt" onclick="display(this.value)" checked="checked">系统外客户
		  				<input type="radio" value="0" id="isExt" name="isExt" onclick="display(this.value)" >非系统外客户
					</c:when>
					<c:otherwise>
						<input type="radio" value="1" id="isExt" name="isExt" onclick="display(this.value)" >系统外客户
		  				<input type="radio" value="0" id="isExt" name="isExt" onclick="display(this.value)" checked="checked">非系统外客户
						<%-- <form:radiobuttons path="isExternalContacts" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" onclick="display(this.value) htmlEscape="false" class="i-checks "/> --%>
	 				</c:otherwise>
	 				</c:choose>


						<%-- <form:checkboxes path="isExt" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="i-checks "/> --%>
				</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>招标单位：</label></td>
					<td class="width-35" colspan="3">
						<div id ="extContact" style="display:none">
						<form:input path="extCompany" htmlEscape="false"    class="form-control"/>
						</div>
						<div id ="contact" style="display:block">
						<sys:gridselect url="${ctx}/workbidproject/workBidProject/selectbidCompany" id="bidCompany" name="bidCompany.id"  value="${workBidProject.bidCompany.id}"  title="选择招标单位" labelName="bidCompany.name"
						 labelValue="${workBidProject.bidCompany.name}" cssClass="form-control required" fieldLabels="客户" fieldKeys="name" searchLabel="客户名称" searchKey="name"  ></sys:gridselect>
						</div>
					</td>
				</tr>
<%-- 					<td class="width-15 active"><label class="pull-right">联系人：</label></td>
					<td class="width-35" colspan="3">
						<form:input path="contacts" htmlEscape="false"    class="form-control "/>
					</td> --%>
				<tr>
					<td class="width-15 active"><label class="pull-right">联系人：</label></td>
					<td class="width-75"  colspan="3">
					<a id="btnAdd1" style="width:95px;display:none" class="btn btn-white btn-sm" onclick="addRow('#workClientLinkmanList', workClientLinkmanRowIdx, workClientLinkmanTpl);workClientLinkmanRowIdx = workClientLinkmanRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增联系人</a>
					<a id="btnAdd2"  style="width:95px;block" class="btn btn-white btn-sm" onclick="display1()"> 选择联系人</a>
					<div></div>
				<table style="margin-top:10px;" id="contentTable" class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th class="hide"></th>
						<th>联系人姓名</th>
						<th>职务</th>
						<th>QQ</th>
						<th>联系方式1</th>
						<th>联系方式2</th>
						<th>E-mail</th>
<!-- 						<th>是否默认联系人</th> -->
						<th width="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="workClientLinkmanList">
				</tbody>
			</table>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">报名日期：</label></td>
					<td class="width-35">
						<input id="registrationDate" name="registrationDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workBidProject.registrationDate}" pattern="yyyy-MM-dd"/>"/>
					</td>
					<td class="width-15 active"><label class="pull-right">投标日期：</label></td>
					<td class="width-35">
						<input id="bidDate" name="bidDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workBidProject.bidDate}" pattern="yyyy-MM-dd"/>"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">资审日期：</label></td>
					<td class="width-35">
						<input id="trialDate" name="trialDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workBidProject.trialDate}" pattern="yyyy-MM-dd"/>"/>
					</td>
					<td class="width-15 active"><label class="pull-right">资格审查：</label></td>
					<td class="width-35">
						<form:select path="trialType" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('trial_type')}" 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="documentCost" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="pull-right">购买领用招标文件日期：</label></td>
					<td class="width-35">
						<input id="purchaseDate" name="purchaseDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workBidProject.purchaseDate}" pattern="yyyy-MM-dd"/>"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">装订费用（元）：</label></td>
					<td class="width-35">
						<form:input path="bindCost" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="pull-right">其他费用（元）：</label></td>
					<td class="width-35">
						<form:input path="otherCost" 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:input path="bidBond" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="pull-right">投标保证金形式：</label></td>
					<td class="width-35">
						<form:select path="bondStyle" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getMainDictList('bond_style')}" 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="refundDate" name="refundDate" type="text" maxlength="20" class="laydate-icondate form-control layer-date "
							value="<fmt:formatDate value="${workBidProject.refundDate}" pattern="yyyy-MM-dd"/>"/>
					</td>
					<td class="width-15 active"><label class="pull-right">报价（元）：</label></td>
					<td class="width-35">
						<form:input path="offer" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">是否投标：</label></td>
					<td class="width-35">
						<form:select path="isBid" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('is_bid')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
						</form:select>
					</td>
					<td class="width-15 active"><label class="pull-right">项目实施部门：</label></td>
					<%--<td class="width-35">
					 	<sys:gridselect url="${ctx}/workbidproject/workBidProject/selectimplementingDept" id="implementingDept" name="implementingDept"  value="${workBidProject.implementingDept.id}"  title="选择实施部门" labelName="implementingDept.id"
						 labelValue="${workBidProject.implementingDept.id}" cssClass="form-control required" fieldLabels="name" fieldKeys="name" searchLabel="id" searchKey="id" ></sys:gridselect>
 --%>
 			         <td class="width-35" >
 			         <sys:treeselect id="dept" name="implementingDeptIds" value="${workBidProject.implementingDeptIds}" labelName="implementingDeptNames" labelValue="${workBidProject.implementingDeptNames}"
							title="选择实施部门" url="/sys/office/treeData?type=2&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">
						<sys:gridselect url="${ctx}/workbidproject/workBidProject/selectprojectMaster" id="projectMaster" name="projectMaster"  value="${workBidProject.projectMaster.id}"  title="选择负责人" labelName="projectMaster.id"
						 labelValue="${workBidProject.projectMaster.id}" cssClass="form-control required" fieldLabels="name" fieldKeys="name" searchLabel="id" searchKey="id" ></sys:gridselect>
 --%>
   					<td class="width-35" ><sys:treeselect id="projectMaster" name="projectMasterIds" value="${workBidProject.projectMasterIds}" labelName="projectMasterNames" labelValue="${workBidProject.projectMasterNames}"
							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">
						<form:select path="isSubcontract" class="form-control ">
							<form:option value="" label=""/>
							<form:options items="${fns:getDictList('is_subcontract')}" 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:input path="subcontractCompany" htmlEscape="false"    class="form-control "/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>项目概况：</label></td>
					<td class="width-35" colspan="3">
						<form:textarea path="projectSituation" htmlEscape="false" rows="6"    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="remarks" htmlEscape="false" rows="4"    class="form-control "/>
					</td>
				</tr>
		 	</tbody>
		</table>
	</form:form>
</body>
</html>