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) =
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.lukouguoji.gjc.holder
|
||||
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjc.databinding.ItemGjcQueryStorageBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjcStorageUse
|
||||
|
||||
/**
|
||||
* 国际出港查询详情-库位信息ViewHolder
|
||||
*/
|
||||
class GjcQueryStorageViewHolder(view: View) :
|
||||
BaseViewHolder<GjcStorageUse, ItemGjcQueryStorageBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item) ?: return
|
||||
binding.bean = bean
|
||||
binding.position = position // 用于显示序号和背景切换
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,115 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||
|
||||
<data>
|
||||
|
||||
<import type="android.view.View" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingHorizontal="15dp"
|
||||
android:paddingBottom="15dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_white_radius_bottom_8"
|
||||
android:orientation="vertical"
|
||||
android:paddingEnd="8dp">
|
||||
|
||||
<!-- 表头 (浅灰色背景) -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="40dp"
|
||||
android:background="@color/color_f2"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="10dp">
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
android:text="序号"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="库位号"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="入库人"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="入库时间"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="出库人"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="出库时间"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="14sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 数据列表 -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_storage_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:nestedScrollingEnabled="true"
|
||||
android:overScrollMode="never"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
<!-- 暂无数据提示 (数据为空时显示) -->
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_empty"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical"
|
||||
android:visibility="gone">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
@@ -14,6 +117,10 @@
|
||||
android:text="暂无数据"
|
||||
android:textColor="@color/text_gray"
|
||||
android:textSize="16sp" />
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
|
||||
86
module_gjc/src/main/res/layout/item_gjc_query_storage.xml
Normal file
86
module_gjc/src/main/res/layout/item_gjc_query_storage.xml
Normal file
@@ -0,0 +1,86 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="bean"
|
||||
type="com.lukouguoji.module_base.bean.GjcStorageUse" />
|
||||
|
||||
<variable
|
||||
name="position"
|
||||
type="Integer" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@{position % 2 == 0 ? @color/white : @color/color_f2}"
|
||||
android:gravity="center_vertical"
|
||||
android:minHeight="40dp"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="8dp">
|
||||
|
||||
<!-- 序号 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.5"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(position + 1)}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 库位号 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.storageCode ?? `--`}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 入库人 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.inId ?? `--`}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 入库时间 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.inDate != null ? String.valueOf(bean.inDate).substring(0, 16) : `--`}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 出库人 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.outId ?? `--`}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 出库时间 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.5"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.outDate != null ? String.valueOf(bean.outDate).substring(0, 16) : `--`}"
|
||||
android:textColor="@android:color/black"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
</layout>
|
||||
Reference in New Issue
Block a user