PalletIn.js
17.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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
layui.config({
base: "/js/"
}).use(['form', 'element', 'vue', 'layer', 'laydate', 'jquery','hhweb', 'table', 'utils', 'Universal'], function () {
var form = layui.form,
layer = layui.layer,
element = layui.element,
laydate = layui.laydate,
$ = layui.jquery,
table = layui.table,
Universal = layui.Universal;
var AreaName = 'task';
var TableName = 'TaskDetail';
var vm = new Vue({
el: '#PalletForm'
});
var PalletIn = new Vue({
data: {}
});
var mainList = {
//NoData: function () {
// return "<div id='background' style='width:100%;height:100%;background-image:url(../../images/NoData.png);background-repeat:no-repeat;background-size:cover;'>.</div>"
//},
mainList: function (vm) {
console.log(vm);
table.reload('mainList', {
url: "/" + "task" + "/" + "Task" + "/StationToInventory"
, where: { stationCode: vm }
, method: "post"
, text: { none: "暂无数据,请扫码容器编号!" }
// , text: { none: this.NoData() }
});
}
};
var selector = {
'TaskType': {
SelType: "FromDict",
SelFrom: "taskType",
SelModel: "TaskType",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='TaskType']")]
},
'ContainerStatus': {
SelType: "FromDict",
SelFrom: "containerStatus",
SelModel: "ContainerStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='ContainerStatus']")]
},
'Type': {
SelType: "FromDict",
SelFrom: "containerType",
SelModel: "Type",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='Type']")]
}
};
var vml = new Array({
vm: vm,
});
Universal.BindSelector($, form, vml, selector);
//空栈板出库
$(document).on("click", "#btnEmpty", function () {
var str = $('[name = "IsShou"]:checked').val();
if (str == undefined) {
layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
} else if (str == "EntranceStationY01") {
var type = "p_1";
$.ajax({
async: false,
type: "post",
url: "/task/Task/EmptyPalletOut",
data: { station: "ExitStationY01", type: type },
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
} else if (str == "EntranceStationB01") {
var type = "p_1";
$.ajax({
async: false,
type: "post",
url: "/task/Task/EmptyPalletOut",
data: { station: "ExitStationB01", type: type },
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
} else if (str == "EntranceStationB02") {
var type = "p_1";
$.ajax({
async: false,
type: "post",
url: "/task/Task/EmptyPalletOut",
data: { station: "ExitStationB02", type: type },
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
}
else {
var type = "p_1";
$.ajax({
async: false,
type: "post",
url: "/task/Task/EmptyPalletOut",
data: { station: str, type: type },
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("呼叫空栈板成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
}
});
//空板回库
$(document).on("click", "#btnEmptyBack", function () {
var b = $('[name = "IsShou"]:checked').val();
if (b == undefined) {
layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
} else {
layer.open({
title: '空板回库',
area: ["350px","350px"],
type: 1,
content: $('#PalletEmptyIn'),
btn: ['提交', '关闭'],
yes: function (index) {
if ($('[name = "Type"]').val() != '') {
layer.close(index);
$.ajax({
async: false,
url: "/" + "task" + "/" + "Task" + "/BulidEmptyContainerBack",
type: "post",
data: { station: $('[name = "IsShou"]:checked').val(), containerCode: $('[name = "ContainerId"]')[0].value, type: $('[name = "Type"]').val() },
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg("空托回库成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
} else {
layer.alert("请选择托盘类型", { icon: 5, shadeClose: true, title: "错误信息" });
}
},
btn2: function (index) {
layer.close(index);
}
});
}
});
//仓库选择
$(document).on("click", "#btnstation", function () {
layer.open({
title: '仓库选择',
//area: ["800px", "400px"],
type: 1,
content: $('#Tunnel'),
btn: ['确认'],
yes: function (index) {
layer.close(index);
$('[name = "ContainerId"]').focus();
}
});
});
//选择仓库
$(document).on("click", ".d1", function () {
if ($("#Juan").is(":checked")) {
AddStation(0);
}
if ($("#Pian").is(":checked")) {
AddStation(1);
}
if ($("#Tong").is(":checked")) {
AddStation(2);
}
});
function AddStation(data) {
var Station
if (data == 0) {
Station = $("#StationJuan");
}
if (data == 1) {
Station = $("#StationPian");
}
if (data == 2) {
Station = $("#StationTong");
}
layer.open({
title: '站台选择',
type: 1,
content: Station,
btn: ['确认'],
yes: function (index) {
$('#btnstation').text($('[name = "IsShou"]:checked').parent().text());
var a = $('#btnstation').text()
console.log(a)
console.log(a.indexOf("暂存"));
if (a.indexOf("暂存") != -1) {
$('[name = "ContainerId"]').attr("disabled", "disabled");
$('[name = "ContainerId"]').css("background-color", "#eee");
$("#btnEmpty").hide();
$("#btnEmptyBack").hide();
}
else {
$('[name = "ContainerId"]').removeAttr("disabled");
$('[name = "ContainerId"]').removeClass("background-color");
$("#btnEmpty").show();
$("#btnEmptyBack").show();
}
layer.close(index);
}
});
}
//物料添加
$(document).on("click", "#btnInventory", function () {
AddInventory();
});
//托盘入库
$(document).on("click", "#btnPalletIn", function () {
var b = $('[name = "IsShou"]:checked').val();
var isBuffer = 0;
if (b == undefined) {
layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
} else {
console.log(b);
if (b == "ProductStationD01") {
layer.open({
title : '回库选择'
, content: '请选择回库地址'
, btn: ['立库', '暂存区']
, yes: function (index, layero) {
isBuffer = 0;
layer.close(index);
}
, btn2: function (index, layero) {
isBuffer = 1;
layer.close(index);
}, end: function () {
$.ajax({
async: false,
url: "/" + "task" + "/" + "Task" + "/HandTaskIn",
type: "post",
data: { containerCode: "", station: b, isBuffer: isBuffer },
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
$('[name = "Num"]').val("");
$('[name = "MaterialCode"]').val("");
$('[name = "SourceCode"]').val("");
$('[name = "Batch"]').val("");
$('[name = "ContainerId"]').val("");
$('[name = "ContainerId"]').focus();
//mainList.mainList("#");
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
});
} else {
$.ajax({
async: false,
url: "/" + "task" + "/" + "Task" + "/HandTaskIn",
type: "post",
data: { containerCode: "", station: b, isBuffer: isBuffer },
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
$('[name = "Num"]').val("");
$('[name = "MaterialCode"]').val("");
$('[name = "SourceCode"]').val("");
$('[name = "Batch"]').val("");
$('[name = "ContainerId"]').val("");
$('[name = "ContainerId"]').focus();
//mainList.mainList("#");
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
}
});
//打开页面聚焦“容器管理”
$(document).ready(function () {
$('[name = "ContainerId"]').focus();
});
//“容器编号”回车监听
$('[name = "ContainerId"]').bind("keydown", function (e) {
if (e.which == 13) {
AddInventory();
e.preventDefault(); //Skip default behavior of the enter key
}
});
//根据站台请求物料信息
function AddInventory() {
var b = $('[name = "IsShou"]:checked').val();
if (b == undefined) {
layer.alert("请选择站台", { icon: 5, shadeClose: true, title: "错误信息" });
} else {
var str = $('[name = "ContainerId"]').val();
var strs = str.split('%');
if (strs.length > 3) {
$('[name = "Num"]').val(strs[3]);
$('[name = "MaterialCode"]').val(strs[0]);
$('[name = "SourceCode"]').val(strs[1]);
$('[name = "Batch"]').val(strs[2]);
}
$.ajax({
async: false,
url: "/" + "task" + "/" + "Task" + "/AddInventory",
type: "post",
data: { containerCode: '', material: $('[name = "MaterialCode"]').val(), batch: $('[name = "Batch"]').val(), station: b, num: $('[name = "Num"]').val(), sourceCode: $('[name = "SourceCode"]').val() },
dataType: "json",
success: function (result) {
if (result.code == 200) {
if (strs.length < 3) {
$('[name = "Num"]').val("");
$('[name = "MaterialCode"]').val("");
$('[name = "SourceCode"]').val("");
$('[name = "Batch"]').val("");
$('[name = "ContainerId"]').val("");
} else {
$('[name = "ContainerId"]').val("");
}
layer.msg("入库成功", { icon: 6, shade: 0.4, time: 1000 });
}
else {
$('[name = "ContainerId"]').val("");
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
//mainList.mainList(b);
}
}
//根据站台请求物料信息
function FindInventory(station) {
table.reload('listForm', {
url: "/" + "task" + "/" + "Task" + "/StationToInventory"
, where: station
, method: "post"
, text: { none: "暂无数据,请扫码容器编号!" }
// , text: { none: this.NoData() }
});
//$.ajax({
// async: false,
// url: "/" + "task" + "/" + "Task" + "/StationToInventory",
// type: "post",
// data: { stationCode: station },
// dataType: "json",
// success: function (result) {
// console.log(result)
// if (result.code == 200) {
// PalletIn.$set('$data', result.data);
// mainList.mainList(PalletIn);
// }
// else if (result.code == 0) {
// }
// else {
// layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
// }
// },
// error: function (XMLHttpRequest, textStatus, errorThrown) {
// layer.alert(errorThrown, { icon: 2, title: '提示' });
// }
//});
}
});