Inventory.js
26.6 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
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
layui.config({
base: "/js/"
}).use(['form', 'element', 'vue', 'layer', 'laydate', 'jquery', 'table', 'hhweb', 'utils', 'Universal'], function () {
var form = layui.form,
layer = layui.layer,
element = layui.element,
laydate = layui.laydate,
$ = layui.jquery,
table = layui.table,
hhweb = layui.hhweb,
Universal = layui.Universal;
var AreaName = 'inventory';
var TableName = 'Inventory';
var vm = new Vue({
el: '#modifyForm'
});
var vmq = new Vue({
el: '#panelSearch',
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 () {
table.reload('mainList', {
url: "/" + AreaName + "/" + TableName + "/Load"
, method: "post"
, text: { none: this.NoData() }
});
}
};
//编辑
var EditInfo = function (tabledata) {
data = tabledata;
vm.$set('$data', data);
//表单修改时填充需修改的数据
var list = {};
$('.ClearSelector_' + TableName).each(function () {
var selDom = ($(this));
if ($(selDom)[0].name.search("q") == -1) {
list[$(selDom)[0].name] = data[$(selDom)[0].name] + "";
}
});
//表单修改时填充需修改的数据
form.val('modifyForm', list);
};
var selfbtn = {
//自定义按钮
//直接出库
GoodsOut: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4});
return;
}
$("#selectLoad").empty();
var list;
var IsOne = true;
$.ajax({
async: true,
type: "post",
url: "/receipt/ReceiptHeader/LoadStation",
data: { list: data1},
dataType: "json",
success: function (result) {
if (result.code == 200) {
list = result.data;
var html ;
var IsExistence = 0;
for (var i = 0; i < list.length; i++) {
var a = list[i].Code;
if (a == "ExitStationD01(P1000)" || a == "OutStationB05(P3310)" || a == "InStationB06(P3316)" || a == "OutStationB07(P3300)" || a == "ProductStationB03") {
continue;
}
else {
html += "<option class='select_Station' value='" + list[i].Code + "'>" + list[i].Name + "</option>";
}
}
$("#selectLoad").append(html);
layer.open({
type: 1,
// skin: 'layui-layer-molv',
btnAlign: 'c',
moveType: 1, //拖拽模式,0或者1
title: "选择站台并出库", //不显示标题
area: ['600px', '400px'], //宽高
content: $('#tanchuang'), //捕获的元素
scrollbar: true,
btn: ['出库', '关闭'],
yes: function (index, layero) {
if (IsOne) {
IsOne = false;
$.ajax({
url: "/" + AreaName + "/" + TableName + "/" + "GoodsOut",
type: "POST",
data: { Table_entitys: data1, Station: $("#selectLoad").val() },
dataType: "json",
success: function (result) {
layer.close(index);
if (result.Code == 200) {
layer.msg("出库任务创建成功!", { icon: 6, shade: 0.4, time: 1000 });
mainList.mainList();
} else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
},
cancel: function (index) {
layer.close(index);
}
});
} else {
layer.alert("请选择相同仓库类型的库存出库", { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
},
//盘点出库
InventoryOut: function () {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4, time: 1000 });
return;
}
$("#selectLoad").empty();
var list;
$.ajax({
async: true,
type: "post",
url: "/receipt/ReceiptHeader/LoadStation",
data: { list: data1 },
dataType: "json",
success: function (result) {
if (result.code == 200) {
list = result.data;
var html ;
for (var i = 0; i < list.length; i++) {
var a = list[i].Code;
if (a == "ExitStationY01" || a == "EntranceStationB01" || a == "EntranceStationB02" || a == "EntranceStationD01" ) {
html += "<option class='select_Station' value='" + list[i].Code + "'>" + list[i].Name + "</option>";
}
else {
continue;
}
}
$("#selectLoad").append(html);
layer.open({
type: 1,
btnAlign: 'c',
moveType: 1, //拖拽模式,0或者1
title: "选择站台并出库", //不显示标题
area: ['600px', '400px'], //宽高
content: $('#tanchuang'), //捕获的元素
scrollbar: true,
btn: ['出库', '关闭'],
yes: function (index, layero) {
$.ajax({
url: "/" + AreaName + "/" + TableName + "/" + "CYCOutNoBack",
type: "POST",
data: { entitys: data1, Station: $("#selectLoad").val() },
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("盘点任务创建成功!", { icon: 6, shade: 0.4, time: 1000 });
layer.close(index);
mainList.mainList();
} else {
layer.alert(result.Message, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
//}
},
cancel: function (index) {
layer.close(index);
}
});
} else {
layer.alert("请选择相同库位的库存出库", { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
},
//关闭盘点
InventoryClose: function () {
//layer.alert("确定关闭盘点模式?", { shadeClose: true, title: "提示信息" }, function (index) {
layer.open({
type: 1,
btnAlign: 'c',
moveType: 1, //拖拽模式,0或者1
title: "选择结束盘点仓库", //不显示标题
area: ['600px', '400px'], //宽高
content: $('#region'), //捕获的元素
scrollbar: true,
btn: ['关闭', '关闭'],
yes: function (index, layero) {
$.ajax({
async: true,
type: "post",
url: "/inventory/Inventory/CloseCYC",
data: { region: $('[name = "region"]').val()},
dataType: "json",
success: function (result) {
if (result.Code == 200) {
layer.msg("盘点任务关闭成功!", { icon: 6, shade: 0.4, time: 1000 });
mainList.mainList();
layer.close(index);
ContainerIdFocus();
}
else {
layer.alert("错误:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
},
cancel: function (index) {
layer.close(index);
}
});
//});
},
//删除库存
DelInv: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4 });
return;
}
$("[name = 'DelName']").val("");
layer.open({
title: '请输入删除人姓名或姓名首字母',
area: ["300px", "350px"],
type: 1,
content: $('#DeleteName'),
btn: ['确认'],
yes: function (index) {
var name = $("[name = 'DelName']").val();
if (name == "") {
layer.alert("请输入删除人姓名或姓名首字母!", { icon: 2, title: '提示' });
} else {
layer.close(index);
layer.alert("确定删除当前所选的库存数据吗?", { icon: 3, shadeClose: true, title: "信息确认" }, function (index) {
$.ajax({
async: false,
type: "post",
url: "/" + AreaName + "/" + TableName + "/" + "DelInv",
data: { Invs: data1, Name: name },
dataType: "json",
success: function (result) {
console.log(result)
if (result.Code == 200) {
layer.msg("库存删除成功", { icon: 6, shade: 0.4, time: 1000 });
layer.close(index);
mainList.mainList();
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { InEnd(); layer.close(index); });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
});
}
}
});
},
//修改备注
UpRemark: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4 });
return;
}
$("[name = 'RemarkVal']").val("");
layer.open({
title: '修改备注',
area: ["300px", "250px"],
type: 1,
content: $('#UpRemark'),
btn: ['确认'],
yes: function (index) {
var name = $("[name = 'RemarkVal']").val();
if (name == "") {
layer.alert("请输入备注!", { icon: 2, title: '提示' });
} else {
layer.close(index);
layer.alert("确定修改当前所选的库存数据吗?", { icon: 3, shadeClose: true, title: "信息确认" }, function (index) {
$.ajax({
async: false,
type: "post",
url: "/" + AreaName + "/" + TableName + "/" + "UpRemark",
data: { Invs: data1, Name: name },
dataType: "json",
success: function (result) {
console.log(result)
if (result.Code == 200) {
layer.msg("备注修改成功", { icon: 6, shade: 0.4, time: 1000 });
layer.close(index);
mainList.mainList();
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { InEnd(); layer.close(index); });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
});
}
}
});
},
//修改仓库
UpSpecialWarehouseVal: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4 });
return;
}
$("[name = 'UpSpecialWarehouseVal']").val("");
layer.open({
title: '修改仓库',
area: ["300px", "250px"],
type: 1,
content: $('#UpSpecialWarehouse'),
btn: ['确认'],
yes: function (index) {
var warehouse = $("[name = 'UpSpecialWarehouseVal']").val();
if (warehouse == "") {
layer.alert("请输入仓库!", { icon: 2, title: '提示' });
} else {
layer.close(index);
layer.alert("确定修改当前所选的库存数据吗?", { icon: 3, shadeClose: true, title: "信息确认" }, function (index) {
$.ajax({
async: false,
type: "post",
url: "/" + AreaName + "/" + TableName + "/" + "UpSpecialWarehouse",
data: { Invs: data1, Warehouse: warehouse },
dataType: "json",
success: function (result) {
console.log(result)
if (result.Code == 200) {
layer.msg("仓库修改成功", { icon: 6, shade: 0.4, time: 1000 });
layer.close(index);
mainList.mainList();
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { InEnd(); layer.close(index); });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
});
}
}
});
},
//修改数量
UpQty: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data1 = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4 });
return;
}
$("[name = 'UpQtyVal']").val("");
layer.open({
title: '修改数量',
area: ["300px", "250px"],
type: 1,
content: $('#UpQty'),
btn: ['确认'],
yes: function (index) {
var Qty = $("[name = 'UpQtyVal']").val();
if (Qty == "") {
layer.alert("请输入数量!", { icon: 2, title: '提示' });
} else {
layer.close(index);
layer.alert("确定修改当前所选库存的库存数量吗?", { icon: 3, shadeClose: true, title: "信息确认" }, function (index) {
$.ajax({
async: false,
type: "post",
url: "/" + AreaName + "/" + TableName + "/" + "UpQty",
data: { Invs: data1, Qty: Qty },
dataType: "json",
success: function (result) {
console.log(result)
if (result.Code == 200) {
layer.msg("数量修改成功", { icon: 6, shade: 0.4, time: 1000 });
layer.close(index);
mainList.mainList();
}
else {
layer.alert("失败:" + result.Message, { icon: 5, shadeClose: true, title: "错误信息" }, function (index) { InEnd(); layer.close(index); });
}
},
error: function (errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
});
}
}
});
},
//修改良品不良品
UpGoods: function (index) {
var checkStatus = table.checkStatus('mainList');
var count = checkStatus.data.length;//选中的行数
var data = checkStatus.data;
if (count < 1) {
layer.alert("请至少选择一条数据", { icon: 5, shade: 0.4 });
return;
}
else {
console.log(data);
layer.confirm('确定更改所选物料的库存状态?',
{ icon: 3 },
function (index) {
//取消所选任务
$.ajax({
url: "/" + AreaName + "/" + TableName + "/" + "UpGoods",
type: "post",
data: { Invs: data },
dataType: "json",
// async: false,
success: function (result) {
if (result.Code === 200) {
mainList.mainList(vm);
layer.msg("物料状态更改成功", { icon: 1, shade: 0.4, time: 2000 });
} else {
layer.msg('物料状态更改失败:' + result.Message, { icon: 7, shade: 0.4, time: 3000 });
}
},
error: function (error) {
layer.alert(error.responseText, { icon: 2, title: '提示' });
}
})
},
function () {
layer.close();
});
}
},
DomConfig: function (AddOrUpdate) {
if (AddOrUpdate) {
hhweb.DomEnable($("#modifyForm [name='MaterialCode']"));
hhweb.DomEnable($("#modifyForm [name='Status']"));
hhweb.DomEnable($("#modifyForm [name='Qty']"));
}
else {
hhweb.DomDisable($("#modifyForm [name='WirePart']"));
hhweb.DomDisable($("#modifyForm [name='Status']"));
hhweb.DomDisable($("#modifyForm [name='Qty']"));
}
},
SaveBefore: function (AddOrEditOrDelete) {
if (AddOrEditOrDelete in { Add: null, Edit: null }) {
var rtn = hhweb.CheckRequired("#modifyForm", AddOrEditOrDelete);
return rtn;
}
}
};
var selector = {
'Status': {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelModel: "Status",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='Status']"), $("[name='qStatus']")]
},
'ContainerStatus': {
SelType: "FromDict",
SelFrom: "containerStatus",
SelModel: "ContainerStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='ContainerStatus']"), $("[name='qContainerStatus']")]
},
'TaskStatus': {
SelType: "FromDict",
SelFrom: "IsCyclecountStatus",
SelModel: "TaskStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='TaskStatus']"), $("[name='qTaskStatus']")]
},
'LocationCode': {
SelType: "FromUrl",
SelFrom: "/general/Station/Load",
SelModel: "LocationCode",
SelLabel: "Name",
SelValue: "Code",
Dom: [$("[name='LocationCode']"), $("[name='qLocationCode']")]
},
'IsPack': {
SelType: "FromDict",
SelFrom: "IsPack",
SelModel: "IsPack",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='IsPack']"), $("[name='qIsPack']")]
},
'IsFold': {
SelType: "FromDict",
SelFrom: "IsFold",
SelModel: "IsFold",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='IsFold']"), $("[name='qIsFold']")]
},
'TaskStatus': {
SelType: "FromDict",
SelFrom: "IsCyclecountStatus",
SelModel: "TaskStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='TaskStatus']"), $("[name='qTaskStatus']")]
},
'WarehouseType': {
SelType: "FromDict",
SelFrom: "WarehouseType",
SelModel: "WarehouseType",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='WarehouseType']"), $("[name='qWarehouseType']")]
},
'TaskSteps': {
SelType: "FromDict",
SelFrom: "TaskSteps",
SelModel: "TaskSteps",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='TaskSteps']"), $("[name='qTaskSteps']")]
},
};
var vml = new Array({
vm: vm,
vmq: vmq,
});
Universal.BindSelector($, form, vml, selector);
Universal.mmain(AreaName, TableName, table, layer, element, laydate, $, vm, vmq, EditInfo, selfbtn, mainList, form);
});