Ben Lin
2024-06-24 c8f8a9c645f7857859a9d56fac96192d994be70b
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
/*
 * @Description: 不良代码组相关
 * @Author: Ben Lin
 * @version:
 * @Date: 2024-06-19 20:34:27
 * @LastEditors: Ben Lin
 * @LastEditTime: 2024-06-24 15:52:18
 */
 
import { ActionItem, BasicColumn } from '/@/components/Table';
import { buildUUID } from '/@/utils/uuid';
import { useI18n } from '/@/hooks/web/useI18n';
 
const { t } = useI18n();
function _default() {
  /**
   * @description: 自定义编辑方法
   * @param {Fn} args
   * @param {*} params
   * @return {*}
   */
  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))}`);
  }
 
  const ActionColumn: BasicColumn = {
    width: 100,
    title: '操作',
    dataIndex: 'action',
    slots: { customRender: 'action' },
    fixed: 'right',
  };
 
  const methods = {
    /**
     * @description: 获取新增按钮的行为
     * @return {*}
     */
    CreateAction: (fnName: string) => {
      return {
        action: 'go', //drawer(打开左侧抽屉框) | go(跳转到新的页面)
        url: 'BAS_DEFECT/High',
        params: {
          CODE: '0',
          ID: buildUUID(),
          Name: 'BAS_DEFECT',
          Title: '新增不良代码组',
          pCode: 'DFTG_CODE',
          IsID: false,
        },
      };
    },
    /**
     * @description: 产品绑定工艺路线操作字段自定义按钮
     * @return {*}
     */
    ActionItem: (params: Recordable<any>, data, ...args): ActionItem[] => {
      data[0].onClick = DftGrpEdit.bind(null, args, params);
      return data;
    },
    GetSelectSuccess:(d, u) => {
      return {
        ITEM_CODE: d.values['val'],
      };
    },
    OpenSelectItem:(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'}
      });
    }
  };
 
  return [methods, ActionColumn];
}
 
export default _default;