Ben Lin
2024-06-02 6adf0062e368dae083b1f15df39f0a38f425013c
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
import { DftGrpRelease, dftGrpactionColumn } from './basDefectGrp';
import { DeleteEntity } from '/@/api/tigerapi/system';
import { ActionItem, BasicColumn } from '/@/components/Table';
 
export function GetActionsData(params: {}, ...args: Fn[]) {
  let data = [
    {
      icon: 'clarity:note-edit-line',
      onClick: editRecord.bind(null, args[0], params),
    },
    {
      icon: 'ant-design:delete-outlined',
      color: 'error',
      popConfirm: {
        title: '是否确认删除?',
        placement: 'left',
        confirm: deleteRecord.bind(null, args[1], params),
      },
    },
  ] as ActionItem[];
  switch (params.entityName) {
    case 'BAS_DEFECT_GRP':
      const _d = [
        // {
        //   icon: 'release|svg',
        //   tooltip: '下发',
        //   onClick: DftGrpRelease.bind(null, args[1], params),
        // },
      ];
      data = [...data, ..._d];
      break;
  }
  return data;
}
 
function editRecord(fn: Fn, params: {}) {
  fn(true, params);
}
 
function deleteRecord(fn: Fn, params: {}) {
  console.log(params.record);
  //删除
  const apiAction = DeleteEntity(params.record, params.entityName);
  apiAction.then((action) => {
    if (action.IsSuccessed) {
      fn();
    }
  });
}
 
export function GetActionColumn(entityName: string) {
  let data: BasicColumn = {};
  switch (entityName) {
    case 'BAS_DEFECT_GRP':
      data = dftGrpactionColumn;
      break;
    default:
      data = {
        width: 80,
        title: '操作',
        dataIndex: 'action',
        slots: { customRender: 'action' },
        fixed: undefined,
      };
      break;
  }
  return data;
}