|
@@ -12,6 +12,7 @@
|
12
|
12
|
<link rel="icon" href="${basePath!}/static/logo.png">
|
13
|
13
|
<link rel="stylesheet" href="${basePath!}/static/layui/css/layui.css" media="all" />
|
14
|
14
|
<link rel="stylesheet" href="${basePath!}/static/css/public.css" media="all" />
|
|
15
|
+ <script src="${basePath!}/static/layui/layui.js" charset="utf-8"></script>
|
15
|
16
|
<script src="${basePath!}/static/layui/layui.all.js" charset="utf-8"></script>
|
16
|
17
|
<script src="${basePath!}/static/layui/lay/modules/jquery.js"></script>
|
17
|
18
|
</head>
|
|
@@ -25,7 +26,7 @@
|
25
|
26
|
<div class="layui-form-item" id="materialchoose">
|
26
|
27
|
<div class="layui-form-label">物料信息</div>
|
27
|
28
|
<div class="layui-input-inline" style="width: 100px;">
|
28
|
|
- <select name="Variety" id="Variety" class="province-selector" data-value="品类" lay-filter="Variety" onclick="dele()" lay-search="">
|
|
29
|
+ <select name="materialType" id="materialType" class="province-selector" data-value="品类" lay-filter="materialType" onclick="dele()" lay-search="">
|
29
|
30
|
<option value="">品类</option>
|
30
|
31
|
</select>
|
31
|
32
|
</div>
|
|
@@ -116,7 +117,7 @@
|
116
|
117
|
</center>
|
117
|
118
|
<div class="layui-form-item">
|
118
|
119
|
<div class="layui-input-block">
|
119
|
|
- <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="adddata(event)">立即提交</button>
|
|
120
|
+ <button class="layui-btn" lay-submit lay-filter="formDemo" onclick="adddata(); return false;">立即提交</button>
|
120
|
121
|
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
121
|
122
|
</div>
|
122
|
123
|
</div>
|
|
@@ -125,6 +126,10 @@
|
125
|
126
|
</fieldset>
|
126
|
127
|
|
127
|
128
|
<script>
|
|
129
|
+ layui.use('form', function(){
|
|
130
|
+ var form = layui.form;
|
|
131
|
+ form.render();
|
|
132
|
+ });
|
128
|
133
|
layui.use(['form', 'table', "laydate", 'layer','jquery'], function () {
|
129
|
134
|
var materialdetil=null;
|
130
|
135
|
var materialRealPrice=null;
|
|
@@ -133,30 +138,18 @@
|
133
|
138
|
var table = layui.table;
|
134
|
139
|
var $ = layui.$ //重点处
|
135
|
140
|
,layer = layui.layer;
|
136
|
|
-
|
137
|
|
- function handleError(error) {
|
138
|
|
- layer.alert('请求失败: ' + error);
|
139
|
|
- }
|
140
|
|
-
|
141
|
141
|
$.ajax({
|
142
|
142
|
url: 'type',
|
143
|
143
|
type: 'get',
|
144
|
144
|
success: function (data) {
|
145
|
|
- $("#Variety").empty();
|
146
|
|
- try {
|
147
|
|
- $.each($.parseJSON(data), function(idx, obj) {
|
148
|
|
- $("#materialType").append("<option value=\""+obj.brandCode+"\">"+obj.brandName+"</option>");
|
149
|
|
- });
|
150
|
|
- } catch (e) {
|
151
|
|
- handleError(e.message);
|
152
|
|
- }
|
|
145
|
+ $("#materialType").empty();
|
|
146
|
+ $.each($.parseJSON(data), function(idx, obj) {
|
|
147
|
+ $("#materialType").append("<option value=\""+obj.brandCode+"\">"+obj.brandName+"</option>");
|
|
148
|
+ });
|
153
|
149
|
layui.form.render("select");
|
154
|
|
- },
|
155
|
|
- error: function (xhr, status, error) {
|
156
|
|
- handleError(error);
|
157
|
|
- }
|
158
|
|
- });
|
159
|
|
-
|
|
150
|
+ },error:function (xhr, status, error) {
|
|
151
|
+ layer.alert('请求失败: ' + error);
|
|
152
|
+ }});
|
160
|
153
|
form.on('select(materialType)', function(data){
|
161
|
154
|
$.ajax({
|
162
|
155
|
url: 'brand',
|
|
@@ -165,21 +158,15 @@
|
165
|
158
|
success: function (data) {
|
166
|
159
|
$("#brand").empty();
|
167
|
160
|
$("#brand").append('<option value="">品牌</option>');
|
168
|
|
- try {
|
169
|
|
- $.each($.parseJSON(data), function(idx, obj) {
|
170
|
|
- $("#brand").append("<option value=\""+obj.brandCode+"\">"+obj.brandName+"</option>");
|
171
|
|
- });
|
172
|
|
- } catch (e) {
|
173
|
|
- handleError(e.message);
|
174
|
|
- }
|
|
161
|
+ $.each($.parseJSON(data), function(idx, obj) {
|
|
162
|
+ $("#brand").append("<option value=\""+obj.brandCode+"\">"+obj.brandName+"</option>");
|
|
163
|
+ });
|
|
164
|
+
|
175
|
165
|
layui.form.render("select");
|
176
|
|
- },
|
177
|
|
- error: function (xhr, status, error) {
|
178
|
|
- handleError(error);
|
179
|
|
- }
|
180
|
|
- });
|
|
166
|
+ },error:function (xhr, status, error) {
|
|
167
|
+ layer.alert('请求失败: ' + error);
|
|
168
|
+ }});
|
181
|
169
|
});
|
182
|
|
-
|
183
|
170
|
form.on('select(brand)', function(data){
|
184
|
171
|
$.ajax({
|
185
|
172
|
url: 'group',
|
|
@@ -188,21 +175,15 @@
|
188
|
175
|
success: function (data) {
|
189
|
176
|
$("#materialGroup").empty();
|
190
|
177
|
$("#materialGroup").append('<option value="">物料组</option>');
|
191
|
|
- try {
|
192
|
|
- $.each($.parseJSON(data), function(idx, obj) {
|
193
|
|
- $("#materialGroup").append("<option value=\""+obj.materialGroupCode+"\">"+obj.materialGroupName+"</option>");
|
194
|
|
- });
|
195
|
|
- } catch (e) {
|
196
|
|
- handleError(e.message);
|
197
|
|
- }
|
|
178
|
+ $.each($.parseJSON(data), function(idx, obj) {
|
|
179
|
+ $("#materialGroup").append("<option value=\""+obj.materialGroupCode+"\">"+obj.materialGroupName+"</option>");
|
|
180
|
+ });
|
|
181
|
+
|
198
|
182
|
layui.form.render("select");
|
199
|
|
- },
|
200
|
|
- error: function (xhr, status, error) {
|
201
|
|
- handleError(error);
|
202
|
|
- }
|
203
|
|
- });
|
|
183
|
+ },error:function (xhr, status, error) {
|
|
184
|
+ layer.alert('请求失败: ' + error);
|
|
185
|
+ }});
|
204
|
186
|
});
|
205
|
|
-
|
206
|
187
|
form.on('select(materialGroup)', function(data){
|
207
|
188
|
$.ajax({
|
208
|
189
|
url: 'price',
|
|
@@ -211,19 +192,13 @@
|
211
|
192
|
success: function (data) {
|
212
|
193
|
$("#materialdetil").empty();
|
213
|
194
|
$("#materialdetil").append('<option value="">物料描述</option>');
|
214
|
|
- try {
|
215
|
|
- $.each($.parseJSON(data), function(idx, obj) {
|
216
|
|
- $("#materialdetil").append("<option value=\""+obj.materialCode+"\">"+obj.materialName+"</option>");
|
217
|
|
- });
|
218
|
|
- } catch (e) {
|
219
|
|
- handleError(e.message);
|
220
|
|
- }
|
|
195
|
+ $.each($.parseJSON(data), function(idx, obj) {
|
|
196
|
+ $("#materialdetil").append("<option value=\""+obj.materialCode+"\">"+obj.materialName+"</option>");
|
|
197
|
+ });
|
221
|
198
|
layui.form.render("select");
|
222
|
|
- },
|
223
|
|
- error: function (xhr, status, error) {
|
224
|
|
- handleError(error);
|
225
|
|
- }
|
226
|
|
- });
|
|
199
|
+ },error:function (xhr, status, error) {
|
|
200
|
+ layer.alert('请求失败: ' + error);
|
|
201
|
+ }});
|
227
|
202
|
});
|
228
|
203
|
|
229
|
204
|
form.on('select(materialdetil)', function(data){
|
|
@@ -234,27 +209,18 @@
|
234
|
209
|
success: function (data) {
|
235
|
210
|
$("#materialCode").empty();
|
236
|
211
|
$("#materialRealPrice").empty();
|
237
|
|
- try {
|
238
|
|
- $.each($.parseJSON(data), function(idx, obj) {
|
239
|
|
- $("#materialCode").append("<option value=\""+obj.materialCode+"\">"+obj.materialCode+"</option>");
|
240
|
|
- $("#materialRealPrice").append("<option value=\""+obj.retailPrice+"\">"+obj.retailPrice+"</option>");
|
241
|
|
- });
|
242
|
|
- } catch (e) {
|
243
|
|
- handleError(e.message);
|
244
|
|
- }
|
|
212
|
+ $.each($.parseJSON(data), function(idx, obj) {
|
|
213
|
+ $("#materialCode").append("<option value=\""+obj.materialCode+"\">"+obj.materialCode+"</option>");
|
|
214
|
+ $("#materialRealPrice").append("<option value=\""+obj.retailPrice+"\">"+obj.retailPrice+"</option>");
|
|
215
|
+ });
|
245
|
216
|
layui.form.render("select");
|
246
|
|
- },
|
247
|
|
- error: function (xhr, status, error) {
|
248
|
|
- handleError(error);
|
249
|
|
- }
|
250
|
|
- });
|
|
217
|
+ },error:function (xhr, status, error) {
|
|
218
|
+ layer.alert('请求失败: ' + error);
|
|
219
|
+ }});
|
251
|
220
|
});
|
252
|
221
|
|
|
222
|
+ //因为动态添加的元素class属性是无效的,所以不能用$('.add').click(function(){});
|
253
|
223
|
window.addtable= function(){
|
254
|
|
- var selectedCode = $('#materialCode option:selected').text();
|
255
|
|
- var selectedDetail = $('#materialdetil option:selected').text();
|
256
|
|
- var selectedPrice = $('#materialRealPrice option:selected').text();
|
257
|
|
-
|
258
|
224
|
var html = '<tr>'+
|
259
|
225
|
'<td style = "width: 100px"><input type="button" class="layui-btn layui-btn-radius" onclick="dele(this)" value="删除" /></td>'+
|
260
|
226
|
'<td style="width:200px">'+
|
|
@@ -269,10 +235,10 @@
|
269
|
235
|
'<option value="C">采购</option>'+
|
270
|
236
|
'<option value="T">退货</option>'+
|
271
|
237
|
'</select></td>'+
|
272
|
|
- '<td style = "width: 200px"> <input type="text" name="username" required lay-verify="required" placeholder="用户名字" autocomplete="off" class="layui-input" readonly="true" value="${currentUser.userName!}"/></td>'+
|
273
|
|
- '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="'+ selectedCode +'"/></td>'+
|
274
|
|
- '<td style = "width: 800px"> <input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="'+ selectedDetail +'"/></td>'+
|
275
|
|
- '<td style = "width: 200px"> <input type="text" name="price" required lay-verify="required" placeholder="价格" autocomplete="off" class="layui-input" readonly="true" value="'+ selectedPrice +'"/></td>'+
|
|
238
|
+ '<td style = "width: 200px"> <input type="text" name="username" required lay-verify="required" placeholder="用户名字" autocomplete="off" class="layui-input" readonly="true" value="${currentUser.userName!}"+"/></td>'+
|
|
239
|
+ '<td style = "width: 200px"> <input type="text" name="materialCode" required lay-verify="required" placeholder="物料编码" autocomplete="off" class="layui-input" readonly="true" value="'+ $('#materialCode option:selected').text()+'"/></td>'+
|
|
240
|
+ '<td style = "width: 800px"> <input type="text" name="materialDetile" required lay-verify="required" placeholder="物料描述" autocomplete="off" class="layui-input" readonly="true" value="'+$('#materialdetil option:selected').text()+'"/></td>'+
|
|
241
|
+ '<td style = "width: 200px"> <input type="text" name="price" required lay-verify="required" placeholder="价格" autocomplete="off" class="layui-input" readonly="true" value="'+$('#materialRealPrice option:selected').text()+'"/></td>'+
|
276
|
242
|
'<td style = "width: 100px"> <input type="text" name="NUM" required lay-verify="required" placeholder="数量" autocomplete="off" class="layui-input" value ="1"/></td>'+
|
277
|
243
|
'<td style = "width: 300px"> <input type="text" name="SPH" placeholder="球镜" autocomplete="off" class="layui-input"></td>'+
|
278
|
244
|
'<td style = "width: 300px"> <input type="text" name="CYL" placeholder="柱镜" autocomplete="off" class="layui-input"></td>'+
|
|
@@ -302,18 +268,29 @@
|
302
|
268
|
'<td style = "width: 300px"> <input type="text" name="PS" placeholder="片色" autocomplete="off" class="layui-input"></td>'+
|
303
|
269
|
'<td style = "width: 300px"> <input type="text" name="MARK" placeholder="备注" autocomplete="off" class="layui-input"></td>'+
|
304
|
270
|
'</tr>';
|
|
271
|
+ //添加到表格最后
|
305
|
272
|
$(html).appendTo($('#table tbody:last'));
|
306
|
|
- form.render('select');
|
307
|
|
- };
|
308
|
|
-
|
|
273
|
+ form.render();
|
|
274
|
+ }
|
309
|
275
|
window.dele= function (obj){
|
|
276
|
+ debugger;
|
310
|
277
|
var otr = obj.parentNode.parentNode;
|
311
|
|
- var tab = otr.parentNode;
|
|
278
|
+// var tab = document.getElementById("tab");
|
|
279
|
+// tab.deleteRow(otr.rowIndex)
|
|
280
|
+ var tab = otr.parentNode; //自己的父节点 就是table
|
312
|
281
|
tab.removeChild(otr);
|
|
282
|
+ }
|
|
283
|
+ window.deltable= function() {
|
|
284
|
+ if ($('#table tbody tr').length === 1) {
|
|
285
|
+ layer.msg('只有一条不允许删除。', {
|
|
286
|
+ time : 2000
|
|
287
|
+ });
|
|
288
|
+ } else {
|
|
289
|
+ //删除当前按钮所在的tr
|
|
290
|
+ $(this).closest('tr').remove();
|
|
291
|
+ }
|
313
|
292
|
};
|
314
|
|
-
|
315
|
|
- window.adddata= function(event) {
|
316
|
|
- event.preventDefault();
|
|
293
|
+ window.adddata= function() {
|
317
|
294
|
table=document.getElementById("table");
|
318
|
295
|
let tr=table.getElementsByTagName("tr");
|
319
|
296
|
var arrayObj = new Array();
|
|
@@ -341,11 +318,15 @@
|
341
|
318
|
time : 5000
|
342
|
319
|
});
|
343
|
320
|
}, error: function (xhr, status, error) {
|
344
|
|
- handleError(error);
|
|
321
|
+ layer.alert('请求失败: ' + error);
|
345
|
322
|
}
|
346
|
323
|
});
|
347
|
|
- };
|
|
324
|
+ }
|
|
325
|
+ form.on('submit(login)', function (data) {
|
|
326
|
+ //alert(data.value);
|
|
327
|
+ });
|
348
|
328
|
});
|
|
329
|
+
|
349
|
330
|
</script>
|
350
|
331
|
|
351
|
332
|
</body>
|