feat: 国际出港查询详情
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package com.lukouguoji.gjc.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ActivityGjcQueryDetailsBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.base.CustomVP2Adapter
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国际出港查询详情页面
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJC_QUERY_DETAILS)
|
||||
class GjcQueryDetailsActivity :
|
||||
BaseBindingActivity<ActivityGjcQueryDetailsBinding, GjcQueryDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjc_query_details
|
||||
override fun viewModelClass() = GjcQueryDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际出港查询详情")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 初始化ViewModel(传入maWbId)
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
// 配置ViewPager2
|
||||
binding.vp.adapter = CustomVP2Adapter(
|
||||
viewModel.fragmentList,
|
||||
supportFragmentManager,
|
||||
lifecycle
|
||||
)
|
||||
binding.vp.isUserInputEnabled = false // 禁用滑动
|
||||
binding.vp.offscreenPageLimit = 3 // 预加载3个Fragment
|
||||
|
||||
// 监听Tab索引变化,切换Fragment
|
||||
viewModel.currentTab.observe(this) {
|
||||
binding.vp.setCurrentItem(it, false) // false:无动画
|
||||
}
|
||||
|
||||
// 加载详情数据
|
||||
viewModel.loadDetails()
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, maWbId: Long?) {
|
||||
val starter = Intent(context, GjcQueryDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.ID, maWbId?.toString() ?: "")
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,13 +25,9 @@ class GjcQueryEditActivity :
|
||||
override fun viewModelClass() = GjcQueryEditViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("国际出港运单修改")
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 处理返回按钮点击
|
||||
binding.root.findViewById<android.widget.LinearLayout>(R.id.tool_back)?.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
// 初始化数据
|
||||
viewModel.initOnCreated(intent)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.lukouguoji.gjc.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.FragmentGjcQueryStorageBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel
|
||||
|
||||
/**
|
||||
* 国际出港查询详情 - 库位信息Fragment (空实现)
|
||||
*/
|
||||
class GjcQueryStorageFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentGjcQueryStorageBinding
|
||||
private lateinit var viewModel: GjcQueryDetailsViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = DataBindingUtil.inflate(
|
||||
inflater,
|
||||
R.layout.fragment_gjc_query_storage,
|
||||
container,
|
||||
false
|
||||
)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
return binding.root
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(vm: GjcQueryDetailsViewModel) =
|
||||
GjcQueryStorageFragment().apply {
|
||||
viewModel = vm
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.lukouguoji.gjc.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.FragmentGjcQueryWarehouseBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel
|
||||
|
||||
/**
|
||||
* 国际出港查询详情 - 仓库信息Fragment (空实现)
|
||||
*/
|
||||
class GjcQueryWarehouseFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentGjcQueryWarehouseBinding
|
||||
private lateinit var viewModel: GjcQueryDetailsViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = DataBindingUtil.inflate(
|
||||
inflater,
|
||||
R.layout.fragment_gjc_query_warehouse,
|
||||
container,
|
||||
false
|
||||
)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
return binding.root
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(vm: GjcQueryDetailsViewModel) =
|
||||
GjcQueryWarehouseFragment().apply {
|
||||
viewModel = vm
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.lukouguoji.gjc.fragment
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.FragmentGjcQueryWaybillBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel
|
||||
|
||||
/**
|
||||
* 国际出港查询详情 - 运单信息Fragment
|
||||
*/
|
||||
class GjcQueryWaybillFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentGjcQueryWaybillBinding
|
||||
private lateinit var viewModel: GjcQueryDetailsViewModel
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
savedInstanceState: Bundle?
|
||||
): View {
|
||||
binding = DataBindingUtil.inflate(
|
||||
inflater,
|
||||
R.layout.fragment_gjc_query_waybill,
|
||||
container,
|
||||
false
|
||||
)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
binding.viewModel = viewModel
|
||||
return binding.root
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(vm: GjcQueryDetailsViewModel) =
|
||||
GjcQueryWaybillFragment().apply {
|
||||
viewModel = vm
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.lukouguoji.gjc.holder
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.activity.GjcQueryDetailsActivity
|
||||
import com.lukouguoji.gjc.activity.GjcQueryEditActivity
|
||||
import com.lukouguoji.gjc.databinding.ItemGjcQueryBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
@@ -21,11 +22,10 @@ class GjcQueryViewHolder(view: View) :
|
||||
// 立即更新UI(避免闪烁)
|
||||
binding.executePendingBindings()
|
||||
|
||||
// 整行点击事件(暂时不跳转详情页)
|
||||
// binding.ll.setOnClickListener {
|
||||
// // 后续可添加详情页跳转
|
||||
// // GjcQueryDetailsActivity.start(it.context, bean.maWbId)
|
||||
// }
|
||||
// 整行点击事件 - 跳转详情页
|
||||
binding.ll.setOnClickListener {
|
||||
GjcQueryDetailsActivity.start(it.context, bean.maWbId)
|
||||
}
|
||||
|
||||
// 修改按钮点击事件
|
||||
binding.root.findViewById<TextView>(R.id.btnEdit)?.setOnClickListener {
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.lukouguoji.gjc.viewModel
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.gjc.fragment.GjcQueryStorageFragment
|
||||
import com.lukouguoji.gjc.fragment.GjcQueryWarehouseFragment
|
||||
import com.lukouguoji.gjc.fragment.GjcQueryWaybillFragment
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
|
||||
/**
|
||||
* 国际出港查询详情-ViewModel
|
||||
*/
|
||||
class GjcQueryDetailsViewModel : BaseViewModel() {
|
||||
|
||||
// ==================== 基础数据 ====================
|
||||
var maWbId: String = "" // 运单主键ID
|
||||
|
||||
// ==================== Tab管理 ====================
|
||||
val currentTab = MutableLiveData(0) // 当前Tab索引 (0/1/2)
|
||||
|
||||
// ==================== 详情数据 ====================
|
||||
val detailData = MutableLiveData<Map<String, Any>>(emptyMap())
|
||||
|
||||
// ==================== Fragment列表 ====================
|
||||
val fragmentList by lazy {
|
||||
listOf(
|
||||
GjcQueryWaybillFragment.newInstance(this), // 运单信息
|
||||
GjcQueryWarehouseFragment.newInstance(this), // 仓库信息
|
||||
GjcQueryStorageFragment.newInstance(this) // 库位信息
|
||||
)
|
||||
}
|
||||
|
||||
// ==================== 方法区 ====================
|
||||
|
||||
/**
|
||||
* 初始化(从Intent获取maWbId)
|
||||
*/
|
||||
fun initOnCreated(intent: Intent) {
|
||||
maWbId = intent.getStringExtra(Constant.Key.ID) ?: ""
|
||||
}
|
||||
|
||||
/**
|
||||
* Tab点击事件
|
||||
*/
|
||||
fun onTabClick(index: Int) {
|
||||
currentTab.value = index
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载详情数据
|
||||
*/
|
||||
fun loadDetails() {
|
||||
if (maWbId.isEmpty()) {
|
||||
showToast("运单ID为空")
|
||||
return
|
||||
}
|
||||
|
||||
val params = mapOf("maWbId" to maWbId.toLongOrNull()).toRequestBody()
|
||||
|
||||
launchLoadingCollect({ NetApply.api.getGjcQueryDetails(params) }) {
|
||||
onSuccess = { result ->
|
||||
detailData.value = result.data ?: emptyMap()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user