feat: 国际出港查询详情 tab 库位信息
This commit is contained in:
@@ -6,17 +6,23 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.FragmentGjcQueryStorageBinding
|
||||
import com.lukouguoji.gjc.holder.GjcQueryStorageViewHolder
|
||||
import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.CommonAdapter
|
||||
import com.lukouguoji.module_base.bean.GjcStorageUse
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
|
||||
/**
|
||||
* 国际出港查询详情 - 库位信息Fragment (空实现)
|
||||
* 国际出港查询详情 - 库位信息Fragment
|
||||
*/
|
||||
class GjcQueryStorageFragment : Fragment() {
|
||||
|
||||
private lateinit var binding: FragmentGjcQueryStorageBinding
|
||||
private lateinit var viewModel: GjcQueryDetailsViewModel
|
||||
private lateinit var adapter: CommonAdapter
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@@ -30,9 +36,58 @@ class GjcQueryStorageFragment : Fragment() {
|
||||
false
|
||||
)
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
initRecyclerView()
|
||||
observeData()
|
||||
|
||||
return binding.root
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化RecyclerView
|
||||
*/
|
||||
private fun initRecyclerView() {
|
||||
adapter = CommonAdapter(
|
||||
requireContext(),
|
||||
R.layout.item_gjc_query_storage,
|
||||
GjcQueryStorageViewHolder::class.java
|
||||
)
|
||||
|
||||
binding.rvStorageList.apply {
|
||||
layoutManager = LinearLayoutManager(requireContext())
|
||||
adapter = this@GjcQueryStorageFragment.adapter
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 观察数据变化
|
||||
*/
|
||||
private fun observeData() {
|
||||
viewModel.storageUseList.observe(viewLifecycleOwner) { mapList ->
|
||||
if (mapList.isEmpty()) {
|
||||
// 显示空数据提示
|
||||
binding.rvStorageList.visibility = View.GONE
|
||||
binding.llEmpty.visibility = View.VISIBLE
|
||||
} else {
|
||||
// Map → GjcStorageUse Bean 转换
|
||||
val beanList = mapList.map { map ->
|
||||
try {
|
||||
val json = NetApply.gson.toJson(map)
|
||||
NetApply.gson.fromJson(json, GjcStorageUse::class.java)
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
GjcStorageUse() // 转换失败返回空对象
|
||||
}
|
||||
}
|
||||
|
||||
// 更新RecyclerView
|
||||
binding.rvStorageList.visibility = View.VISIBLE
|
||||
binding.llEmpty.visibility = View.GONE
|
||||
adapter.refresh(beanList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun newInstance(vm: GjcQueryDetailsViewModel) =
|
||||
|
||||
Reference in New Issue
Block a user