import { listDictModel, uploadApi } from '@/api/common';
import { FormSchema } from '@/components/Form';
// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '上传日期',
    field: 'updateTime',
    required: true,
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入上传日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '文书类型',
    field: 'type',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'md',
      },
      getPopupContainer: () => document.body,
    },
  },
  // {
  //   label: '文书上传',
  //   field: 'files',
  //   component: 'Upload',
  //   componentProps: {
  //     api: uploadApi,
  //     maxSize: 10,
  //     maxNumber: 5,
  //     helpText: '仅支持上传jpg/png/pdf文件，文件大小不超过5M',
  //     accept: ['image/*', '.pdf'],
  //   },
  //   colProps: {
  //     span: 24,
  //   },
  // },
  {
    label: '文书上传',
    field: 'files',
    component: 'XTUpload',
    componentProps: ({ formModel, schema }) => {
      return {
        api: uploadApi,
        maxSize: 20,
        maxNumber: 10,
        helpText: '文件大小不超过20M',
        accept: ['image/*', '.pdf', '.doc', '.docx', '.ppt', '.pptx', '.xls', '.xlsx'],
        onChange: data => {
          console.log('🚀 ~ file: data.ts:57 ~ data:', data);
          formModel[schema.field] = data;
        },
      };
    },
    colProps: {
      span: 24,
    },
  },
];
