import { globalOption } from '@/const/globalOption';
/**
 * @数据映射
 */
// 数据显示的映射
export const typeMap = {
  INTEGER: 'INT',
  DOUBLE: 'DOU',
  STRING: 'STR',
  LONG: 'LONG',
  FLOAT: 'FLOAT',
  DATE: 'DATE',
  TIMESTAMP: 'TS',
  DATETIME: 'DT',
  BOOLEAN: 'BOOL',
  ARRAY: 'ARR',
  OBJECT: 'OBJ',
};
export const dataTypeDict = [
  {
    label: '整数',
    value: 'INTEGER',
  },
  {
    label: '浮点数',
    value: 'DOUBLE',
  },
  {
    label: '字符串',
    value: 'STRING',
  },
  {
    label: '布尔值',
    value: 'BOOLEAN',
  },
  {
    label: '数组',
    value: 'ARRAY',
  },
  {
    label: '对象',
    value: 'OBJECT',
  },
  {
    label: '日期',
    value: 'DATE',
  },
  {
    label: '日期时间',
    value: 'DATETIME',
  },
  {
    label: '时间戳',
    value: 'TIMESTAMP',
  },
];

// 显示查看表单
export const showOption = {
  ...globalOption,
  minHeight: '100',
  calcHeight: 30,
  tip: false,
  searchShow: false,
  searchMenuSpan: 24,
  addBtn: false,
  viewBtn: false,
  selection: false,
  editBtn: false,
  delBtn: false,
  dialogClickModal: false,
  header: false,
  dialogWidth: '50%',
  menuWidth: 60,
  // dialogFullscreen: true,
  column: [
    {
      label: '名称',
      prop: 'ident',
      span: 12,
      trigger: 'blur',
      placeholder: '请输入名称',
      rules: [
        { required: true, message: '名称不能为空' },
        { pattern: /^[a-z][a-zA-Z0-9]*$/, message: '名称符需要为首字母小写的驼峰命名法' },
        { max: 50, message: '名称最长为50个字符' },
      ],
    },
    {
      label: '数据类型',
      prop: 'type',
      type: 'select',
      placeholder: '请选择数据类型',
      dicData: dataTypeDict,
      trigger: 'blur',
      rules: [{ required: true, message: '数据类型不能为空' }],
    },
    // 需要加上change
    {
      label: '数组类型',
      prop: 'generic',
      slot: true,
      formSlot: true,
      placeholder: '请选择数组类型',
      dicData: dataTypeDict.filter((item) => item.value !== 'ARRAY'),
      rules: [{ required: true, message: '数组类型不能为空' }],
    },
    {
      label: '参数描述',
      prop: 'desc',
    },
  ],
};
