package com.wd.workoffice.ui.adapter;


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.workEnum.PagePermissionType;
import com.wd.workoffice.util.WorkUtils;

import java.util.List;

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

public class SupplierOrderDetailProductAdapter extends BaseQuickAdapter<OrderDetail.OrderItemsBean, BaseViewHolder> {
    int status;

    public SupplierOrderDetailProductAdapter(int layoutResId, List data, Integer status) {
        super(layoutResId, data);
        this.status = status;
    }


    @Override
    protected void convert(BaseViewHolder helper, OrderDetail.OrderItemsBean item) {
        helper.setText(R.id.tv_name, item.getProductName());
        helper.setText(R.id.tv_card, item.getProductSoleCode());
        helper.setText(R.id.tv_card_name, item.getProductSimpleCode());
        helper.setText(R.id.tv_spec, item.getProductSpec());
        helper.setText(R.id.tv_price, "￥".concat(String.valueOf(item.getInnerPrice())));
        helper.setText(R.id.tv_all_price, "￥".concat(String.valueOf(item.getInnerPrice())));
        helper.setText(R.id.tv_unit, item.getProductUnit());
        helper.setText(R.id.tv_from, WorkUtils.getOrderFrom(item.getType()));
        helper.setText(R.id.tv_num, String.valueOf(item.getProductCount()));
        helper.addOnClickListener(R.id.tv_get);
        helper.addOnClickListener(R.id.tv_return);
        helper.addOnClickListener(R.id.tv_flow);
        helper.addOnClickListener(R.id.tv_add);
        helper.addOnClickListener(R.id.tv_quality);
        helper.setGone(R.id.tv_quality, true);
        switch (status) {
//          "待审核", "待接单", "待生产", "已入库","已交付"};
//           "100", "200", "710", "500","600"};
            case 100:
                break;
            case 200:
                break;
            case 300:
                helper.setGone(R.id.ll_btn, true);
                helper.setGone(R.id.tv_get, false);
                helper.setGone(R.id.tv_return, false);
                break;
            case 400:
                helper.setGone(R.id.ll_btn, true);
                helper.setGone(R.id.tv_get, false);
                helper.setGone(R.id.tv_return, false);
                break;
            case 500:
                helper.setGone(R.id.ll_btn, true);
                helper.setGone(R.id.tv_get, false);
                helper.setGone(R.id.tv_return, false);
                break;
            case 600:
                helper.setGone(R.id.ll_btn, true);
                helper.setGone(R.id.tv_get, false);
                break;
        }
        if (!WorkUtils.hasPermission(PagePermissionType.FO_QUALITY_PAGE.getPermission())) {
            helper.setGone(R.id.tv_quality, false);
        }
        if (!WorkUtils.hasPermission(PagePermissionType.FO_ENTER_PAGE.getPermission())) {
            helper.setGone(R.id.tv_add, false);
        }
    }
}

