package com.sixin.module_p.ui.enter.gj

import com.lukouguoji.module_base.base.BaseViewModel
import com.lukouguoji.module_base.bean.ActionBean
import com.lukouguoji.module_base.common.Constant
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
import com.lukouguoji.module_base.ktx.loge
import com.sixin.module_p.R
import com.sixin.module_p.ui.guobang.PdaGuoBangActivity
import com.sixin.module_p.ui.lihuo.PdaLiHuoActivity
import com.sixin.module_p.ui.shouyun.PdaShouYunActivity
import com.sixin.module_p.ui.zuzhuang.PdaZuZhuangActivity
import dev.DevUtils

class GjViewModel : BaseViewModel() {

    val actionList = listOf(
        ActionBean("普货收运", R.drawable.gjc_shou_yun_icon, Constant.AuthName.GjcAppDomExpCheckin),
        ActionBean("板箱组装", R.drawable.img_bxzz, Constant.AuthName.GjcBanXListActivity),
        ActionBean("板箱过磅", R.drawable.gjc_fu_bang_icon, Constant.AuthName.GjcFuBangActivity),
        ActionBean("进港理货", R.drawable.img_jglh, Constant.AuthName.GjjTallyListActivity),
    ).filter { SharedPreferenceUtil.getString(Constant.Share.authList).contains(it.key) }

    fun onItemClick(position: Int) {
        when (val title = actionList[position].title) {
            "普货收运" -> {
                PdaShouYunActivity.start(DevUtils.getTopActivity())
            }

            "板箱组装" -> {
                PdaZuZhuangActivity.start(DevUtils.getTopActivity())
            }

            "板箱过磅" -> {
                PdaGuoBangActivity.start(DevUtils.getTopActivity())
            }

            "进港理货" -> {
                PdaLiHuoActivity.start(DevUtils.getTopActivity())
            }

            else -> {
                loge("点击事件 $title 未处理")
            }
        }
    }

}