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.ProductBean;
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 WorkProductAdapter extends BaseQuickAdapter<ProductBean.RecordsBean, BaseViewHolder> {

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

    @Override
    protected void convert(BaseViewHolder helper, ProductBean.RecordsBean item) {
        helper.setText(R.id.tv_name, item.getSimpleCode());
        helper.setText(R.id.tv_card, "品号:" + item.getSoleCode());
        helper.setText(R.id.tv_img_card, "图号:" + item.getSimpleCode());
        helper.setText(R.id.tv_spec, "规格:" + item.getSpec());
        helper.setText(R.id.tv_price, "￥".concat(String.valueOf(item.getInternalPrice())));
        helper.addOnClickListener(R.id.btn_modify);
        helper.addOnClickListener(R.id.btn_on_sale);
        if (item.getIsExpectOut() == 0) {//未上架
            helper.setText(R.id.btn_on_sale, "上架");
        } else {
            helper.setText(R.id.btn_on_sale, "下架");
        }
        if (!WorkUtils.hasPermission(PagePermissionType.MODIFY_PRICE.getPermission())){
            helper.setGone(R.id.btn_modify,false);
        }
        if (!WorkUtils.hasPermission(PagePermissionType.SHELF.getPermission())){
            helper.setGone(R.id.btn_on_sale,false);
        }
    }
}

