package com.grkj.iscs.presentation

import com.grkj.iscs.R
import com.grkj.iscs.view.base.BaseActivity
import com.grkj.iscs.databinding.ActivityCurrentTicketBinding
import com.zhy.adapter.recyclerview.CommonAdapter
import com.zhy.adapter.recyclerview.base.ViewHolder

class CurrentTicketActivity : BaseActivity<ActivityCurrentTicketBinding>() {

    override val viewBinding: ActivityCurrentTicketBinding
        get() = ActivityCurrentTicketBinding.inflate(layoutInflater)

    override fun initView() {
        mBinding?.loTitile?.root?.setBackgroundColor(resources.getColor(R.color.main_color))
        mBinding?.loTitile?.tvNumber?.text = resources.getString(R.string.sop_number)
        mBinding?.loTitile?.tvName?.text = resources.getString(R.string.sop_name)
        mBinding?.loTitile?.tvType?.text = resources.getString(R.string.sop_type)
        mBinding?.loTitile?.tvStartTime?.text = resources.getString(R.string.start_time)
        mBinding?.loTitile?.tvEndTime?.text = resources.getString(R.string.end_time)

        mBinding?.rvCurrent?.adapter = object : CommonAdapter<PresentationManager.PServerTicket>(this, R.layout.item_rv_sop, PresentationManager.workTicketList) {
            override fun convert(holder: ViewHolder, ticket: PresentationManager.PServerTicket?, position: Int) {
                holder.setText(R.id.tv_number, "${ticket?.ticketId}")
                holder.setText(R.id.tv_name, ticket?.sop?.ticketName)
                holder.setText(R.id.tv_type, ticket?.sop?.type)
                holder.setText(R.id.tv_start_time, ticket?.startTime)
                holder.setText(R.id.tv_end_time, ticket?.endTime)
                holder.setText(R.id.tv_action, when(ticket?.status) {
                    0 -> "待上锁人上锁"
                    1 -> "部分共锁人上锁"
                    2 -> "待共锁人解锁"
                    3 -> "部分共锁人解锁"
                    4 -> "待上锁人解锁"
                    5 -> "待归还设备"
                    6 -> "已完成"
                    else -> ""
                })
            }
        }
    }
}