ReceiptContainerHeader.js
15.1 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
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 = 'receipt';
var TableName = 'ReceiptDetail';
var vm = new Vue({
});
var vmq = new Vue({
});
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 + "/FindReceiptDetail"
, where: svm.$data
, method: "post"
//, text: { none: this.NoData() }
});
}
};
//回车监听
function keylisten() {
$('#keyword').bind("keydown", function (e) {
if (e.which == 13) {
$('#searchDetail').click();
RefreshStatus();
}
});
}
//头工具栏事件
table.on('toolbar(mainList)', function (obj) {
switch (obj.event) {
case 'searchDetail': //跳转至单据页面,新增数据
var str = $('#keyword').val();
if (str != "") {
vm.$set('ReceiptCode', str);
mainList.mainList(vm);
$('#keyword').val(str)
RefreshStatus();
}
else {
layer.alert("必须填写入库单号!", { icon: 5, shadeClose: true, title: "错误信息" });
$('#keyword').focus();
}
keylisten();
break;
}
});
keylisten();
var selector = {
'InventoryStatus': {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelModel: "InventoryStatus",
},
'Status': {
SelType: "FromDict",
SelFrom: "receiptHeaderStatus",
SelModel: "Status",
},
'WarehouseType': {
SelType: "FromDict",
SelFrom: "warehouseType",
SelModel: "WarehouseType",
},
'IStatus': {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelModel: "IStatus",
},
'LStatus': {
SelType: "FromDict",
SelFrom: "locationStatus",
SelModel: "LStatus",
},
'ContainerStatus': {
SelType: "FromDict",
SelFrom: "containerStatus",
SelModel: "ContainerStatus",
},
'Type': {
SelType: "FromDict",
SelFrom: "warehouseType",
SelModel: "Type",
},
};
//相同物料仓位
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: ''}
});
All.push({ AreaNameDtl: AreaNameDtlInventory, TableNameDtl: TableNameDtlInventory, vmqDtl: vmqDtlInventory, vmDtl: vmDtlInventory, NameDtl: NameDtlInventory });
//空栈板
var AreaNameDtlLocation = 'general';
var TableNameDtlLocation = 'Location';
//{子表字段:主表字段}
var NameDtlLocation = {};
var vmDtlLocation = new Vue({
el: '#modifyFormDtl_' + TableNameDtlLocation
});
var vmqDtlLocation = new Vue({
data: { Status: 'emptycontainer', Type: $('#Type').val()}
});
All.push({ AreaNameDtl: AreaNameDtlLocation, TableNameDtl: TableNameDtlLocation, vmqDtl: vmqDtlLocation, vmDtl: vmDtlLocation, NameDtl: NameDtlLocation });
var vml = new Array({
vmDtlLocation: vmDtlLocation,
vmDtlInventory: vmDtlInventory
});
Universal.BindSelector($, form, vml, selector);
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;
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 = {
mainListDtl: function (mainDtl) {
var url = "Load";
if (mainDtl.AreaNameDtl == "inventory") {
url = "FindInventory";
}
table.reload('mainListDtl' + mainDtl.TableNameDtl, {
url: "/" + mainDtl.AreaNameDtl + "/" + mainDtl.TableNameDtl + "/" + url
, where: mainDtl.vmqDtl.$data
, method: "post"
});
}
};
var mainListDtlClear = {
Clear: function () {
table.reload('mainListDtlLocation', {
url: "/general/Location/Load"
, where: { Status: "####" }
, method: "post"
});
table.reload('mainListDtlInventory', {
url: "/inventory/Inventory/FindInventory"
, where: { MaterialCode: "####" }
, method: "post"
});
}
};
//监听折叠
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 'btnReceipt_Inventory': //收货
layer.open({
type: 1
, title:"收货"
, content: $('#Receipt')
, btnAlign: 'c'
, area: ['300px', '150px']
, btn: ['收货', '取消']
, success: function (index) {
$('#Num').val(Value.Qty - Value.QtyDivided);
}
, yes: function (index, layero) {
if ($('#Num').val() > (Value.Qty - Value.QtyDivided)) {
layer.alert("失败:分配数量必须小于等于系统数量", { icon: 5, shadeClose: true, title: "错误信息" });
} else {
$.ajax({
async: true,
type: "post",
data: { receiptdetail: Value, inv: obj.data, num: $('#Num').val() },
url: "/receipt/ReceiptHeader/HandDivide_Inventory",
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg(result.msg, { icon: 6, shade: 0.4, time: 1000 });
mainList.mainList(vm);
RefreshStatus();
mainListDtlClear.Clear();
//for (i = 0; i < All.length; i++) {
// mainListDtl.mainListDtl(All[i]);
//}
} else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
layer.close(index);
}
, cancel: function (index) {
layer.close(index);
}
});
break;
case 'btnReceipt_Location': //收货
layer.open({
type: 1
, title: "收货"
, content: $('#Receipt')
, btnAlign: 'c'
, btn: ['收货', '取消']
, success: function (index) {
$('#Num').val(Value.Qty - Value.QtyDivided);
}
, yes: function (index, layero) {
if ($('#Num').val() > (Value.Qty - Value.QtyDivided)) {
layer.alert("失败:分配数量必须小于等于系统数量", { icon: 5, shadeClose: true, title: "错误信息" });
} else {
$.ajax({
async: true,
type: "post",
data: { receiptdetail: Value, loc: obj.data, num: $('#Num').val() },
url: "/receipt/ReceiptHeader/HandDivide_Location",
dataType: "json",
success: function (result) {
if (result.code == 200) {
layer.msg(result.msg, { icon: 6, shade: 0.4, time: 1000 });
mainList.mainList(vm);
RefreshStatus();
mainListDtlClear.Clear();
//for (i = 0; i < All.length; i++) {
// mainListDtl.mainListDtl(All[i]);
//}
} else {
layer.alert("失败:" + result.msg, { icon: 5, shadeClose: true, title: "错误信息" });
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
layer.close(index);
}
, cancel: function (index) {
layer.close(index);
}
});
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').val() != '') {
$('#searchDetail').click();
}
function RefreshStatus() {
$.ajax({
async: true,
type: "post",
data: { Code: $('#keyword').val() },
url: "/receipt/ReceiptContainerHeader/GetReceiptStatus",
dataType: "json",
success: function (result) {
if (result.count > 0) {
$("#TotalLines").html(result.data.TotalLines);
$("#TotalQty").html(result.data.TotalQty);
$("#TotalQtyDivided").html(result.data.TotalQtyDivided);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
layer.alert(errorThrown, { icon: 2, title: '提示' });
}
});
}
});