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: 'name',
    width: 100,
  },
  {
    title: '配置项编码',
    key: 'code',
    width: 100,
  },
  {
    title: '配置项值',
    key: 'value',
    width: 100,
  },
  {
    title: '配置项类型',
    key: 'type',
    width: 100,
    render(record) {
      let typeText = '';
      switch (record.type) {
        case 'hidden':
          typeText = '隐藏';
          break;
        case 'readonly':
          typeText = '只读文本';
          break;
        case 'number':
          typeText = '数字';
          break;
        case 'text':
          typeText = '单行文本';
          break;
        case 'textarea':
          typeText = '多行文本';
          break;
        case 'password':
          typeText = '密码';
          break;
        case 'radio':
          typeText = '单选框';
          break;
        case 'checkbox':
          typeText = '复选框';
          break;
        case 'select':
          typeText = '下拉框(单选)';
          break;
        case 'selects':
          typeText = '下拉框(多选)';
          break;
        case 'icon':
          typeText = '字体图标';
          break;
        case 'date':
          typeText = '日期';
          break;
        case 'datetime':
          typeText = '时间';
          break;
        case 'image':
          typeText = '单张图片';
          break;
        case 'images':
          typeText = '多张图片';
          break;
        case 'file':
          typeText = '单个文件';
          break;
        case 'files':
          typeText = '多个文件';
          break;
        case 'ueditor':
          typeText = '富文本编辑器';
          break;
        default:
          break;
      }
      return h('span', typeText || '-');
    },
  },
  {
    title: '配置项状态',
    key: 'status',
    width: 100,
    render(record) {
      return h(
        NTag,
        {
          type: record.status == 1 ? 'success' : 'error',
        },
        {
          default: () => (record.status == 1 ? '正常' : '停用'),
        },
      );
    },
  },
];
