package com.phlx.anchorcollect.ui.fragment;

import android.app.Dialog;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.text.InputType;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.FrameLayout;

import androidx.annotation.Nullable;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProviders;

import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectChangeListener;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
import com.bigkoo.pickerview.view.TimePickerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.kongzue.dialogx.datepicker.DatePickerDialog;
import com.kongzue.dialogx.datepicker.interfaces.OnDateSelected;
import com.kongzue.dialogx.dialogs.BottomMenu;
import com.kongzue.dialogx.dialogs.InputDialog;
import com.kongzue.dialogx.interfaces.OnInputDialogButtonClickListener;
import com.kongzue.dialogx.interfaces.OnMenuItemClickListener;
import com.kongzue.dialogx.util.InputInfo;
import com.kongzue.dialogx.util.TextInfo;
import com.phlx.anchorcollect.BR;
import com.phlx.anchorcollect.Configs;
import com.phlx.anchorcollect.R;
import com.phlx.anchorcollect.data.VMFactory;
import com.phlx.anchorcollect.databinding.FragmentColletBinding;
import com.phlx.anchorcollect.entity.UIParamEntity;
import com.phlx.anchorcollect.ui.fragment.vm.CollectVM;
import com.phlx.anchorcollect.ui.info.CattleActivity;
import com.phlx.anchorcollect.util.BaseImageUtils;
import com.phlx.anchorcollect.util.DictUtils;
import com.phlx.anchorcollect.util.ImagePicker;
import com.phlx.anchorcollect.util.TextUtil;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import me.goldze.mvvmhabit.base.BaseFragment;
import me.goldze.mvvmhabit.utils.ToastUtils;

public class CollectFragment extends BaseFragment<FragmentColletBinding, CollectVM> {

    private TimePickerView pvTime;

    private ImagePicker mImagePicker;

    private String collectType;

    public static CollectFragment newInstance(String text) {
        CollectFragment collectFragment = new CollectFragment();
        Bundle bundle = new Bundle();
        bundle.putString("collectType", text);
        collectFragment.setArguments(bundle);
        return collectFragment;
    }

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_collet;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public void initParam() {
        super.initParam();

        if (getArguments() != null) {
            //取出保存的值
            collectType = getArguments().getString("collectType");
        }
    }

    @Override
    public CollectVM initViewModel() {
        VMFactory factory = VMFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(CollectVM.class);
    }

    @Override
    public void onHiddenChanged(boolean hidden) {
        super.onHiddenChanged(hidden);
        //列表页面切回来回显
        if (!hidden)
            if (Configs.tempTag != null && !Configs.tempTag.equals("")) {
                viewModel.tag.set(Configs.tempTag);
                viewModel.initData(Configs.tempTag);
            }
    }

