ShipmentContainerHeader.js
16.3 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
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,
Universal = layui.Universal;
var AreaName = 'shipment';
var TableName = 'ShipmentDetail';
var vm = new Vue({
data: { ShipmentCode: 'ShipmentCode' }
});
var vmq = new Vue({
});
//Universal.BindSelector($, form, vm, vmq);
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 (svm) {
table.reload('mainList', {
url: "/" + AreaName + "/" + TableName + "/LoadForDivide"
, where: svm.$data
, method: "post"
, text: { none: this.NoData() }
});
}
};
//头工具栏事件
table.on('toolbar(mainList)', function (obj) {
switch (obj.event) {
case 'searchDetail': //跳转至单据页面,新增数据
var str = $('#keyword').val();
if (str != "") {
vm.$set('ShipmentCode', str);
mainList.mainList(vm);
$('#keyword').val(str)
RefreshStatus();
}
else {
layer.alert("必须填写出库单号!", { icon: 5, shadeClose: true, title: "错误信息" });
$('#keyword').focus();
}
keylisten();
break;
}
});
//回车监听
$('#keyword').on('keypress', function (event) {
if (event.keyCode == 13) {
var str = $('#keyword').val();
vm.$set('ShipmentCode', str);
mainList.mainList(vm);
$('#keyword').val(str)
}
});
function keylisten() {
$('#keyword').bind("keydown", function (e) {
if (e.which == 13) {
$('#searchDetail').click();
RefreshStatus();
}
});
}
keylisten();
var selector = {
'InventoryStatus': {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelModel: "InventoryStatus"
},
'Status': {
SelType: "FromDict",
SelFrom: "shipmentContainerHeaderStatus",
SelModel: "Status"
},
'WarehouseType': {
SelType: "FromDict",
SelFrom: "warehouseType",
SelModel: "WarehouseType"
},
'IStatus': {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelModel: "IStatus"
},
'ContainerStatus': {
SelType: "FromDict",
SelFrom: "containerStatus",
SelModel: "ContainerStatus"
}
};
//相同物料仓位
var All = new Array();
var AreaNameDtlInventory = 'inventory';
var TableNameDtlInventory = 'Inventory';
//{子表字段:主表字段}
var NameDtlInventory = { MaterialCode: 'MaterialCode' };
var vmDtlInventory = new Vue({
el: '#modifyFormDtl_' + TableNameDtlInventory
});
var vmqDtlInventory = new Vue({
data: { MaterialCode: ''}
});
var vml = new Array({
vmDtlInventory: vmDtlInventory
});
Universal.BindSelector($, form, vml, selector);
All.push({ AreaNameDtl: AreaNameDtlInventory, TableNameDtl: TableNameDtlInventory, vmqDtl: vmqDtlInventory, vmDtl: vmDtlInventory, NameDtl: NameDtlInventory });
var selfbtn = {};
var DtlShowbool = {};//所有折叠的当前状态
var Dtl = {};//当前点击All数据
var Value = {};//主表数据缓存数据
//所有折叠状态初始化
for (i = 0; i < All.length; i++) {
DtlShowbool[All[i].TableNameDtl] = false;
}
//监听单元格点击
table.on('tool(mainList)', function (obj) {
var Dtlbtn = {};
var mainListDtl;
if (obj.data.QtyDivided == '' || obj.data.QtyDivided == null) {
obj.data.QtyDivided = 0;
}
$("input[name='DDqty']").val(obj.data.Qty);
$("input[name='DqtyDivided']").val(obj.data.QtyDivided);
$("input[name='DqtyDivide']").val(obj.data.Qty - obj.data.QtyDivided);
var id = obj.data.Id;
var dqty = obj.data.Qty;
var ydqty = obj.data.QtyDivided;
var sdqty = obj.data.Qty - obj.data.QtyDivided;
var shipdetail = obj.data;
for (i = 0; i < All.length; i++) {
if (obj.event === All[i].TableNameDtl) {
Dtl = All[i];
}
}
if (Dtl != {}) {
//主表数据赋值
Value = obj.data;
for (i = 0; i < Object.keys(Dtl.NameDtl).length; i++) {
//重载赋值(防止主子表字段名不一样)
Dtl.vmqDtl.$data[Object.keys(Dtl.NameDtl)[i]] = obj.data[Dtl.NameDtl[Object.keys(Dtl.NameDtl)[i]]];
}
//重载方法
mainListDtl = {
NoData: function () {
return "<div id='backgroundDtl'" + Dtl.TableNameDtl + " style='width:100%;height:100%;background-image:url(../../images/NoData.png);background-repeat:no-repeat;background-size:cover;'>.</div>"
},
mainListDtl: function (mainDtl) {
table.reload('mainListDtl' + mainDtl.TableNameDtl, {
url: "/" + mainDtl.AreaNameDtl + "/" + mainDtl.TableNameDtl + "/Load"
, where: mainDtl.vmqDtl.$data
, method: "post"
, text: { none: this.NoData() }
});
}
};
//监听折叠
element.on('collapse(DisplayDtl)', function (data) {
//记录当前折叠状态
DtlShowbool[data.title[0].id.split('_')[1]] = data.show;
//单元格事件
table.on('tool(mainListDtl' + data.title[0].id.split('_')[1] + ')', function (obj) {
for (i = 0; i < All.length; i++) {
if (obj.event.split('_')[1] === All[i].TableNameDtl) {
Dtlbtn = All[i];
}
}
if (Dtlbtn != {}) {
switch (obj.event) {
case 'btnShipment_' + Dtlbtn.TableNameDtl: //分配
//layer.alert(JSON.stringify(obj.data) + ' Id:' + Value.Id, {
// title: '当前行数据:'
//});
$("input[name='DqtyDivide']").focus();
//读取托盘在库存中数量(除去已经被其它单据分的后的托盘库存数量)
$.ajax({
url: "/shipment/ShipmentContainerHeader/GetContainerQty",
type: "post",
data: { invt: obj.data },
dataType: "json",
success: function (result) {
if (result.code == 200) {
if (result.data.yqty > 0) {
$("input[name='DIqty']").val(result.data.yqty);
if ($("input[name='DqtyDivide']").val() > result.data.yqty) {
$("input[name='DqtyDivide']").val(result.data.yqty);
}
layer.open({
type: 1,
// skin: 'layui-layer-lan',
btnAlign: 'c',
title: "出库分配确认",
area: ['670px', '260px'],
content: $('#divideForm'),
btn: ['确定', '取消'],
yes: function (index) {
if ($("input[name='DqtyDivide']").val() <= sdqty && $("input[name='DqtyDivide']").val() <= result.data.yqty ) {
//分配数据写入任务表
$.ajax({
url: "/shipment/ShipmentContainerHeader/DivideContainer",
type: "post",
data: { shipmentdt: shipdetail, invt: obj.data, dvqty: $("input[name='DqtyDivide']").val() },
dataType: "json",
success: function (result) {
if (result.code == 200) {
// $('.layui-collapse').hide();
mainList.mainList(vm);
var url = "/" + AreaName + "/" + TableName + "/Load";
var urlData = { 'Id': id };
$.post(url, urlData, function (result) {
$("input[name='DqtyDivided']").val(result.data[0].QtyDivided);
$("input[name='DqtyDivide']").val(dqty - result.data[0].QtyDivided);
shipdetail = result.data[0];
if (result.data[0].QtyDivided == dqty) {
table.reload('mainListDtlInventory', {
url: '/inventory/Inventory/Load'
, where: { 'MaterialCode': 'no' }
, method: "post"
, text: { none: "此物料已全部分配完成,请分配其它项此的物料!" }
});
};
}, "json");
RefreshStatus();
layer.msg(result.msg, { icon: 7, shade: 0.4, time: 1000 });
layer.close(index);
} else {
layer.msg('分配失败:' + result.msg, { icon: 7, shade: 0.4, time: 2000 });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
$("input[name='DqtyDivide']").focus();
}
})
} else {
layer.msg('超出可分配数量,请重新分配!', { icon: 7, shade: 0.4, time: 2000 });
}
//table.reload('mainList', {
// url: '/shipment/ShipmentContainerHeader/Load'
// , where: { shipNo: $("input[name='SourceCode']").val() }
// , text: { none: "未查找到匹配的数据,请确认输入数据是否有误!" }
//});
},
cancel: function (index) {
layer.close(index);
}
});
} else {
layer.msg('此托盘的此物料已被全部分配完成,没有可被再分配的数量!', { icon: 7, shade: 0.4, time: 2000 });
}
} else {
layer.msg('请求返回失败:' + result.msg, { icon: 7, shade: 0.4, time: 2000 });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
})
break;
}
}
});
});
//显示折叠
$('#DisplayDtl' + Dtl.TableNameDtl).show();
for (i = 0; i < Object.keys(DtlShowbool).length; i++) {
if (DtlShowbool[Object.keys(DtlShowbool)[i]] == true && Object.keys(DtlShowbool)[i] != DtlShowbool[Dtl.TableNameDtl]) {
//关闭其他折叠
$('#title_' + Object.keys(DtlShowbool)[i]).click();
DtlShowbool[Object.keys(DtlShowbool)[i]] = false;
}
}
if (DtlShowbool[Dtl.TableNameDtl] == false) {
//打开当前数据对应折叠
$('#title_' + Dtl.TableNameDtl).click();
}
for (i = 0; i < All.length; i++) {
for (x = 0; x < Object.keys(All[i].NameDtl).length; x++) {
//重载赋值(防止主子表字段名不一样)
All[i].vmqDtl.$data[Object.keys(All[i].NameDtl)[x]] = Value[All[i].NameDtl[Object.keys(All[i].NameDtl)[x]]];
}
mainListDtl.mainListDtl(All[i]);
}
}
});
if ($('#keyword') != '') {
$('#searchDetail').click();
}
function RefreshStatus() {
$.ajax({
async: true,
type: "post",
data: { Code: $('#keyword').val() },
url: "/shipment/ShipmentContainerHeader/GetShipmentStatus",
dataType: "json",
success: function (result) {
if (result.count > 0) {
$("#TotalLines").html(result.data.TotalLines);
$("#TotalQty").html(result.data.TotalQty);
$("#TotalQtyCompleted").html(result.data.TotalQtyCompleted);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
});