feat: 国际出港/进港子列表展开按钮始终显示并增加空状态占位

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 14:18:39 +08:00
parent 8c689d9d65
commit 0427020bc1
12 changed files with 142 additions and 47 deletions

View File

@@ -5,8 +5,8 @@ import com.lukouguoji.gjj.R
import com.lukouguoji.gjj.databinding.ItemIntArrAirManifestBinding
import com.lukouguoji.module_base.adapter.setCommonAdapter
import com.lukouguoji.module_base.base.BaseViewHolder
import com.lukouguoji.module_base.common.ConstantEvent
import com.lukouguoji.module_base.impl.FlowBus
import com.lukouguoji.module_base.common.ConstantEvent
import com.lukouguoji.module_base.impl.FlowBus
import com.lukouguoji.module_base.bean.GjjAirManifest
import com.lukouguoji.module_base.ktx.refresh
@@ -47,7 +47,23 @@ class IntArrAirManifestViewHolder(view: View) :
R.layout.item_int_arr_air_manifest_sub
)
val subList = bean.haWbList ?: emptyList()
binding.rvSub.tag = bean
binding.rvSub.refresh(bean.haWbList ?: emptyList())
binding.rvSub.refresh(subList)
updateSubListVisibility(subList.isNotEmpty())
}
private fun updateSubListVisibility(hasData: Boolean) {
if (hasData) {
binding.llHeader.visibility = View.VISIBLE
binding.dividerHeader.visibility = View.VISIBLE
binding.rvSub.visibility = View.VISIBLE
binding.tvEmpty.visibility = View.GONE
} else {
binding.llHeader.visibility = View.GONE
binding.dividerHeader.visibility = View.GONE
binding.rvSub.visibility = View.GONE
binding.tvEmpty.visibility = View.VISIBLE
}
}
}

View File

@@ -45,5 +45,20 @@ class IntImpStorageUseViewHolder(view: View) :
val storageUseList = bean.storageUseList ?: emptyList()
binding.rvSub.tag = bean
binding.rvSub.refresh(storageUseList)
updateSubListVisibility(storageUseList.isNotEmpty())
}
private fun updateSubListVisibility(hasData: Boolean) {
if (hasData) {
binding.llHeader.visibility = View.VISIBLE
binding.dividerHeader.visibility = View.VISIBLE
binding.rvSub.visibility = View.VISIBLE
binding.tvEmpty.visibility = View.GONE
} else {
binding.llHeader.visibility = View.GONE
binding.dividerHeader.visibility = View.GONE
binding.rvSub.visibility = View.GONE
binding.tvEmpty.visibility = View.VISIBLE
}
}
}

View File

@@ -41,15 +41,15 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
// ========== 全选状态 ==========
val isAllChecked = MutableLiveData(false)
fun onItemCheckChanged() {
updateCheckAllStatus()
}
fun updateCheckAllStatus() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
}
fun onItemCheckChanged() {
updateCheckAllStatus()
}
fun updateCheckAllStatus() {
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
isAllChecked.value = list.isNotEmpty() && list.all { it.checked.get() }
}
// ========== 全部展开状态 ==========
val isAllExpanded = MutableLiveData(false)
@@ -90,9 +90,7 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
isAllExpanded.value = shouldExpand
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return
list.forEach { bean ->
if (!bean.haWbList.isNullOrEmpty()) {
bean.showMore.set(shouldExpand)
}
bean.showMore.set(shouldExpand)
}
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
}

View File

@@ -103,9 +103,7 @@ class IntImpStorageUseViewModel : BasePageViewModel() {
isAllExpanded.value = shouldExpand
list.forEach { bean ->
if (!bean.storageUseList.isNullOrEmpty()) {
bean.showMore.set(shouldExpand)
}
bean.showMore.set(shouldExpand)
}
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()

View File

@@ -314,7 +314,6 @@
<!-- 展开/折叠按钮(卡片内部底部) -->
<ImageView
android:id="@+id/iv_show"
visible="@{bean.haWbList != null &amp;&amp; !bean.haWbList.empty}"
android:layout_width="match_parent"
android:layout_height="20dp"
android:paddingVertical="2.5dp"
@@ -334,8 +333,21 @@
android:orientation="vertical"
android:visibility="gone">
<!-- 暂无数据提示 -->
<TextView
android:id="@+id/tv_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingVertical="15dp"
android:text="暂无分单数据"
android:textColor="@color/text_gray"
android:textSize="14sp"
android:visibility="gone" />
<!-- 表头 -->
<LinearLayout
android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
@@ -445,6 +457,7 @@
</LinearLayout>
<com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_header"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/sub_list_divider" />

View File

@@ -305,7 +305,6 @@
<!-- 展开/折叠按钮 -->
<ImageView
android:id="@+id/iv_show"
visible="@{bean.storageUseList != null &amp;&amp; !bean.storageUseList.empty}"
android:layout_width="match_parent"
android:layout_height="20dp"
android:paddingVertical="2.5dp"
@@ -325,8 +324,21 @@
android:orientation="vertical"
android:visibility="gone">
<!-- 暂无数据提示 -->
<TextView
android:id="@+id/tv_empty"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:paddingVertical="15dp"
android:text="暂无库位数据"
android:textColor="@color/text_gray"
android:textSize="14sp"
android:visibility="gone" />
<!-- 表头 -->
<LinearLayout
android:id="@+id/ll_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginVertical="10dp"
@@ -396,6 +408,7 @@
</LinearLayout>
<com.google.android.material.divider.MaterialDivider
android:id="@+id/divider_header"
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/sub_list_divider" />