<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/webpage/include/taglib.jsp"%>
<html>
<head>
	<title>新增送审决算信息</title>
	<meta name="decorator" content="ani"/>
	<script type="text/javascript">

		$(document).ready(function() {
	        $('#inDate').datetimepicker({
				 format: "YYYY-MM-DD HH:mm:ss"
		    });
		});

		function save() {
            var isValidate = jp.validateForm('#inputForm');//校验表单
            if(!isValidate){
                return false;
			}else{
                jp.loading();
                jp.post("${ctx}/sg/financial/erpCredit/save",$('#inputForm').serialize(),function(data){
                    if(data.success){
                        jp.getParent().refresh();
                        var dialogIndex = parent.layer.getFrameIndex(window.name); // 获取窗口索引
                        parent.layer.close(dialogIndex);
                        jp.success(data.msg)

                    }else{
                        jp.error(data.msg);
                    }
                })
			}

        }
		function addRow(list, idx, tpl, row){
			$(list).append(Mustache.render(tpl, {
				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");
					}
				}
			});
			$(list+idx).find(".form_datetime").each(function(){
				 $(this).datetimepicker({
					 format: "YYYY-MM-DD HH:mm:ss"
			    });
			});
		}
		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).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");
			}
		}
	</script>
</head>
<body class="bg-white">
		<form:form id="inputForm" modelAttribute="erpCredit" action="${ctx}/sg/financial/erpCredit/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<table class="table table-bordered">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>项目定义编号：</label></td>
					<td class="width-35">
						<form:input path="itemId" htmlEscape="false" class="form-control required"/>
					</td>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>项目名称：</label></td>
					<td class="width-35">
						<form:input path="itemName" htmlEscape="false"    class="form-control required"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">实际投资：</label></td>
					<td class="width-35">
						<form:input path="actualInvestment" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="">移交生产的资产总值：</label></td>
					<td class="width-35">
						<form:input path="transferAssets" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">建筑费：</label></td>
					<td class="width-35">
						<form:input path="consBuildingFee" htmlEscape="false"    class="form-control  number"/>
					</td>
					<td class="width-15 active"><label class="">安装费：</label></td>
					<td class="width-35">
						<form:input path="consInstallFee" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">施工费：合计：</label></td>
					<td class="width-35">
						<form:input path="consTotalFee" htmlEscape="false"    class="form-control  number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">监理费：</label></td>
					<td class="width-35">
						<form:input path="otherSupervisorFee" htmlEscape="false"    class="form-control number"/>
					</td>
					<td class="width-15 active"><label class="">设计费：</label></td>
					<td class="width-35">
						<form:input path="otherDesignFee" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">项目前期工作费：</label></td>
					<td class="width-35">
						<form:input path="otherBeWorkFee" htmlEscape="false"    class="form-control number"/>
					</td>
					<td class="width-15 active"><label class="">建设期贷款利息：</label></td>
					<td class="width-35">
						<form:input path="otherBuildLoan" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">线路施工赔偿费：</label></td>
					<td class="width-35">
						<form:input path="otherLineDamages" htmlEscape="false"    class="form-control number"/>
					</td>
					<td class="width-15 active"><label class="">法人管理费：</label></td>
					<td class="width-35">
						<form:input path="otherLegalManage" htmlEscape="false"    class="form-control number"/>
					</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="">其他费用：合计：</label></td>
					<td class="width-35">
						<form:input path="otherTotalFee" htmlEscape="false"    class="form-control  number"/>
					</td>
				</tr>
		 	</tbody>
		</table>
		<div class="tabs-container">
            <ul class="nav nav-tabs">
				<li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true">设备费</a>
                </li>
				<li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">材料费</a>
                </li>
            </ul>
            <div class="tab-content">
				<div id="tab-1" class="tab-pane fade in  active">
			<a class="btn btn-white btn-sm" onclick="addRow('#testDataChild11List', testDataChild11RowIdx, testDataChild11Tpl);testDataChild11RowIdx = testDataChild11RowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th class="hide"></th>
						<th><font color="red">*</font>物料描述</th>
						<th>单位</th>
						<th>台数</th>
						<th>总容量（千伏安）</th>
						<th>入账金额（不含税价）</th>
						<th width="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="testDataChild11List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild11Tpl">
				<tr id="testDataChild11List{{idx}}">
					<td class="hide">
						<input id="testDataChild11List{{idx}}_id" name="erpCreditChild1s[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild11List{{idx}}_delFlag" name="erpCreditChild1s[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					<td  class="max-width-250">
						<input  name="erpCreditChild1s[{{idx}}].eqmMaterialDetails1" class="form-control required" type="text" value="{{row.eqmMaterialDetails1}}"/>
					</td>
					<td  class="max-width-250">
						<input  name="erpCreditChild1s[{{idx}}].eqmUnit" class="form-control" type="text" value="{{row.eqmUnit}}"/>
					</td>
					<td>
						<input  name="erpCreditChild1s[{{idx}}].eqmNumbers" class="form-control number" type="text" value="{{row.eqmNumbers}}"/>
					</td>
					<td>
						<input  name="erpCreditChild1s[{{idx}}].eqmTotalCapacity" class="form-control" type="text" value="{{row.eqmTotalCapacity}}"/>
					</td>
					<td>
						<input  name="erpCreditChild1s[{{idx}}].eqmBookedFee1" class="form-control number" type="text" value="{{row.eqmBookedFee1}}"/>
					</td>

					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild11List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>
			</script>
			<script type="text/javascript">
				var testDataChild11RowIdx = 0, testDataChild11Tpl = $("#testDataChild11Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fns:toJson(erpCredit.erpCreditChild1s)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild11List', testDataChild11RowIdx, testDataChild11Tpl, data[i]);
						testDataChild11RowIdx = testDataChild11RowIdx + 1;
					}
				});
			</script>
			</div>
				<div id="tab-2" class="tab-pane fade">
			<a class="btn btn-white btn-sm" onclick="addRow('#testDataChild12List', testDataChild12RowIdx, testDataChild12Tpl);testDataChild12RowIdx = testDataChild12RowIdx + 1;" title="新增"><i class="fa fa-plus"></i> 新增</a>
			<table class="table table-striped table-bordered table-condensed">
				<thead>
					<tr>
						<th class="hide"></th>
						<th><font color="red">*</font>物料描述</th>
						<th>入账金额（不含税价）</th>
						<th width="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="testDataChild12List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild12Tpl">
				<tr id="testDataChild12List{{idx}}">
					<td class="hide">
						<input id="testDataChild12List{{idx}}_id" name="erpCreditChild2s[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild12List{{idx}}_delFlag" name="erpCreditChild2s[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<input  name="erpCreditChild2s[{{idx}}].eqmMaterialDetails2" class="form-control " type="text" value="{{row.eqmMaterialDetails2}}"/>
					</td>
					
					
					<td  class="max-width-250">
						<input  name="erpCreditChild2s[{{idx}}].mtlBookedFee2" class="form-control number" type="text" value="{{row.mtlBookedFee2}}"/>
					</td>
					
					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild12List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>
			</script>
			<script type="text/javascript">
				var testDataChild12RowIdx = 0, testDataChild12Tpl = $("#testDataChild12Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fns:toJson(erpCredit.erpCreditChild2s)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild12List', testDataChild12RowIdx, testDataChild12Tpl, data[i]);
						testDataChild12RowIdx = testDataChild12RowIdx + 1;
					}
				});
			</script>
			</div>
		</div>
		</div>
		</form:form>
</body>
</html>