import { h } from 'vue' import { ElTag } from 'element-plus' import ArtButtonMore from '@/components/core/forms/art-button-more/index.vue' import { $t } from '@/locales' export function createContractTableColumns({ handleView, handleEdit, handleDelete, canEdit = true, canDelete = true }) { const operations = [{ key: 'view', label: $t('common.actions.detail'), icon: 'ri:eye-line' }] if (canEdit && handleEdit) { operations.push({ key: 'edit', label: $t('common.actions.edit'), icon: 'ri:pencil-line' }) } if (canDelete && handleDelete) { operations.push({ key: 'delete', label: $t('common.actions.delete'), icon: 'ri:delete-bin-5-line', color: 'var(--art-error)' }) } return [ { type: 'selection', width: 48, align: 'center' }, { type: 'globalIndex', label: $t('table.index'), width: 72, align: 'center' }, { prop: 'code', label: $t('pages.basicInfo.contract.table.code'), minWidth: 160, showOverflowTooltip: true }, { prop: 'name', label: $t('pages.basicInfo.contract.table.name'), minWidth: 180, showOverflowTooltip: true }, { prop: 'projectName', label: $t('pages.basicInfo.contract.table.projectName'), minWidth: 180, showOverflowTooltip: true }, { prop: 'status', label: $t('table.status'), width: 100, align: 'center', formatter: (row) => h(ElTag, { type: row.statusType || 'info', effect: 'light' }, () => row.statusText || '--') }, { prop: 'updateByText', label: $t('table.updateBy'), minWidth: 120, showOverflowTooltip: true }, { prop: 'updateTimeText', label: $t('table.updateTime'), minWidth: 170, showOverflowTooltip: true }, { prop: 'createByText', label: $t('table.createBy'), minWidth: 120, showOverflowTooltip: true }, { prop: 'createTimeText', label: $t('table.createTime'), minWidth: 170, showOverflowTooltip: true }, { prop: 'memo', label: $t('table.remark'), minWidth: 200, showOverflowTooltip: true }, { prop: 'operation', label: $t('table.operation'), 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) } }) } ] }