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

// 抽屉 Table 表格
export const columnsDrawer: BasicColumn[] = [
  {
    title: '类型',
    dataIndex: 'typeName',
    edit: true,
    editable: true,
    editComponent: 'Input',
    editRule: true,
    width: 150,
    // editComponent: 'ApiSelect',
    // editComponentProps: ({ record }) => {
    //   return {
    //     api: listDictModel,
    //     params: {
    //       dictCode: 'dh_allergic',
    //     },
    //     showSearch: true,
    //     placeholder: '请选择',
    //     getPopupContainer: () => document.body,
    //   };
    // },
  },
  {
    title: '名称',
    dataIndex: 'name',
    edit: true,
    editable: true,
    editComponent: 'Input',
    editRule: true,
    width: 150,
    // editComponent: 'ApiSelect',
    // // 默认必填校验
    // editRule: true,
    // editComponentProps: ({ record }) => {
    //   // console.log('🚀 ~ file: data.ts:103 ~ record:', record);
    //   return {
    //     api: listDictModel,
    //     params: {
    //       dictCode: 'dh_allergic',
    //     },
    //     placeholder: '请选择',
    //   };
    // },
  },
  {
    title: '数量',
    dataIndex: 'count',
    width: 200,
    edit: true,
    editable: true,
    editComponent: 'InputNumber',
    // 默认必填校验
    editRule: true,
    editComponentProps: {
      placeholder: '请输入',
    },
  },
];
// 抽屉 Form 表单
export const dataFormSchema: FormSchema[] = [
  {
    label: '血管通路',
    field: 'vascularAccess',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'va_type',
      },
    },
  },
  {
    label: '透析模式',
    field: 'dialysisType',
    required: true,
    component: 'ApiSelect',
    componentProps: {
      api: listDictModel,
      params: {
        dictCode: 'dt',
      },
    },
  },
  {
    label: '制定日期',
    field: 'enactedTime',
    required: true,
    component: 'DatePicker',
    componentProps: () => {
      return {
        placeholder: '请输入制定日期',
        getPopupContainer: () => document.body,
        valueFormat: 'YYYY-MM-DD',
      };
    },
  },
  {
    field: 'vitals',
    component: 'PlainTitle',
    defaultValue: '体征',
    subLabel: '查看历史',
    subLabelColor: 'rgba(0, 109, 255, 1)',
    colProps: {
      span: 24,
    },
  },
  {
    label: '干体重 (kg)',
    field: 'vitals.dryWeight',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入干体重',
      step: '0.01',
    },
  },
  {
    label: 'OH值 (kg)',
    field: 'vitals.oh',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入干体重',
      step: '0.01',
    },
  },
  {
    label: 'V值 (kg)',
    field: 'vitals.v',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入干体重',
      step: '0.01',
    },
  },
  {
    field: 'anticoagulant',
    component: 'PlainTitle',
    defaultValue: '抗凝',
    colProps: {
      span: 24,
    },
  },
  {
    label: '抗凝方式',
    field: 'anticoagulant.type',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入抗凝方式',
    },
    colProps: {
      span: 12,
    },
  },
  {
    field: 'anticoagulant.firstDose',
    label: '首剂',
    component: 'ApiInputDict',
    componentProps: ({ formModel }) => {
      return {
        placeholder: '请输入异常内容',
        api: listDictModel,
        params: {
          dictCode: 'sys_dict_type',
          dictSort: false,
        },
        onChange: e => {
          console.log('🚀 ~ file: data.ts:81 ~ e:', e);
          return (formModel['firstDose'] = e);
        },
      };
    },
  },
  {
    label: '追加 (mg)',
    field: 'anticoagulant.appendDose',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入追加',
      step: '0.01',
    },
  },
  {
    field: 'suppliesTemplateTitle',
    component: 'PlainTitle',
    defaultValue: '耗材',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'suppliesTemplate',
    component: 'PlainText',
    slot: 'suppliesTemplate',
    labelClass: 'hidden',
    colProps: {
      span: 24,
    },
  },
  {
    field: 'dialysisParam11',
    component: 'PlainTitle',
    defaultValue: '透析参数',
    colProps: {
      span: 24,
    },
  },
  {
    label: '透析时长 (h)',
    field: 'dialysisParam.dialysisTime',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '流量 (ml/min)',
    field: 'dialysisParam.flowRate',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '湿度 (℃)',
    field: 'dialysisParam.temperature',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '血流量 (ml/min)',
    field: 'dialysisParam.bloodFlow',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: 'K (mmolL)',
    field: 'dialysisParam.k',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: 'Na (mmolL)',
    field: 'dialysisParam.na',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: 'Ca (mmolL)',
    field: 'dialysisParam.ca',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '碳酸氢根 (mmolL)',
    field: 'dialysisParam.hco',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: 'Mg (mmolL)',
    field: 'dialysisParam.mg',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: 'Cl (mmolL)',
    field: 'dialysisParam.cl',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '葡萄糖 (mmolL)',
    field: 'dialysisParam.glucose',
    component: 'InputNumber',
    componentProps: {
      placeholder: '请输入',
      step: '0.01',
    },
  },
  {
    label: '置换液',
    field: 'dialysisParam.dsplacementFluid',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
    ifShow: ({ values }) => {
      return values.dialysisType == 'dt_hd_crrt';
    },
  },
  {
    label: '稀释方式',
    field: 'dialysisParam.dilute',
    component: 'Input',
    componentProps: {
      placeholder: '请输入',
    },
    ifShow: ({ values }) => {
      return values.dialysisType == 'dt_hd_crrt';
    },
  },
];

// 抽屉 History Table 表格
export const columnsHistory: BasicColumn[] = [
  {
    title: '时间',
    dataIndex: 'dialysisTime',
    align: 'left',
  },
  {
    title: '透前血压(mmHg)',
    dataIndex: 'preBloodPressure',
    align: 'left',
  },
  {
    title: '透前体重(kg)',
    dataIndex: 'preWeight',
    align: 'left',
  },
  {
    title: '透后体重(kg)',
    dataIndex: 'postWeight',
    align: 'left',
  },
  {
    title: '干体重(kg)',
    dataIndex: 'dryWeight',
    align: 'left',
  },
  {
    title: '实际超滤量(kg)',
    dataIndex: 'actualUltrafiltration',
    align: 'left',
  },
];