    @Override
    public void initData() {
        super.initData();

        //修改重量数字字体
        binding.tvWeight.setTypeface(Configs.typeface);
        binding.tvUnit.setTypeface(Configs.typeface);
        binding.tvADG.setTypeface(Configs.typeface);
        binding.tvBWG.setTypeface(Configs.typeface);

//        initTimePicker();

        viewModel.setCollectType(collectType);
        //根据不同的功能初始化右边控件列表
        switch (collectType) {
            case Configs.BASE_ARCHIVES:
                initCardParamList();
                break;
            case Configs.SIGN_MEASURE:
                initWeightingParamList();
                break;
            case Configs.TREATMENT_RECORD:
                initSignParamList();
                break;
            case Configs.WEIGHTING_MANAGE:
                initHealthParamList();
                break;
            case Configs.IMMUN_RECORD:
                initImmunParamList();
                break;
        }

        if (mImagePicker == null) {
            mImagePicker = new ImagePicker(getActivity());
            mImagePicker.setOnImagePickerListener(new ImagePicker.OnImagePickerListener() {
                @Override
                public void onSuccess(String path) {
                    Bitmap bitmap = BaseImageUtils.decodeBitmap(path, getActivity());
                    BaseImageUtils.saveBitmapToSDCard(bitmap, viewModel.getImgUrl());
                    viewModel.uiList.get(17).setValue(viewModel.getImgUrl());
                    Glide.with(getActivity())
                            .load(viewModel.uiList.get(17).getValue())
                            .apply(
                                    new RequestOptions()
                                            .skipMemoryCache(true)
                                            .diskCacheStrategy(DiskCacheStrategy.NONE)
                                            .error(R.drawable.no_image)
                                            .fallback(R.drawable.no_image)
                            )
                            .into(binding.ivCattlePhoto);
                }
            });
        }
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();

        viewModel.onCardClickEvent.observe(getActivity(), new Observer<Boolean>() {
            @Override
            public void onChanged(Boolean aBoolean) {
                if (viewModel.currentParamEntity != null) {
                    switch (viewModel.currentParamEntity.getType()) {
                        case 0:
                            break;
                        case 1:
                        case 2:
                            showInputDialog(viewModel.currentParamEntity);
                            break;
                        case 3:
                            showSelectDateDialog(viewModel.currentParamEntity);
                            break;
                        case 4:
                            showSpinnerDialog(viewModel.currentParamEntity);
                            break;
                        case 5:
                            if (viewModel.tag.get().equals("")) {
                                ToastUtils.showShort("请先输入可视耳标号");
                            } else {
                                showPhotoDialog(viewModel.currentParamEntity);
                            }
                            break;
                    }

                }
            }
        });

        viewModel.onTagClickEvent.observe(getActivity(), new Observer<Boolean>() {
            @Override
            public void onChanged(Boolean aBoolean) {
                //设置字体大小
                TextInfo textInfo = new TextInfo();
                textInfo.setFontSize(10);

                InputDialog.show("耳标号", "", "确定", "取消")
                        .setCancelable(false)
                        .setInputInfo(new InputInfo().setTextInfo(textInfo))
                        .setTitleTextInfo(textInfo)
                        .setOkTextInfo(textInfo)
                        .setCancelTextInfo(textInfo)
                        .setMaxWidth(600)
                        .setInputHintText("请输入可视化耳标号").setOkButton(new OnInputDialogButtonClickListener<InputDialog>() {
                    @Override
                    public boolean onClick(InputDialog baseDialog, View v, String inputStr) {
                        viewModel.tag.set(inputStr);
                        viewModel.initData(inputStr);
                        return false;
                    }
                });

            }
        });

        viewModel.onCattleClickEvent.observe(getActivity(), new Observer<Boolean>() {
            @Override
            public void onChanged(Boolean aBoolean) {
                if (TextUtil.isSpace(viewModel.tag.get())) {
                    ToastUtils.showShort("请先输入可视耳标号");
                } else {
                    Bundle bundle = new Bundle();
                    bundle.putString("Tag", viewModel.tag.get());
                    startActivity(CattleActivity.class, bundle);
                }

            }
        });

        viewModel.onNotifyAllEvent.observe(getActivity(), new Observer<Boolean>() {
            @Override
            public void onChanged(Boolean aBoolean) {
                if (aBoolean)
                    clearParamList();

                for (UIParamEntity uipe : viewModel.uiList) {
                    uipe.notifyChange();
                }
            }
        });
    }

    //选择框
    private void showSpinnerDialog(UIParamEntity uiParamEntity) {
        //设置字体大小
        TextInfo textInfo = new TextInfo();
        textInfo.setFontSize(10);

        BottomMenu.showStringList(DictUtils.getDistNameList(uiParamEntity.getDictType()))
                .setMessage(uiParamEntity.getName())
                .setMessageTextInfo(textInfo)
                .setOnMenuItemClickListener(new OnMenuItemClickListener<BottomMenu>() {
                    @Override
                    public boolean onClick(BottomMenu dialog, CharSequence text, int index) {
                        viewModel.currentParamEntity.setName((String) text);
                        viewModel.currentParamEntity.setValue((String) text);
                        viewModel.currentParamEntity.notifyChange();
                        return false;
                    }
                });
    }

