import { h } from 'vue';
import { NTag } from 'naive-ui';

export const columns = [
  {
    type: 'selection',
    width: 50,
    fixed: 'left',
  },
  {
    title: 'ID',
    key: 'id',
    fixed: 'left',
    width: 50,
  },
  {
    title: '模板名称',
    key: 'title',
    width: 150,
  },
  {
    title: '模板编码',
    key: 'code',
    width: 150,
  },
  {
    title: '模板类型',
    key: 'type',
    width: 100,
    render(record) {
      let typeText = '';
      switch (record.type) {
        case 1:
          typeText = '普通邮件';
          break;
        case 2:
          typeText = '图文邮件';
          break;
        case 3:
          typeText = '模板文件';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    title: '文件名称',
    key: 'fileName',
    width: 100,
  },
  {
    title: '文件路径',
    key: 'filePath',
    width: 100,
    render(record) {
      return h(
        'a',
        {
          href: record.filePath,
          target: '_blank',
        },
        '点击查看文件',
      );
    },
  },
  {
    title: '创建人',
    key: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    key: 'createTime',
    width: 180,
  },
];
