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

@@ -24,20 +24,17 @@ class IntExpArriveViewHolder(view: View) :
// 添加图标点击事件 - 切换选择状态
binding.ivIcon.setOnClickListener {
// 反转checked状态
bean.checked.set(!bean.checked.get())
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
// 立即更新UI图片自动切换
binding.executePendingBindings()
}
// ========== 展开按钮点击事件 ==========
// 展开按钮点击事件
binding.ivShow.setOnClickListener {
bean.showMore.set(!bean.showMore.get())
}
// ========== 初始化子列表 RecyclerView ==========
// 初始化子列表 RecyclerView
setCommonAdapter(
binding.rvSub,
IntExpArriveSubViewHolder::class.java,
@@ -45,6 +42,22 @@ class IntExpArriveViewHolder(view: View) :
)
// 刷新子列表数据
binding.rvSub.refresh(bean.haWbList ?: emptyList())
val subList = 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

@@ -24,20 +24,17 @@ class IntExpTallyViewHolder(view: View) :
// 图标点击切换选择状态(主单和分单独立,互不干扰)
binding.ivIcon.setOnClickListener {
// 只切换主单自己的选择状态,不同步到分单
bean.checked.set(!bean.checked.get())
FlowBus.with<String>(ConstantEvent.EVENT_CHECK_CHANGED).tryEmit("check_changed")
// 刷新UI
binding.executePendingBindings()
}
// ========== 新增:展开按钮点击事件 ==========
// 展开按钮点击事件
binding.ivShow.setOnClickListener {
bean.showMore.set(!bean.showMore.get())
}
// ========== 新增:初始化子列表 RecyclerView ==========
// 初始化子列表 RecyclerView
setCommonAdapter(
binding.rvSub,
IntExpTallySubViewHolder::class.java,
@@ -45,6 +42,22 @@ class IntExpTallyViewHolder(view: View) :
)
// 刷新子列表数据
binding.rvSub.refresh(bean.haWbList ?: emptyList())
val subList = 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

@@ -95,13 +95,9 @@ class IntExpArriveViewModel : BasePageViewModel() {
val shouldExpand = !isAllExpanded.value!!
isAllExpanded.value = shouldExpand
// 更新所有列表项的 showMore 状态
list.forEach { bean ->
// 只有当有子列表时才设置展开状态
if (!bean.haWbList.isNullOrEmpty()) {
bean.showMore.set(shouldExpand)
}
}
// 刷新列表UI
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()

View File

@@ -96,13 +96,9 @@ class IntExpTallyViewModel : BasePageViewModel() {
val shouldExpand = !isAllExpanded.value!!
isAllExpanded.value = shouldExpand
// 更新所有列表项的 showMore 状态
list.forEach { bean ->
// 只有当有子列表时才设置展开状态
if (!bean.haWbList.isNullOrEmpty()) {
bean.showMore.set(shouldExpand)
}
}
// 刷新列表UI
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()

View File

@@ -336,7 +336,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"
@@ -356,8 +355,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"
@@ -467,6 +479,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

@@ -76,7 +76,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"
@@ -86,8 +85,19 @@
</LinearLayout>
<!-- 子订单列表容器(在白色卡片外面) -->
<LinearLayout visible="@{bean.showMore}" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="5dp" android:background="#e3f6e0" 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:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginVertical="10dp" android:paddingHorizontal="10dp" android:orientation="horizontal">
<LinearLayout android:id="@+id/ll_header" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginVertical="10dp" android:paddingHorizontal="10dp" android:orientation="horizontal">
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.5" android:gravity="center" android:text="选项" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1.2" android:gravity="center" android:text="分单号" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.8" android:gravity="center" android:text="件数" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
@@ -100,6 +110,7 @@
<TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="0.9" android:gravity="center" android:text="删除费率" android:textColor="@color/text_normal" android:textSize="14sp" android:textStyle="bold"/>
</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

@@ -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

@@ -90,10 +90,8 @@ 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)
}
}
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
}

View File

@@ -103,10 +103,8 @@ class IntImpStorageUseViewModel : BasePageViewModel() {
isAllExpanded.value = shouldExpand
list.forEach { bean ->
if (!bean.storageUseList.isNullOrEmpty()) {
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" />