Station.js
19 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
let action = null;
layui.config({
base: "/js/",
version: 1222
}).use(['ztree', 'system', "jqprint"], function () {
var form = layui.form,
$ = layui.jquery,
table = layui.table,
system = layui.system,
u = new system.u(),
sendData = {
isok: null,
keys: null,
lineCode:null
},
Rowid=null,
processRouteBodyKeys = null, //工位工序表 【工艺路线明细标识 】
areaName = "configure",
tableName = "Station";
action = {
addOptions: function () {
var options = {
fromId: "#modifyForm form",
url: `/${areaName}/${tableName}/Ins`,
submit: "submit(fromAdd)"
}
return options;
},
editOptions: function () {
debugger
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`,
sendData: {
lineCode: sendData.lineCode == null ? 0 : sendData.lineCode
},
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`
}
return options;
},
editBefore: function (data, callBack) {
data.enable=data.enable.toString();
form.val("modifyForm", data);
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if (callBack != null) callBack();
},
addBefore: function (callBack) {
if (sendData.isok !== "true") {
layer.alert("addBefore:请选择线体节点新增工序", { icon: 6, shade: 0.4, time: u.config.errorTime });
return;
}
//callBack是回调函数,如果editBefore有ajax 放在成功之后
if (callBack != null) callBack();
},
addSaveBefore: function (data, callBack) {
debugger
if (sendData.isok !== "true") {
layer.alert("addSaveBefore:请选择线体节点新增工序", { icon: 6, shade: 0.4, time: u.config.errorTime });
return;
}
data.field.lineCode = sendData.lineCode;
data.field.lineKey = sendData.keys;
if (callBack != null) callBack();
},
rowClickOptions: function () {
var options = {
isDefault: false,
customFn: function (obj) {
debugger
var stationData = obj.data;
//通知主页面 返回code给工序缓存
u.initParentEvent(stationData);
}
}
return options;
},
//checkboxMethod: function (obj) {
// debugger
// //工位工序表新增
// var processRoute = "".GetUrlParam("page"),
// oprSequenceCode = "".GetUrlParam("oprSequenceCode"),
// headKeys = "".GetUrlParam("headKeys");
// if (processRoute =="processRoute") {
// var checkBoxData = {
// stationCode: null,
// bodyKeys: processRouteBodyKeys,
// oprSequenceCode: oprSequenceCode,
// checkeds: obj.checked,
// headKeys: headKeys
// };
// if (obj.type == "all") {
// checkBoxData.stationCode = u.getTableAllData(app.data.tableElem).GetArrValue("workStationCode");
// } else {
// checkBoxData.stationCode = obj.data.workStationCode;
// }
// if (checkBoxData.stationCode == null || checkBoxData.stationCode == "") {
// layer.alert("checkboxMethod:工位标识【workStationCode】为空,请重新关闭后再操作,反复出现请联系管理员", { icon: 2, shadeClose: true, title: "提示" });
// return false;
// }
// if (checkBoxData.bodyKeys == null) {
// layer.alert("checkboxMethod:工序标识Id为空,请重新关闭后再操作,反复出现请联系管理员", { icon: 2, shadeClose: true, title: "提示" });
// return false;
// }
// var ajaxConfig = {
// data: checkBoxData,
// url: `/configure/Workcenter/OperateWorkCenterStation`,
// success: function (result) {
// if (u.successBefore(result)) return false;
// layer.msg(result.Message);
// }
// };
// u.ajax(ajaxConfig);
// }
//},
checkboxMethod: function (obj) {
debugger
var workCenter = "".GetUrlParam("page"),
workCenterCode = "".GetUrlParam("workCenterCode"),
workKey = "".GetUrlParam("workKey");
/* workCenterId = "".GetUrlParam("workCenterId");*/
if (workCenter == "Workcenter") {
var checkBoxData = {
stationCode: null,
workCenterCode: workCenterCode,
checkeds: obj.checked,
workKey: workKey
};
if (obj.type == "all") {
checkBoxData.stationCode = u.getTableAllData(app.data.tableElem).GetArrValue("workStationCode");
} else {
checkBoxData.stationCode = obj.data.workStationCode;
}
if (checkBoxData.stationCode == null || checkBoxData.stationCode == "") {
layer.alert("checkboxMethod:工位标识【workStationCode】为空,请重新关闭后再操作,反复出现请联系管理员", { icon: 2, shadeClose: true, title: "提示" });
return false;
}
if (checkBoxData.workKey == null) {
layer.alert("checkboxMethod:工序标识Id为空,请重新关闭后再操作,反复出现请联系管理员", { icon: 2, shadeClose: true, title: "提示" });
return false;
}
var ajaxConfig = {
data: checkBoxData,
url: `/configure/Workcenter/OperateWorkCenterStation`,
success: function (result) {
if (u.successBefore(result)) return false;
layer.msg(result.Message);
}
};
u.ajax(ajaxConfig);
}
},
qcCodePrintOptions: () => {
var options = {
qrCodeValueKey: "workStationCode",
//【qrcodeElem】 是要修改的内容其他的不要变 id 的变量值不需要变
customFn: (sysU, parameter, selectData) => {
for (var i = 0; i < selectData.length; i++) {
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_lable">
<label>工位条码:</label><label>${qcCodeValue}</label>
</div>
<div class="qcCode_lable">
<label>工位名称:</label><label>${selectData[i].workStationName}</label>
</div>
<div class="qcCode_lable">
<label>产线:</label><label>${selectData[i].lineName}</label>
</div>
</div>`;
sysU.qRCodeWirtDom(parameter, qrcodeElem, qrcodeId, qcCodeValue);
}
return true;
}
}
return options;
},
//工位分配班组
btnStationTeam: function (sysU, toolbarId, obj) {
var checkStatus = table.checkStatus(toolbarId),
data = checkStatus.data;
if (data.length !== 1) {
layer.msg("请选择一条要分配的工位");
return false;
}
layer.open({
title: "为工位【" + data[0].workStationName + "】分配人员",
type: 2,
area: ['1000px', '600px'],
content: "/Configure/BaseTeam/Index?menuFlag=-2&selectColKeyCustom=teamCode&page=base_station_team_rel&stationId=" + data[0].id,
cancel: function () {
action.actionSuccess("", app.data.tableIns.config.page.index);
}
});
},
//所有动作成功之后
actionSuccess: (falg) => {
if (falg === "add" || falg === "edit" || falg === "delete" || falg === "upload") {
app.methods.initTable({ lineCode: sendData.lineCode });
} else if (falg === "refresh") {
//app.data.tableIns.config.where = {};
app.data.tableIns.config.page.curr = 1;
app.data.tableIns.reload("mainList", {});
}
}
}
var app = {
data: {
cols: [[
{ checkbox: true, fixed: true },
{ field: "id", width: 80, hide: true, title: "Id" },
{ field: "workStationCode", width: 180, title: "工位编码" },
{ field: "workStationName", width: 180, title: "工位名称" },
{ field: "lineCode", width: 100, hide: true , title: "线体代号" },
{ field: "lineName", width: 180, title: "线体名称" },
{ field: 'otherCode', width: 120, title: '外部编码' },
{ field: "sequence", width: 80, title: "顺序" },
{ field: "monitorIP", width: 150, title: "看板IP" },
{ field: "attribute", width: 150, title: "工位属性", templet: function (d) { return GetLabel("Attribute", "DictValue", "DictLabel", d.attribute) } },
{ field: "enable", width: 100, title: "是否有效", templet: function (d) { return GetLabel("Enable", "DictValue", "DictLabel", d.enable.toString()) } },
{ field: "createTime", width: 150, title: "建立时间" },
{ field: "createBy", width: 150, title: "建立者" },
{ field: "updateTime", width: 150, title: "更新时间" },
{ field: "updateBy", width: 150, title: "更新者" }
]],
urlTable: `/${areaName}/${tableName}/Load`,
tableIns: null,
tableElem: "mainList",
tree: $("#tree"),
treeObj: null,
setting: {
view: { selectedMulti: false },
async: {
enable: true,
url: `/${areaName}/${tableName}/GetTreeList`,
type: "get"
},
data: {
simpleData: {
enable: true,
idKey: "keys",
pIdKey: "parentId",
rootPId: ""
}
},
callback: {
onClick: function (event, treeId, treeNode) {
debugger
sendData.isok = treeNode.isok;
sendData.keys = treeNode.keys;
sendData.lineCode = treeNode.lineCode;
if (sendData.isok === "true") {
app.methods.initTable({ lineCode: sendData.lineCode });
var selectColKey = "".GetUrlParam("selectColKey");
}
},
onAsyncSuccess: function (event, treeId, treeNode, msg) {
app.data.treeObj.expandAll(true);
}
}
},
selectOption: {
Enable: {
SelType: "FromDict",
SelFrom: "IsEnable",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='enable']"), $("[name='qenable']")]
},
Attribute: {
SelType: "FromDict",
SelFrom: "Attribute",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='attribute']"), $("[name='qattribute']")]
},
Line: {
SelType: "FromUrl",
SelFrom: "/HomeRedis/GetBaseInfoByKey?key=base_line",
SelLabel: "LineName",
SelValue: "LineCode",
Dom: [$("[name='lineCode']"), $("[name='qlineCode']")]
},
WorkCenter: {
SelType: "FromDict",
SelFrom: "WorkCenter",
SelLabel: "DictLabel",
SelValue: "DictValue",
Dom: [$("[name='workCenterCode']")]
},
//返回的数据 用于后续操作
selectData: {
}
}
},
methods: {
//initTable: function (options) {
// debugger
// var config = {};
// if (options != undefined) $.extend(config, options);
// var saveKeys = "".GetUrlParam("saveKeys");
// if ("".GetUrlParam("saveKeys") != null) {
// processRouteBodyKeys = saveKeys;
// }
// //通过工序筛选工位
// if ("".GetUrlParam("workCenterCode") != null) {
// config["workCenterCode"] = "".GetUrlParam("workCenterCode");
// }
// let opt = {
// cols: u.columnRecord(app.data.tableElem, app.data.cols),
// elem: "#" + app.data.tableElem,
// url: `/${areaName}/${tableName}/Load`,
// toolbar: '#toolbarTable',
// where: config,
// doneExtend: function (res, obj) {
// debugger;
// //工艺线路的实时刷新选中
// var processRoute = "".GetUrlParam("page");
// if (processRoute == "processRoute") {
// var ajaxConfig = {
// data: { ids: processRouteBodyKeys },
// url: `/configure/ProcessRoute/getProcessRouteStationByProcessRouteDetailId`,
// success: function (result) {
// if (u.successBefore(result)) return false;
// var targetArrValue = result.Result.map(function (e) { return e.workStationCode; });
// var selectColKey = "".GetUrlParam("selectColKeyCustom");
// u.SetTableCheck(targetArrValue, res, selectColKey, app.data.tableElem);
// }
// };
// u.ajax(ajaxConfig);
// }
// }
// }
// app.data.tableIns = u.initTable(opt);
//},
initTable: function (options) {
var config = {};
if (options != undefined) $.extend(config, options);
let opt = {
cols: u.columnRecord(app.data.tableElem, app.data.cols),
elem: "#" + app.data.tableElem,
url: `/${areaName}/${tableName}/Load`,
toolbar: '#toolbarTable',
where: config,
doneExtend: function (res, obj) {
debugger;
//工艺线路的实时刷新选中
var workCenter = "".GetUrlParam("page"),
workCenterCode = "".GetUrlParam("workCenterCode");
if (workCenter == "Workcenter") {
var ajaxConfig = {
data: { workCenterCode: workCenterCode },
url: `/configure/Workcenter/GetWorkCenterCode`,
success: function (result) {
if (u.successBefore(result)) return false;
var targetArrValue = result.Result.map(function (e) { return e.workStationCode; });
var selectColKey = "".GetUrlParam("selectColKeyCustom");
u.SetTableCheck(targetArrValue, res, selectColKey, app.data.tableElem);
}
};
u.ajax(ajaxConfig);
}
}
}
app.data.tableIns = u.initTable(opt);
},
initTree: function () {
setTimeout(() => {
app.data.treeObj = $.fn.zTree.init(app.data.tree, app.data.setting);
app.data.tree.height($("div.layui-table-view").height() - 20);
}, 50);
},
initFrom: function() {
u.initSelect(app.data.selectOption);
}
},
registerEvent: function () {
},
init: function () {
app.methods.initTable();
app.methods.initTree();
app.registerEvent();
app.methods.initFrom();
}
};
app.init();
})