    //输入框
    private void showInputDialog(UIParamEntity uiParamEntity) {

        //设置字体大小
        TextInfo textInfo = new TextInfo();
        textInfo.setFontSize(10);

        int inputType = 0;
        if (uiParamEntity.getType() == 1) {
            inputType = InputType.TYPE_CLASS_NUMBER;
        } else if (uiParamEntity.getType() == 2) {
            inputType = InputType.TYPE_CLASS_TEXT;
        }

        InputInfo inputInfo = new InputInfo();
        inputInfo.setInputType(inputType);
        inputInfo.setTextInfo(textInfo);

        InputDialog.show(uiParamEntity.getTitle(), "", "确定", "取消")
                .setCancelable(false)
                .setInputInfo(inputInfo)
                .setTitleTextInfo(textInfo)
                .setOkTextInfo(textInfo)
                .setCancelTextInfo(textInfo)
                .setMaxWidth(600)
                .setInputHintText("请输入" + uiParamEntity.getTitle())
                .setOkButton(new OnInputDialogButtonClickListener<InputDialog>() {
                    @Override
                    public boolean onClick(InputDialog baseDialog, View v, String inputStr) {
                        viewModel.currentParamEntity.setName(inputStr);
                        viewModel.currentParamEntity.setValue(inputStr);
                        viewModel.currentParamEntity.notifyChange();
                        return false;
                    }
                });
    }

    //拍照
    private void showPhotoDialog(UIParamEntity uiParamEntity) {

//        RxPermissions rxPermissions = new RxPermissions(getActivity());
//        rxPermissions.request(Manifest.permission.CAMERA, Manifest.permission
//                .READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE)
//                .subscribe(new Consumer<Boolean>() {
//                    @Override
//                    public void accept(Boolean aBoolean) throws Exception {
//                        if (aBoolean) {
//                            mImagePicker.show(getActivity());
//                        } else {
//                            ToastUtils.showShort("权限被拒绝");
//                        }
//                    }
//                });
    }

    //时间选择
    private void showSelectDateDialog(UIParamEntity uiParamEntity) {
        Calendar calendar = Calendar.getInstance();
        DatePickerDialog.build()
                .setTitle(uiParamEntity.getName())  //设置标题
                .setMinTime(1990, 5, 20)            //指定最小可选日期 1990年5月20日
                .setMaxTime(2030, 2, 10)            //指定最大可选日期 2030年2月10日
                .setDefaultSelect(calendar.get(Calendar.YEAR), calendar.get(Calendar.MONTH) + 1, calendar.get(Calendar.DAY_OF_MONTH))    //设置默认选中日期
                .show(new OnDateSelected() {
                    /**
                     * 此处为回调，
                     * @param text 直接返回默认文本，例如“2021-9-25”
                     * @param year  年
                     * @param month 月
                     * @param day   日
                     */
                    @Override
                    public void onSelect(String text, int year, int month, int day) {
                        viewModel.currentParamEntity.setValue(text);
                        viewModel.currentParamEntity.setName(text);
                        viewModel.currentParamEntity.notifyChange();
                    }
                });
    }

