search.jsp
4.8 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
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ 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 PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><spring:message code="menu.consignor_info_set" /></title>
<script type="text/javascript" src="<%=basePath%>resource/easyui/jquery.min.js"></script>
<script type="text/javascript" src="<%=basePath%>resource/validate/jquery.validate.js"></script>
<script type="text/javascript" src="<%=basePath%>resource/validate/validate-extends.js"></script>
<!-- validate 验证中英文 -->
<script type="text/javascript"
src="<%=basePath %>resource/validate/jquery.validate-${pageContext.response.locale}.js"></script>
<link rel="stylesheet" href="<%=basePath%>resource/layui/css/layui.css" media="all">
<script type="text/javascript" src="<%=basePath%>resource/layui/layui.js"></script>
<script type="text/javascript" src="<%=basePath%>resource/js/tools.js"></script>
</head>
<body>
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">
<spring:message code="consignor.list" />
</h2>
<div class="layui-colla-content layui-show">
<div class="layui-row">
<div class="layui-col-md12">
<button class="layui-btn" onclick="edit()">新增</button>
<button class="layui-btn layui-btn-danger" onclick="onDelete()">删除</button>
</div>
</div>
<table id="consignor-table" class="layui-hide" lay-filter="consignor-table"></table>
</div>
</div>
</div>
<script type="text/html" id="opt-bar">
<i class="layui-icon layui-icon-edit" style="font-size: 14px; color: #1E9FFF;" lay-event="edit">编辑</i>
</script>
<script>
var layer;
layui.use('layer', function() {
layer = layui.layer;
});
layui.use('element', function() {
var element = layui.element;
});
$(window).load(function() {
doSearch();
});
var table;
function doSearch() {
var api = "<%=basePath%>consignor/search";
layui.use('table', function() {
table = layui.table;
table.on('checkbox(consignor-table)', function(obj) {
/* console.log(JSON.stringify(obj)) */
});
table.render({
elem : '#consignor-table',
url : api,
limit : 10,
page : true,
loading : true,
limits : [ 10, 15, 20, 25, 30, 35, 40, 45, 50 ],
text : '暂无数据',
cols : [ [ //表头
{
type : 'checkbox',
fixed : 'left',
width : 60
}, {
field : '',
title : '操作',
toolbar : '#opt-bar',
width : 80
}, {
field : 'co_company',
title : '发货人公司',
}, {
field : 'co_city',
title : '发货人城市',
sort : true
}, {
field : 'co_country',
title : '国家代码',
sort : true,
width : 80
}, {
field : 'co_telephone',
title : '电话'
} ] ]
});
});
}
function onDelete() {
var checkStatus = table.checkStatus('consignor-table');
var data = checkStatus.data;
if(data&&data.length){
var ids="";
for (var i = 0; i < data.length; i++) {
var item = data[i];
var id = item.id;
ids+=id;
ids+=","
}
parent.layer.confirm('确定删除吗?', function(index) {
layer.close(index);
doDelete(ids);
});
}
}
function doDelete(ids) {
var api = "<%=basePath%>consignor/delete";
$.post(api, "ids="+ids, function(response, status) {
if(response.status==200){
layer.msg('删除成功');
window.location.reload();
}else{
layer.msg("操作失败");
console.log("response-->"+JSON.stringify(response));
}
});
}
layui.use('table', function() {
var table = layui.table;
table.on('tool(consignor-table)', function(obj) { //注:tool是工具条事件名,test是table原始容器的属性 lay-filter="对应的值"
var data = obj.data; //获得当前行数据
var layEvent = obj.event; //获得 lay-event 对应的值(也可以是表头的 event 参数对应的值)
var tr = obj.tr; //获得当前行 tr 的DOM对象
if (layEvent === 'edit') { //编辑
window.location.href = "<%=basePath%>/consignor/edit?id="+data.id;
}
});
});
function edit(){
window.location.href = "<%=basePath%>/consignor/edit";
}
</script>
</body>
</html>