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

import { h } from 'vue';

export const drawerFormSchema: FormSchemaGetter = () => [
  {
    component: 'Select',
    fieldName: 'executivePost',
    label: '执行岗位',
    rules: 'required',
    componentProps: {
      placeholder: '请选择执行岗位',
      allowClear: true,
      options: [],
    },
  },
  {
    component: 'ApiSelect',
    fieldName: 'executor',
    label: '执行人',
    rules: 'required',
    componentProps: {
      placeholder: '请选择执行人',
      allowClear: true,
      showSearch: true,
      filterOption: false,
    },
  },
  {
    component: 'Input',
    fieldName: 'taskName',
    label: '任务名称',
    rules: 'required',
    componentProps: {
      placeholder: '请输入任务名称',
      maxlength: 100,
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'startTime',
    label: '开始时间',
    rules: 'required',
    componentProps: {
      placeholder: '请选择开始时间',
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    component: 'DatePicker',
    fieldName: 'endTime',
    label: '截至时间',
    rules: 'required',
    componentProps: {
      placeholder: '请选择截至时间',
      showTime: true,
      format: 'YYYY-MM-DD HH:mm:ss',
    },
  },
  {
    component: 'Select',
    fieldName: 'taskType',
    label: '任务类型',
    rules: 'required',
    componentProps: {
      placeholder: '请选择任务类型',
      allowClear: true,
      options: [],
    },
  },
  {
    component: 'ApiSelect',
    fieldName: 'ccPerson',
    label: '抄送人',
    componentProps: {
      placeholder: '请选择抄送人',
      allowClear: true,
      showSearch: true,
      filterOption: false,
    },
  },
  {
    component: 'Input',
    fieldName: 'taskDescription',
    label: '任务描述',
    componentProps: {
      type: 'textarea',
      placeholder: '请输入任务描述',
      maxlength: 500,
      showWordLimit: true,
      rows: 4,
    },
  },
  {
    component: 'Upload',
    fieldName: 'descriptionImage',
    label: '描述图片',
    componentProps: {
      accept: 'image/*',
      listType: 'picture-card',
      maxCount: 1,
    },
  },
  {
    component: 'Upload',
    fieldName: 'attachment',
    label: '附件',
    componentProps: {
      accept: '.png',
      listType: 'text',
      showUploadList: true,
      disabled: false,
      maxCount: 5,
      // limit: 5,
      // multiple: true,
    },
    renderComponentContent: () => {
      return {
        default: () =>
          h(
            'div',
            {
              class: 'flex items-center justify-center',
            },
            [
              h(
                'ElIcon',
                { class: 'el-upload__icon' },
                { default: () => h('Plus', { size: '18' }) },
              ),
              h(
                'div',
                {
                  class: 'el-upload__text',
                },
                [
                  h('div', {}, '上传附件'),
                  h(
                    'div',
                    { class: 'text-xs text-gray-500' },
                    '最多上传5个附件',
                  ),
                ],
              ),
            ],
          ),
      };
    },
  },
];