    private void initTimePicker() {//Dialog
        pvTime = new TimePickerBuilder(getActivity(), new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {
                SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");

            }
        })
                .setTimeSelectChangeListener(new OnTimeSelectChangeListener() {
                    @Override
                    public void onTimeSelectChanged(Date date) {
                    }
                })
                .setType(new boolean[]{true, true, true, false, false, false})
                .isDialog(true) //默认设置false ，内部实现将DecorView 作为它的父控件。
                .addOnCancelClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        Log.i("pvTime", "onCancelClickListener");
                    }
                })
                .setItemVisibleCount(5) //若设置偶数，实际值会加1（比如设置6，则最大可见条目为7）
                .setLineSpacingMultiplier(2.0f)
                .isAlphaGradient(true)
                .build();

        Dialog mDialog = pvTime.getDialog();
        if (mDialog != null) {

            FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    ViewGroup.LayoutParams.WRAP_CONTENT,
                    Gravity.CENTER);

            params.leftMargin = 0;
            params.rightMargin = 0;
            pvTime.getDialogContainerLayout().setLayoutParams(params);

            Window dialogWindow = mDialog.getWindow();
            if (dialogWindow != null) {
                dialogWindow.setWindowAnimations(com.bigkoo.pickerview.R.style.picker_view_slide_anim);//修改动画样式
                dialogWindow.setGravity(Gravity.CENTER);//改成Bottom,底部显示
                dialogWindow.setDimAmount(0.3f);
            }
        }
    }

    //清空数据源
    private void clearParamList() {

        for (UIParamEntity uipe : viewModel.uiList) {
            uipe.setName("");
            uipe.setValue("");
        }
    }

    //基础档案-初始化控件列表
    private void initCardParamList() {

        UIParamEntity ui0 = new UIParamEntity(0, "出生重量", "", "", 1, "");
        viewModel.uiList.add(ui0);
        binding.tvTitle0.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui1 = new UIParamEntity(1, "出生日期", "", "", 3, "");
        viewModel.uiList.add(ui1);
        binding.tvTitle1.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui2 = new UIParamEntity(2, "品种", "", "", 4, "card_varieties");
        viewModel.uiList.add(ui2);
        binding.tvTitle2.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui3 = new UIParamEntity(3, "性别", "", "", 4, "card_sex");
        viewModel.uiList.add(ui3);
        binding.tvTitle3.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui4 = new UIParamEntity(4, "出生难易度", "", "", 4, "ease_birth");
        viewModel.uiList.add(ui4);
        binding.tvTitle4.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui5 = new UIParamEntity(5, "父登记号", "", "", 1, "");
        viewModel.uiList.add(ui5);
        binding.tvTitle5.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui6 = new UIParamEntity(6, "母登记号", "", "", 1, "");
        viewModel.uiList.add(ui6);
        binding.tvTitle6.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui7 = new UIParamEntity(7, "胎次", "", "", 1, "");
        viewModel.uiList.add(ui7);
        binding.tvTitle7.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui8 = new UIParamEntity(8, "是否双胎", "", "", 4, "card_isTwins");
        viewModel.uiList.add(ui8);
        binding.tvTitle8.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui9 = new UIParamEntity(9, "是否初乳", "", "", 4, "card_isTwins");
        viewModel.uiList.add(ui9);
        binding.tvTitle9.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui10 = new UIParamEntity(10, "是否去角", "", "", 4, "card_isTwins");
        viewModel.uiList.add(ui10);
        binding.tvTitle10.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui11 = new UIParamEntity(11, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui11);

        UIParamEntity ui12 = new UIParamEntity(12, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui12);

        UIParamEntity ui13 = new UIParamEntity(13, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui13);

        UIParamEntity ui14 = new UIParamEntity(14, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui14);

        UIParamEntity ui15 = new UIParamEntity(15, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui15);


        UIParamEntity ui16 = new UIParamEntity(16, "备注", "", "", 2, "");
        viewModel.uiList.add(ui16);
        UIParamEntity ui100 = new UIParamEntity(100, "照片", "", "", 5, "");
        viewModel.uiList.add(ui100);

    }

    //称重管理-初始化控件列表
    private void initWeightingParamList() {

        UIParamEntity ui0 = new UIParamEntity(0, "事件名称", "", "", 2, "");
        viewModel.uiList.add(ui0);
        binding.tvTitle0.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui1 = new UIParamEntity(1, "称重日期", "", "", 3, "");
        viewModel.uiList.add(ui1);
        binding.tvTitle1.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui2 = new UIParamEntity(2, "负责人", "", "", 4, "weight_principal");
        viewModel.uiList.add(ui2);
        binding.tvTitle2.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui3 = new UIParamEntity(3, "称重动物数量", "", "", 1, "");
        viewModel.uiList.add(ui3);
        binding.tvTitle3.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui4 = new UIParamEntity(4, "圈号", "", "", 4, "card_circleNo");
        viewModel.uiList.add(ui4);
        binding.tvTitle4.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui5 = new UIParamEntity(5, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui5);

        UIParamEntity ui6 = new UIParamEntity(6, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui6);

        UIParamEntity ui7 = new UIParamEntity(7, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui7);

        UIParamEntity ui8 = new UIParamEntity(8, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui8);

        UIParamEntity ui9 = new UIParamEntity(9, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui9);

        UIParamEntity ui10 = new UIParamEntity(10, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui10);

        UIParamEntity ui11 = new UIParamEntity(11, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui11);

        UIParamEntity ui12 = new UIParamEntity(12, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui12);

        UIParamEntity ui13 = new UIParamEntity(13, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui13);

        UIParamEntity ui14 = new UIParamEntity(14, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui14);

        UIParamEntity ui15 = new UIParamEntity(15, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui15);


        UIParamEntity ui16 = new UIParamEntity(16, "备注", "", "", 2, "");
        viewModel.uiList.add(ui16);
        UIParamEntity ui100 = new UIParamEntity(100, "照片", "", "", 5, "");
        viewModel.uiList.add(ui100);

    }

    //体征测定-初始化控件列表
    private void initSignParamList() {

        UIParamEntity ui0 = new UIParamEntity(0, "几牙", "", "", 1, "");
        viewModel.uiList.add(ui0);
        binding.tvTitle0.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui1 = new UIParamEntity(1, "测量日期", "", "", 3, "");
        viewModel.uiList.add(ui1);
        binding.tvTitle1.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui2 = new UIParamEntity(2, "体高(cm)", "", "", 1, "");
        viewModel.uiList.add(ui2);
        binding.tvTitle2.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui3 = new UIParamEntity(3, "体长(cm)", "", "", 1, "");
        viewModel.uiList.add(ui3);
        binding.tvTitle3.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui4 = new UIParamEntity(4, "胸围(cm)", "", "", 1, "");
        viewModel.uiList.add(ui4);
        binding.tvTitle4.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui5 = new UIParamEntity(5, "胸宽(cm)", "", "", 1, "");
        viewModel.uiList.add(ui5);
        binding.tvTitle5.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui6 = new UIParamEntity(6, "胸深(cm)", "", "", 1, "");
        viewModel.uiList.add(ui6);
        binding.tvTitle6.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui7 = new UIParamEntity(7, "腰角宽(cm)", "", "", 1, "");
        viewModel.uiList.add(ui7);
        binding.tvTitle7.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui8 = new UIParamEntity(8, "十字部宽(cm)", "", "", 1, "");
        viewModel.uiList.add(ui8);
        binding.tvTitle8.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui9 = new UIParamEntity(9, "管围(cm)", "", "", 1, "");
        viewModel.uiList.add(ui9);
        binding.tvTitle9.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui10 = new UIParamEntity(10, "毛长度(cm)", "", "", 1, "");
        viewModel.uiList.add(ui10);
        binding.tvTitle10.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui11 = new UIParamEntity(11, "眼肌面积", "", "", 1, "");
        viewModel.uiList.add(ui11);
        binding.tvTitle11.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui12 = new UIParamEntity(12, "体况评分", "", "", 1, "");
        viewModel.uiList.add(ui12);
        binding.tvTitle12.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui13 = new UIParamEntity(13, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui13);

        UIParamEntity ui14 = new UIParamEntity(14, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui14);

        UIParamEntity ui15 = new UIParamEntity(15, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui15);


        UIParamEntity ui16 = new UIParamEntity(16, "备注", "", "", 2, "");
        viewModel.uiList.add(ui16);
        UIParamEntity ui100 = new UIParamEntity(100, "照片", "", "", 5, "");
        viewModel.uiList.add(ui100);

    }

    //健康管理-初始化控件列表
    private void initHealthParamList() {

        UIParamEntity ui0 = new UIParamEntity(0, "诊疗日期", "", "", 3, "");
        viewModel.uiList.add(ui0);
        binding.tvTitle0.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui1 = new UIParamEntity(1, "治疗人员", "", "", 4, "weight_principal");
        viewModel.uiList.add(ui1);
        binding.tvTitle1.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui2 = new UIParamEntity(2, "病因", "", "", 2, "");
        viewModel.uiList.add(ui2);
        binding.tvTitle2.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui3 = new UIParamEntity(3, "用药名称", "", "", 4, "health_drug_name");
        viewModel.uiList.add(ui3);
        binding.tvTitle3.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui4 = new UIParamEntity(4, "规格", "", "", 4, "health_specifications");
        viewModel.uiList.add(ui4);
        binding.tvTitle4.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui5 = new UIParamEntity(5, "用药方法", "", "", 4, "health_methods");
        viewModel.uiList.add(ui5);
        binding.tvTitle5.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui6 = new UIParamEntity(6, "用药数量", "", "", 1, "");
        viewModel.uiList.add(ui6);
        binding.tvTitle6.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui7 = new UIParamEntity(7, "蹄病处理", "", "", 4, "card_isTwins");
        viewModel.uiList.add(ui7);
        binding.tvTitle7.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui8 = new UIParamEntity(8, "驱虫", "", "", 4, "card_isTwins");
        viewModel.uiList.add(ui8);
        binding.tvTitle8.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui9 = new UIParamEntity(9, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui9);

        UIParamEntity ui10 = new UIParamEntity(10, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui10);

        UIParamEntity ui11 = new UIParamEntity(11, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui11);

        UIParamEntity ui12 = new UIParamEntity(12, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui12);

        UIParamEntity ui13 = new UIParamEntity(13, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui13);

        UIParamEntity ui14 = new UIParamEntity(14, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui14);

        UIParamEntity ui15 = new UIParamEntity(15, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui15);


        UIParamEntity ui16 = new UIParamEntity(16, "备注", "", "", 2, "");
        viewModel.uiList.add(ui16);
        UIParamEntity ui100 = new UIParamEntity(100, "照片", "", "", 5, "");
        viewModel.uiList.add(ui100);

    }

    //免疫管理-初始化控件列表
    private void initImmunParamList() {

        UIParamEntity ui0 = new UIParamEntity(0, "免疫日期", "", "", 3, "");
        viewModel.uiList.add(ui0);
        binding.tvTitle0.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui1 = new UIParamEntity(1, "免疫有效期(月)", "", "", 1, "");
        viewModel.uiList.add(ui1);
        binding.tvTitle1.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui2 = new UIParamEntity(2, "免疫人员", "", "", 4, "weight_principal");
        viewModel.uiList.add(ui2);
        binding.tvTitle2.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui3 = new UIParamEntity(3, "围药期(月)", "", "", 1, "");
        viewModel.uiList.add(ui3);
        binding.tvTitle3.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui4 = new UIParamEntity(4, "疫苗名称", "", "", 4, "immun_name");
        viewModel.uiList.add(ui4);
        binding.tvTitle4.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui5 = new UIParamEntity(5, "疫苗批号", "", "", 4, "immun_batch");
        viewModel.uiList.add(ui5);
        binding.tvTitle5.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui6 = new UIParamEntity(6, "规格", "", "", 4, "health_specifications");
        viewModel.uiList.add(ui6);
        binding.tvTitle6.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui7 = new UIParamEntity(7, "免疫剂量", "", "", 1, "");
        viewModel.uiList.add(ui7);
        binding.tvTitle7.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui8 = new UIParamEntity(8, "免疫方法", "", "", 4, "health_methods");
        viewModel.uiList.add(ui8);
        binding.tvTitle8.setTextColor(getActivity().getResources().getColor(R.color.colorPrimary));

        UIParamEntity ui9 = new UIParamEntity(9, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui9);

        UIParamEntity ui10 = new UIParamEntity(10, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui10);

        UIParamEntity ui11 = new UIParamEntity(11, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui11);

        UIParamEntity ui12 = new UIParamEntity(12, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui12);

        UIParamEntity ui13 = new UIParamEntity(13, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui13);

        UIParamEntity ui14 = new UIParamEntity(14, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui14);

        UIParamEntity ui15 = new UIParamEntity(15, "暂无项目", "", "", 0, "");
        viewModel.uiList.add(ui15);


        UIParamEntity ui16 = new UIParamEntity(16, "备注", "", "", 2, "");
        viewModel.uiList.add(ui16);
        UIParamEntity ui100 = new UIParamEntity(100, "照片", "", "", 5, "");
        viewModel.uiList.add(ui100);

    }

}
