<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('提交演出退款')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-post-add">
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">演出id：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="targetId" id="targetId" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">演出名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="title">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label is-required">演出统计：</label>
				<div class="col-sm-8">
					<div class="col-sm-12 select-table table-bordered">
						<table id="bootstrap-table"></table>
					</div>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label layui-required is-required">备注：</label>
				<div class="col-sm-8">
					<textarea name="reason" maxlength="500" class="form-control layui-required" rows="3"></textarea>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">
		var prefix = ctx + "kylin/refundBatch";
	    
		$("#form-post-add").validate({
			onkeyup: false,
			rules:{
				targetId:{
					submitHandler: function(form) {
						var config = {
							url: prefix + "/applyPerformance",
							type: "post",
							dataType: "json",
							data: {
								"targetId" : function() {
									return $.common.trim($("#targetId").val());
								}
							},
							beforeSend: function () {
								$.modal.loading("正在查询演出，请稍后...");
							},
							success: function(result) {
								var options = {
									data: result.orderTicketEntitiesVo,
									pagination: false,
									columns: [{
										checkbox: true
									},
										{
											field: 'orderTicketEntitiesId',
											title: '票种数据'
										},
									]
								};
								$.table.init(options);
								$.modal.closeLoading();
							}
						};
						$.ajax(config)
					}
				},
			},
		    focusCleanup: true
		});
		
		function submitHandler() {
			var reason = $('#form-post-add').find("[name='reason']").val();
			var targetId = $('#form-post-add').find("[name='targetId']").val();
			if (!targetId || !reason) {
				layer.msg("请完善数据");
				return false;
			}
			if ($.validate.form()) {
				var data = $('#form-post-add').serializeArray();
				$.operate.save(prefix + "/apply", data);
			}
		}
	</script>
</body>
</html>
