import { h } from 'vue';
import { BasicColumn } from '@/components/Table';
import { NTag } from 'naive-ui';
import { renderIcon } from '@/utils';
import * as VueIcon from '@vicons/antd';
const iconComponent = (icon) => {
  const IconComponent = renderIcon(VueIcon[icon]);
  return IconComponent;
};
export const columns: BasicColumn[] = [
  {
    title: '菜单名称',
    key: 'name',
    width: 200,
    align: 'left',
  },
  {
    title: '类型',
    key: 'type',
    width: 100,
    render(record) {
      return h(
        NTag,
        {
          type: record.type == 1 ? 'success' : 'info',
        },
        {
          default: () => (record.type == 1 ? '按钮' : '菜单'),
        },
      );
    },
  },
  {
    title: '图标',
    key: 'icon2',
    width: 100,
    render(record) {
      return h(iconComponent(record.icon2));
    },
  },
  {
    title: '权限标识',
    key: 'permission',
    width: 200,
  },
  {
    title: '状态',
    key: 'status',
    width: 100,
    render(record) {
      return h(
        NTag,
        {
          type: record.status == 0 ? 'info' : 'error',
        },
        {
          default: () => (record.status == 0 ? '正常' : '停用'),
        },
      );
    },
  },
  {
    title: '是否隐藏',
    key: 'type',
    width: 100,
    render(record) {
      return h(
        NTag,
        {
          type: record.hide == 0 ? 'success' : 'error',
        },
        {
          default: () => (record.hide == 0 ? '显示' : '隐藏'),
        },
      );
    },
  },
  {
    title: '排序',
    key: 'sort',
    width: 100,
  },
  {
    title: '更新时间',
    key: 'updateTime',
    width: 180,
  },
];
