package com.wd.workoffice.ui.adapter;


import android.graphics.Color;
import android.text.TextUtils;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.OrderDetail;
import com.wd.workoffice.bean.ReturnApplyBean;
import com.wd.workoffice.bean.ReturnHistoryBean;

import java.util.List;

import androidx.annotation.Nullable;

/**
 * Created by flexible on 2018/8/13.
 */

public class ReturnHistoryAdapter extends BaseQuickAdapter<ReturnHistoryBean, BaseViewHolder> {


    public ReturnHistoryAdapter(int layoutResId, @Nullable List<ReturnHistoryBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ReturnHistoryBean item) {
        if (helper.getAdapterPosition() == 0) {
            helper.setTextColor(R.id.tv_desc, Color.parseColor("#ff359486"));
            helper.setTextColor(R.id.tv_time, Color.parseColor("#ff359486"));
            helper.setTextColor(R.id.tv_remark, Color.parseColor("#ff359486"));
            helper.setBackgroundRes(R.id.tv_dep, R.drawable.shape_green_btn);
            helper.setGone(R.id.iv_last, true);
            helper.setGone(R.id.iv_simple, false);
        } else {
            helper.setTextColor(R.id.tv_desc, helper.getConvertView().getResources().getColor(R.color.flexible_text_gray));
            helper.setTextColor(R.id.tv_time, helper.getConvertView().getResources().getColor(R.color.flexible_text_gray));
            helper.setTextColor(R.id.tv_remark, helper.getConvertView().getResources().getColor(R.color.flexible_text_gray));
            helper.setBackgroundRes(R.id.tv_dep, R.drawable.shape_blue_btn);
            helper.setGone(R.id.iv_last, false);
            helper.setGone(R.id.iv_simple, true);
        }
        String startNum = item.getStatus().substring(0, 1);
        String endNum = item.getStatus().substring(item.getStatus().length() - 1);

        String dep = "";
        switch (endNum) {
            case "0":
                dep = "买家";
                break;
            case "1":
                dep = "部门管理员";
                break;
            case "2":
                dep = "业务员";
                break;
            case "3":
                dep = "财务部";
                break;
            case "4":
                dep = "集团";
                break;
        }
        helper.setText(R.id.tv_dep, dep);
        if (TextUtils.equals("10", item.getStatus())) {
            helper.setText(R.id.tv_time, item.getCreatedTime());
            helper.setText(R.id.tv_desc, item.getCreatedByName().concat("发起退货"));
            helper.setText(R.id.tv_remark,TextUtils.isEmpty(item.getApplyRemark())?"":item.getApplyRemark());
        } else {
            helper.setText(R.id.tv_time, item.getUpdatedTime());
            helper.setText(R.id.tv_desc, item.getUpdatedByName().concat(TextUtils.equals("1", startNum) ? "通过审核" : "驳回审核"));
            helper.setText(R.id.tv_remark,TextUtils.isEmpty(item.getAuditRemark())?"":item.getAuditRemark());
        }
    }

}

