recover_stationroute.html 6.95 KB
<!-- 编辑路段 -->
<div class="modal fade" id="recover_station_modal" role="basic"
	aria-hidden="true">
	<div style="margin:5% auto">
		<div class="modal-content">
			<div class="col-md-12">
				<div class="portlet light porttlet-fit bordered">
					<div class="portlet-title">
						<div class="tipso-animation">
						</div>
						<div class="caption">
							 <i class="fa fa-info-circle font-dark"></i> 
							 <span class="caption-subject font-dark sbold uppercase">站点信息</span>
						</div>
						<div class="actions">
							<div class="btn-group btn-group-devided" data-toggle="buttons">
								<button type="button" class="btn btn-primary" id="batchDeleteStationButton">批量恢复站点</button>									
								<button type="button" class="btn default" data-dismiss="modal">取消</button>
							</div>
						</div>
					</div>
					<div class="portlet-body">
						<div class="table-container" style="margin-top: 10px">
							<from class="form-horizontal" role="form" id="batch_delete_station_form">
							<table class="table table-striped table-bordered table-hover table-checkable" id="stationroute_datatable">
								<thead>
									<tr role="row" class="heading">
										<th width="2%"><input type="checkbox" name="checkItems"
											id="stationCheckItems"></input></th>
										<th width="2%">序号</th>
										<th width="5%">站点路由编号</th>
										<th width="5%">线路编号</th>										
										<th width="8%">线路名称</th>
										<th width="5%">线路方向</th>
										<th width="8%">站点路由名称</th>
										<th width="4%">站点编码</th>
										<th width="4%">站点序号</th>
										<th width="4%">站点类型</th>
										<th width="6%">站点距离(km)</th>
										<th width="6%">站点时长(min)</th>
										<th width="4%">版本号</th>
									</tr>
								</thead>
								<tbody></tbody>
							</table>
							</from>
							<div class="actions">
								<div style="text-align: right">
										<ul id="pagination" class="pagination"></ul>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>

<script type="text/html" id="stationroute_datatable_template">
	{{each list as obj i }}
		<tr>
			<td style="vertical-align: middle;">
				<input type="checkbox" class="group-checkable icheck" name="items" value="{{obj.id}}" id="{{obj.id}}" >
			</td>
			<td style="vertical-align: middle;">
				 {{(list.page*10)+(i+1)}}
			</td>
			<td style="vertical-align: middle;">
				{{obj.id}}
			</td>
			<td>
				{{obj.lineCode}}
			</td>
			<td>
				{{obj.line.name}}
			</td>
			<td>
				{{if obj.directions == '0'}}
					上行
				{{else if obj.directions == '1'}}
					下行
				{{/if}}
			</td>
			<td>
				{{obj.stationName}}
			</td>
			<td>
				{{obj.stationCode}}
			</td>
			<td>
				{{obj.stationRouteCode}}
			</td>
			<td>	
				{{if obj.stationMark == 'B'}}
					起始站
				{{else if obj.stationMark == 'Z'}}
					中途站
				{{else if obj.stationMark== 'E'}}
					终点站
				{{/if}}
			</td>
			<td>
				{{obj.distances}}
			</td>
			<td>
				{{obj.toTime}} 
			</td>
			<td>
				{{obj.versions}}
			</td>		
		</tr>
	{{/each}}
	{{if list.length == 0}}
		<tr>
			<td colspan=13><h6 class="muted">没有找到相关数据</h6></td>
		</tr>
	{{/if}}
</script>
<script type="text/javascript">
$('#recover_station_modal').on('modal.show',function(event) {
	var properties = RoutesOperation.getProperties();
	layer.closeAll();
	// 显示mobal
	$('#recover_station_modal').modal({
		show : true,
		backdrop : 'static',
		keyboard : false
	});
	// 提交数据按钮事件
	$('#batchDeleteStationButton').on('click', function() {
		let checked = $("[name=items]:checked");
		let ids = new Array();
		checked.each(function() {
			ids.push($(this).val());
		});
		if (ids.length > 0) {
			let params = {};
			params.ids = ids;
			params.status = properties.status;
			$.post('/api/lsstationroute/batchRecover',params,function(res) {
				if (res.status == 'SUCCESS') {
					layer.msg('恢复成功...');
				} else {
					layer.msg('恢复失败...');
				}
				initSearch();
				// 刷新左边树
				RoutesOperation.resjtreeDate(properties.lineId, properties.directions, properties.versions);
			});
		} else {
			layer.msg('请选择要恢复的站点!!!');
		}
	});

	/** 全选框 */
	$('#stationCheckItems').on('click', function() {
		$('input[name=items]').prop('checked', $(this).prop("checked"));
	});

	/** 页面加载完显示数据 */
	window.onload = initSearch();

	/**
	 * @description : (TODO) 页面加载事件
	 * 
	 */
	var page = 0;
	function initSearch() {
		var params = new getParams();
		page = 0;
		loadTableDate(params, true);
	}
	function getParams() {
		var params = {};
		params['line.id_eq'] = properties.lineId;
		params.directions_eq = properties.directions;
		params.versions_eq = properties.versions;
		params.destroy_eq = 1;

		return params;
	}
	/**
	 * @description : (TODO) 表格数据分页加载事件
	 * 
	 * ------@param : 查询参数
	 * 
	 * ------@isPon : 是否重新分页
	 * 
	 */
	function loadTableDate(param, isPon) {
		// 初始化全选按钮
		$('#stationCheckItems').prop('checked', false);
		// 搜索参数
		var params = {};
		if (param)
			params = param;
		// 排序(按方向与序号)
		params['order'] = 'directions,stationRouteCode';
		// 排序方向.
		params['direction'] = 'ASC,ASC';
		// 记录当前页数
		params['page'] = page;

		// 弹出正在加载层
		var i = layer.load(2);
		// 异步请求获取表格数据
		$.get('/api/lsstationroute/findPageByParams', params, function(result) {
			// 添加序号
			if (!result.content) {
				result.content = new Array();
			}
			result.content.page = page;
			// 把数据填充到模版中
			var tbodyHtml = template('stationroute_datatable_template',{list : result.content});
			// 把渲染好的模版html文本追加到表格中
			$('#stationroute_datatable tbody').html(tbodyHtml);
			// 是重新分页且返回数据长度大于0
			if (isPon && result.content.length > 0) {
			// 重新分页
			initPag = true;
			// 分页栏
			showPagination(result);
			}
			// 关闭弹出加载层
			layer.close(i);
		});
	}
	/**
	 * @description : (TODO) 分页栏组件
	 * 
	 */
	function showPagination(data) {
		// 分页组件
		$('#pagination').jqPaginator({
			// 总页数
			totalPages: data.totalPages,
			// 中间显示页数
			visiblePages: 6,
			// 当前页
			currentPage: page + 1,
			first: '<li class="first"><a href="javascript:void(0);">首页<\/a><\/li>',
			prev: '<li class="prev"><a href="javascript:void(0);">上一页<\/a><\/li>',
			next: '<li class="next"><a href="javascript:void(0);">下一页<\/a><\/li>',
			last: '<li class="last"><a href="javascript:void(0);">尾页<\/a><\/li>',
			page: '<li class="page"><a href="javascript:void(0);">{{page}}<\/a><\/li>',
			onPageChange : function(num, type) {
				if (initPag) {
					initPag = false;
					return;
				}
				var pData = getParams();
				page = num - 1;
				loadTableDate(pData, false);
			}
		});
	}
});
</script>