<%
layout("/include/_dialog.html"){
%>
	<script type="text/javascript">

		$(document).ready(function() {
					        $('#inDate').datetimepicker({
				 format:'Y-m-d H:i'
		    });
		});

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

                    }else{
                        jp.toastr_error(data.msg);
                    }
                    jp.close(index);
                })
			}

        }

		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"  method="post" class="form-horizontal">
		<input type="hidden" name="id" value="${testDataMainDialog.id!}"/>
		<table class="table table-bordered">
		   <tbody>
				<tr>
					<td class="width-15 active"><label class="pull-right">归属用户：</label></td>
					<td class="width-35">
						<#userselect id="tuser" name="tuser.id" value="${testDataMainDialog.tuser.id!}" labelName="tuser.name" labelValue="${testDataMainDialog.tuser.name!}"
							    class="jp-input "/>
				</td>
					<td class="width-15 active"><label class="pull-right">归属部门：</label></td>
					<td class="width-35">
						<#treeselect id="office" name="office.id" value="${testDataMainDialog.office.id!}" labelName="office.name" labelValue="${testDataMainDialog.office.name!}"
							title="部门" url="/sys/office/treeData?type=2" class="jp-input " allowClear="true" notAllowSelectParent="true"/>
				</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">归属区域：</label></td>
					<td class="width-35">
						<#treeselect id="area" name="area.id" value="${testDataMainDialog.area.id!}" labelName="area.name" labelValue="${testDataMainDialog.area.name!}"
							title="区域" url="/sys/area/treeData" class="jp-input " allowClear="true" notAllowSelectParent="true"/>
				</td>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>名称：</label></td>
					<td class="width-35">
						<input name="name" value="${testDataMainDialog.name!}"    class="jp-input required"/>
				</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right"><font color="red">*</font>性别：</label></td>
					<td class="width-35">
						<#radiobuttons path="sex" value="${testDataMainDialog.sex!}" items="${fn.getDictList('sex')}" itemLabel="label" itemValue="value" class="required"/>
				</td>
					<td class="width-15 active"><label class="pull-right">加入日期：</label></td>
					<td class="width-35">
						<span class="jp-calendar-picker">
								<input readonly=""  id="inDate" name="inDate"  placeholder="请选择日期" class="jp-calendar-picker-input jp-input   "   value="${fn.formatDate(testDataMainDialog.inDate!, 'yyyy-MM-dd HH:mm:ss')}">
								<span class="jp-calendar-picker-icon"></span>
						</span>
				</td>
				</tr>
				<tr>
					<td class="width-15 active"><label class="pull-right">备注信息：</label></td>
					<td class="width-35">
						<textarea name="remarks" rows="4"    class="jp-input ">${testDataMainDialog.remarks!}</textarea>
				</td>
					<td class="width-15 active"></td>
		   			<td class="width-35" ></td>
		  		</tr>
		 	</tbody>
		</table>
		<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('#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><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="testDataChild11List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild11Tpl">//<!--
				<tr id="testDataChild11List{{idx}}">
					<td class="hide">
						<input id="testDataChild11List{{idx}}_id" name="testDataChild11List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild11List{{idx}}_delFlag" name="testDataChild11List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild11List{{idx}}_startArea" name="testDataChild11List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild11List{{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="testDataChild11List{{idx}}_endArea" name="testDataChild11List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild11List{{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="testDataChild11List{{idx}}_starttime"   name="testDataChild11List[{{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="testDataChild11List{{idx}}_endtime" name="testDataChild11List[{{idx}}].endtime" type="text" value="{{row.endtime}}"    class="jp-input required"/>
					</td>
					
					
					<td>
						<input id="testDataChild11List{{idx}}_price" name="testDataChild11List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required isFloatGteZero"/>
					</td>
					
					
					<td>
					    <#fileUpload id="testDataChild11List{{idx}}_file"  name="testDataChild11List[{{idx}}].file" class="jp-input  required" value="{{row.file}}" type="file" uploadPath="/test/onetomany.dialog/testDataMainDialog"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild11List{{idx}}_remarks" name="testDataChild11List[{{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, '#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 = ${fn.toJson(testDataMainDialog.testDataChild11List)};
					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><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="testDataChild12List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild12Tpl">//<!--
				<tr id="testDataChild12List{{idx}}">
					<td class="hide">
						<input id="testDataChild12List{{idx}}_id" name="testDataChild12List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild12List{{idx}}_delFlag" name="testDataChild12List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild12List{{idx}}_startArea" name="testDataChild12List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild12List{{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="testDataChild12List{{idx}}_endArea" name="testDataChild12List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild12List{{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="testDataChild12List{{idx}}_startTime"   name="testDataChild12List[{{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="testDataChild12List{{idx}}_price" name="testDataChild12List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required isFloatGteZero"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild12List{{idx}}_remarks" name="testDataChild12List[{{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, '#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 = ${fn.toJson(testDataMainDialog.testDataChild12List)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild12List', testDataChild12RowIdx, testDataChild12Tpl, data[i]);
						testDataChild12RowIdx = testDataChild12RowIdx + 1;
					}
				});
			</script>
			</div>
				<div id="tab-3" class="tab-pane fade">
			<a class="btn btn-white btn-sm" onclick="addRow('#testDataChild13List', testDataChild13RowIdx, testDataChild13Tpl);testDataChild13RowIdx = testDataChild13RowIdx + 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="testDataChild13List">
				</tbody>
			</table>
			<script type="text/template" id="testDataChild13Tpl">//<!--
				<tr id="testDataChild13List{{idx}}">
					<td class="hide">
						<input id="testDataChild13List{{idx}}_id" name="testDataChild13List[{{idx}}].id" type="hidden" value="{{row.id}}"/>
						<input id="testDataChild13List{{idx}}_delFlag" name="testDataChild13List[{{idx}}].delFlag" type="hidden" value="0"/>
					</td>
					
					<td  class="max-width-250">
						<#treeselect id="testDataChild13List{{idx}}_startArea" name="testDataChild13List[{{idx}}].startArea.id" value="{{row.startArea.id}}" labelName="testDataChild13List{{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="testDataChild13List{{idx}}_endArea" name="testDataChild13List[{{idx}}].endArea.id" value="{{row.endArea.id}}" labelName="testDataChild13List{{idx}}.endArea.name" labelValue="{{row.endArea.name}}"
							title="区域" url="/sys/area/treeData" class="jp-input  required" allowClear="true" notAllowSelectParent="true"/>
					</td>
					
					
					<td>
						<input id="testDataChild13List{{idx}}_price" name="testDataChild13List[{{idx}}].price" type="text" value="{{row.price}}"    class="jp-input required"/>
					</td>
					
					
					<td>
						<textarea id="testDataChild13List{{idx}}_remarks" name="testDataChild13List[{{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, '#testDataChild13List{{idx}}')" title="删除">&times;</span>{{/delBtn}}
					</td>
				</tr>//-->
			</script>
			<script type="text/javascript">
				var testDataChild13RowIdx = 0, testDataChild13Tpl = $("#testDataChild13Tpl").html().replace(/(\/\/\<!\-\-)|(\/\/\-\->)/g,"");
				$(document).ready(function() {
					var data = ${fn.toJson(testDataMainDialog.testDataChild13List)};
					for (var i=0; i<data.length; i++){
						addRow('#testDataChild13List', testDataChild13RowIdx, testDataChild13Tpl, data[i]);
						testDataChild13RowIdx = testDataChild13RowIdx + 1;
					}
				});
			</script>
			</div>
		</div>
		</div>
		</form>
</div>
<% } %>