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
| import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
| import type { VxeTableGridOptions } from '#/adapter/vxe-table';
| import type { MesProAndonConfigApi } from '#/api/mes/pro/andon/config';
| import type { MesProAndonRecordApi } from '#/api/mes/pro/andon/record';
|
| import { markRaw } from 'vue';
|
| import { DICT_TYPE, MesProWorkOrderStatusEnum } from '../../../../../packages/constants/src';
| import { getDictOptions } from '../../../../../packages/effects/hooks/src';
|
| import { getSimpleUserList } from '#/api/system/user';
| import { getRangePickerDefaultProps } from '#/utils';
| import { MdWorkstationSelect } from '#/views/mes/md/workstation/components';
| import { ProProcessSelect } from '#/views/mes/pro/process/components';
| import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
|
| import { AndonConfigSelect } from '../config/components';
|
| /** 表单类型 */
| export type FormType = 'create' | 'detail' | 'update';
|
| /** 列表的搜索表单 */
| export function useGridFormSchema(): VbenFormSchema[] {
| return [
| {
| fieldName: 'workstationId',
| label: '工作站',
| component: markRaw(MdWorkstationSelect),
| componentProps: {
| allowClear: true,
| placeholder: '请选择工作站',
| },
| },
| {
| fieldName: 'userId',
| label: '发起人',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: getSimpleUserList,
| labelField: 'nickname',
| placeholder: '请选择发起人',
| valueField: 'id',
| },
| },
| {
| fieldName: 'handlerUserId',
| label: '处置人',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: getSimpleUserList,
| labelField: 'nickname',
| placeholder: '请选择处置人',
| valueField: 'id',
| },
| },
| {
| fieldName: 'status',
| label: '处理状态',
| component: 'Select',
| componentProps: {
| allowClear: true,
| options: getDictOptions(DICT_TYPE.MES_PRO_ANDON_STATUS, 'number'),
| placeholder: '请选择状态',
| },
| },
| {
| fieldName: 'createTime',
| label: '发起时间',
| component: 'RangePicker',
| componentProps: {
| ...getRangePickerDefaultProps(),
| allowClear: true,
| },
| },
| ];
| }
|
| /** 列表的字段 */
| export function useGridColumns(): VxeTableGridOptions<MesProAndonRecordApi.AndonRecord>['columns'] {
| return [
| { field: 'workstationCode', title: '工作站编码', width: 140 },
| { field: 'workstationName', title: '工作站名称', minWidth: 140 },
| { field: 'workOrderCode', title: '工单编码', width: 140 },
| { field: 'processName', title: '工序名称', width: 140 },
| { field: 'userNickname', title: '发起人', width: 110 },
| {
| field: 'createTime',
| title: '发起时间',
| width: 180,
| formatter: 'formatDateTime',
| },
| { field: 'reason', title: '呼叫原因', minWidth: 160 },
| {
| field: 'level',
| title: '级别',
| width: 90,
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.MES_PRO_ANDON_LEVEL },
| },
| },
| {
| field: 'handleTime',
| title: '处理时间',
| width: 180,
| formatter: 'formatDateTime',
| },
| { field: 'handlerUserNickname', title: '处理人', width: 110 },
| {
| field: 'status',
| title: '处置状态',
| width: 110,
| cellRender: {
| name: 'CellDict',
| props: { type: DICT_TYPE.MES_PRO_ANDON_STATUS },
| },
| },
| {
| title: '操作',
| width: 200,
| fixed: 'right',
| slots: { default: 'actions' },
| },
| ];
| }
|
| /**
| * 新增/处置/详情安灯呼叫记录的表单
| *
| * - create:录入呼叫主体信息(工作站/发起人/工单/工序/呼叫原因/备注)
| * - update:呼叫主体只读展示创建时的快照字段(workstationName/workOrderCode/processName/reason),编辑处置时间/处置人/备注
| * - detail:所有字段只读
| */
| export function useFormSchema(
| formType: FormType,
| formApi?: VbenFormApi,
| ): VbenFormSchema[] {
| const isCreate = formType === 'create';
| const isUpdate = formType === 'update';
| return [
| {
| fieldName: 'id',
| component: 'Input',
| dependencies: { triggerFields: [''], show: () => false },
| },
| isCreate
| ? {
| fieldName: 'workstationId',
| label: '工作站',
| component: markRaw(MdWorkstationSelect),
| componentProps: {
| placeholder: '请选择工作站',
| },
| rules: 'selectRequired',
| }
| : {
| fieldName: 'workstationName',
| label: '工作站',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| isCreate
| ? {
| fieldName: 'userId',
| label: '发起人',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: getSimpleUserList,
| labelField: 'nickname',
| placeholder: '请选择发起人',
| valueField: 'id',
| },
| }
| : {
| fieldName: 'userNickname',
| label: '发起人',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| isCreate
| ? {
| fieldName: 'workOrderId',
| label: '生产工单',
| component: markRaw(ProWorkOrderSelect),
| componentProps: {
| placeholder: '请选择工单(可选)',
| status: MesProWorkOrderStatusEnum.CONFIRMED,
| },
| }
| : {
| fieldName: 'workOrderCode',
| label: '生产工单',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| isCreate
| ? {
| fieldName: 'processId',
| label: '工序',
| component: markRaw(ProProcessSelect),
| componentProps: {
| placeholder: '请选择工序(可选)',
| },
| }
| : {
| fieldName: 'processName',
| label: '工序',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| isCreate
| ? {
| fieldName: 'configId',
| label: '呼叫原因',
| component: markRaw(AndonConfigSelect),
| componentProps: {
| // 选择呼叫原因后,自动填充对应的级别
| onChange: async (config?: MesProAndonConfigApi.AndonConfig) => {
| await formApi?.setValues({
| level: config?.level,
| reason: config?.reason,
| });
| },
| },
| rules: 'selectRequired',
| }
| : {
| fieldName: 'reason',
| label: '呼叫原因',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| {
| fieldName: 'level',
| label: '级别',
| component: 'Select',
| componentProps: {
| disabled: true,
| options: getDictOptions(DICT_TYPE.MES_PRO_ANDON_LEVEL, 'number'),
| placeholder: '由呼叫原因自动带出',
| },
| },
| // 处置信息:update / detail 模式才展示
| ...(isCreate
| ? []
| : ([
| {
| fieldName: 'status',
| label: '状态',
| component: 'Select',
| componentProps: {
| disabled: true,
| options: getDictOptions(DICT_TYPE.MES_PRO_ANDON_STATUS, 'number'),
| },
| },
| {
| fieldName: 'handleTime',
| label: '处置时间',
| component: 'DatePicker',
| componentProps: {
| disabled: !isUpdate,
| format: 'YYYY-MM-DD HH:mm:ss',
| placeholder: '请选择处置时间',
| showTime: true,
| valueFormat: 'x',
| },
| },
| isUpdate
| ? {
| fieldName: 'handlerUserId',
| label: '处置人',
| component: 'ApiSelect',
| componentProps: {
| allowClear: true,
| api: getSimpleUserList,
| labelField: 'nickname',
| placeholder: '请选择处置人',
| valueField: 'id',
| },
| }
| : {
| fieldName: 'handlerUserNickname',
| label: '处置人',
| component: 'Input',
| componentProps: {
| disabled: true,
| },
| },
| ] as VbenFormSchema[])),
| {
| fieldName: 'remark',
| label: '备注',
| component: 'Textarea',
| componentProps: {
| disabled: formType === 'detail',
| maxLength: 250,
| placeholder: '请输入备注',
| rows: 2,
| },
| },
| ];
| }
|
|