edit.jsp
11.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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ 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.consignee_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?version=${version}"></script>
<link rel="stylesheet" href="<%=basePath%>resource/layui/css/layui.css?version=${version}" media="all">
<script type="text/javascript" src="<%=basePath%>resource/layui/layui.js?version=${version}"></script>
<script type="text/javascript" src="<%=basePath%>resource/js/tools.js?version=${version}"></script>
<script src="<%=basePath%>resource/easyui/jquery.easyui.min.js?version=${version}"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>resource/easyui/uimaker/icon.css?version=${version}">
<link rel="stylesheet" href="<%=basePath%>resource/easyui/uimaker/easyui.css?version=${version}">
<style type="text/css">
.required_span {
color: red;
margin-left: 10px;
font-size: 20px;
}
</style>
</head>
<body>
<div style="padding: 15px;">
<h3>编辑收货人</h3>
<form class="layui-form">
<input type="hidden" id="id" name="id" value="${consignee.id}">
<table class="layui-table">
<tbody>
<tr>
<td><spring:message code="manifest.company" /><span class="required_span">*</span></td>
<td colspan="5">
<input type="text" name="name" id="name" maxlength="70" lay-verify="required"
value="${consignee.name}" autocomplete="off" class="layui-input" required
oninput="onInputChange(event,'name','oninput')" lay-verify="required"
onpropertychange="onInputChange(event,'name','onpropertychange')">
</td>
</tr>
<tr>
<td><spring:message code="manifest.shr.name" /><span class="required_span">*</span></td>
<td>
<input type="text" name="code" id="code" value="${consignee.code}"
maxlength="70" autocomplete="off" class="layui-input" required lay-verify="required"
oninput="onInputChange(event,'code','oninput')"
onpropertychange="onInputChange(event,'code','onpropertychange')">
</td>
<td><spring:message code="manifest.telephone" /></td>
<td>
<input type="text" name="tel" id="tel" value="${consignee.tel}"
autocomplete="off" class="layui-input" maxlength="50"
oninput="onInputChange(event,'tel','oninput')"
onpropertychange="onInputChange(event,'tel','onpropertychange')">
</td>
<td><spring:message code="manifest.fax" /></td>
<td>
<input type="text" name="fax" id="fax" value="${consignee.fax}"
oninput="onInputChange(event,'fax','oninput')"
onpropertychange="onInputChange(event,'fax','onpropertychange')"
autocomplete="off" class="layui-input" maxlength="50">
</td>
</tr>
<tr>
<td><spring:message code="manifest.country" /><span class="required_span">*</span></td>
<td>
<input required lay-verify="required" class="layui-input"
id="country" name="country" maxlength="2" type="text"
<c:if test="${empty consignee.country}">value=""</c:if>
<c:if test="${not empty consignee.country}">value="${consignee.country}"</c:if>
oninput="onInputChange(event,'country','oninput')"
onpropertychange="onInputChange(event,'country','onpropertychange')">
</td>
<td><spring:message code="manifest.city" /><span class="required_span">*</span></td>
<td>
<input required type="text" name="city" id="city" value="${consignee.city}"
autocomplete="off" class="layui-input" required lay-verify="required" maxlength="70"
oninput="onInputChange(event,'city','oninput')"
onpropertychange="onInputChange(event,'city','onpropertychange')">
</td>
<td><spring:message code="manifest.zip.code" /></td>
<td>
<input type="text" name="zipcode" id="zipcode" value="${consignee.zipcode}"
oninput="onInputChange(event,'zipcode','oninput')"
onpropertychange="onInputChange(event,'zipcode','onpropertychange')"
autocomplete="off" class="layui-input" maxlength="9">
</td>
</tr>
<tr>
<td><spring:message code="manifest.address" /><span class="required_span">*</span></td>
<td colspan="2">
<input required type="text" name="address" id="address" value="${consignee.address}"
autocomplete="off" class="layui-input" maxlength="70" lay-verify="required"
oninput="onInputChange(event,'address','oninput')"
onpropertychange="onInputChange(event,'address','onpropertychange')">
</td>
<td><spring:message code="manifest.shr.cneaeo" /></td>
<td colspan="2">
<input type="text" name="aeo" id="cneaeo"
value="${consignee.aeo}" autocomplete="off" class="layui-input" maxlength="20"
oninput="onInputChange(event,'cneaeo','oninput')"
onpropertychange="onInputChange(event,'cneaeo','onpropertychange')">
</td>
</tr>
<%-- <tr>
<td><spring:message code="manifest.enterprise.code" /><span class="required_span">*</span></td>
<td>
<input required id="cnecusid" type="text" name="cusid" value="${consignee.cusid}"
autocomplete="off" class="layui-input" maxlength="128" lay-verify="required"
oninput="onInputChange(event,'cnecusid','oninput')"
onpropertychange="onInputChange(event,'cnecusid','onpropertychange')">
</td>
</tr> --%>
<tr>
<td colspan="6">
<div class="layui-row">
<div class="layui-col-md2">
<select id="cne_cusid" required lay-verify="required">
<c:if test="${not empty consignee.cusid}">
<c:set var="tempCneType" value='${fn:split(consignee.cusid,"+")[0]}' />
<option value="${tempCneType}">${tempCneType}</option>
</c:if>
<c:if test="${empty consignee.cusid}">
<option value=""><spring:message code="manifest.enterprise.code.type" /></option>
</c:if>
</select>
</div>
<div class="layui-col-md1" style="text-align: center; margin-top: 10px;width:20px;">
<span style="color: black; font-size: 16px;">+</span>
</div>
<div class="layui-col-md5">
<input id="cnecusid" type="text" maxlength="100" class="layui-input" required lay-verify="required"
<c:if test="${not empty consignee.cusid}">
<c:set var="tempCneValue" value='${fn:split(consignee.cusid,"+")[1]}' />
value="${tempCneValue}"
</c:if>
placeholder="<spring:message code='manifest.enterprise.code' />"
oninput="onInputChange(event,'cnecusid','oninput')"
onpropertychange="onInputChange(event,'cnecusid','onpropertychange')">
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div class="layui-form-item">
<div class="layui-input-block">
<button class="layui-btn" lay-submit lay-filter="formDemo"><spring:message code="opt.save"/></span></button>
<button type="button" class="layui-btn layui-btn-primary"
onclick="self.location=document.referrer;">返回</button>
</div>
</div>
</form>
</div>
<script>
var api = "<%=basePath %>enterprise/search";
$('#country').combogrid({
panelWidth:260,
url: api,
idField:'country_code',
textField:'start',
mode:'remote',
fitColumns:true,
onBeforeLoad: function (parm) { //在请求加载数据之前触发,返回 false 则取消加载动作
var value = $('#country').combobox('getValue');
if (value) {
var upper = value.toUpperCase();
$('#country').combogrid('setValue',upper);
parm.start = upper;
onGetData('cne_cusid','country');
return true;
}
return false;
},
onSelect: function(row,rowData){
//当用户选择一个列表项时触发。
$('#country').combogrid('setValue',rowData.country_code);
onGetData('cne_cusid','country');
},
columns:[[
{field:'name_cn',title:'名称',width:106},
{field:'country_code',title:'代码',width:106}
]]
});
function onGetData(selectId,inputId) {
var cneType = "";
var cne_cusid = "${consignee.cusid}";
if(notEmpty(cne_cusid)){
cneType = cne_cusid.split("+")[0];
}
var select = $("#"+selectId);
select.html("");
select.append("<option value=''><spring:message code='manifest.enterprise.code.type' /></option>");
var countryCode = $('#'+inputId).combobox('getValue');
$.ajax({
url:"<%=basePath%>/enterprise/list?countryCode="+countryCode,
success:function(data){
if(data.status == 200){
if(data.data){
for(var i = 0; i < data.data.length; i++){
var type = data.data[i].enterprise_type;
if(notEmpty(cneType)&&type&&(type==cneType)){
select.append("<option selected value='"+type+"'>"+type+"</option>");
}else{
select.append("<option value='"+type+"'>"+type+"</option>");
}
layui.use('form', function() {
var form = layui.form;
form.render("select");
});
}
}
}
}
});
}
var layer;
layui.use('layer', function() {
layer = layui.layer;
});
$(window).load(function() {
});
layui.use('form', function() {
var form = layui.form;
form.on('submit(formDemo)', function(data){
save(data.field);
return false;
});
});
function save(data){
var url = "<%=basePath%>/consignee/save";
var params = "code=" + data.code;
params += "&name=" + data.name;
if (data.id) {
params += "&id=" + data.id;
}
if (data.cusid) {
params += "&cusid=" + data.cusid;
}
var cusid_type = getSelectedValue("cne_cusid");
var cusid = $("#cnecusid").val();
if(notEmpty(cusid_type)&¬Empty(cusid)){
cusid = cusid_type+"+"+cusid;
params+="&cusid="+encodeURIComponent(cusid);
}
if (data.aeo) {
params += "&aeo=" + data.aeo;
}
if (data.address) {
params += "&address=" + data.address;
}
if (data.zipcode) {
params += "&zipcode=" + data.zipcode;
}
if (data.city) {
params += "&city=" + data.city;
}
if (data.deltaname) {
params += "&deltaname=" + data.deltaname;
}
if (data.country) {
params += "&country=" + data.country;
}
if (data.provincecode) {
params += "&provincecode=" + data.provincecode;
}
if (data.tel) {
params += "&tel=" + data.tel;
}
if (data.fax) {
params += "&fax=" + data.fax;
}
$.post(url, params, function(response, status) {
if (response.status == 200) {
setInterval("afterSuccess()","1000");
}
layer.msg(response.msg);
});
}
function afterSuccess(){
self.location = document.referrer;
}
</script>
</body>
</html>