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
| /*
| * @Description: 工单自定义方法ts
| * @Author: Ben Lin
| * @version:
| * @Date: 2024-06-05 16:10:24
| * @LastEditors: your name
| * @LastEditTime: 2024-06-15 22:43:55
| */
| /* 工单相关自定义方法 */
| import { FunctionType } from '/@/api/tigerapi/model/systemModel';
| import { GetEnum, SaveEntity, getEntity } from '/@/api/tigerapi/system';
| import { FormSchema } from '/@/components/Table';
| import { useUserStore } from '/@/store/modules/user';
| import { useI18n } from '/@/hooks/web/useI18n';
| import { uploadApi } from '/@/api/sys/upload';
| import { useLocale } from '/@/locales/useLocale';
| import { ref, unref } from 'vue';
| import { BIZ_MES_WO_BATCH } from '/@/api/tigerapi/model/mesModel';
| import { buildUUID } from '/@/utils/uuid';
| import LogicFlow from '@logicflow/core';
| import { BpmnElement } from '@logicflow/extension';
| import { getRouteData } from '/@/api/tigerapi/mes/router';
| import customEdge from '/@/components/FlowChart/src/customEdge';
| import actionRect from '/@/components/FlowChart/src/actionRect';
| import TestNode from '/@/components/FlowChart/src/TestNode';
| import CollectNode from '/@/components/FlowChart/src/CollectNode';
| import AssemblyNode from '/@/components/FlowChart/src/AssemblyNode';
| import PackingNode from '/@/components/FlowChart/src/PackingNode';
| import RepairNode from '/@/components/FlowChart/src/RepairNode';
| import { multiply } from 'lodash-es';
|
| const { t } = useI18n();
| const { getLocale } = useLocale();
|
| /**
| * @description: 自定义方法
| * @return {*}
| */
| export const getWoFns: Record<string, FunctionType> = {
| handleSubmit: async (e, ...args) => {
| const values = await args[0][0].validate();
| return new Promise((resolve, reject) => {
| try {
| args[0][1]({ confirmLoading: true });
| values.AUTH_PROD = useUserStore().getUserInfo.prodCode;
| // const apiAction = SaveEntity(values, e, 'MES_LINE');
| // apiAction.then((action) => {
| // if (action.IsSuccessed) {
| // args[0][2]();
| // args[0][3]('success');
| // }
| // });
| args[0][2]();
| args[0][3]('success');
| resolve(true);
| } catch {
| reject(false);
| } finally {
| args[0][1]({ confirmLoading: false });
| }
| });
| },
| rvSubmit: (e, ...args) => {
| return new Promise((resolve, reject) => {
| try {
| args[0][0]({ confirmLoading: true });
| args[0][1]();
| args[0][2]('success');
| resolve(true);
| } catch {
| reject(false);
| } finally {
| args[0][0]({ confirmLoading: false });
| }
| });
| },
|
| /**
| * @description: 工单配置保存方法
| * @param {*} e
| * @param {array} args
| * @return {*}
| */
| SaveCofig: (e, ...args) => {
| return new Promise((resolve, reject) => {
| try {
| const form = e['prodinfo'];
| const wo = e['mValues'];
| wo.ROUTE_STATUS = 1;
| SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
| if (action.IsSuccessed) {
| resolve(true);
| } else {
| reject(false);
| }
| });
| } catch {
| reject(false);
| }
| });
| },
| /**
| * @description: 工单下发保存方法
| * @param {*} e
| * @param {array} args
| * @return {*}
| */
| SaveWoBatch: (e, ...args) => {
| return new Promise((resolve, reject) => {
| try {
| const form = e['forminfo'];
| const wo = e['mValues'];
| wo.ROUTE_CODE = form.ROUTE_CODE;
| wo.STATUS = 2;
| const woBatch: BIZ_MES_WO_BATCH = {
| ID: buildUUID(),
| CREATE_TIME: new Date(),
| CREATE_USER: useUserStore().getUserInfo.userId as string,
| UPDATE_TIME: new Date(),
| UPDATE_USER: useUserStore().getUserInfo.userId as string,
| GHOST_ROW: false,
| AUTH_ORG: '',
| AUTH_PROD: useUserStore().getUserInfo.prodCode as string,
| AUTH_WH: '',
| ORDER_NO: wo.ORDER_NO,
| STATUS: wo.STATUS,
| ITEM_CODE: wo.ITEM_CODE,
| CUST_CODE: wo.CUST_CODE,
| FACTORY: wo.FACTORY,
| WS_CODE: wo.WS_CODE,
| ACT_LINE: form.PLAN_LINE,
| STD_WORKER_QTY: wo.STD_WORKER_QTY,
| ACT_WORKER_QTY: wo.ACT_WORKER_QTY,
| RELEASE_TIME: new Date(),
| RELEASE_USER: useUserStore().getUserInfo.userId as string,
| PLAN_QTY: wo.PLAN_QTY,
| INPUT_QTY: wo.INPUT_QTY,
| OUTPUT_QTY: wo.OUTPUT_QTY,
| SCRAP_QTY: wo.SCRAP_QTY,
| STOCK_IN_QTY: wo.STOCK_IN_QTY,
| UPH: wo.UPH,
| UPPH: wo.UPPH,
| REMARK: wo.REMARK,
| ACT_START_TIME: wo.ACT_START_TIME,
| ACT_END_TIME: wo.ACT_END_TIME,
| };
| SaveEntity(woBatch, false, 'BIZ_MES_WO_BATCH').then((action) => {
| if (action.IsSuccessed) {
| SaveEntity(wo, true, 'BIZ_MES_WO').then((action) => {
| if (action.IsSuccessed) {
| resolve(true);
| } else {
| reject(false);
| }
| });
| } else {
| reject(false);
| }
| });
| } catch {
| reject(false);
| }
| });
| },
| initRoute: async (e, ...args) => {
| const _data = await getRouteData(args[0][0].ROUTE_CODE);
| args[0][1] = ref({
| nodes: [],
| edges: [],
| });
| return new Promise((resolve, reject) => {
| try {
| LogicFlow.use(BpmnElement);
| const lf = new LogicFlow({
| container: document.querySelector('#lfContainer'),
| edgeGenerator: (sourceNode) => {
| // console.log('a');
| // 起始节点类型 rect 时使用 自定义的边 custom-edge
| if (sourceNode.properties.isReturn) return 'custom-edge';
| // if (sourceNode.type === 'rect') return 'custom-edge';
| // return 'custom-edge';
| },
| });
| lf.register(customEdge);
| lf.register(actionRect);
| lf.register(TestNode);
| lf.register(CollectNode);
| lf.register(AssemblyNode);
| lf.register(PackingNode);
| lf.register(RepairNode);
| lf.render({});
| //通过工艺路线ID获取图形数据,并渲染
| console.log('组件已挂载', _data);
| //工艺路线全信息,包括Node、Edge和Act
| // routeConfig.routeData = _data.Data;
| if (_data.Data != null) {
| //工艺路线主信息
| const currRoute = _data.Data.route;
| _data.Data.nodes.forEach((n) => {
| n.node.properties = JSON.parse(n.node.properties);
| args[0][1].value.nodes.push(n.node);
| });
| console.log('111', args[0][1]);
| _data.Data.edges.forEach((e) => {
| e.edge.properties = JSON.parse(e.edge.properties);
| args[0][1].value.edges.push(e.edge);
| });
| _data.Data.acts.forEach((act) => {
| act.node.properties = JSON.parse(act.node.properties);
| args[0][1].value.nodes.push(act.node);
| });
| console.log('init', unref(lf).getGraphData(), JSON.parse(JSON.stringify(args[0][1])));
| lf.render(args[0][1].value);
| // lf.graphModel.resize(500, 400);
| lf.graphModel.fitView();
| lf.graphModel.translateCenter();
| }
| resolve(true);
| } catch {
| reject(false);
| }
| });
| },
| };
|
| export const woCfgformSchema: FormSchema[] = [
| {
| field: 'ORDER_NO',
| component: 'Input',
| label: '工单号',
| colProps: {
| span: 8,
| },
| componentProps: {
| placeholder: '请输入工单号',
| onChange: (e: any) => {
| console.log(e);
| },
| },
| dynamicDisabled: true,
| },
| {
| field: 'ORDER_TYPE',
| component: 'Select',
| label: '工单类型',
| colProps: {
| span: 8,
| },
| defaultValue: 'Normal',
| componentProps: {
| options: [
| {
| label: '正常',
| value: 'Normal',
| },
| {
| label: '返工',
| value: 'Rework',
| },
| ],
| },
| dynamicDisabled: true,
| },
| {
| field: 'PLAN_QTY',
| component: 'Input',
| label: '计划数量',
| colProps: {
| span: 8,
| },
| dynamicDisabled: true,
| },
| ];
|
| export const prodCfgformSchema: FormSchema[] = [
| {
| field: 'ITEM_CODE',
| component: 'Input',
| label: '物料编码',
| required: true,
| colProps: {
| span: 12,
| },
| componentProps: {
| placeholder: '请输入物料编码',
| onChange: (e: any) => {
| console.log(e);
| },
| },
| dynamicDisabled: true,
| },
| {
| field: 'ITEM_TYPE',
| component: 'Input',
| label: '物料类型',
| colProps: {
| span: 12,
| },
| },
| {
| label: '工艺路线',
| field: 'ROUTE_CODE',
| component: 'Input',
| required: true,
| colProps: {
| span: 12,
| },
| },
| {
| field: 'addRot',
| component: 'Input',
| label: '1',
| colSlot: 'addRot',
| defaultValue: 'MES_ROUTE',
| colProps: {
| span: 1,
| },
| },
| {
| field: 'setRot',
| component: 'Input',
| label: '1',
| colSlot: 'setRot',
| defaultValue: 'MES_ROUTE',
| colProps: {
| span: 1,
| },
| },
| {
| field: 'fieldsc',
| component: 'Upload',
| label: '打印模板',
| colProps: {
| span: 10,
| },
| rules: [{ required: true, message: '请选择上传文件' }],
| componentProps: {
| api: uploadApi,
| multiple: false,
| },
| },
| ];
|
| export const xxCfgformSchema: FormSchema[] = [
| {
| field: 'field10',
| component: 'Input',
| label: '字段1',
| colProps: {
| span: 8,
| },
| componentProps: {
| placeholder: '自定义placeholder',
| onChange: (e: any) => {
| console.log(e);
| },
| },
| },
| {
| field: 'ROUTE_CODE',
| component: 'Input',
| label: '字段2',
| colProps: {
| span: 8,
| },
| },
| {
| field: 'add',
| component: 'Input',
| label: '1',
| colSlot: 'add',
| defaultValue: 'MES_ROUTE',
| colProps: {
| span: 1,
| },
| },
| {
| field: 'field12',
| component: 'DatePicker',
| label: '字段3',
| colProps: {
| span: 8,
| },
| },
| ];
|
| export const woformSchema: FormSchema[] = [
| {
| field: 'PLAN_QTY',
| label: '工单数量',
| component: 'Input',
| required: true,
| colProps: {
| span: 12,
| },
| },
| {
| label: '计划产线',
| field: 'PLAN_LINE',
| component: 'ApiSelect',
| required: true,
| colProps: {
| span: 12,
| },
| componentProps: {
| api: getEntity,
| params: { entityName: 'MES_LINE', sqlcmd: ' 1=1 ' },
| resultField: 'Data.Items',
| labelField: 'LINE_NAME',
| valueField: 'LINE_CODE',
| },
| },
| {
| label: '工艺路线',
| field: 'ROUTE_CODE',
| component: 'Input',
| required: true,
| colProps: {
| span: 12,
| },
| },
| {
| field: 'add',
| component: 'Input',
| label: '1',
| colSlot: 'add',
| defaultValue: 'MES_ROUTE',
| colProps: {
| span: 1,
| },
| },
| {
| field: 'set',
| component: 'Input',
| label: '1',
| colSlot: 'set',
| defaultValue: 'MES_ROUTE',
| colProps: {
| span: 1,
| },
| },
| {
| field: 'fieldsc',
| component: 'Upload',
| label: '打印模板',
| colProps: {
| span: 10,
| },
| rules: [{ required: true, message: '请选择上传文件' }],
| componentProps: {
| api: uploadApi,
| },
| },
| ];
|
| /**
| * @description: 工艺路线弹框返回
| * @param {*} d
| * @param {*} u
| * @return {*}
| */
| export function woGetSelectSuccess(d, u) {
| return {
| ROUTE_CODE: d.values['val'],
| ID: d.values['id'],
| };
| }
|
| /**
| * @description: 自定义模态框打开方法
| * @param {Fn} openModal
| * @param {string} slotName
| * @param {Fn} others
| * @param {array} args
| * @return {*}
| */
| export function woCustFn(openModal: Fn, slotName: string, others: Fn[], ...args) {
| switch (slotName) {
| case 'add':
| case 'addRot':
| openModal(true, {
| title: '工艺路线列表',
| schemas: [
| {
| field: 'ROT_CODE',
| component: 'Input',
| label: '工艺路线编码',
| colProps: {
| span: 12,
| },
| },
| ],
| ItemColumns: [
| {
| title: t('工艺路线编码'),
| dataIndex: 'ROT_CODE',
| resizable: true,
| sorter: true,
| width: 200,
| },
| {
| title: t('工艺路线名称'),
| dataIndex: 'ROT_NAME',
| resizable: true,
| sorter: true,
| width: 180,
| },
| ],
| tableName: 'MES_ROUTE',
| rowKey: 'ROT_CODE',
| returnFieldName: 'ROUTE_CODE', //返回值要赋值的字段名称
| searchInfo: {TABLE_NAME: 'MES_ROUTE' }
| });
| break;
| case 'set':
| case 'setRot':
| // notification.success({
| // message: '点击了设置按钮',
| // description: `OK`,
| // duration: 3,
| // });
| others[0](true, { rotId: args[0][0], slotName: slotName });
| break;
| default:
| () => {};
| break;
| }
| }
|
|