From 8e1d716159120670da9bdfba22b6b5f8330ffe5d Mon Sep 17 00:00:00 2001 From: YANGJIANKUAN Date: Thu, 4 Dec 2025 12:13:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BD=E9=99=85=E5=87=BA=E6=B8=AF?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=A6=E6=83=85=20tab=20=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/settings.local.json | 3 +- .../gjc/fragment/GjcQueryWarehouseFragment.kt | 57 ++++++- .../gjc/holder/GjcQueryWarehouseViewHolder.kt | 20 +++ .../res/layout/activity_gjc_query_details.xml | 3 +- .../layout/fragment_gjc_query_warehouse.xml | 147 ++++++++++++++++-- .../res/layout/item_gjc_query_warehouse.xml | 106 +++++++++++++ 6 files changed, 323 insertions(+), 13 deletions(-) create mode 100644 module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcQueryWarehouseViewHolder.kt create mode 100644 module_gjc/src/main/res/layout/item_gjc_query_warehouse.xml diff --git a/.claude/settings.local.json b/.claude/settings.local.json index ce47dc4..cced56b 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -31,7 +31,8 @@ "Bash(git -C /Users/kid/Development/Fusion/Projects/aerologic-app branch -a)", "Bash(adb:*)", "Bash(emulator:*)", - "Bash(logcat:*)" + "Bash(logcat:*)", + "Bash(grep:*)" ], "deny": [], "ask": [] diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/fragment/GjcQueryWarehouseFragment.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/fragment/GjcQueryWarehouseFragment.kt index e0f6f90..ac7f168 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/fragment/GjcQueryWarehouseFragment.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/fragment/GjcQueryWarehouseFragment.kt @@ -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.FragmentGjcQueryWarehouseBinding +import com.lukouguoji.gjc.holder.GjcQueryWarehouseViewHolder import com.lukouguoji.gjc.viewModel.GjcQueryDetailsViewModel +import com.lukouguoji.module_base.base.CommonAdapter +import com.lukouguoji.module_base.bean.GjcWarehouse +import com.lukouguoji.module_base.http.net.NetApply /** - * 国际出港查询详情 - 仓库信息Fragment (空实现) + * 国际出港查询详情 - 仓库信息Fragment */ class GjcQueryWarehouseFragment : Fragment() { private lateinit var binding: FragmentGjcQueryWarehouseBinding private lateinit var viewModel: GjcQueryDetailsViewModel + private lateinit var adapter: CommonAdapter override fun onCreateView( inflater: LayoutInflater, @@ -30,9 +36,58 @@ class GjcQueryWarehouseFragment : Fragment() { false ) binding.lifecycleOwner = viewLifecycleOwner + + initRecyclerView() + observeData() + return binding.root } + /** + * 初始化RecyclerView + */ + private fun initRecyclerView() { + adapter = CommonAdapter( + requireContext(), + R.layout.item_gjc_query_warehouse, + GjcQueryWarehouseViewHolder::class.java + ) + + binding.rvWarehouseList.apply { + layoutManager = LinearLayoutManager(requireContext()) + adapter = this@GjcQueryWarehouseFragment.adapter + } + } + + /** + * 观察数据变化 + */ + private fun observeData() { + viewModel.warehouseList.observe(viewLifecycleOwner) { mapList -> + if (mapList.isEmpty()) { + // 显示空数据提示 + binding.rvWarehouseList.visibility = View.GONE + binding.llEmpty.visibility = View.VISIBLE + } else { + // Map → GjcWarehouse Bean 转换 + val beanList = mapList.map { map -> + try { + val json = NetApply.gson.toJson(map) + NetApply.gson.fromJson(json, GjcWarehouse::class.java) + } catch (e: Exception) { + e.printStackTrace() + GjcWarehouse() // 转换失败返回空对象 + } + } + + // 更新RecyclerView + binding.rvWarehouseList.visibility = View.VISIBLE + binding.llEmpty.visibility = View.GONE + adapter.refresh(beanList) + } + } + } + companion object { @JvmStatic fun newInstance(vm: GjcQueryDetailsViewModel) = diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcQueryWarehouseViewHolder.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcQueryWarehouseViewHolder.kt new file mode 100644 index 0000000..588465d --- /dev/null +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/holder/GjcQueryWarehouseViewHolder.kt @@ -0,0 +1,20 @@ +package com.lukouguoji.gjc.holder + +import android.view.View +import com.lukouguoji.gjc.databinding.ItemGjcQueryWarehouseBinding +import com.lukouguoji.module_base.base.BaseViewHolder +import com.lukouguoji.module_base.bean.GjcWarehouse + +/** + * 国际出港查询详情-仓库信息ViewHolder + */ +class GjcQueryWarehouseViewHolder(view: View) : + BaseViewHolder(view) { + + override fun onBind(item: Any?, position: Int) { + val bean = getItemBean(item) ?: return + binding.bean = bean + binding.position = position // 用于显示序号和背景切换 + binding.executePendingBindings() + } +} diff --git a/module_gjc/src/main/res/layout/activity_gjc_query_details.xml b/module_gjc/src/main/res/layout/activity_gjc_query_details.xml index 72b94d0..34b34b7 100644 --- a/module_gjc/src/main/res/layout/activity_gjc_query_details.xml +++ b/module_gjc/src/main/res/layout/activity_gjc_query_details.xml @@ -110,7 +110,8 @@ diff --git a/module_gjc/src/main/res/layout/fragment_gjc_query_warehouse.xml b/module_gjc/src/main/res/layout/fragment_gjc_query_warehouse.xml index e7e63f4..f42e7f4 100644 --- a/module_gjc/src/main/res/layout/fragment_gjc_query_warehouse.xml +++ b/module_gjc/src/main/res/layout/fragment_gjc_query_warehouse.xml @@ -1,19 +1,146 @@ - + + + + + + + android:orientation="vertical" + android:paddingHorizontal="15dp" + android:paddingBottom="15dp"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/module_gjc/src/main/res/layout/item_gjc_query_warehouse.xml b/module_gjc/src/main/res/layout/item_gjc_query_warehouse.xml new file mode 100644 index 0000000..05481ef --- /dev/null +++ b/module_gjc/src/main/res/layout/item_gjc_query_warehouse.xml @@ -0,0 +1,106 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +