Ben Lin
2024-06-21 0990f596791ebc4518e293a2d60407ff1165b53c
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
import { Ref, h, unref } from 'vue';
import { ActionItem, BasicColumn, FormSchema } from '/@/components/Table';
import { useI18n } from '/@/hooks/web/useI18n';
import { useLocale } from '/@/locales/useLocale';
import { Tag } from 'ant-design-vue';
import { DeleteEntity, GetEnum, getEntity } from '/@/api/tigerapi/system';
import { isNullOrEmpty } from '/@/utils/is';
import { buildUUID } from '/@/utils/uuid';
import { useUserStore } from '/@/store/modules/user';
import { formatToDateTime } from '/@/utils/dateUtil';
 
const { t } = useI18n();
const { getLocale } = useLocale();
 
/**
 * @description: 自定义按钮方法
 * @param {Fn} args
 * @param {*} params
 * @return {*}
 */
export function DftGrpRelease(args: Fn[], params: {}) {
  console.log('点击了下发按钮');
  // notification.success({
  //   message: '点击了下发按钮',
  //   description: `${params.entityName}`,
  //   duration: 3,
  // });
  // reload();
  // if (params.STATUS == 2) {
  //   createErrorModal({
  //     title: t('警告'),
  //     content: t('工单已经下发,不能再下发!'),
  //     getContainer: () => document.body,
  //   });
  //   return;
  // }
  params['dtlSlots'].value = [
    {
      name: 'forminfo',
      slots: ['add', 'set'],
      preIcons: { add: 'search|svg', set: 'config|svg' }, //如果是多个表单,增加多个插槽。slots是弹出框按钮的插槽,preIcons是插槽对应的按钮图标
      title: '下发配置',
    },
  ];
 
  args[2](true, {
    isUpdate: true, //是否更新操作
    ctype: params['cType'].value, //是哪个页面
    title: '工单下发', //标题
    width: '900px', //弹出框宽度
    formEl: params['useFormData'].value,
    formElName: ['forminfo'], //表单插槽名称
    RowKeys: { add: 'ROUTE_CODE', set: 'ROUTE_CODE' }, //插槽的弹出框选择的code
    fnName: { BIZ_MES_WO: 'SaveWoBatch' }, //保存方法名
    initFnName: {}, //初始化方法名
    values: params['record'], //表单记录
  });
}
 
/**
 * @description: 自定义编辑方法
 * @param {Fn} args
 * @param {*} params
 * @return {*}
 */
export function DftGrpEdit(args: Fn[], params: {}) {
  const param = { CODE: params['record']['DFTG_CODE'], ID: params['record']['ID'], Name: 'BAS_DEFECT', Title: `编辑不良代码组:${params['record']['DFTG_CODE']}`, pCode: 'DFTG_CODE', IsID: false };
  args[5](`/BAS_DEFECT/High/${encodeURI(JSON.stringify(param))}`);
}
 
/**
 * @description: 自定义删除方法
 * @param {Fn} args
 * @param {*} params
 * @return {*}
 */
export function DftGrpDel(args: Fn[], params: {}) {
  if (!isNullOrEmpty(params['data'])) {
    var _data = params['data'].value.filter((item) => item['ID'] != params['record']['ID']);
    params['data'].value = _data;
    args[6]({
      dataSource: [],
    });
    args[6]({
      dataSource: params['data'],
    });
    args[1]();
  } else {
    DeleteEntity(params['record'], params['entityName']).then((action) => {
      if (action.IsSuccessed) {
        args[1]();
      }
    });
  }
}
 
/**
 * @description: 自定义明细表中编辑返回方法
 * @param {string} type
 * @param {*} d
 * @param {*} u
 * @return {*}
 */
export function dftEditeOperation(data: Ref<any[]>, d, u) {
  if (u.isUpdate) {
    //更新
    var _data = data.value.map((item) => {
      if (item['ID'] == d.ID)
        return {
          ...item,
          DFT_CODE: d.DFT_CODE,
          DFT_NAME: d.DFT_NAME,
          DFT_LEVEL: d.DFT_LEVEL,
          REMARK: d.REMARK,
        };
      return item;
    });
    data.value = _data;
  } else {
    //新增
    d.ID = buildUUID();
    d.CREATE_USER = useUserStore().getUserInfo.userId as string;
    d.UPDATE_TIME = formatToDateTime(new Date());
    d.UPDATE_USER = useUserStore().getUserInfo.userId as string;
    var _data2: any[] = [];
    if (!isNullOrEmpty(data.value)) {
      _data2 = data.value.map((item) => {
        return item;
      });
    }
    _data2.push(d);
    data.value = _data2;
  }
}
 
export const dftGrpactionColumn: BasicColumn = {
  width: 100,
  title: '操作',
  dataIndex: 'action',
  slots: { customRender: 'action' },
  fixed: 'right',
};
 
