package com.example.chemical.ui.adapter

import android.content.Context
import androidx.core.content.ContextCompat
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.example.chemical.R
import com.rc.httpcore.bean.InventoryBean

//库存台账 - 列表
class InventoryAdapter(private val ct: Context) :
    BaseQuickAdapter<InventoryBean, BaseViewHolder>(R.layout.item_inventory) {
    override fun convert(holder: BaseViewHolder, item: InventoryBean) {
        holder.setText(R.id.chemicalName, item.chemicalName)
        holder.setText(R.id.tagCode, item.tagCode)
        holder.setText(R.id.specNum, "${item.specNum}${item.specUnit}/${item.packUnit}")
        holder.setText(R.id.cabinetName, "${item.cabinetName}-${item.doorName}-${item.layers}层")
        if (item.expireTime != null) {
            if (item.expireStatus == 1) {
                holder.setTextColor(R.id.expireTime,ContextCompat.getColor(ct, R.color.purple_ffff7919))
                holder.setText(R.id.expireTime, "${item.expireTime}已过期")
            } else {
                holder.setTextColor(R.id.expireTime,ContextCompat.getColor(ct, R.color.black))
                holder.setText(R.id.expireTime, item.expireTime)
            }
        }else{
            holder.setText(R.id.expireTime, "")
        }
        holder.setText(R.id.belongName, item.belongName)
        holder.setText(R.id.joinTime, item.joinTime)
        holder.setText(R.id.usages, "${item.usages}${item.specUnit}")
        holder.setText(R.id.outTime, item.outTime)
        holder.setText(R.id.statusStr, item.statusStr)
        holder.setText(R.id.surplus, "${item.surplus}${item.specUnit}")

    }
}