zhou zhou
2 天以前 50e95b985a72fcec4a93a2470e9efdfb2620148a
rsf-design/src/views/basic-info/loc/locTable.columns.js
@@ -1,7 +1,41 @@
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 { getLocStatusMeta, getLocUseStatusMeta } from './locPage.helpers'
function createTextColumn(prop, label, minWidth, formatter) {
  return {
    prop,
    label,
    minWidth,
    showOverflowTooltip: true,
    formatter: formatter || ((row) => row[prop] || '--')
  }
}
function createNumberColumn(prop, label, width) {
  return {
    prop,
    label,
    width,
    align: 'center',
    formatter: (row) => row[prop] ?? '--'
  }
}
function createTagColumn(prop, label, width, resolveMeta) {
  return {
    prop,
    label,
    width,
    align: 'center',
    formatter: (row) => {
      const statusMeta = resolveMeta(row)
      return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => statusMeta.text)
    }
  }
}
export function createLocTableColumns({
  handleView,
@@ -10,135 +44,40 @@
  canEdit = true,
  canDelete = true
} = {}) {
  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: 160,
      showOverflowTooltip: true,
      formatter: (row) => row.code || '--'
    },
    {
      prop: 'warehouseName',
      label: '仓库',
      minWidth: 150,
      showOverflowTooltip: true,
      formatter: (row) => row.warehouseName || row.warehouseId$ || '--'
    },
    {
      prop: 'areaName',
      label: '库区',
      minWidth: 150,
      showOverflowTooltip: true,
      formatter: (row) => row.areaName || row.areaId$ || '--'
    },
    {
      prop: 'typeIdsText',
      label: '库位类型',
      minWidth: 180,
      showOverflowTooltip: true,
      formatter: (row) => row.typeIdsText || '--'
    },
    {
      prop: 'row',
      label: '排',
      width: 80,
      align: 'center',
      formatter: (row) => row.row ?? '--'
    },
    {
      prop: 'col',
      label: '列',
      width: 80,
      align: 'center',
      formatter: (row) => row.col ?? '--'
    },
    {
      prop: 'lev',
      label: '层',
      width: 80,
      align: 'center',
      formatter: (row) => row.lev ?? '--'
    },
    {
      prop: 'channel',
      label: '巷道',
      width: 90,
      align: 'center',
      formatter: (row) => row.channel ?? '--'
    },
    {
      prop: 'useStatus',
      label: '使用状态',
      width: 110,
      align: 'center',
      formatter: (row) => {
        const statusMeta = getLocUseStatusMeta(row.useStatus)
        return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => statusMeta.text)
      }
    },
    {
      prop: 'flagLogicText',
      label: '虚拟库位',
      width: 110,
      align: 'center',
      formatter: (row) => row.flagLogicText || '--'
    },
    {
      prop: 'flagLabelMangeText',
      label: '标签管理',
      width: 110,
      align: 'center',
      formatter: (row) => row.flagLabelMangeText || '--'
    },
    {
      prop: 'barcode',
      label: '容器编码',
      minWidth: 150,
      showOverflowTooltip: true,
      formatter: (row) => row.barcode || '--'
    },
    {
      prop: 'status',
      label: '状态',
      width: 100,
      align: 'center',
      formatter: (row) => {
        const statusMeta = getLocStatusMeta(row.statusBool ?? row.status)
        return h(ElTag, { type: statusMeta.type, effect: 'light' }, () => statusMeta.text)
      }
    },
    {
      prop: 'updateTimeText',
      label: '更新时间',
      minWidth: 170,
      showOverflowTooltip: true,
      formatter: (row) => row.updateTimeText || row.updateTime$ || '--'
    },
    {
      prop: 'memo',
      label: '备注',
      minWidth: 180,
      showOverflowTooltip: true,
      formatter: (row) => row.memo || '--'
    },
    { type: 'globalIndex', label: $t('table.index'), width: 72, align: 'center' },
    createTextColumn('code', $t('pages.basicInfo.loc.table.code'), 160),
    createTextColumn('warehouseName', $t('pages.basicInfo.loc.table.warehouseName'), 150, (row) => row.warehouseName || row.warehouseId$ || '--'),
    createTextColumn('areaName', $t('pages.basicInfo.loc.table.areaName'), 150, (row) => row.areaName || row.areaId$ || '--'),
    createTextColumn('typeIdsText', $t('pages.basicInfo.loc.table.typeIds'), 180),
    createNumberColumn('row', $t('pages.basicInfo.loc.table.row'), 80),
    createNumberColumn('col', $t('pages.basicInfo.loc.table.col'), 80),
    createNumberColumn('lev', $t('pages.basicInfo.loc.table.lev'), 80),
    createNumberColumn('channel', $t('pages.basicInfo.loc.table.channel'), 90),
    createTagColumn('useStatus', $t('pages.basicInfo.loc.table.useStatus'), 110, (row) => getLocUseStatusMeta(row.useStatus)),
    createTextColumn('flagLogicText', $t('pages.basicInfo.loc.table.flagLogic'), 110),
    createTextColumn('flagLabelMangeText', $t('pages.basicInfo.loc.table.flagLabelManage'), 110),
    createTextColumn('barcode', $t('pages.basicInfo.loc.table.barcode'), 150),
    createTagColumn('status', $t('table.status'), 100, (row) => getLocStatusMeta(row.statusBool ?? row.status)),
    createTextColumn('updateTimeText', $t('table.updateTime'), 170, (row) => row.updateTimeText || row.updateTime$ || '--'),
    createTextColumn('memo', $t('table.remark'), 180),
    {
      prop: 'operation',
      label: '操作',
      width: 160,
      align: 'right',
      label: $t('table.operation'),
      width: 120,
      align: 'center',
      fixed: 'right',
      formatter: (row) =>
        h(ArtButtonMore, {
          list: operations,