zhou zhou
9 天以前 6877c9caa25162e570a3e2a99a5b2ce3ef88368b
rsf-design/src/views/system/dict-type/dictTypeTable.columns.js
@@ -1,62 +1,92 @@
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 }) {
export function createDictTypeTableColumns({
  handleView,
  handleEdit,
  handleDelete,
  handleManageData,
  t = $t
}) {
  const hasStandaloneView = !handleManageData && handleView
  return [
    {
      prop: 'code',
      label: '编码',
      label: t('table.code'),
      minWidth: 180,
      showOverflowTooltip: true
    },
    {
      prop: 'name',
      label: '名称',
      label: t('table.name'),
      minWidth: 180,
      showOverflowTooltip: true
    },
    {
      prop: 'description',
      label: '描述',
      label: t('pages.system.dictType.table.description'),
      minWidth: 220,
      showOverflowTooltip: true,
      formatter: (row) => row.description || '-'
      formatter: (row) => row.description || t('common.placeholder.empty')
    },
    {
      prop: 'status',
      label: '状态',
      label: t('table.status'),
      width: 100,
      formatter: (row) => h(ElTag, { type: row.statusType, effect: 'light' }, () => row.statusText || '-')
      formatter: (row) =>
        h(
          ElTag,
          { type: row.statusType, effect: 'light' },
          () => row.statusText || t('common.placeholder.empty')
        )
    },
    {
      prop: 'updateByLabel',
      label: '更新人',
      label: t('table.updateBy'),
      width: 120,
      formatter: (row) => row.updateByLabel || '-'
      formatter: (row) => row.updateByLabel || t('common.placeholder.empty')
    },
    {
      prop: 'updateTimeText',
      label: '更新时间',
      label: t('table.updateTime'),
      minWidth: 180,
      formatter: (row) => row.updateTimeText || '-'
      formatter: (row) => row.updateTimeText || t('common.placeholder.empty')
    },
    {
      prop: 'operation',
      label: '操作',
      width: handleDelete ? 160 : 120,
      align: 'right',
      label: t('table.operation'),
      width: handleDelete ? (hasStandaloneView ? 200 : 240) : hasStandaloneView ? 160 : 200,
      align: 'center',
      formatter: (row) => {
        const buttons = [
          h(ArtButtonTable, {
            type: 'view',
            onClick: () => handleView(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(
@@ -67,7 +97,7 @@
          )
        }
        return h('div', { class: 'flex justify-end' }, buttons)
        return h('div', { class: 'flex items-center justify-center gap-2' }, buttons)
      }
    }
  ]