list.jsp
6.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>航班日期修改</title>
<%-- <link href="<%=basePath %>static/css/login.css" rel="stylesheet"> --%>
<script src="<%=basePath %>static/easyui/jquery.min.js"></script>
<link href="<%=basePath %>static/layui2.4.5/css/layui.css" rel="stylesheet">
<script src="<%=basePath %>static/layui2.4.5/layui.js"></script>
<script type="text/javascript" src="<%=basePath %>static/layer-v3.0.3/layer/layer.js"></script>
</head>
<body>
<div class="demoTable">
航班号:
<div class="layui-inline">
<input class="layui-input" style="text-transform:uppercase;" name="flightno" id="flightno" autocomplete="off" onkeyup="if (this.value != this.value.toUpperCase()) this.value=this.value.toUpperCase();">
</div>
<button class="layui-btn" lay-submit="" id="searchBtn" data-type="getInfo">查询</button>
<button class="layui-btn" data-type="reload" id="add">新增</button>
</div>
<table class="layui-hide" id="flight" lay-filter="flight"></table>
<%--
<script type="text/html" id="toolbar">
<div class="layui-btn-container">
<button class="layui-btn layui-btn-sm" >新增</button>
<input id="searchInput" type="text" placeholder="请输入关键字">
<button class="layui-btn layui-btn-sm" >查询</button>
</div>
</script> --%>
<script type="text/html" id="barDemo">
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script>
layui.use('table', function(){
var table = layui.table;
table.render({
elem: '#flight'
,url:'<%=basePath %>/flight/getList'
/* ,toolbar: '#toolbar' */
,title: '航班跨天配置'
,page: true //开启分页
,cols: [[
{type: 'checkbox', fixed: 'left'}
,{field:'flightno', title:'航班号', width:90, fixed: 'left', unresize: true, sort: true}
,{field:'crossdatys', title:'跨天数', width:120, edit: 'text'}
,{field:'originatingstation', title:'起始站', width:80, edit: 'text', sort: true}
,{field:'week', title:'星期', width:100}
,{fixed: 'right', title:'操作', toolbar: '#barDemo', width:150}
]]
});
$('#searchBtn').on('click',function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
// 点击获取数据
var active = {
getInfo: function () {
var flightno=$('#flightno').val();
/* if (flightno) { */
var index = layer.msg('查询中,请稍候...',{icon: 16,time:false,shade:0});
setTimeout(function(){
table.reload('flight', { //表格的id
url:'<%=basePath %>/flight/selectByFlightno',
page:{
curr:1 //从第一页开始
},
where: {
'flightno':$.trim(flightno)
}
});
layer.close(index);
},800);
/* } else {
layer.msg("请输入航班号");
} */
},
};
$("#flightno").bind("keyup", function (e) {
if (e.keyCode == 13) {
var type = "getInfo";
active[type] ? active[type].call(this) : '';
}
});
//监听行工具事件
table.on('tool(flight)', function(obj){
var data = obj.data;
console.log(obj)
if(obj.event === 'del'){
layer.confirm('您确定要删除吗', function(index){
$.ajax({
type : "post",
url : "<%=basePath %>/flight/del",
data : data,
success: function(data){
if(data.success){
layer.alert( data.msg, function () {
window.parent.location.reload(); //刷新父页面
parent.layer.close(index); //关闭当前弹窗
});
}
},
error: function() {
layer.alert("删除失败,请重试");
}
});
});
} else if(obj.event === 'edit'){
if (data) {
var id = data.id;
layer.open({
type: 2,
title: "航班跨天编辑", //不显示标题栏
closeBtn: 2,
shade: 0.8,
id: (new Date()).valueOf(), //设定一个id,防止重复弹出 时间戳1280977330748
moveType: 1, //拖拽模式,0或者1
type: 2,
skin: 'layui-layer-rim', //加上边框
/* area: [window.screen.width / 2 + 'px', window.screen.height / 2 + 'px'], //宽高 */
area: ['700px', '260px'],
maxmin: true, //开启最大化最小化按钮
content: "<%=basePath %>/flight/edit?id="+id,
success: function (layero, index) {
// 获取子页面的iframe
var iframe = window['layui-layer-iframe' + index];
// 向子页面的全局函数child传参
iframe.child(data);
}
})
} else {
alert("先选择行")
}
}
});
});
$("#add").click(function(){
layer.open({
type: 2,
title: "航班跨天添加", //不显示标题栏
closeBtn: 2,
shade: 0.8,
id: (new Date()).valueOf(), //设定一个id,防止重复弹出 时间戳1280977330748
moveType: 1, //拖拽模式,0或者1
type: 2,
skin: 'layui-layer-rim', //加上边框
/* area: [window.screen.width / 2 + 'px', window.screen.height / 2 + 'px'], //宽高 */
area: ['700px', '260px'],
maxmin: true, //开启最大化最小化按钮
content: "<%=basePath %>/flight/edit",
success: function (layero, index) {
// 获取子页面的iframe
var iframe = window['layui-layer-iframe' + index];
// 向子页面的全局函数child传参
iframe.child(data);
}
})
})
</script>
</body>
</html>