<%@ 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);
					}
				}
			});
            getCurrentDocumentHei();
		});
        function addRow(list, idx, tpl, row){
            var idx1 = $("#workProjectCalcDecors tr").length;
            if(list == '#workProjectCalcDecors'){
                bornTemplete(list, idx, tpl, row, idx1);
            }
            var idx2 = $("#workProjectCalcBuilds tr").length;
            if(list == '#workProjectCalcBuilds'){
                bornTemplete(list, idx, tpl, row, idx2);
            }
        }
        function bornTemplete(list, idx, tpl, row, idx1){
            $(list).append(Mustache.render(tpl, {
                idx: idx, delBtn: true, row: row,
                order:idx1 + 1
            }));
            getCurrentDocumentHei();
        }
        function delRow(obj, prefix,othis){
            var id = $(prefix+"_id");
            var delFlag = $(prefix+"_delFlag");
            if (id.val() == ""){
                delFlag.val("1");
                $(obj).parent().parent().remove();
            }else if(delFlag.val() == "0"){
                delFlag.val("1");
                $(obj).html("&divide;").attr("title", "撤回删除");
                $(obj).parent().parent().addClass("error");
                $(obj).parent().parent().addClass("hide");
            }else if(delFlag.val() == "1"){
                delFlag.val("0");
                $(obj).parent().parent().removeClass("error");
            }
            getCurrentDocumentHei(othis)
        }
        function getCurrentDocumentHei(obj){
            var height = $(document).outerHeight();
            var hei = 0;
            if(obj){
                hei = $(obj).find("tr").eq(0).height() || 0;
			}
            parent.$("#controltype").attr("height",(height - hei) +"px")
        }
	</script>
