import { listDictModel } from '@/api/common';
import { FormSchema } from '@/components/Form';
import dayjs from 'dayjs';

export const BasicData = [
  {
    title: '基本信息',
    icon: 'icon-xt-edit_default',
    type: 'basic',
    data: [
      { field: 'name', label: '姓名', value: '' },
      { field: 'gender', label: '性别', value: '', dict: true },
      { field: 'age', label: '年龄', value: '' },
      { field: 'height', label: '身高(cm)', value: '' },
      { field: 'uniqueNo', label: '编号', value: '' },
      { field: 'createTime', label: '建档时间', value: '' },
      { field: 'cardNo', label: '证件号码', value: '', dictName: 'cardType', dictField: 'label' },
      { field: 'birthday', label: '出生日期', value: '' },
      { field: 'type', label: '类型', value: '', dict: true },
      {
        field: 'infectiousDiseases',
        label: '传染病',
        value: '',
        tags: [],
        dict: true,
        hiddenValue: 'true',
      },
      { field: 'bloodType', label: '血型', value: '', dict: true },
      { field: 'address', label: '详细地址', value: '' },
      { field: 'mobile', label: '联系电话', value: '' },
      { field: 'familyName', label: '家属姓名', value: '' },
      { field: 'familyMobile', label: '家属电话', value: '' },
    ],
  },
  {
    title: '血管通路',
    type: 'vc',
    data: [
      { field: 'type', label: '当前血管通路', value: '', dict: true },
      { field: 'setUpTime', label: '建立时间', value: '' },
    ],
  },
  {
    title: '诊断记录',
    type: 'record',
    data: [
      // {
      //   field: 'firstDialysis',
      //   label: '首次透析',
      //   value: '2022-01-19 ～',
      //   tags: [{ id: '12', label: '活动中', type: 'error' }],
      // },
      // {
      //   field: 'clinic',
      //   label: '临床诊断',
      //   value: '临床诊断',
      //   tags: [{ id: '12', label: '活动中', type: 'error' }],
      // },
      // {
      //   field: 'pathological',
      //   label: '病理诊断',
      //   value: '病理诊断',
      //   tags: [{ id: '12', label: '活动中', type: 'error' }],
      // },
      // {
      //   field: 'complications',
      //   label: '治疗前合并症',
      //   value: '治疗前合并症',
      //   tags: [{ id: '12', label: '活动中', type: 'error' }],
      // },
      // {
      //   field: 'ckd',
      //   label: 'CKD/AKI',
      //   value: 'CKD/AKI',
      //   tags: [{ id: '12', label: '活动中', type: 'error' }],
      // },
      // {
      //   field: 'elseRemark',
      //   label: '其他诊断',
      //   value: '其他诊断',
      // },
    ],
  },
];

// 表单新增编辑
export const dataFormSchema: FormSchema[] = [
  {
    label: '患者姓名',
    field: 'name',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入患者姓名',
      maxLength: 60,
    },
  },
  {
    label: '性别',
    field: 'gender',
    required: true,
    component: 'ApiRadioGroup',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_sex',
      },
    },
  },
  {
    label: '证件号码',
    field: 'cardNo',
    required: true,
    component: 'ApiInputDict',
    componentProps: ({ formModel }) => {
      return {
        placeholder: '请输入证件号码',
        api: listDictModel,
        params: {
          dictCode: 'pb_card',
          dictSort: true,
        },
        inputLength: 18,
        dictWidth: 40,
        onChange: e => {
          return (formModel['cardNo'] = e);
        },
      };
    },
  },
  {
    label: '出生日期',
    field: 'birthday',
    required: true,
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: '请输入出生日期',
      getPopupContainer: () => document.body,
      valueFormat: 'YYYY-MM-DD',
      disabledDate: current => {
        return current > dayjs().endOf('day');
      },
    },
  },
  {
    label: '身高(cm)',
    field: 'height',
    required: true,
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入身高',
      min: 10,
      max: 300,
    },
  },
  {
    label: '详细地址',
    field: 'address',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入详细地址',
      maxLength: 120,
    },
  },
  {
    label: '联系电话',
    field: 'mobile',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入联系电话',
      maxLength: 11,
    },
  },
  {
    label: '类型',
    field: 'type',
    required: true,
    component: 'ApiRadioGroup',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_type',
      },
    },
  },
  {
    label: '血型',
    field: 'bloodType',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'pb_blood',
      },
    },
  },
  {
    label: '传染病',
    field: 'infectiousDiseases',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      mode: 'multiple',
      params: {
        dictCode: 'pb_epidemic',
      },
    },
  },
  {
    label: '家属姓名',
    field: 'familyName',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入家属姓名',
      maxLength: 60,
    },
  },
  {
    label: '家属电话',
    field: 'familyMobile',
    required: true,
    component: 'Input',
    componentProps: {
      placeholder: '请输入家属电话',
      maxLength: 11,
    },
  },
];
