| | |
| | | import { h } from 'vue' |
| | | import { ElTag } from 'element-plus' |
| | | import ArtButtonMore from '@/components/core/forms/art-button-more/index.vue' |
| | | import { $t } from '@/locales' |
| | | import { getCompanysStatusMeta } from './companysPage.helpers' |
| | | |
| | | export function createCompanysTableColumns({ |
| | | t = $t, |
| | | handleView, |
| | | handleEdit, |
| | | handleDelete, |
| | |
| | | canDelete = true, |
| | | resolveTypeLabel |
| | | } = {}) { |
| | | const operations = [{ key: 'view', label: '详情', icon: 'ri:eye-line' }] |
| | | const operations = [{ key: 'view', label: $t('common.actions.detail'), icon: 'ri:eye-line' }] |
| | | |
| | | if (canEdit && handleEdit) { |
| | | operations.push({ key: 'edit', label: '编辑', icon: 'ri:pencil-line' }) |
| | | operations.push({ key: 'edit', label: $t('common.actions.edit'), icon: 'ri:pencil-line' }) |
| | | } |
| | | |
| | | if (canDelete && handleDelete) { |
| | | operations.push({ key: 'delete', label: '删除', icon: 'ri:delete-bin-5-line', color: 'var(--art-error)' }) |
| | | 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: '序号', 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 || '--' }, |
| | | { type: 'globalIndex', label: $t('table.index'), width: 72, align: 'center' }, |
| | | { prop: 'code', label: $t('pages.basicInfo.companys.table.code'), minWidth: 140, showOverflowTooltip: true, formatter: (row) => row.code || '--' }, |
| | | { prop: 'name', label: $t('pages.basicInfo.companys.table.name'), minWidth: 170, showOverflowTooltip: true, formatter: (row) => row.name || '--' }, |
| | | { prop: 'nameEn', label: $t('pages.basicInfo.companys.table.nameEn'), minWidth: 160, showOverflowTooltip: true, formatter: (row) => row.nameEn || '--' }, |
| | | { prop: 'breifCode', label: $t('pages.basicInfo.companys.table.briefCode'), minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.breifCode || '--' }, |
| | | { |
| | | prop: 'typeText', |
| | | label: '企业类型', |
| | | label: $t('pages.basicInfo.companys.table.type'), |
| | | 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: 'contact', label: $t('pages.basicInfo.companys.table.contact'), minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.contact || '--' }, |
| | | { prop: 'tel', label: $t('pages.basicInfo.companys.table.tel'), minWidth: 140, showOverflowTooltip: true, formatter: (row) => row.tel || '--' }, |
| | | { prop: 'email', label: $t('pages.basicInfo.companys.table.email'), minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.email || '--' }, |
| | | { prop: 'pcode', label: $t('pages.basicInfo.companys.table.postCode'), minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.pcode || '--' }, |
| | | { prop: 'province', label: $t('pages.basicInfo.companys.table.province'), minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.province || '--' }, |
| | | { prop: 'city', label: $t('pages.basicInfo.companys.table.city'), minWidth: 120, showOverflowTooltip: true, formatter: (row) => row.city || '--' }, |
| | | { prop: 'address', label: $t('pages.basicInfo.companys.table.address'), minWidth: 220, showOverflowTooltip: true, formatter: (row) => row.address || '--' }, |
| | | { |
| | | prop: 'status', |
| | | label: '状态', |
| | | label: $t('table.status'), |
| | | width: 100, |
| | | align: 'center', |
| | | formatter: (row) => { |
| | | const statusMeta = getCompanysStatusMeta(row.statusBool ?? row.status) |
| | | return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => statusMeta.text) |
| | | return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => |
| | | statusMeta.textKey ? t(statusMeta.textKey) : statusMeta.fallback |
| | | ) |
| | | } |
| | | }, |
| | | { prop: 'memo', label: '备注', minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.memo || '--' }, |
| | | { prop: 'memo', label: $t('table.remark'), minWidth: 180, showOverflowTooltip: true, formatter: (row) => row.memo || '--' }, |
| | | { |
| | | prop: 'createByText', |
| | | label: '创建人', |
| | | label: $t('table.createBy'), |
| | | minWidth: 120, |
| | | showOverflowTooltip: true, |
| | | formatter: (row) => row.createByText || row.createBy$ || '--' |
| | | }, |
| | | { |
| | | prop: 'createTimeText', |
| | | label: '创建时间', |
| | | label: $t('table.createTime'), |
| | | minWidth: 170, |
| | | showOverflowTooltip: true, |
| | | formatter: (row) => row.createTimeText || row.createTime$ || '--' |
| | | }, |
| | | { |
| | | prop: 'updateByText', |
| | | label: '更新人', |
| | | label: $t('table.updateBy'), |
| | | minWidth: 120, |
| | | showOverflowTooltip: true, |
| | | formatter: (row) => row.updateByText || row.updateBy$ || '--' |
| | | }, |
| | | { |
| | | prop: 'updateTimeText', |
| | | label: '更新时间', |
| | | label: $t('table.updateTime'), |
| | | minWidth: 170, |
| | | showOverflowTooltip: true, |
| | | formatter: (row) => row.updateTimeText || row.updateTime$ || '--' |
| | | }, |
| | | { |
| | | prop: 'operation', |
| | | label: '操作', |
| | | label: $t('table.operation'), |
| | | width: 120, |
| | | align: 'center', |
| | | fixed: 'right', |