import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns = [
  {
    title: '菜单名称',
    dataIndex: 'name',
    key: 'name',
    width: 250,
  },
  {
    title: '类型',
    dataIndex: 'type',
    key: 'type',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.type == 1 ? 'success' : 'processing',
        },
        {
          default: () => (record.type == 1 ? '按钮' : '菜单'),
        },
      );
    },
  },
  {
    title: '图标',
    dataIndex: 'icon2',
    key: 'icon2',
    width: 100,
  },
  {
    title: '权限标识',
    dataIndex: 'permission',
    key: 'permission',
    width: 200,
  },
  {
    title: '状态',
    dataIndex: 'status',
    key: 'status',
    width: 100,
    customRender(row) {
      return h(
        Tag,
        {
          color: row.record.status == 0 ? 'processing' : 'error',
        },
        {
          default: () => (row.record.status == 0 ? '正常' : '停用'),
        },
      );
    },
  },
  {
    title: '是否隐藏',
    dataIndex: 'type',
    key: 'type',
    width: 100,
    customRender({ record }) {
      return h(
        Tag,
        {
          color: record.hide == 0 ? 'success' : 'error',
        },
        {
          default: () => (record.hide == 0 ? '显示' : '隐藏'),
        },
      );
    },
  },
  {
    title: '排序',
    dataIndex: 'sort',
    key: 'sort',
    width: 100,
  },
  {
    title: '更新时间',
    dataIndex: 'updateTime',
    key: 'updateTime',
    width: 180,
  },
  {
    title: '操作',
    width: 200,
    fixed: 'right',
    key: 'action',
    dataIndex: 'action',
  },
];
