import { BasicColumn, FormSchema } from '/@/components/Table';
import {
  archivesPatientBasicQueryPage,
  archivesPatientBasicDetail,
} from '@/api/biz/archives/patientBasicApi';
import { listDictModel } from '/@/api/common';

export const columns: BasicColumn[] = [
  {
    title: '患者姓名',
    dataIndex: 'name',
  },
  {
    title: '信息',
    dataIndex: 'message',
  },
  {
    title: '交班类型',
    dataIndex: 'type',
  },
  {
    title: '交班重点内容',
    dataIndex: 'content',
  },
  {
    title: '记录日期',
    dataIndex: 'shiftTime',
  },
  {
    title: '记录人',
    dataIndex: 'updatorName',
  },
];
// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '患者姓名',
    field: 'patientBasicId',
    required: true,
    ifShow: ({ values }) => {
      return values.id ? false : 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 => {
          formModel.patientBasicName = e;
        },
        onChange: async e => {
          const detail = await archivesPatientBasicDetail(e);
          formModel.message = (detail.gender == 'pb_sex_man' ? '男' : '女') + detail.age;
        },
      };
    },
  },
  {
    label: '患者姓名',
    field: 'name',
    component: 'Input',
    componentProps: {
      disabled: true,
    },
    ifShow: ({ values }) => {
      return values.name ? true : false;
    },
  },
  {
    label: '患者信息',
    field: 'message',
    component: 'Input',
    componentProps: {
      disabled: true,
    },
  },
  {
    label: 'ID',
    field: 'id',
    component: 'Input',
    ifShow: false,
  },
  {
    label: '交班日期',
    field: 'shiftTime',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入上传日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
    },
  },
  {
    label: '交班类型',
    field: 'type',
    component: 'ApiSelect',
    componentProps: {
      placeholder: '请选择交班类型',
      api: listDictModel,
      params: {
        dictCode: 'hb',
      },
    },
  },
  {
    label: '交班内容',
    field: 'content',
    component: 'InputTextArea',
    componentProps: {
      placeholder: '请输入交班内容',
    },
  },
];
