<%@ 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(obj){//回调函数，在编辑和保存动作时，供openDialog调用提交表单。
            if(validateForm.form()){
                if(obj == 1){
                    $("#inputForm").attr("action","${ctx}/workprequalification/workPrequalification/save");
                }else if (obj == 2){
                    $("#inputForm").attr("action","${ctx}/workprequalification/workPrequalification/store");
                }else if (obj == 3){
                    $("#inputForm").attr("action","${ctx}/workprequalification/workPrequalification/save");
                }else if (obj == 4){
                    $("#inputForm").attr("action","${ctx}/workprequalification/workPrequalification/store");
                }else {
                    $("#inputForm").attr("action","${ctx}/workprequalification/workPrequalification/save");
                }
                $("#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: false, 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){
            $('#workClientLinkmanList').html("");
            $('#bidCompanyName').val("");
            if(n==0){
                $("#contact").show();
                $("#btnAdd1").hide();
                //$("#btnAdd2").show();
                $("#extContact").hide();
            }else{
                $("#extContact").show();
                $("#btnAdd1").show();
                //$("#btnAdd2").hide();
                $("#contact").hide();
            }

			//显示系统外客户联系人
			if(n==1){
                getExtCompany();
			}
        }
        function getExtCompany(){
            var workBidProjectId =$("#workBidProjectId").val(); console.log("id="+workBidProjectId);
            $.get("${ctx}/workprequalification/workPrequalification/getExtCompany", { "workBidProjectId": workBidProjectId},
                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;
                        }
                    }
                });
        }

        function changeTypeExplain(obj) {
			if (obj.value == 4){
                $("#typeExplain").attr("class","form-control required");
			}else {
                $("#typeExplain").attr("class","form-control");
			}
        }
        function changeSourceExplain(obj) {
			if (obj.value == 3){
                $("#sourceExplain").attr("class","form-control required");
			}else {
                $("#sourceExplain").attr("class","form-control");
			}
        }

	</script>
	<script type="text/template" id="workClientLinkmanTpl">//<!--
				<tr id="workClientLinkmanList{{idx}}">
					<td class="hide">
						<input id="workClientLinkmanList{{idx}}_id" name="workClientLinkmanList[{{idx}}].id" type="hidden" value="{{row.id}}" />
						<input id="workClientLinkmanList{{idx}}_delFlag" name="workClientLinkmanList[{{idx}}].delFlag" type="hidden" value="0" />
					</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_name" name="workClientLinkmanList[{{idx}}].name" type="text" value="{{row.name}}"    class="form-control "/>
					</td>
      				<td>
                    	<input id="workClientLinkmanList{{idx}}_office" name="workClientLinkmanList[{{idx}}].office" type="text" value="{{row.office}}"    class="form-control "/>
                	</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_position" name="workClientLinkmanList[{{idx}}].position" type="text" value="{{row.position}}"    class="form-control"/>
					</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_qq" name="workClientLinkmanList[{{idx}}].qq" type="text" value="{{row.qq}}"    class="form-control " />
					</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_linkPhone" name="workClientLinkmanList[{{idx}}].linkPhone" type="text" value="{{row.linkPhone}}"    class="form-control "/>
					</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_linkMobile" name="workClientLinkmanList[{{idx}}].linkMobile" type="text" value="{{row.linkMobile}}"    class="form-control " />
					</td>
					<td>
						<input id="workClientLinkmanList{{idx}}_email" name="workClientLinkmanList[{{idx}}].email" type="text" value="{{row.email}}"    class="form-control "/>
					</td>
					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#workClientLinkmanList{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>//-->
	</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;
                }
            }
        });
        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>
	<script type="text/javascript">
        /**
         * 设置系统内客户信息
         * @param obj
         */

        function setValuee(obj){
            $('#workClientLinkmanList').html("");
            $.get("${ctx}/workclientinfo/workClientInfo/selectLinkman", { clientId: obj},
                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>
</head>
<body class="hideScroll">
<form:form id="inputForm" modelAttribute="workBidProject" method="post" class="form-horizontal">
	<form:hidden path="id" id="workBidProjectId"/>
	<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"><font color="red">*</font>项目类型：</label></td>
			<td class="width-35">
				<form:select path="projectType" class="form-control required" onChange="changeTypeExplain(this)">
					<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 id="typeExplain" path="typeExplain" 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">
				<form:select path="projectSource" class="form-control required" onChange="changeSourceExplain(this)">
					<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 id="sourceExplain" 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">
				<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">
				<c:choose>
					<c:when test="${workBidProject.isExt == 1}">
						<input type="radio" class="i-checks" value="1" id="isExt" name="isExt" onclick="display(this.value)" checked="checked">系统外客户
						<input type="radio" class="i-checks" value="0" id="isExt" name="isExt" onclick="display(this.value)" >系统内客户
					</c:when>
					<c:otherwise>
						<input type="radio" class="i-checks" value="1" id="isExt" name="isExt" onclick="display(this.value)" >系统外客户
						<input type="radio" class="i-checks" 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 required"/>
				</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>

		<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>
				<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>职务</th>
						<th>QQ</th>
						<th>联系方式1</th>
						<th>联系方式2</th>
						<th>E-mail</th>
						<th>&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" ><sys:treeselect id="projectMaster" name="projectMasterIds" value="${workBidProject.projectMasterIds}" labelName="projectMasterNames" labelValue="${workBidProject.projectMasterNames}"
												  title="选择负责人" url="/sys/office/treeDataAll?type=3&isAll=false" cssClass="form-control" notAllowSelectParent="true" checked="true"/>
			</td>
			<td class="width-15 active"><label class="pull-right">项目组成员：</label></td>
			<td class="width-35" ><sys:treeselect id="projectMember" name="projectMemberIds" value="${workBidProject.projectMemberIds}" labelName="projectMemberNames" labelValue="${workBidProject.projectMemberNames}"
												  title="选择成员" url="/sys/office/treeDataAll?type=3&isAll=false" cssClass="form-control" notAllowSelectParent="true" checked="true"/>
		</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">
				<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="documentCost" 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="bindCost" htmlEscape="false"    class="form-control  number"/>
			</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>
		</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 required"/>
			</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>