import dayjs from 'dayjs';
import { BasicColumn, FormSchema } from '/@/components/Table';
import { archivesPatientBasicQueryPage } from '@/api/biz/archives/patientBasicApi';
import { getSailings } from '/@/api/biz/management/working';
export const columns: BasicColumn[] = [
  {
    title: '填写日期',
    dataIndex: 'createTime',
  },
  {
    title: '患者信息',
    dataIndex: 'patientInfo',
  },
  {
    title: '预约日期',
    dataIndex: 'appointmentDate',
  },
  {
    title: '预约班次',
    dataIndex: 'appointmentSailingsName',
  },
  {
    title: '备注',
    dataIndex: 'remark',
  },
  {
    title: '记录人',
    dataIndex: 'creatorName',
  },
  {
    title: '待办处理人',
    dataIndex: 'todoName',
  },
];

// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '患者名称搜索',
    field: 'patientBasicName',
    component: 'Input',
    ifShow: false,
  },
  {
    label: '患者姓名',
    field: 'patientBasicId',
    required: true,
    component: 'ApiSelect',
    componentProps: ({ formModel }) => {
      return {
        api: archivesPatientBasicQueryPage,
        params: {
          name: formModel.patientBasicName,
          pageSize: 999,
        },
        labelField: 'name',
        valueField: 'id',
        resultField: 'data',
        placeholder: '请输入患者姓名',
        getPopupContainer: () => document.body,
        showSearch: true,
        filterOption: false,
        onSearch: e => {
          console.log('🚀 ~ file: data.ts:66 ~ e:', e);
          formModel.patientBasicName = e;
        },
      };
    },
  },
  {
    label: '预约日期',
    field: 'appointmentDate',
    required: true,
    component: 'DatePicker',
    componentProps: {
      placeholder: '请输入预约日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
      disabledDate: current => {
        return current < dayjs().subtract(1, 'day').endOf('day');
      },
    },
  },
  {
    label: '预约班次',
    field: 'appointmentSailingsSort',
    required: true,
    component: 'ApiCheckboxGroup',
    componentProps: {
      api: getSailings,
      resultField: 'infos',
      valueField: 'sort',
      labelField: 'name',
      // options: [
      //   {
      //     label: '第一班',
      //     value: '1',
      //   },
      //   {
      //     label: '第二班',
      //     value: '2',
      //   },
      //   {
      //     label: '第三班',
      //     value: '3',
      //   },
      // ],
    },
  },
  {
    label: '备注',
    field: 'remark',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入备注',
    },
  },
];
