import type { FormSchemaGetter } from '#/adapter/form';

// 编辑表单配置
export const drawerFormSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'title',
    label: '标题',
    componentProps: {
      placeholder: '请输入章节标题',
    },
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'content',
    label: '内容',
    componentProps: {
      placeholder: '请输入章节内容',
      rows: 10,
    },
    // 使用自定义插槽渲染Tinymce编辑器
    slot: 'content',
    rules: 'required',
  },
  {
    component: 'Input',
    fieldName: 'attachments',
    label: '附件',
    componentProps: {
      placeholder: '请上传附件',
      readonly: true,
    },
  },
];

// 提醒表单配置
export const remindFormSchema: FormSchemaGetter = () => [
  {
    component: 'Input',
    fieldName: 'remindContent',
    label: '提醒内容',
    componentProps: {
      placeholder: '请输入提醒内容',
      rows: 4,
      maxlength: 200,
      type: 'textarea',
      showWordLimit: true,
    },
    // 使用自定义插槽渲染文本域
    slot: 'remindContent',
    rules: 'required',
  },
  {
    // 组件需要在 #/adapter.ts内注册，并加上类型
    component: 'ApiSelect',
    // 对应组件的参数
    componentProps: {
      placeholder: '请选择或搜索提醒人',
      // 菜单接口转options格式
      afterFetch: (data: { name: string; path: string }[]) => {
        return data.map((item: any) => ({
          label: item.name,
          value: item.path,
        }));
      },
      // 菜单接口
      api: () => {},
    },
    // 字段名
    fieldName: 'remindPerson',
    // 界面显示的label
    label: '提醒人',
  },
];
