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

export const columns = [
  {
    title: '部门名称',
    dataIndex: 'name',
    key: 'name',
    width: 200,
  },
  {
    title: '部门类型',
    dataIndex: 'type',
    key: 'type',
    width: 100,
    customRender({ record }) {
      let typeText = '';
      let color = '';
      switch (record.type) {
        case 1:
          typeText = '公司';
          color = 'processing';
          break;
        case 2:
          typeText = '子公司';
          color = 'success';
          break;
        case 3:
          typeText = '部门';
          color = 'warning';
          break;
        case 4:
          typeText = '小组';
          color = 'default';
          break;
        default:
          break;
      }
      return h(
        Tag,
        {
          color: color,
        },
        {
          default: () => typeText,
        },
      );
    },
  },
  {
    title: '部门排序',
    dataIndex: 'sort',
    key: 'sort',
    width: 100,
  },
  {
    title: '部门备注',
    dataIndex: 'note',
    key: 'note',
    width: 100,
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    key: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    key: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
