import { checkRange, checkIsInteger, checkNumberIsToFixed, checkNumberIsToFixedTwo } from '@/utils/followup/followupUtils/checkField';

export default ($this) => {
  return [
    {
      formType: 'input',
      className: 'float-none',
      prop: 'fastingBloodSugar',
      model: 'fastingBloodSugar',
      disabled: false,
      label: '空腹血糖值：',
      placeholder: '请输入空腹血糖值',
      spanNum: 6,
      maxlength: 30,
      type: 'text',
      labmsg: '',
      slots: [{name: 'mmol/L', type: 'append'}],
      rules: [{ required: true, message: '请输入空腹血糖值', trigger: ['submit','change'] },{ validator: checkRange , trigger: ['submit','change'] },{ validator: checkNumberIsToFixed , trigger: ['submit','change'] }]
    },
    {
      formType: 'div',
      name: '其他检查',
      className: 'sec-title',
    },
    {
      formType: 'input',
      className: 'float-none',
      prop: 'glycosylatedHemoglobinPercent',
      model: 'glycosylatedHemoglobinPercent',
      disabled: false,
      label: '糖化血红蛋白值：',
      placeholder: '请输入糖化血红蛋白值',
      spanNum: 6,
      maxlength: 30,
      type: 'text',
      labmsg: '',
      slots: [{name: '%', type: 'append'}],
      rules: [{ required: false, message: '请输入糖化血红蛋白值', trigger: ['submit','change'] },{ validator: checkRange , trigger: ['submit','change'] },{ validator: checkNumberIsToFixedTwo , trigger: ['submit','change'] }],
      changeFun: (val)=>{
        let flag = val ? true : false;
        $this.addComponents.forEach((item,index)=>{
          if(item.name == 'diabetesSourseAuxiliary'){
            let len = $this.addComponents[index].dataSource.length;
            $this.addComponents[index].dataSource[len-1].rules[0].required = flag;
            // $this.addComponents[index].dataSource.forEach((item,index2)=>{
            //
            // })
          }
        })
      }
    },
    {
      formType: 'date-picker',
      className: 'float-none',
      prop: 'glycosylatedHemoglobinDate',
      model: 'glycosylatedHemoglobinDate',
      placeholder: '请选择',
      label: '检查日期：',
      format: 'MM 月 dd 日',
      valueFormat: 'MM-dd',
      dateType: 'date',
      type: 'date',
      rules: [{required: false, message: '请选择检查日期', trigger: ['submit','change']}],
      spanNum: 12,
    },
  ]
}

