package com.lukouguoji.gjc.page.assemble

import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.databinding.ActivityIntExpAssembleBinding
import com.lukouguoji.gjc.viewModel.IntExpAssembleViewModel
import com.lukouguoji.module_base.base.BaseBindingActivity
import com.lukouguoji.module_base.common.ConstantEvent
import com.lukouguoji.module_base.impl.FlowBus
import com.lukouguoji.module_base.impl.observe
import com.lukouguoji.module_base.ktx.addOnItemClickListener
import com.lukouguoji.module_base.router.ARouterConstants

/**
 * 国际出港-出港组装Activity
 */
@Route(path = ARouterConstants.ACTIVITY_URL_INT_EXP_ASSEMBLE)
class IntExpAssembleActivity :
    BaseBindingActivity<ActivityIntExpAssembleBinding, IntExpAssembleViewModel>() {

    override fun layoutId() = R.layout.activity_int_exp_assemble
    override fun viewModelClass() = IntExpAssembleViewModel::class.java

    override fun initOnCreate(savedInstanceState: Bundle?) {
        setBackArrow("国际出港组装")
        binding.viewModel = viewModel

        // 初始化组装人下拉列表
        viewModel.initAssemblerList()

        // 绑定分页
        viewModel.pageModel.bindSmartRefreshLayout(binding.srl, binding.rv, viewModel, this)

        // 设置item点击监听
        binding.rv.addOnItemClickListener(viewModel)

        // 监听刷新事件
        FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).observe(this) {
            viewModel.refresh()
        }

        // 首次加载数据
        viewModel.refresh()
    }
}
