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

import { getDepartOptionApi } from '#/views/doctor/doctor/api';
import { getDoctorTitleOptionApi } from '#/views/doctor/pharmacist/api';
import { getStoreOption } from '#/views/system/store/api';

export const modalFormProps: VbenFormProps = {
  wrapperClass: 'grid-cols-12',
  commonConfig: {
    formItemClass: 'col-span-12',
    componentProps: {
      class: 'w-full',
    },
  },
  layout: 'horizontal',
  schema: [
    {
      component: 'VbenInput',
      fieldName: 'id',
      label: 'ID',
      formItemClass: 'col-span-6',
      dependencies: {
        show: false,
        triggerFields: ['id'],
      },
    },
    {
      component: 'ApiSelect',
      componentProps: {
        allowClear: true,
        filterOption: (input: string, option: any) =>
          option?.label.toLowerCase().indexOf(input.toLowerCase()) >= 0,
        showSearch: true,
        afterFetch: (data: { id: number; name: string }[]) =>
          data.map((item: any) => ({
            label: item.name,
            value: item.id,
          })),
        api: getStoreOption,
        placeholder: '请选择诊所',
        mode: 'multiple',
      },
      fieldName: 'stores',
      formItemClass: 'col-span-12',
      label: '关联诊所',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传医生头像',
      },
      fieldName: 'avatar',
      formItemClass: 'col-span-12',
      label: '医生头像',
      rules: 'required',
    },
    {
      component: 'ApiSelect',
      componentProps: {
        allowClear: true,
        afterFetch: (data: { id: number; name: string }[]) =>
          data.map((item: any) => ({
            label: item.name,
            value: item.id,
          })),
        api: getDoctorTitleOptionApi,
        placeholder: '请选择职称',
      },
      fieldName: 'title_id',
      formItemClass: 'col-span-6',
      label: '职称',
    },
    {
      component: 'ApiSelect',
      componentProps: {
        allowClear: true,
        afterFetch: (data: { id: number; name: string }[]) =>
          data.map((item: any) => ({
            label: item.name,
            value: item.id,
          })),
        api: getDepartOptionApi,
        placeholder: '请选择科室',
      },
      fieldName: 'depart_id',
      formItemClass: 'col-span-6',
      label: '科室',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请填写医生名称',
      },
      fieldName: 'name',
      formItemClass: 'col-span-6',
      label: '医生名称',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请填写手机号码',
      },
      fieldName: 'mobile',
      formItemClass: 'col-span-6',
      label: '手机号码',
      rules: 'required',
    },
    {
      component: 'VbenInput',
      componentProps: {
        placeholder: '请填写身份证',
      },
      fieldName: 'idcard',
      formItemClass: 'col-span-6',
      label: '身份证',
      rules: 'required',
    },
    {
      component: 'VbenSelect',
      componentProps: {
        placeholder: '请选择身份',
        options: [
          { label: '中医医生', value: 1 },
          { label: '西医医生', value: 2 },
        ],
      },
      fieldName: 'type',
      formItemClass: 'col-span-6',
      label: '身份',
      rules: 'required',
    },
    {
      component: 'VbenSelect',
      componentProps: {
        placeholder: '请选择签名类型',
        options: [
          { label: '电子签名', value: 1 },
          { label: '手写签名', value: 2 },
        ],
      },
      fieldName: 'sign_type',
      formItemClass: 'col-span-6',
      label: '签名类型',
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入擅长',
      },
      fieldName: 'good_at',
      label: '擅长',
      rules: 'required',
    },
    {
      component: 'Textarea',
      componentProps: {
        placeholder: '请输入简介',
      },
      fieldName: 'intro',
      label: '简介',
      rules: 'required',
    },
    {
      component: 'InputNumber',
      componentProps: {
        min: 0,
        precision: 2,
        placeholder: '请输入挂号费',
        class: 'w-full',
      },
      fieldName: 'register_price',
      formItemClass: 'col-span-6',
      label: '挂号费',
      defaultValue: 0,
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传资格证书',
      },
      fieldName: 'qualification',
      formItemClass: 'col-span-6',
      label: '资格证书',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传执业证书',
      },
      fieldName: 'practicing',
      formItemClass: 'col-span-6',
      label: '执业证书',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传职称证书',
      },
      fieldName: 'title',
      formItemClass: 'col-span-6',
      label: '职称证书',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传身份证正面',
      },
      fieldName: 'card_up',
      formItemClass: 'col-span-6',
      label: '身份证正面',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传身份证反面',
      },
      fieldName: 'card_down',
      formItemClass: 'col-span-6',
      label: '身份证反面',
      rules: 'required',
    },
    {
      component: 'Avatar',
      componentProps: {
        placeholder: '请上传签名图片',
      },
      fieldName: 'sign_image',
      formItemClass: 'col-span-6',
      label: '签名图片',
      rules: 'required',
    },
  ],
  showDefaultActions: false,
};
