package com.lukouguoji.aerologic.page.gnj.move.stash.list

import android.view.View
import android.widget.Toast
import com.lukouguoji.aerologic.databinding.ItemGnjMoveStashListBinding
import com.lukouguoji.gnj.page.yiku.handover.GnjYiKuHandoverActivity
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.bean.MoveStashBean

class GnjMoveStashListViewHolder(view: View) :
    BaseViewHolder<MoveStashBean, ItemGnjMoveStashListBinding>(view) {

    override fun onBind(item: Any?, position: Int) {
        val bean = getItemBean(item)!!
        binding.bean = bean

        binding.ivIcon.setOnClickListener {
            bean.checked.set(!bean.checked.get())
        }

        // 点击列表项进入移交详情
        binding.ll.setOnClickListener {
            GnjYiKuHandoverActivity.startForDetails(itemView.context, bean.mawbId)
        }

        // 侧滑菜单 - 编辑按钮
        binding.btnEdit.setOnClickListener {
            binding.swipeMenu.quickClose()
            if (bean.pickFlag == "1") {
                Toast.makeText(itemView.context, "已出库，不可编辑", Toast.LENGTH_SHORT).show()
                return@setOnClickListener
            }
            GnjYiKuHandoverActivity.startForEdit(itemView.context, bean.mawbId)
        }
    }
}