</head>
<body class="hideScroll">
		<form:form id="inputForm" modelAttribute="workProjectCalcDecor" action="${ctx}/workprojectcalc/workProjectCalcDecor/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<sys:message content="${message}"/>
		<input type="hidden" name="projectId" id="projectId">
			<div class="ibox">
				<div class="ibox-title" style="min-height:0px;">
					装饰部分
				</div>
				<div class="ibox-content">
					<a class="btn btn-white btn-sm addBtn" onclick="addRow('#workProjectCalcDecors', workProjectCalcDecorsRowIdx, workProjectCalcDecorsTpl);workProjectCalcDecorsRowIdx = workProjectCalcDecorsRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
					<table id="contentTable1" class="table table-striped table-bordered table-condensed">
						<thead>
						<tr>
							<th><font color="red">*</font>序号</th>
							<th><font color="red">*</font>清单编号/定额编号</th>
							<th><font color="red">*</font>项目名称</th>
							<th><font color="red">*</font>计量单位</th>
							<th><font color="red">*</font>计算式</th>
							<th><font color="red">*</font>工程量</th>
							<th><font color="red">*</font>其他</th>
							<th><font color="red">*</font>工程来源</th>
							<th width="150px">操作</th>
						</tr>
						</thead>
						<tbody id="workProjectCalcDecors">
						<c:if test="${not empty workProjectCalcDecor.workProjectCalcDecorList}">
							<c:forEach items="${workProjectCalcDecor.workProjectCalcDecorList}" var="workProjectCalcDecor" varStatus="index">
								<tr id="workHandBillDetailList${index.index}">
									<td class="hide">
										<input id="workProjectCalcDecorList${index.index}_id" name="workProjectCalcDecorList[${index.index}].id" type="hidden" value="${workProjectCalcDecor.id}"/>
										<input id="workProjectCalcDecorList${index.index}_delFlag" name="workProjectCalcDecorList[${index.index}].delFlag" type="hidden" value="0"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}decorNumber"  name="workProjectCalcDecorList[${index.index}].decorNumber" type="text" value="${workProjectCalcDecor.decorNumber}"    class="form-control required"/>
									</td>

									<td>
										<input id="workProjectCalcDecorList${index.index}_decorCode" name="workProjectCalcDecorList[${index.index}].decorCode" type="text" value="${workProjectCalcDecor.decorCode}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_projectName" name="workProjectCalcDecorList[${index.index}].projectName" type="text" value="${workProjectCalcDecor.projectName}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_decorUnit" name="workProjectCalcDecorList[${index.index}].decorUnit" type="text" value="${workProjectCalcDecor.decorUnit}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_decorMode" name="workProjectCalcDecorList[${index.index}].decorMode" type="text" value="${workProjectCalcDecor.decorMode}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_decorSize" name="workProjectCalcDecorList[${index.index}].decorSize" type="text" value="${workProjectCalcDecor.decorSize}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_decorOther" name="workProjectCalcDecorList[${index.index}].decorOther" type="text" value="${workProjectCalcDecor.decorOther}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcDecorList${index.index}_decorOrigin" name="workProjectCalcDecorList[${index.index}].decorOrigin" type="text" value="${workProjectCalcDecor.decorOrigin}"    class="form-control required"/>
									</td>
									<td class="text-center" style="width:80px;">
										<span class="btn btn-danger btn-xs" onclick="delRow(this, '#workProjectCalcDecorList${index.index}','#workProjectCalcDecors')" title="删除"><i class="fa fa-trash"></i> 删除</span>
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
					<script type="text/template" id="workProjectCalcDecorsTpl">//<!--
						<tr id="workProjectCalcDecorList{{idx}}">
							<td class="hide">
								<input id="workProjectCalcDecorList{{idx}}_id" name="workDeviceRecordList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
								<input id="workProjectCalcDecorList{{idx}}_delFlag" name="workDeviceRecordList[{{idx}}].delFlag" type="hidden" value="0"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorNumber"  name="workProjectCalcDecorList[{{idx}}].decorNumber" type="text" value="{{row.decorNumber}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorCode"  name="workProjectCalcDecorList[{{idx}}].decorCode" type="text" value="{{row.decorCode}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_projectName" name="workProjectCalcDecorList[{{idx}}].projectName" type="text" value="{{row.projectName}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorUnit" name="workProjectCalcDecorList[{{idx}}].decorUnit" type="text" value="{{row.decorUnit}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorMode" name="workProjectCalcDecorList[{{idx}}].decorMode" type="text" value="{{row.decorMode}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorSize" name="workProjectCalcDecorList[{{idx}}].decorSize" type="text" value="{{row.decorMode}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorOther" name="workProjectCalcDecorList[{{idx}}].decorOther" type="text" value="{{row.decorMode}}"    class="form-control required"/>
							</td>
							<td>
								<input id="workProjectCalcDecorList{{idx}}_decorOrigin" name="workProjectCalcDecorList[{{idx}}].decorOrigin" type="text" value="{{row.decorOrigin}}"    class="form-control required"/>
							</td>
							<td class="text-center" style="width:80px;">
								{{#delBtn}}<span class="btn btn-danger btn-xs" onclick="delRow(this, '#workProjectCalcDecorList{{idx}}','#workProjectCalcDecors')" title="删除"><i class="fa fa-trash"></i> 删除</span>{{/delBtn}}
							</td>
						</tr>//-->
					</script>
					<script type="text/javascript">
                        var workProjectCalcDecorsRowIdx = 0, workProjectCalcDecorsTpl = $("#workProjectCalcDecorsTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
					</script>
				</div>
			</div>
			<div class="ibox">
				<div class="ibox-title" style="min-height:0px;">
					建筑部分
				</div>
				<div class="ibox-content">
					<a class="btn btn-white btn-sm addBtn" onclick="addRow('#workProjectCalcBuilds', workProjectCalcBuildsRowIdx, workProjectCalcBuildsTpl);workProjectCalcBuildsRowIdx = workProjectCalcBuildsRowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
					<table id="contentTable2" class="table table-striped table-bordered table-condensed">
						<thead>
						<tr>
							<th><font color="red">*</font>序号</th>
							<th><font color="red">*</font>清单编号/定额编号</th>
							<th><font color="red">*</font>项目名称</th>
							<th><font color="red">*</font>计量单位</th>
							<th><font color="red">*</font>计算式/索引</th>
							<th><font color="red">*</font>工程量</th>
							<th><font color="red">*</font>其他</th>
							<th><font color="red">*</font>分项数据索引</th>
							<th width="150px">操作</th>
						</tr>
						</thead>
						<tbody id="workProjectCalcBuilds">
						<c:if test="${not empty workProjectCalcDecor.workProjectCalcBuildList}">
							<c:forEach items="${workProjectCalcDecor.workProjectCalcBuildList}" var="workProjectCalcBuild" varStatus="index">
								<tr id="workHandBillDetailList${index.index}">
									<td class="hide">
										<input id="workProjectCalcBuildList${index.index}_id" name="workProjectCalcBuildList[${index.index}].id" type="hidden" value="${workProjectCalcBuild.id}"/>
										<input id="workProjectCalcBuildList${index.index}_delFlag" name="workProjectCalcBuildList[${index.index}].delFlag" type="hidden" value="0"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}buildNumber"  name="workProjectCalcBuildList[${index.index}].buildNumber" type="text" value="${workProjectCalcBuild.buildNumber}"    class="form-control required"/>
									</td>

									<td>
										<input id="workProjectCalcBuildList${index.index}_buildCode" name="workProjectCalcBuildList[${index.index}].buildCode" type="text" value="${workProjectCalcBuild.buildCode}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_projectName" name="workProjectCalcBuildList[${index.index}].projectName" type="text" value="${workProjectCalcBuild.projectName}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_buildUnit" name="workProjectCalcBuildList[${index.index}].buildUnit" type="text" value="${workProjectCalcBuild.buildUnit}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_buildMode" name="workProjectCalcBuildList[${index.index}].buildMode" type="text" value="${workProjectCalcBuild.buildMode}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_buildSize" name="workProjectCalcBuildList[${index.index}].buildSize" type="text" value="${workProjectCalcBuild.buildSize}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_buildOther" name="workProjectCalcBuildList[${index.index}].buildOther" type="text" value="${workProjectCalcBuild.buildOther}"    class="form-control required"/>
									</td>
									<td>
										<input id="workProjectCalcBuildList${index.index}_buildIndex" name="workProjectCalcBuildList[${index.index}].buildIndex" type="text" value="${workProjectCalcBuild.buildIndex}"    class="form-control required"/>
									</td>
									<td class="text-center" style="width:80px;">
										<span class="btn btn-danger btn-xs" onclick="delRow(this, '#workProjectCalcBuildList${index.index}','#workProjectCalcBuilds')" title="删除"><i class="fa fa-trash"></i> 删除</span>
									</td>
								</tr>
							</c:forEach>
						</c:if>
						</tbody>
					</table>
					<script type="text/template" id="workProjectCalcBuildsTpl">//<!--
				<tr id="workProjectCalcBuildList{{idx}}">
					<td class="hide">
						<input id="workProjectCalcBuildList{{idx}}_id" name="workProjectCalcBuildList[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="workProjectCalcBuildList{{idx}}_delFlag" name="workProjectCalcBuildList[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildNumber"  name="workProjectCalcBuildList[{{idx}}].buildNumber" type="text" value="{{row.buildNumber}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildCode"  name="workProjectCalcBuildList[{{idx}}].buildCode" type="text" value="{{row.buildCode}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_projectName" name="workProjectCalcBuildList[{{idx}}].projectName" type="text" value="{{row.projectName}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildUnit" name="workProjectCalcBuildList[{{idx}}].buildUnit" type="text" value="{{row.buildUnit}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildMode" name="workProjectCalcBuildList[{{idx}}].buildMode" type="text" value="{{row.buildMode}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildSize" name="workProjectCalcBuildList[{{idx}}].buildSize" type="text" value="{{row.buildSize}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildOther" name="workProjectCalcBuildList[{{idx}}].buildOther" type="text" value="{{row.buildOther}}"    class="form-control required"/>
					</td>
					<td>
						<input id="workProjectCalcBuildList{{idx}}_buildIndex" name="workProjectCalcBuildList[{{idx}}].buildIndex" type="text" value="{{row.buildIndex}}"    class="form-control required"/>
					</td>
					<td class="text-center" style="width:80px;">
						{{#delBtn}}<span class="btn btn-danger btn-xs" onclick="delRow(this, '#workProjectCalcBuildList{{idx}}','#workProjectCalcBuilds')" title="删除"><i class="fa fa-trash"></i> 删除</span>{{/delBtn}}
					</td>
				</tr>//-->
					</script>
					<script type="text/javascript">
                        var workProjectCalcBuildsRowIdx = 0, workProjectCalcBuildsTpl = $("#workProjectCalcBuildsTpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
					</script>
				</div>
			</div>
	</form:form>
</body>
</html>