package com.xty.server.adapter

import android.widget.TextView
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.xty.base.adapter.BaseAdapter
import com.xty.network.model.AppointmentBean
import com.xty.network.model.AppointmentNewBean
import com.xty.server.R

class AppointmentAdapter(var page:Int):BaseAdapter<AppointmentNewBean>(R.layout.item_new_appointment) {
    val txtCol by lazy{ arrayOf(R.color.col_455,R.color.col_009)}
    override fun convert(holder: BaseViewHolder, item: AppointmentNewBean) {
//        holder.setTextColorRes(R.id.mTvOnLine,txtCol[page])
        var f = ""

        when (item.orderStatus){
            2-> f = ""
            3-> { f = "确认时间："

            }
            4-> { f = "拒绝时间："

            }
            7-> { f = "过期时间："

            }
        }
        holder.setText(R.id.name_tv,item.realname)
            .setText(R.id.Prud_tv,item.positionName)
            .setText(
                R.id.appiont_time_tv,
                "预约时间：${item.reservationDate} ${item.startTime}-${item.endTime}"
            )
            .setText(R.id.commit_time_tv, "提交时间：${item.orderCreateTime ?: ""}")
            .setText(R.id.category_tv,"备注：${item.remark?:"" }")

        if (item.orderStatus!=2) {
            holder.setText(R.id.ans_time_tv, "$f${item.orderUpdateTime ?: ""}")
        }
//            .setText(R.id.keep_ans_tv,item.reservationDate)

//        var statusView = holder.getView<TextView>(R.id.mTvStatus)

//        when(item.orderStatus){
//
//            1->changeStatus(statusView,R.mipmap.ic_programme_confirm,"待支付")
//            2->changeStatus(statusView,R.mipmap.ic_programme_confirm,"待确认")
//            3->changeStatus(statusView,R.mipmap.ic_programme_confirm,"待接诊")
//            4->changeStatus(statusView,R.mipmap.ic_programme_cancel,"已取消")
//            5->changeStatus(statusView,R.mipmap.ic_programme_cancel,"医生取消")
//            6->changeStatus(statusView,R.mipmap.ic_programme_cancel,"时间重叠")
//            7->changeStatus(statusView,R.mipmap.ic_programme_cancel,"已完成")
//
//        }
    }
    private fun changeStatus(tv:TextView,res:Int,str:String) {
        tv.text=str
        tv.setBackgroundResource(res)

    }
}