import type { FormSchema } from '/@/components/Form/index';

export const schemas: FormSchema[] = [
  {
    field: 'name',
    component: 'Input',
    label: '平台名称',
    colProps: {
      span: 24,
    },
    componentProps: {
      maxLength: 255,
      placeholder: '请输入平台名称',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 255) {
              return Promise.reject('字数不超过255个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'logo',
    component: 'Upload',
    label: '平台Logo',
    colProps: {
      span: 24,
    },
    slot: 'logoUpload',
  },
  {
    field: 'icon',
    component: 'Upload',
    label: '浏览器Icon图标',
    colProps: {
      span: 24,
    },
    slot: 'iconUpload',
  },
  {
    field: 'background',
    component: 'Input',
    label: '登录页背景图片',
    colProps: {
      span: 24,
    },
    slot: 'bgUpload',
  },
  {
    field: 'backgroundColor',
    component: 'AutoComplete',
    label: '登录页背景颜色',
    colProps: {
      span: 24,
    },
    slot: 'colorInput',
  },
  {
    field: 'copyright',
    component: 'Input',
    label: '页面底部版权信息',
    colProps: {
      span: 24,
    },
    componentProps: {
      maxLength: 100,
      placeholder: '请输入页面底部版权信息',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 100) {
              return Promise.reject('字数不超过100个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'presentedOurselves',
    component: 'Input',
    label: '备案信息',
    colProps: {
      span: 24,
    },
    componentProps: {
      maxLength: 50,
      placeholder: '请输入备案信息',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 50) {
              return Promise.reject('字数不超过50个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
  {
    field: 'domain',
    component: 'Input',
    label: '绑定域名',
    colProps: {
      span: 24,
    },
    componentProps: {
      maxLength: 100,
      placeholder: '请输入绑定域名',
    },
    dynamicRules: () => {
      return [
        {
          required: false,
          validator: (_, value) => {
            if (String(value).length > 100) {
              return Promise.reject('字数不超过100个字');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
];
