zhou zhou
43 分钟以前 e12fb4e6e8e0a408e81ce05a269a15cc535d8c78
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
import { h } from 'vue'
import { ElTag } from 'element-plus'
import ArtButtonMore from '@/components/core/forms/art-button-more/index.vue'
import { getCompanysStatusMeta } from './companysPage.helpers'
 
export function createCompanysTableColumns({
  handleView,
  handleEdit,
  handleDelete,
  canEdit = true,
  canDelete = true,
  resolveTypeLabel
} = {}) {
  const operations = [{ key: 'view', label: '详情', icon: 'ri:eye-line' }]
 
  if (canEdit && handleEdit) {
    operations.push({ key: 'edit', label: '编辑', icon: 'ri:pencil-line' })
  }
 
  if (canDelete && handleDelete) {
    operations.push({ key: 'delete', label: '删除', icon: 'ri:delete-bin-5-line', color: 'var(--art-error)' })
  }
 
  return [
    { type: 'selection', width: 48, align: 'center' },
    { type: 'globalIndex', label: '序号', width: 72, align: 'center' },
    { prop: 'code', label: '企业编码', minWidth: 140, showOverflowTooltip: true, formatter: (row) => row.code || '--' },
    { prop: 'name', label: '企业名称', minWidth: 170, showOverflowTooltip: true, formatter: (row) => row.name || '--' },
    { prop: 'nameEn', label: '英文别名', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.nameEn || '--' },
    { prop: 'breifCode', label: '助记码', minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.breifCode || '--' },
    {
      prop: 'typeText',
      label: '企业类型',
      minWidth: 140,
      showOverflowTooltip: true,
      formatter: (row) =>
        row.typeText || (typeof resolveTypeLabel === 'function' ? resolveTypeLabel(row.type) : '') || '--'
    },
    { prop: 'contact', label: '联系人', minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.contact || '--' },
    { prop: 'tel', label: '联系电话', minWidth: 140, showOverflowTooltip: true, formatter: (row) => row.tel || '--' },
    { prop: 'email', label: '邮箱', minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.email || '--' },
    { prop: 'pcode', label: '邮编', minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.pcode || '--' },
    { prop: 'province', label: '省份', minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.province || '--' },
    { prop: 'city', label: '城市', minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.city || '--' },
    { prop: 'address', label: '地址', minWidth: 220, showOverflowTooltip: true, formatter: (row) => row.address || '--' },
    {
      prop: 'status',
      label: '状态',
      width: 100,
      align: 'center',
      formatter: (row) => {
        const statusMeta = getCompanysStatusMeta(row.statusBool ?? row.status)
        return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => statusMeta.text)
      }
    },
    { prop: 'memo', label: '备注', minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.memo || '--' },
    {
      prop: 'createByText',
      label: '创建人',
      minWidth: 120,
      showOverflowTooltip: true,
      formatter: (row) => row.createByText || row.createBy$ || '--'
    },
    {
      prop: 'createTimeText',
      label: '创建时间',
      minWidth: 170,
      showOverflowTooltip: true,
      formatter: (row) => row.createTimeText || row.createTime$ || '--'
    },
    {
      prop: 'updateByText',
      label: '更新人',
      minWidth: 120,
      showOverflowTooltip: true,
      formatter: (row) => row.updateByText || row.updateBy$ || '--'
    },
    {
      prop: 'updateTimeText',
      label: '更新时间',
      minWidth: 170,
      showOverflowTooltip: true,
      formatter: (row) => row.updateTimeText || row.updateTime$ || '--'
    },
    {
      prop: 'operation',
      label: '操作',
      width: 120,
      align: 'center',
      fixed: 'right',
      formatter: (row) =>
        h(ArtButtonMore, {
          list: operations,
          onClick: (item) => {
            if (item.key === 'view') handleView?.(row)
            if (item.key === 'edit') handleEdit?.(row)
            if (item.key === 'delete') handleDelete?.(row)
          }
        })
    }
  ]
}