// export const dftGrpActionItem: ActionItem[] =[
//   {
//     icon: 'clarity:note-edit-line',
//     onClick: () => {},
//   },
//   {
//     icon: 'ant-design:delete-outlined',
//     color: 'error',
//     popConfirm: {
//       title: '是否确认删除?',
//       placement: 'left',
//       confirm: () => {},
//     },
//   },
// ];
 
export function dftGrpGetSelectSuccess(d, u) {
  return {
    ITEM_CODE: d.values['val'],
  };
}
 
export function dftGrpOpenSelectItem(openItemModal: Fn) {
  openItemModal(true, {
    title: '物料列表',
    schemas: [
      {
        field: 'ITEM_CODE',
        component: 'Input',
        label: '物料编码',
        colProps: {
          span: 12,
        },
      },
    ],
    ItemColumns: [
      {
        title: t('物料编码'),
        dataIndex: 'ITEM_CODE',
        resizable: true,
        sorter: true,
        width: 200,
      },
      {
        title: t('物料名称'),
        dataIndex: 'ITEM_NAME',
        resizable: true,
        sorter: true,
        width: 180,
      },
    ],
    tableName: 'BAS_ITEM',
    rowKey: 'ITEM_CODE',
    searchInfo: {TABLE_NAME: 'BAS_ITEM'}
  });
}
 
/**
 * @description: 不良代码基本信息
 * @return {*}
 */
export const baseSchema: FormSchema[] = [
  {
    field: 'DFTG_CODE',
    label: '不良代码组编码',
    component: 'Input',
    required: true,
    colProps: {
      span: 8,
    },
  },
  {
    label: '不良代码组名称',
    field: 'DFTG_NAME',
    required: true,
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
  {
    label: '备注',
    field: 'REMARK',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
  {
    label: 'ID',
    field: 'ID',
    component: 'Input',
    colProps: {
      span: 8,
    },
    show: false,
  },
];
 
export const searchSchema: FormSchema[] = [
  {
    field: 'DFT_CODE',
    label: '不良代码编码',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
  {
    label: '不良代码名称',
    field: 'DFT_NAME',
    component: 'Input',
    colProps: {
      span: 8,
    },
  },
];
 
/**
 * @description: 获取不良代码增删改表单
 * @return {*}
 */
export const crudSchema: FormSchema[] = [
  {
    field: 'DFT_CODE',
    label: '不良代码编码',
    component: 'Input',
    required: true,
    colProps: {
      span: 24,
    },
  },
  {
    label: '不良代码名称',
    field: 'DFT_NAME',
    component: 'Input',
    required: true,
    colProps: {
      span: 24,
    },
  },
  {
    label: '不良代码组编码',
    field: 'DFTG_CODE',
    component: 'ApiSelect',
    colProps: {
      span: 24,
    },
    componentProps: {
      api: getEntity,
      params: { entityName: 'BAS_DEFECT_GRP', sqlcmd: ' 1=1 ' },
      resultField: 'Data.Items',
      labelField: 'DFTG_NAME',
      valueField: 'DFTG_CODE',
    },
    dynamicDisabled: ({ values }) => {
      return true;
    },
  },
  {
    label: '缺陷等级',
    field: 'DFT_LEVEL',
    component: 'ApiSelect',
    required: true,
    colProps: {
      span: 24,
    },
    componentProps: {
      api: GetEnum,
      params: { name: 'BAS_DEFECT+DFT_LEVELs' },
      resultField: 'Data',
      labelField: unref(getLocale) == 'zh_CN' ? 'Desc' : 'Name',
      valueField: 'Value',
    },
  },
  {
    label: '备注',
    field: 'REMARK',
    component: 'Input',
    colProps: {
      span: 24,
    },
  },
  {
    label: 'ID',
    field: 'ID',
    component: 'Input',
    colProps: {
      span: 24,
    },
    show: false,
  },
];
 
/**
 * @description: 不良代码表格列
 * @return {*}
 */
export const defectBaseColumn: BasicColumn[] = [
  {
    title: '不良代码编码',
    dataIndex: 'DFT_CODE',
    // ifShow: false,
    width: 180,
  },
  {
    title: '不良代码名称',
    dataIndex: 'DFT_NAME',
  },
  {
    title: '缺陷等级',
    dataIndex: 'DFT_LEVEL',
    customRender: ({ record }) => {
      const type = record.DFT_LEVEL;
      var text = '';
      var color = 'green';
      switch (type) {
        case 0:
          text = '轻微缺陷';
          break;
        case 1:
          color = 'blue';
          text = '严重缺陷';
          break;
        case 2:
          color = 'red';
          text = '致命缺陷';
          break;
      }
      return h(Tag, { color: color }, () => text);
    },
  },
  {
    title: '不良代码组编码',
    dataIndex: 'DFTG_CODE',
  },
  {
    title: '备注',
    dataIndex: 'REMARK',
  },
  {
    title: '更新时间',
    dataIndex: 'UPDATE_TIME',
  },
  {
    title: '更新人',
    dataIndex: 'UPDATE_USER',
  },
];