<%
layout("/include/_container.html", {title:"表单", parent:"票务代理"}){
%>
	<script type="text/javascript">

		$(document).ready(function() {
			jp.ajaxForm("#inputForm",function(data){
				if(data.success){
				    jp.toastr_success(data.msg);
				    jp.unblock("#inputForm", 0);//立即清除loading层
				    jp.go("${ctx}/test/onetomany/form/testDataMainForm");
				}else{
				    jp.toastr_error(data.msg);
				    $("#inputForm").find("button:submit").button("reset");
				}
			})

	        $('#inDate').datetimepicker({
				 format:'Y-m-d H:i'
		    });
		});
		
		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(".jp-calendar-picker-input").each(function(){
				 $(this).datetimepicker({
					 format:'Y-m-d H:i'
			    });
			});
		}
		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>
<div class="white-box">
		<form id="inputForm"  action="${ctx}/test/onetomany/form/testDataMainForm/save" method="post" class="form-horizontal">
		<input type="hidden" name="id" value="${testDataMainForm.id!}"/>
				<div class="form-group">
					<label class="col-sm-2 control-label">归属用户：</label>
					<div class="col-sm-10">
						<#userselect id="tuser" name="tuser.id" value="${testDataMainForm.tuser.id!}" labelName="tuser.name" labelValue="${testDataMainForm.tuser.name!}"
							    class="jp-input "/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">归属部门：</label>
					<div class="col-sm-10">
						<#treeselect id="office" name="office.id" value="${testDataMainForm.office.id!}" labelName="office.name" labelValue="${testDataMainForm.office.name!}"
							title="部门" url="/sys/office/treeData?type=2" class="jp-input " allowClear="true" notAllowSelectParent="true"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">归属区域：</label>
					<div class="col-sm-10">
						<#treeselect id="area" name="area.id" value="${testDataMainForm.area.id!}" labelName="area.name" labelValue="${testDataMainForm.area.name!}"
							title="区域" url="/sys/area/treeData" class="jp-input " allowClear="true" notAllowSelectParent="true"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>名称：</label>
					<div class="col-sm-10">
						<input name="name" value="${testDataMainForm.name!}"    class="jp-input required"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label"><font color="red">*</font>性别：</label>
					<div class="col-sm-10">
						<#radiobuttons path="sex" value="${testDataMainForm.sex!}" items="${fn.getDictList('sex')}" itemLabel="label" itemValue="value" class="required"/>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">加入日期：</label>
					<div class="col-sm-10">
			            <span class="jp-calendar-picker">
								<input readonly=""  id="inDate" name="inDate"  placeholder="请选择日期" class="jp-calendar-picker-input jp-input   "   value="${fn.formatDate(testDataMainForm.inDate!, 'yyyy-MM-dd HH:mm:ss')}">
								<span class="jp-calendar-picker-icon"></span>
						</span>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-2 control-label">备注信息：</label>
					<div class="col-sm-10">
						<textarea name="remarks" rows="4"    class="jp-input ">${testDataMainForm.remarks!}</textarea>
					</div>
				</div>
		<div class="tabs-container">
            <ul class="nav customtab nav-tabs" role="tablist">
				<li role="presentation" class="active">
					<a data-toggle="tab"  role="tab" href="#tab-1" aria-expanded="true">火车票：</a>
                </li>
				<li>
					<a data-toggle="tab"  role="tab" href="#tab-2" aria-expanded="false">飞机票：</a>
                </li>
				<li>
					<a data-toggle="tab"  role="tab" href="#tab-3" 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('#testDataChild21List', testDataChild21RowIdx, testDataChild21Tpl);testDataChild21RowIdx = testDataChild21RowIdx + 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><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="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="testDataChild21List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild21Tpl">//<!--
				<tr id="testDataChild21List{{idx}}">
					<td class="hide">
						<input id="testDataChild21List{{idx}}_id" name="testDataChild21List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild21List{{idx}}_delFlag" name="testDataChild21List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild21List{{idx}}_startArea" name="testDataChild21List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild21List{{idx}}.startArea.name" labelValue="{{row.startArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild21List{{idx}}_endArea" name="testDataChild21List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild21List{{idx}}.endArea.name" labelValue="{{row.endArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td>
						<span class="jp-calendar-picker">
								<input readonly=""   id="testDataChild21List{{idx}}_starttime"   name="testDataChild21List[{{idx}}].starttime" placeholder="请选择日期" class="jp-calendar-picker-input jp-input  required"  value="{{row.starttime}}">
								<span class="jp-calendar-picker-icon"></span>
						</span>
					</td>
					
					
					<td>
						<input id="testDataChild21List{{idx}}_endtime" name="testDataChild21List[{{idx}}].endtime" type="text" value="{{row.endtime}}"    class="jp-input required"/>
					</td>
					
					
					<td>
						<input id="testDataChild21List{{idx}}_price" name="testDataChild21List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required isFloatGteZero"/>
					</td>
					
					
					<td>
					    <#fileUpload id="testDataChild21List{{idx}}_file"  name="testDataChild21List[{{idx}}].file" class="jp-input  required" value="{{row.file}}" type="file" uploadPath="/test/onetomany.form/testDataMainForm"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild21List{{idx}}_remarks" name="testDataChild21List[{{idx}}].remarks" rows="4"    class="jp-input required">{{row.remarks}}</textarea>
					</td>
					
					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild21List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>//-->
			</script>
			<script type="text/javascript">
				var testDataChild21RowIdx = 0, testDataChild21Tpl = $("#testDataChild21Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fn.toJson(testDataMainForm.testDataChild21List)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild21List', testDataChild21RowIdx, testDataChild21Tpl, data[i]);
						testDataChild21RowIdx = testDataChild21RowIdx + 1;
					}
				});
			</script>
			</div>
				<div id="tab-2" class="tab-pane fade">
			<a class="btn btn-white btn-sm" onclick="addRow('#testDataChild22List', testDataChild22RowIdx, testDataChild22Tpl);testDataChild22RowIdx = testDataChild22RowIdx + 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><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="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="testDataChild22List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild22Tpl">//<!--
				<tr id="testDataChild22List{{idx}}">
					<td class="hide">
						<input id="testDataChild22List{{idx}}_id" name="testDataChild22List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild22List{{idx}}_delFlag" name="testDataChild22List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild22List{{idx}}_startArea" name="testDataChild22List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild22List{{idx}}.startArea.name" labelValue="{{row.startArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild22List{{idx}}_endArea" name="testDataChild22List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild22List{{idx}}.endArea.name" labelValue="{{row.endArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td>
						<span class="jp-calendar-picker">
								<input readonly=""   id="testDataChild22List{{idx}}_startTime"   name="testDataChild22List[{{idx}}].startTime" placeholder="请选择日期" class="jp-calendar-picker-input jp-input  required"  value="{{row.startTime}}">
								<span class="jp-calendar-picker-icon"></span>
						</span>
					</td>
					
					
					<td>
						<input id="testDataChild22List{{idx}}_price" name="testDataChild22List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required isFloatGteZero"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild22List{{idx}}_remarks" name="testDataChild22List[{{idx}}].remarks" rows="4"    class="jp-input required">{{row.remarks}}</textarea>
					</td>
					
					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild22List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>//-->
			</script>
			<script type="text/javascript">
				var testDataChild22RowIdx = 0, testDataChild22Tpl = $("#testDataChild22Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fn.toJson(testDataMainForm.testDataChild22List)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild22List', testDataChild22RowIdx, testDataChild22Tpl, data[i]);
						testDataChild22RowIdx = testDataChild22RowIdx + 1;
					}
				});
			</script>
			</div>
				<div id="tab-3" class="tab-pane fade">
			<a class="btn btn-white btn-sm" onclick="addRow('#testDataChild23List', testDataChild23RowIdx, testDataChild23Tpl);testDataChild23RowIdx = testDataChild23RowIdx + 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><font color="red">*</font>目的地</th>
						<th><font color="red">*</font>代理价格</th>
						<th><font color="red">*</font>备注信息</th>
						<th width="10">&nbsp;</th>
					</tr>
				</thead>
				<tbody id="testDataChild23List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild23Tpl">//<!--
				<tr id="testDataChild23List{{idx}}">
					<td class="hide">
						<input id="testDataChild23List{{idx}}_id" name="testDataChild23List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild23List{{idx}}_delFlag" name="testDataChild23List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild23List{{idx}}_startArea" name="testDataChild23List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild23List{{idx}}.startArea.name" labelValue="{{row.startArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild23List{{idx}}_endArea" name="testDataChild23List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild23List{{idx}}.endArea.name" labelValue="{{row.endArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td>
						<input id="testDataChild23List{{idx}}_price" name="testDataChild23List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild23List{{idx}}_remarks" name="testDataChild23List[{{idx}}].remarks" rows="4"    class="jp-input required">{{row.remarks}}</textarea>
					</td>
					
					<td class="text-center" width="10">
						{{#delBtn}}<span class="close" onclick="delRow(this, '#testDataChild23List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>//-->
			</script>
			<script type="text/javascript">
				var testDataChild23RowIdx = 0, testDataChild23Tpl = $("#testDataChild23Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fn.toJson(testDataMainForm.testDataChild23List)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild23List', testDataChild23RowIdx, testDataChild23Tpl, data[i]);
						testDataChild23RowIdx = testDataChild23RowIdx + 1;
					}
				});
			</script>
			</div>
		</div>
		</div>
		<% if(mode == "add" || mode == "edit"){ %>
		<div class="form-group">
				<div class="col-lg-3"></div>
		        <div class="col-lg-6">
		             <button class="jp-btn jp-btn-primary jp-btn-lg  btn-block btn-lg btn-parsley" data-loading-text="正在提交...">提 交</button>
		        </div>
		</div>
		<% } %>
		</form>
</div>
<% } %>