zhou zhou
21 小时以前 6877c9caa25162e570a3e2a99a5b2ce3ef88368b
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
import { h } from 'vue'
import { ElTag } from 'element-plus'
import ArtButtonTable from '@/components/core/forms/art-button-table/index.vue'
import { $t } from '@/locales'
 
export function createDictTypeTableColumns({
  handleView,
  handleEdit,
  handleDelete,
  handleManageData,
  t = $t
}) {
  const hasStandaloneView = !handleManageData && handleView
 
  return [
    {
      prop: 'code',
      label: t('table.code'),
      minWidth: 180,
      showOverflowTooltip: true
    },
    {
      prop: 'name',
      label: t('table.name'),
      minWidth: 180,
      showOverflowTooltip: true
    },
    {
      prop: 'description',
      label: t('pages.system.dictType.table.description'),
      minWidth: 220,
      showOverflowTooltip: true,
      formatter: (row) => row.description || t('common.placeholder.empty')
    },
    {
      prop: 'status',
      label: t('table.status'),
      width: 100,
      formatter: (row) =>
        h(
          ElTag,
          { type: row.statusType, effect: 'light' },
          () => row.statusText || t('common.placeholder.empty')
        )
    },
    {
      prop: 'updateByLabel',
      label: t('table.updateBy'),
      width: 120,
      formatter: (row) => row.updateByLabel || t('common.placeholder.empty')
    },
    {
      prop: 'updateTimeText',
      label: t('table.updateTime'),
      minWidth: 180,
      formatter: (row) => row.updateTimeText || t('common.placeholder.empty')
    },
    {
      prop: 'operation',
      label: t('table.operation'),
      width: handleDelete ? (hasStandaloneView ? 200 : 240) : hasStandaloneView ? 160 : 200,
      align: 'center',
      formatter: (row) => {
        const buttons = []
 
        if (handleManageData) {
          buttons.push(
            h(ArtButtonTable, {
              type: 'view',
              onClick: () => handleManageData(row)
            })
          )
        }
 
        if (hasStandaloneView) {
          buttons.push(
            h(ArtButtonTable, {
              type: 'view',
              onClick: () => handleView(row)
            })
          )
        }
 
        buttons.push(
          h(ArtButtonTable, {
            type: 'edit',
            onClick: () => handleEdit(row)
          })
        )
 
        if (handleDelete) {
          buttons.push(
            h(ArtButtonTable, {
              type: 'delete',
              onClick: () => handleDelete(row)
            })
          )
        }
 
        return h('div', { class: 'flex items-center justify-center gap-2' }, buttons)
      }
    }
  ]
}