bomUpdate.jsp
9.4 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
<%--
Created by IntelliJ IDEA.
User: kangmor
Date: 2015/10/15
Time: 13:45
--%>
<%@ include file="/common/taglibs.jsp" %>
<%@ page language="java" pageEncoding="UTF-8" %>
<!-- BEGIN PAGE HEADER-->
<h3 class="page-title">
<fmt:message key="menu.component.bom"/>
<small><fmt:message key="bom.update.subtitle"/></small>
</h3>
<!--Begin of update-->
<div class="row">
<div class="col-md-12">
<!-- BEGIN PORTLET-->
<div class="portlet box green-jungle">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-pencil"></i><fmt:message key="bom.update.subtitle"/>
</div>
<div class="actions">
<a href="bomSearch.html" class="btn btn-default btn-sm">
<i class="fa fa-reply"></i> <fmt:message key="button.return"/> </a>
</div>
</div>
<div class="portlet-body form">
<!-- BEGIN FORM-->
<form:form commandName="bomUpdateForm" class="form-horizontal form-bordered" id="bomUpdateForm"
action="bomUpdate.html">
<form:hidden path="bom.id"/>
<form:hidden path="operation"/>
<form:hidden path="opId"/>
<form:hidden path="amount"/>
<input type="hidden" name="id" value="${bomUpdateForm.bom.id}"/>
<div class="form-body">
<%@include file="/common/success.jsp"%>
<%@include file="/common/error.jsp"%>
<div class="form-group">
<label class="control-label col-md-2"><fmt:message key="bom.name"/> </label>
<div class="col-md-2">
<div style="text-align:left" class="input-group">
<form:input type="text" id="name" path="bom.name" class="form-control"/>
<form:errors path="bom.name" cssStyle="color: red"/>
</div>
</div>
</div>
</div>
<div class="form-actions">
<div class="row">
<div class="col-md-offset-3 col-md-9">
<button class="btn green" onclick="saveBom()"><i class="fa fa-save"></i><fmt:message key="button.save"/></button>
<c:if test="${not empty bomUpdateForm.bom.id}">
<button class="btn red" onclick="deleteBom()"><i class="fa fa-trash-o"></i><fmt:message key="button.delete"/></button>
</c:if>
<button class="btn default" type="button" onclick="window.location.assign('')"><i class="fa fa-history"></i><fmt:message key="button.cancel"/></button>
</div>
</div>
</div>
</form:form>
<!-- END FORM-->
</div>
</div>
<!-- END PORTLET-->
</div>
</div>
<c:if test="${not empty bomUpdateForm.bom.id}">
<div class="row">
<div class="col-md-12">
<!-- BEGIN EXAMPLE TABLE PORTLET-->
<div class="portlet box blue">
<div class="portlet-title">
<div class="caption">
<i class="fa fa-list-alt"></i><fmt:message key="component.list"/>
</div>
</div>
<div class="portlet-body">
<div class="row">
<div class="col-md-9 col-sm-12">
<div class="form-group">
<label class="control-label col-md-3"><fmt:message key="bom.update.components.add.name"/> </label>
<div class="col-md-2">
<input id="tags" class="form-control">
</div>
<label class="control-label col-md-2"><fmt:message key="bom.update.components.add.amount"/> </label>
<div class="col-md-2">
<input id="componentAmount" class="form-control">
</div>
<button onclick="addComponent()" class="btn green"><i class="fa fa-plus"></i><fmt:message key="button.add"/> </button>
</div>
</div>
</div>
<div class="table-scrollable">
<table id="bomUpdateForm.componentList"
class="table table-striped table-hover table-bordered dataTable no-footer" role="grid"
aria-describedby="sample_editable_1_info">
<thead>
<tr role="row">
<th tabindex="0" rowspan="1" colspan="1"><fmt:message key="bom.update.components.add.name"/></th>
<th tabindex="0" rowspan="1" colspan="1"><fmt:message key="component.partNumber"/></th>
<th tabindex="0" rowspan="1" colspan="1"><fmt:message key="component.amount"/></th>
<th tabindex="0" rowspan="1" colspan="1"><fmt:message key="table.edit"/></th>
</tr>
</thead>
<tbody>
<c:if test="${not empty bomUpdateForm.componentList}">
<c:forEach var="component" items="${bomUpdateForm.componentList}" varStatus="vStatus">
<tr>
<td>
<c:out value="${component.name}"/>
</td>
<td>
<c:out value="${component.partNumber}"/>
</td>
<td>
<c:out value="${component.amount}"/>
</td>
<td>
<button class="btn red" onclick="removeComponent(${component.id})"><i class="fa fa-trash-o"></i><fmt:message key="button.delete"/></button>
</td>
</tr>
</c:forEach>
</c:if>
</tbody>
</table>
</div>
</div>
</div>
<!-- END EXAMPLE TABLE PORTLET-->
</div>
</div>
<!--End of update-->
</c:if>
<c:set var="scripts" scope="request">
<script language="JavaScript" type="text/javascript">
$(function () {
$("#tags").autocomplete({
source: function (request, response) {
$.ajax({
url: "${ctx}/component/fetchComponent",
dataType: "json",
data: {
comp: request.term
},
success: function (data) {
response($.map(data, function (item) {
//alert($("#opId").val());
return {
label: item.name,
id: item.id
};
}));
}
});
},
minLength: 1,
select: function( event, ui ) {
// log( ui.item ?
// "Selected: " + ui.item.label :
// "Nothing selected, input was " + this.value);
$("#opId").val(ui.item.id);
}
// open: function() {
// $( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
// },
// close: function() {
// $( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
// }
});
});
function addComponent() {
var hasError = false;
$("#operation").val("add");
var a = $("#componentAmount").val();
if ($("#opId").val().length <= 0) {
hasError = true;
alert("必须选择料件");
}else if (a <= 0) {
hasError = true;
alert("料件数量必须大于0");
}
if (!hasError) {
$("#amount").val(a);
$("#bomUpdateForm").submit();
}
}
function saveBom() {
$("#operation").val("save");
$("#bomUpdateForm").submit();
}
function removeComponent(componentId) {
$("#opId").val(componentId);
$("#operation").val("remove");
$("#bomUpdateForm").submit();
}
function deleteBom() {
$("#operation").val("delete");
$("#bomUpdateForm").submit();
}
</script>
</c:set>