PalletInOut.js
17.2 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
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 taskDel = new Vue({
data: {}
});
var vmq = new Vue({
data: {
ContainerCode: 'ContainerCode',
TaskNo: 'TaskNo'
}
});
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) {
table.reload('mainList', {
url: "/" + AreaName + "/" + TableName + "/FindTaskDel"
, where: vm.$data
, method: "post"
, text: { none: "暂无数据,请扫码容器编号!" }
// , text: { none: this.NoData() }
});
}
};
var selector = {
'TaskType': {
SelType: "FromDict",
SelFrom: "taskType",
SelModel: "TaskType",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='TaskType']")]
},
'Code': {
SelType: "FromUrl",
SelFrom: "/general/Station/Load",
SelModel: "Code",
SelLabel: "Name",
SelValue: "Code",
Dom: [$("[name='Code']")]
},
'Type': {
SelType: "FromDict",
SelFrom: "containerType",
SelModel: "Type",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='Type']")]
}
};
var vml = new Array({
vm: vm,
vmq: vmq
});
Universal.BindSelector($, form, vml, selector);
mainList.mainList(vmq);
//出库查看完成
$(document).on("click", "#btnFinishCheck", function () {
var type = $('[name = "OperationType"]')[0].value;
if (type == "出库") {
$.ajax({
async: false,
url: "/task/Task/FinishCheck",
type: "post",
data: { taskDel: taskDel.$data },
dataType: "json",
success: function (result) {
if (result.code == 200) {
FindFirstTask();
layer.msg("查看完成!", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
} else {
layer.alert("失败:" + type + "类型无效", { icon: 5, shadeClose: true, title: "错误信息" });
}
FindFirstTask();
});
//收(取)料完成
$(document).on("click", "#btnFinish", function () {
var oderQty = eval(vm.OderQty) - eval(vm.HadQty);
var num = eval($('[name = "Num"]')[0].value);
if (num == 0) {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
return null;
}
taskDel.$data.HadQty = num;
console.log(taskDel.$data);
var type = $('[name = "OperationType"]')[0].value;
if (oderQty >= num || type == "盘点") {
if (type == "入库") {
$.ajax({
async: false,
url: "/receipt/ReceiptHeader/FinishMaterial",
type: "post",
data: { taskDel: taskDel.$data},
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 (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
} else if (type == "出库") {
$.ajax({
async: false,
url: "/task/Task/FinishPick",
type: "post",
data: { taskDel: taskDel.$data },
dataType: "json",
success: function (result) {
if (result.code == 200) {
FindFirstTask();
layer.msg("拣货成功!", { icon: 6, shade: 0.4, time: 1000 });
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
} else if (type == "盘点") {
$.ajax({
async: false,
url: "/inventory/CyclecountDetail/FinshCyclecount",
type: "post",
data: { del: taskDel.$data },
dataType: "json",
success: function (result) {
if (result.code == 200) {
FindFirstTask();
layer.alert("盘点成功!数量:" + num, { icon: 6, shade: 0.4});
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}else {
layer.alert("失败:" + type + "类型无效", { icon: 5, shadeClose: true, title: "错误信息" });
}
FindFirstTask();
} else {
layer.alert("失败:完成数量不能大于库存数量", { icon: 5, shadeClose: true, title: "错误信息" });
}
});
//托盘回库
$(document).on("click", "#btnBack", function () {
if ($('[name = "ContainerId"]')[0].value != "") {
$.ajax({
async: false,
url: "/" + "task" + "/" + "Task" + "/BulidContainerBack",
type: "post",
data: { containerCode: $('[name = "ContainerId"]')[0].value, IsFull: $('[name = "IsFull"]:checked')[0].value },
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg("回库成功", { icon: 6, shade: 0.4, time: 1000 });
$('[name = "ContainerId"]').val("");
$('[name = "ContainerId"]').focus();
$('#radioSome').prop("checked", "checked");
form.render();
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
FindFirstTask();
} else {
layer.alert("请填写托盘号", { icon: 5, shadeClose: true, title: "错误信息" });
}
});
//空托盘回库
$(document).on("click", "#btnEmptyBack", function () {
if ($('[name = "ContainerId"]')[0].value != "" && $('[name = "Code"]')[0].value != "") {
layer.open({
title: '空板回库',
area: ["400px", "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 = "Code"]')[0].value, 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 });
$('[name = "ContainerId"]').val("");
$('[name = "ContainerId"]').focus();
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
} else {
layer.alert("请选择托盘类型", { icon: 5, shadeClose: true, title: "错误信息" });
}
mainList.mainList();
},
btn2: function (index) {
layer.close(index);
mainList.mainList();
}
});
vmq.$set('ContainerCode', 'ContainerCode');
vmq.$set('TaskNo', 'TaskNo');
mainList.mainList(vmq);
vm.$set('$data','');
taskDel.$set('$data', '');
$('[name = "Num"]').val("");
$('[name = "OperationType"]').val("");
} else {
layer.alert("请填写托盘号和站台!", { icon: 5, shadeClose: true, title: "错误信息" });
}
});
//打开页面聚焦“容器管理”
$(document).ready(function () {
$('[name = "ContainerId"]').focus();
});
//单击行监听
table.on('row(mainList)', function (obj) {
//行变为点击状态
$(obj.tr[0]).siblings().removeClass('layui-table-click');
$(obj.tr[0]).addClass('layui-table-click');
//赋值
vm.$set('$data', obj.data);
taskDel.$set('$data', obj.data);
FindTaskType(obj.data);
//改变焦点
$('[name = "Num"]').focus();
});
//“容器编号”回车监听
$('[name = "ContainerId"]').bind("keydown", function (e) {
if (e.which == 13) {
e.preventDefault(); //Skip default behavior of the enter key
if ($(this).val() != "") {
FindFirstTask();
//改变焦点
$('[name = "Num"]').focus();
}
else {
$(this).focus();
}
}
});
//“数量”回车监听
$('[name = "Num"]').bind("keydown", function (e) {
if (e.which == 13 && $('[name = "Num"]')[0].value != "") {
e.preventDefault(); //Skip default behavior of the enter key
if ($('[name = "TaskType"]').val() == "出库查看") {
$('#btnFinishCheck').click();
} else {
$('#btnFinish').click();
}
//改变焦点
$('[name = "Num"]').focus();
}
});
//出入库翻译
function FindTaskType(data) {
$.ajax({
async: false,
type: "post",
data: { DictType:'taskType'},
url: '/base/SysDictData/FindSysDictData',
dataType: "json",
success: function (result) {
for (var i = 0; i < result.data.length;i++) {
if (result.data[i].DictValue == data.TaskType) {
vm.$set('TaskType', result.data[i].DictLabel);
$('[name = "TaskType"]').val(result.data[i].DictLabel);
//填写业务类型
if (result.data[i].DictLabel.split("入库").length > 1) {
$('[name = "OperationType"]').css('color', 'forestgreen');
$('[name = "TaskType"]').css('color', 'forestgreen');
$('[name = "OperationType"]').val("入库");
} else if (result.data[i].DictLabel.split("出库").length > 1) {
$('[name = "OperationType"]').css('color', 'blue');
$('[name = "TaskType"]').css('color', 'blue');
$('[name = "OperationType"]').val("出库");
} else {
$('[name = "OperationType"]').val(result.data[i].DictLabel);
}
if ($('[name = "TaskType"]').val() == "出库查看") {
$('[name = "Num"]').val(eval(data.OderQty));
} else {
if (result.data[i].DictLabel.split("入库").length > 1) {
//导入数量
$('[name = "Num"]').val(eval(data.OderQty) - eval(data.HadQty));
} else if (result.data[i].DictLabel.split("出库").length > 1) {
//导入数量
$('[name = "Num"]').val(eval(data.ContainerQty) - eval(data.HadQty));
} else {
$('[name = "Num"]').val(data.ContainerQty);
}
}
break;
}
}
if ($('[name = "TaskType"]').val() == "出库查看") {
$('.btn2').hide();
$('#btn1').show();
$('[name = "Num"]').attr({ readonly: "readonly" });
$('#btnFinishCheck').focus();
} else if ($('[name = "TaskType"]').val() == "盘点") {
$('#btn1').hide();
$('.btn2').show();
$('#btnFinish').text("盘点完成");
}
else {
$('#btnFinish').text("取(收)料完成");
$('#btn1').hide();
$('.btn2').show();
}
// if ($('[name = "TaskType"]').val() == "整盘出库" || $('[name = "TaskType"]').val() == "分拣出库") {
// $('#btn1').hide();
// $('#btn2').show();
//}
}
});
}
//查询容器的第一个任务
function FindFirstTask() {
$.ajax({
async:false,
url: "/" + "task" + "/" + "Task" + "/FindSourceCode",
type: "post",
data: { Code: $('[name = "ContainerId"]')[0].value },
dataType: "json",
success: function (result) {
if (result.code == 200) {
vmq.$set('ContainerCode', result.data.ContainerCode);
vmq.$set('TaskNo', result.data.TaskNo);
mainList.mainList(vmq);
vm.$set('$data', result.data);
taskDel.$set('$data', result.data);
FindTaskType(result.data);
}
else if (result.code == 0) {
vmq.$set('ContainerCode', 'ContainerCode');
vmq.$set('TaskNo', 'TaskNo');
mainList.mainList(vmq);
vm.$set('$data', result.data);
taskDel.$set('$data', result.data);
$('[name = "Num"]').val("");
$('[name = "OperationType"]').val("");
}
else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
});