import { h } from 'vue';

export const columns = [
  {
    title: 'ID',
    dataIndex: 'id',
    width: 50,
  },
  {
    title: '数据源名称',
    dataIndex: 'name',
    width: 150,
  },
  {
    title: '数据库类型',
    dataIndex: 'dbType',
    width: 100,
    customRender({ record }) {
      let typeText = '';
      switch (record.dbType) {
        case 1:
          typeText = 'MySQL';
          break;
        case 2:
          typeText = 'PostgreSQL';
          break;
        case 3:
          typeText = 'SQLServer';
          break;
        case 4:
          typeText = 'Oracle';
          break;
        case 5:
          typeText = 'Sqlite';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    title: '数据源编码',
    dataIndex: 'code',
    width: 100,
  },
  {
    title: '数据库驱动类',
    dataIndex: 'dbDriver',
    width: 100,
  },
  {
    title: '数据源地址',
    dataIndex: 'dbUrl',
    width: 100,
  },
  {
    title: '数据库名称',
    dataIndex: 'dbName',
    width: 100,
  },
  {
    title: '数据库用户名',
    dataIndex: 'dbUsername',
    width: 100,
  },
  {
    title: '备注',
    dataIndex: 'note',
    width: 100,
  },
  {
    title: '创建人',
    dataIndex: 'createUser',
    width: 100,
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
  },
  {
    title: '操作',
    fixed: 'right',
    dataIndex: 'action',
    key: 'action',
    width: 200,
  },
];
