import { h } from 'vue' import { ElTag } from 'element-plus' import ArtButtonMore from '@/components/core/forms/art-button-more/index.vue' import { getLocAreaMatRelaStatusMeta } from './locAreaMatRelaPage.helpers' export function createLocAreaMatRelaTableColumns({ handleView, handleEdit, handleDelete, canEdit = true, canDelete = true } = {}) { 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: 'areaMatIdText', label: '主单', minWidth: 200, showOverflowTooltip: true, formatter: (row) => row.areaMatIdText || row.areaMatId || '--' }, { prop: 'areaIdText', label: '库区', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.areaIdText || '--' }, { prop: 'code', label: '编号', minWidth: 150, showOverflowTooltip: true, formatter: (row) => row.code || '--' }, { prop: 'matnrIdText', label: '物料', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.matnrIdText || '--' }, { prop: 'groupIdText', label: '物料分组', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.groupIdText || '--' }, { prop: 'locTypeIdText', label: '库位类型', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.locTypeIdText || '--' }, { prop: 'locIdText', label: '库位', minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.locIdText || '--' }, { prop: 'relationTypeText', label: '关系类型', width: 110, align: 'center', formatter: (row) => row.relationTypeText || '--' }, { prop: 'status', label: '状态', width: 96, align: 'center', formatter: (row) => { const meta = getLocAreaMatRelaStatusMeta(row.statusBool ?? row.status) return h(ElTag, { type: meta.type, effect: 'light' }, () => meta.text) } }, { prop: 'memo', label: '备注', minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.memo || '--' }, { prop: 'createTimeText', label: '创建时间', minWidth: 170, showOverflowTooltip: true, formatter: (row) => row.createTimeText || '--' }, { prop: 'updateTimeText', label: '更新时间', minWidth: 170, showOverflowTooltip: true, formatter: (row) => row.updateTimeText || '--' }, { 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) } }) } ] }