Inventory.js
15.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
let action = null,
aopTable = null,
app = null;
layui.config({
base: "/js/",
version: 128
}).use(['system', "jqprint"], function () {
var form = layui.form,
$ = layui.jquery,
table = layui.table,
layer = layui.layer,
system = layui.system,
u = new system.u(),
sendData = null,
tableEdit = layui.tableEdit,
isFirstQuery = false,
areaName = 'warehous',
tableName = 'Inventory';
action = {
addOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${tableName}/Ins`,
submit: "submit(fromAdd)"
}
return options;
},
editOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${tableName}/Upd`,
submit: "submit(fromUpdate)"
}
return options;
},
deleteOptions: function () {
var options = {
url: `/${areaName}/${tableName}/DelByIds`,
keyId: "id"
}
return options;
},
exportOptions: function () {
var options = {
fromId: "listForm",
url: `/${areaName}/${tableName}/Export`,
isDefault: false,
excelCols: {
head: app.data.cols
}
}
return options;
},
queryOptions: function () {
var options = {
resetFrom: "form[lay-filter=listForm]",
fromId: "listForm",
urlExport: `/${areaName}/${tableName}/Export`,
urlQuery: `/${areaName}/${tableName}/Load`,
mainTable: app.data.tableIns
}
return options;
},
uploadOptions: function () {
var options = {
url: `/${areaName}/${tableName}/Import`,
fromFile: "#excelfile",
content: $("#ImportData")
}
return options;
},
addBefore: function (callBack) {
if (callBack != null) callBack();
setTimeout(() => {
$("#materialCode").val("");
});
},
addSaveBefore: function (data, callBack) {
if (callBack != null) callBack();
},
editBefore: function (data, callBack) {
form.val("modifyForm", data);
if (callBack != null) callBack();
},
editAfter: function (callBack) {
if (callBack != null) callBack();
},
editSaveBefore: function (data, callBack) {
if (callBack != null) callBack();
},
queryBefore: (sysU, toolbarId) => {
if (!isFirstQuery) u.initSelect(app.data.selectOption);
setTimeout(() => { isFirstQuery = true; });
},
qcCodePrintOptions: () => {
var options = {
qrCodeValueKey: "pipeSN",
//【qrcodeElem】 是要修改的内容其他的不要变 id 的变量值不需要变
customFn: (sysU, parameter, selectData) => {
for (var i = 0; i < selectData.length; i++) {
debugger
var qcCodeValue = selectData[i][parameter.qrCodeValueKey],
qrcodeId = "qrcode" + i,
qrcodeHeadId = "qrcodeHead" + i,
qrcodeElem = `<div id="${qrcodeHeadId}" class="qcCode" >
<div id="${qrcodeId}" ></div>
<div class="qcCode_div">
<label>管材SN:</label><label>${qcCodeValue}</label>
</div>
<div class="qcCode_div">
<label>物料名称:</label><label class="qcCode_div_lable">${selectData[i].materialName}</label>
</div>
<div class="qcCode_div">
<label>管径:</label><label class="qcCode_div_lable">${selectData[i].diameter}</label>
</div>
<div class="qcCode_div">
<label>壁厚:</label><label class="qcCode_div_lable">${selectData[i].thickness}</label>
</div>
<div class="qcCode_div">
<label>管材长度:</label><label>${selectData[i].pipeLength}</label>
</div>
</div>`;
parameter.qcCodeBody.append(qrcodeElem);
var qrcodeObj = new QRCode(document.getElementById(qrcodeId), {
width: 100,
height: 100
});
qrcodeObj.makeCode(qcCodeValue);
}
return true;
}
}
return options;
},
//库存盘点 保存
btnInventoryCheck: function (sysU, toolbarId, obj) {
var allData = sysU.getTableAllData(toolbarId),
allCos = obj.config.cols[0],
validCosName = [],
setData = [];
for (var j = 0; j < allCos.length; j++) {
if (typeof allCos[j].verifyConfig == "undefined") continue;
validCosName.push({
field: allCos[j]["field"],
verifyConfig: allCos[j].verifyConfig
});
}
for (var i = 0; i < allData.length; i++) {
if (typeof allData[i].LAY_CHECKED == "undefined") continue;
var tempVal = {};
for (var k = 0; k < validCosName.length; k++) {
debugger
let field = validCosName[k].field;
var vaCos = allData[i][field];
if (validCosName[k].verifyConfig.empty == "req" && validCosName[k].verifyConfig.type == "number") {
let isVal = "".isNumber(vaCos);
if (!isVal) {
layer.alert(validCosName[k].verifyConfig.msg + allData[i].id, { icon: sysU.config.iconoError, shade: 0.4 });
return;
}
}
else if (validCosName[k].verifyConfig.empty == "req" && validCosName[k].verifyConfig.type == "string") {
let isVal;
if (field == "locationCode") {
if (vaCos != null && typeof vaCos.value != "undefined") vaCos = vaCos.value;
}
isVal = "".isEmpty(vaCos);
if (isVal) {
layer.alert(validCosName[k].verifyConfig.msg + allData[i].id, { icon: sysU.config.iconoError, shade: 0.4 });
return;
}
}
tempVal[field] = vaCos;
}
setData.push(tempVal);
}
if (setData.length == 0) {
layer.alert("请编辑修改后在盘点保存!", { icon: sysU.config.iconoError, shadeClose: true });
return;
}
var ajaxConfig = {
data: {
model: setData
},
url: `/${areaName}/${tableName}/InventoryCheck`,
success: function (result) {
if (sysU.successBefore(result)) return;
layer.msg(result.Message, { icon: sysU.config.iconoOk, shade: 0.4, time: sysU.config.errorTime });
action.actionSuccess("mainList", app.data.tableIns.config.page.curr);
}
};
sysU.ajax(ajaxConfig);
},
//所有动作成功之后
actionSuccess: (falg) => {
u.refreshTable(app, u, null, falg);
}
}
app = {
data: {
cols: [[
{ checkbox: true, fixed: true },
{
field: "id", width: 60, sort: true, fixed: true, hide: true, title: "ID",
verifyConfig: {
empty: "req", msg: "盘点数据【ID】不能为空!,ID:", type: "number"
}
},
{ field: "materialCode", width: 150, sort: true, fixed: false, title: "物料编码" },
{
field: "pipeLength", width: 100, sort: true, fixed: false, title: "管材长度", edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【管材长度】不能为空!,ID:", type: "number"
}
},
{
field: "qty", width: 80, sort: true, fixed: false, title: "数量", edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【数量】不能为空!,ID:", type: "number"
}
},
{ field: "materialName", width: 150, sort: true, fixed: false, title: "物料名称" },
{ field: "diameter", width: 150, sort: true, fixed: false, title: "管径" },
{ field: "thickness", width: 150, sort: true, fixed: false, title: "壁厚" },
{ field: "useState", width: 150, sort: true, fixed: false, title: "物料状态", templet: (d) => { return "".GetState(window.top.InventoryUseState, d.useState) } },
{
field: "pipeSN", width: 150, sort: true, fixed: false, title: "管材SN",
edit: "text",
verifyConfig: {
empty: "req", msg: "盘点数据【管材SN】不能为空!,ID:", type: "string"
}
}
]],
tableIns: null,
tableElem: "mainList",
//下拉框配置
selectOption: {
lineCode: {
SelType: "FromUrl",
SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_line",
SelLabel: "LineName",
SelValue: "LineCode",
Dom: [$("[name='lineCode']")]
},
locationCode: {
SelType: "FromUrl",
SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_location",
SelLabel: "locationName",
SelValue: "locationCode",
Dom: [$("[name='locationCode']")]
},
inventoryStatus: {
SelType: "FromDict",
SelFrom: "inventoryStatus",
SelLabel: "DictLabel",
SelValue: "DictValue",
},
zoneCode: {
SelType: "FromDict",
SelFrom: "zoneCode",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='zoneCode']")]
},
warehouseCode: {
SelType: "FromUrl",
SelFrom: "/warehous/Warehouse/Load",
SelLabel: "name",
SelValue: "code",
Dom: [$("[name='warehouseCode']")]
},
//返回的数据 用于后续操作
selectData: {
}
}
},
methods: {
initTable: function (opts) {
var config = {};
if (opts != undefined) $.extend(config, opts);
let options = {
elem: "#" + app.data.tableElem,
url: `/${areaName}/${tableName}/Load`,
cols: u.columnRecord(app.data.tableElem, app.data.cols),
toolbar: '#toolbarTable',
where: config,
doneExtend: function () {
setTimeout(function () {
app.methods.setColsEditConfig();
app.methods.initAopTable();
}, 2000);
}
}
if ("".GetUrlParam("menuFlag") === -2) options["height"] = 'full-55';
app.data.tableIns = u.initTable(options);
},
setColsEditConfig: function () {
for (var i = 0; i < app.data.cols[0].length; i++) {
if (typeof app.data.cols[0][i].field == "undefined") continue;
if (app.data.cols[0][i].field == "locationCode") {
var locationCodeConfigData = [];
app.data.selectOption.selectData["locationCode"].forEach(x => {
locationCodeConfigData.push({ name: x.id, value: x.locationCode });
});
app.data.cols[0][i]["config"] = { type: 'select', data: locationCodeConfigData }
}
}
},
initAopTable: function () {
aopTable = tableEdit.aopObj(app.data.cols);
aopTable.on(`tool(${app.data.tableElem})`, function (obj) {
debugger
var field = obj.field; //单元格字段
var value = obj.value; //修改后的值
var data = obj.data; //当前行旧数据
var event = obj.event; //当前单元格事件属性值
var update = {};
update[field] = value;
obj.update(update);
});
},
initFrom() {
u.initSelect(app.data.selectOption);
var opt1 = {
elem: "#materialCode",
checkedKey: "MaterialCode",
doneKey: {
key: "MaterialCode",
lableValue: "MaterialName"
},
searchKey: "MaterialCode",
searchName: "物料编码",
doneExtend: function (elem, data, $nowElem) {
debugger
var rootFrom = $("#modifyForm");
rootFrom.find("[name=materialCode]").val(data.data[0].materialCode);
rootFrom.find("[name=materialName]").val(data.data[0].materialName);
}
};
u.initSelectMaterialFeed1(opt1);
}
},
registerEvent: function () {
},
init: function () {
var inventoryId = "".GetUrlParam("InventoryId");
sendData = { id: inventoryId == null ? 0 : inventoryId }
app.methods.initFrom();
app.methods.initTable(sendData);
app.registerEvent();
}
};
app.init();
});