Ben Lin
2024-06-09 2060cb1aec383655dc0e8ee7ecf31e044b4e52a3
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
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 { unref } from 'vue';
 
const { t } = useI18n();
const { getLocale } = useLocale();
 
export const getFns: Record<string, FunctionType> = {
  handleSubmit: async (e, ...args) => {
    try {
      const values = await args[0][0].validate();
      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');
    } finally {
      args[0][1]({ confirmLoading: false });
    }
  },
  rvSubmit: (e, ...args) => {
    try {
      args[0][0]({ confirmLoading: true });
      args[0][1]();
      args[0][2]('success');
    } finally {
      args[0][0]({ confirmLoading: 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: 8,
    },
    componentProps: {
      placeholder: '请输入物料编码',
      onChange: (e: any) => {
        console.log(e);
      },
    },
    dynamicDisabled: true,
  },
  {
    field: 'ITEM_TYPE',
    component: 'Input',
    label: '物料类型',
    colProps: {
      span: 8,
    },
  },
  {
    field: 'field6',
    component: 'DatePicker',
    label: '字段3',
    colProps: {
      span: 8,
    },
  },
  {
    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: 'field8',
    component: 'Input',
    label: '字段5',
    colProps: {
      span: 10,
    },
  },
];
 
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,
    },
  },
];
 
//工艺路线弹框返回
export function woGetSelectSuccess(d, u) {
  return {
    ROUTE_CODE: d.values['val'],
    ID: d.values['id'],
  };
}
 
/* 自定义模态框打开方法 */
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', //返回值要赋值的字段名称
      });
      break;
    case 'set':
    case 'setRot':
      //   notification.success({
      //     message: '点击了设置按钮',
      //     description: `OK`,
      //     duration: 3,
      //   });
      others[0](true, { rotId: args[0][0], slotName: slotName });
      break;
    default:
      () => {};
      break;
  }
}