import { BasicColumn, FormSchema } from '/@/components/Table';
import { listDictModel, uploadApi } from '/@/api/common';

export const columns: BasicColumn[] = [
  {
    title: '封面',
    dataIndex: 'cover',
  },
  {
    title: '标题',
    dataIndex: 'title',
  },
  {
    title: '分类',
    dataIndex: 'type',
  },
  {
    title: '上传时间',
    dataIndex: 'updateTime',
  },
  {
    title: '上传人',
    dataIndex: 'updatorName',
  },
  {
    title: '状态',
    dataIndex: 'disable',
  },
];
// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '宣教标题',
    field: 'title',
    component: 'Input',
    componentProps: {},
  },
  {
    label: '宣教分类',
    field: 'type',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'het',
      },
      placeholder: '请选择宣教分类',
    },
  },

  {
    label: '封面',
    field: 'cover',
    component: 'XTUpload',
    componentProps: ({ formModel, schema }) => {
      return {
        api: uploadApi,
        maxSize: 10,
        maxNumber: 5,
        helpText: '仅支持上传jpg/png/pdf文件，文件大小不超过2M',
        accept: ['image/*', '.pdf', '.doc', 'docx', 'xls'],
        onChange: data => {
          console.log('🚀 ~ file: data.ts:57 ~ data:', data);
          formModel[schema.field] = data;
        },
      };
    },
    colProps: {
      span: 22,
    },
  },
  {
    label: '宣教内容',
    field: 'content',
    component: 'Editor',
    colProps: {
      span: 24,
    },
  },
];
