/**
 * 应急物资表格配置
 */
import type { TableColumnProps } from '@/types/basic-table';

export const SUPPLY_LIST_TABLE_MAX_HEIGHT_DEFAULT = 'calc(70vh - 100px)';
export const SUPPLY_LIST_TABLE_MAX_HEIGHT_PERMISSION = 'calc(70vh - 150px)';

// 基础表格样式配置
const TABLE_OPTIONS = {
  emptyText: '暂无数据',
  loading: true,
};

// 应急物资表格样式配置
export const SUPPLY_LIST_TABLE_OPTIONS = {
  ...TABLE_OPTIONS,
};

// 基础表格配置
const BASIC_TABLE_COLUMNS = {
  INDEX: {
    prop: 'index',
    label: '序号',
    width: '80px',
    type: 'index',
    align: 'center',
  },
  EMERGENCY_TYPE: {
    prop: 'emergencyType',
    label: '应急类型',
    slot: 'emergencyType',
    minWidth: '140px',
  },
  SUPPLY_TYPE: {
    prop: 'supplyType',
    label: '物资类型',
    slot: 'supplyType',
    minWidth: '140px',
  },
  SUPPLY_NAME: {
    prop: 'supplyName',
    label: '应急物资名称',
    minWidth: '140px',
  },
  PARK: {
    label: '园区',
    slot: 'park',
    minWidth: '140px',
  },
  REMARK: {
    prop: 'remark',
    label: '备注',
    width: '200px',
    slot: 'remark',
  },
  ACTION: {
    prop: 'action',
    label: '操作',
    align: 'center',
    slot: 'action',
    fixed: 'right',
    width: '250px',
  },
};

// 应急物资表格列配置
export const SUPPLY_LIST_TABLE_COLUMNS: TableColumnProps[] = [
  BASIC_TABLE_COLUMNS.INDEX,
  BASIC_TABLE_COLUMNS.EMERGENCY_TYPE,
  BASIC_TABLE_COLUMNS.SUPPLY_TYPE,
  BASIC_TABLE_COLUMNS.SUPPLY_NAME,
  {
    label: '应备数量',
    prop: 'requiredQuantity',
    minWidth: '120px',
  },
  {
    label: '当前数量',
    prop: 'currentQuantity',
    minWidth: '120px',
  },
  {
    label: '数量单位',
    prop: 'unit',
    minWidth: '120px',
  },
  BASIC_TABLE_COLUMNS.PARK,
  {
    label: '地点',
    prop: 'location',
    slot: 'location',
    minWidth: '120px',
  },
  {
    label: '保管人',
    prop: 'keeperName',
    minWidth: '120px',
  },
  {
    label: '使用期限',
    prop: 'expirationDate',
    minWidth: '200px',
  },
  {
    label: '状态',
    prop: 'status',
    slot: 'status',
    minWidth: '120px',
  },
  {
    label: '需补充数量',
    prop: 'supplementQuantity',
    minWidth: '120px',
  },
  BASIC_TABLE_COLUMNS.REMARK,
  BASIC_TABLE_COLUMNS.ACTION,
];

// 变更记录表格配置
export const CHANGE_RECORD_TABLE_COLUMNS: TableColumnProps[] = [
  BASIC_TABLE_COLUMNS.INDEX,
  {
    label: '类型',
    prop: 'changeType',
    slot: 'changeType',
    minWidth: '120px',
  },
  {
    label: '详情',
    prop: 'detail',
    minWidth: '120px',
  },
  {
    label: '变更数量',
    prop: 'changeQuantity',
    slot: 'changeQuantity',
    minWidth: '120px',
  },
  {
    label: '变更后数量',
    prop: 'afterQuantity',
    minWidth: '120px',
  },
  {
    label: '变更人',
    prop: 'operatorName',
  },
  {
    label: '变更时间',
    prop: 'updatedAt',
  },
];

export const CHANGE_RECORD_TABLE_OPTIONS = {
  ...TABLE_OPTIONS,
  maxHeight: 'calc(90vh - 150px)',
};

// 物资盘点表格列配置
export const INVENTORY_CHECK_TABLE_COLUMNS: TableColumnProps[] = [
  BASIC_TABLE_COLUMNS.INDEX,
  BASIC_TABLE_COLUMNS.EMERGENCY_TYPE,
  BASIC_TABLE_COLUMNS.SUPPLY_TYPE,
  BASIC_TABLE_COLUMNS.SUPPLY_NAME,
  {
    label: '保管人',
    align: 'center',
    children: [
      {
        label: '盘点前',
        prop: 'beforeKeeperName',
        minWidth: '120px',
      },
      {
        label: '盘点后',
        slot: 'afterKeeperName',
        minWidth: '120px',
      },
    ],
  },
  {
    label: '数量',
    align: 'center',
    children: [
      {
        label: '盘点前',
        prop: 'beforeQuantity',
        minWidth: '120px',
      },
      {
        label: '盘点后',
        slot: 'afterQuantity',
        minWidth: '120px',
      },
      {
        label: '需补充',
        slot: 'supplementQuantity',
        minWidth: '120px',
      },
    ],
  },
  BASIC_TABLE_COLUMNS.PARK,
  {
    label: '地点',
    align: 'center',
    children: [
      {
        label: '盘点前',
        slot: 'beforeLocation',
        minWidth: '120px',
      },
      {
        label: '盘点后',
        slot: 'afterLocation',
        minWidth: '120px',
      },
    ],
  },
  {
    label: '盘点结果',
    slot: 'inventoryResult',
    minWidth: '120px',
  },
  BASIC_TABLE_COLUMNS.REMARK,
  {
    label: '盘点照片',
    slot: 'imageList',
    minWidth: '120px',
    align: 'center',
    fixed: 'right',
  },
];

export const INVENTORY_CHECK_TABLE_MAX_HEIGHT_DEFAULT = 'calc(70vh - 100px)';
export const INVENTORY_CHECK_TABLE_MAX_HEIGHT_PERMISSION = 'calc(70vh - 150px)';

export const INVENTORY_CHECK_TABLE_OPTIONS = {
  ...TABLE_OPTIONS,
};

// 物资申领表格样式配置
export const SUPPLY_REQUEST_TABLE_OPTIONS = {
  ...TABLE_OPTIONS,
};

export const SUPPLY_REQUEST_TABLE_MAX_HEIGHT_DEFAULT = 'calc(70vh - 100px)';
export const SUPPLY_REQUEST_TABLE_MAX_HEIGHT_PERMISSION = 'calc(70vh - 150px)';

// 物资申领表格列配置
export const SUPPLY_REQUEST_TABLE_COLUMNS: TableColumnProps[] = [
  BASIC_TABLE_COLUMNS.INDEX,
  {
    label: '物资申领计划',
    prop: 'planName',
    minWidth: '200px',
  },
  {
    label: '采购日期',
    prop: 'purchaseDate',
    width: '180px',
  },
  {
    label: '总价（元）',
    prop: 'totalPrice',
    minWidth: '140px',
  },
  {
    label: '状态',
    prop: 'status',
    slot: 'status',
    minWidth: '120px',
  },
  BASIC_TABLE_COLUMNS.ACTION,
];
