package com.wd.workoffice.ui.adapter;


import android.text.TextUtils;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wd.workoffice.R;
import com.wd.workoffice.bean.ContactsBean;
import com.wd.workoffice.bean.MoneyOutBean;
import com.wd.workoffice.bean.workEnum.PagePermissionType;
import com.wd.workoffice.util.MathUtils;
import com.wd.workoffice.util.WorkUtils;

import java.util.List;

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

public class WorkFinancialOutAdapter extends BaseQuickAdapter<MoneyOutBean.RecordsBean, BaseViewHolder> {
    int type;

    public WorkFinancialOutAdapter(int layoutResId, List data) {
        super(layoutResId, data);
    }

    public WorkFinancialOutAdapter(int layoutResId, List data, int type) {
        super(layoutResId, data);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder helper, MoneyOutBean.RecordsBean item) {
        helper.setText(R.id.tv_name, item.getSerialNumber());
        helper.setText(R.id.tv_dep, item.getApplyDeptName());
        helper.setText(R.id.tv_client, item.getCustomerName());

        helper.setText(R.id.tv_process, item.getProcessName());
        helper.setText(R.id.tv_order_type, item.getOrderTypeName());
        helper.setText(R.id.tv_price,MathUtils.converData(item.getApplyAmount(),3));
        helper.setText(R.id.tv_status, WorkUtils.getFinancialStatus(Integer.valueOf(item.getStatus())));
        boolean hasPermission;
        if (type == 1) {
            hasPermission = WorkUtils.hasPermission(PagePermissionType.MONEY_BACK_EXAM.getPermission());
        } else {
            hasPermission = WorkUtils.hasPermission(PagePermissionType.MONEY_PAY_EXAM.getPermission());
        }
        if (TextUtils.equals("0", item.getStatus()) && hasPermission) {
            helper.setGone(R.id.ll_check, true);
        } else {
            helper.setGone(R.id.ll_check, false);
        }
        helper.addOnClickListener(R.id.btn_agree);
        helper.addOnClickListener(R.id.btn_refuse);
    }
}

