create.config.ts 1.37 KB
import { h } from 'vue';
import {
  SaveToCustomTableFieldsEnum,
  SaveToCustomTableFieldsNameEnum,
} from '../../../enum/formField/action';
import { AttributeConfiguration } from '../../../src/components/AttributeConfiguration';
import { FormSchema, useComponentRegister } from '/@/components/Form';
import { isObject } from '/@/utils/is';
import { useI18n } from '/@/hooks/web/useI18n';

const { t } = useI18n();

useComponentRegister('AttributeConfiguration', AttributeConfiguration);
export const formSchemas: FormSchema[] = [
  {
    field: SaveToCustomTableFieldsEnum.TABLE_NAME,
    component: 'Input',
    label: h('span', t(SaveToCustomTableFieldsNameEnum.TABLE_NAME)),
    required: true,
    componentProps: {
      placeholder: `请输入${SaveToCustomTableFieldsEnum.TABLE_NAME}`,
    },
  },
  {
    field: SaveToCustomTableFieldsEnum.FIELDS_MAPPING,
    component: 'AttributeConfiguration',
    label: h('span', t(SaveToCustomTableFieldsNameEnum.FIELDS_MAPPING)),
    required: true,
    valueField: 'value',
    changeEvent: 'update:value',
    rules: [
      {
        required: true,
        validator(_rule, value) {
          if (!isObject(value) || !Object.keys(value).length)
            return Promise.reject('至少应该指定一个字段映射。');
          return Promise.resolve();
        },
      },
    ],
    slot: SaveToCustomTableFieldsEnum.FIELDS_MAPPING,
  },
];