feat: 国际进港原始舱单添加分单子列表展开/收起功能
- 主列表项下方新增可展开的分单子列表(淡绿色背景) - 子列表展示10列字段:选项/分单号/件数/重量/申报状态/品名/申报次数/申报费率/删除次数/删除费率 - 搜索区域新增全部展开按钮,支持一键展开/收起所有分单 - 全选/取消全选联动子列表checkbox状态 - 主项选中时同步子列表选中,子项勾选时反向联动主项 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,10 @@ data class GjjAirManifest(
|
||||
// 选中状态(用于列表多选)
|
||||
val checked: ObservableBoolean = ObservableBoolean(false)
|
||||
|
||||
// 展开/收起状态(用于子列表显示控制)
|
||||
@Transient
|
||||
val showMore: ObservableBoolean = ObservableBoolean(false)
|
||||
|
||||
// 兼容现有API的isSelected属性
|
||||
var isSelected: Boolean
|
||||
get() = checked.get()
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.lukouguoji.gjj.holder
|
||||
|
||||
import android.view.View
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.lukouguoji.gjj.databinding.ItemIntArrAirManifestSubBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjjAirManifest
|
||||
import com.lukouguoji.module_base.bean.GjjImportManifest
|
||||
|
||||
/**
|
||||
* 国际进港原始舱单 - 分单子列表 ViewHolder
|
||||
*/
|
||||
class IntArrAirManifestSubViewHolder(view: View) :
|
||||
BaseViewHolder<GjjImportManifest, ItemIntArrAirManifestSubBinding>(view) {
|
||||
|
||||
override fun onBind(item: Any?, position: Int) {
|
||||
val bean = getItemBean(item) ?: return
|
||||
binding.bean = bean
|
||||
binding.position = position
|
||||
binding.executePendingBindings()
|
||||
|
||||
// 单选框点击切换选择状态
|
||||
binding.ivCheckbox.setOnClickListener {
|
||||
val newCheckedState = !bean.checked.get()
|
||||
bean.checked.set(newCheckedState)
|
||||
binding.executePendingBindings()
|
||||
|
||||
// 反向联动主列表项(勾选子项时自动勾选父项)
|
||||
if (newCheckedState) {
|
||||
val recyclerView = itemView.parent as? RecyclerView ?: return@setOnClickListener
|
||||
val parentBean = recyclerView.tag as? GjjAirManifest ?: return@setOnClickListener
|
||||
parentBean.checked.set(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.lukouguoji.gjj.holder
|
||||
|
||||
import android.view.View
|
||||
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.bean.GjjAirManifest
|
||||
import com.lukouguoji.module_base.ktx.refresh
|
||||
|
||||
/**
|
||||
* 国际进港原始舱单 ViewHolder
|
||||
@@ -23,10 +26,30 @@ class IntArrAirManifestViewHolder(view: View) :
|
||||
// 整卡点击 - 跳转详情页
|
||||
notifyItemClick(position, binding.ll)
|
||||
|
||||
// 图标点击 - 切换选择状态(拦截,不触发卡片点击)
|
||||
// 图标点击 - 切换选择状态(联动子列表)
|
||||
binding.ivIcon.setOnClickListener {
|
||||
bean.checked.set(!bean.checked.get())
|
||||
val newCheckedState = !bean.checked.get()
|
||||
bean.checked.set(newCheckedState)
|
||||
// 联动子列表选中状态
|
||||
bean.haWbList?.forEach { sub -> sub.checked.set(newCheckedState) }
|
||||
binding.executePendingBindings()
|
||||
}
|
||||
binding.rvSub.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
// 展开按钮点击事件
|
||||
binding.ivShow.setOnClickListener {
|
||||
bean.showMore.set(!bean.showMore.get())
|
||||
}
|
||||
|
||||
// 初始化分单子列表 RecyclerView
|
||||
setCommonAdapter(
|
||||
binding.rvSub,
|
||||
IntArrAirManifestSubViewHolder::class.java,
|
||||
R.layout.item_int_arr_air_manifest_sub
|
||||
)
|
||||
|
||||
// 设置父Bean引用(用于子列表反向联动)
|
||||
binding.rvSub.tag = bean
|
||||
binding.rvSub.refresh(bean.haWbList ?: emptyList())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,17 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
|
||||
// ========== 全选状态 ==========
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
|
||||
// ========== 全部展开状态 ==========
|
||||
val isAllExpanded = MutableLiveData(false)
|
||||
|
||||
init {
|
||||
// 监听全选状态,自动更新所有列表项
|
||||
// 监听全选状态,自动更新所有列表项(含子列表)
|
||||
isAllChecked.observeForever { checked ->
|
||||
val list = pageModel.rv?.commonAdapter()?.items as? List<GjjAirManifest> ?: return@observeForever
|
||||
list.forEach { it.checked.set(checked) }
|
||||
list.forEach {
|
||||
it.checked.set(checked)
|
||||
it.haWbList?.forEach { sub -> sub.checked.set(checked) }
|
||||
}
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
@@ -69,12 +75,30 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
|
||||
|
||||
// 切换全选状态
|
||||
val shouldCheckAll = !isAllChecked.value!!
|
||||
list.forEach { it.checked.set(shouldCheckAll) }
|
||||
list.forEach {
|
||||
it.checked.set(shouldCheckAll)
|
||||
it.haWbList?.forEach { sub -> sub.checked.set(shouldCheckAll) }
|
||||
}
|
||||
isAllChecked.value = shouldCheckAll
|
||||
|
||||
pageModel.rv?.commonAdapter()?.notifyDataSetChanged()
|
||||
}
|
||||
|
||||
/**
|
||||
* 全部展开/收起
|
||||
*/
|
||||
fun toggleAllExpand() {
|
||||
val shouldExpand = !isAllExpanded.value!!
|
||||
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()
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码运单号
|
||||
*/
|
||||
@@ -268,6 +292,7 @@ class IntArrAirManifestViewModel : BasePageViewModel() {
|
||||
// 获取列表(带Loading,接口直接返回PageInfo,无BaseResultBean包装)
|
||||
launchLoadingCollect({ NetApply.api.getIntArrAirManifestList(listParams) }) {
|
||||
onSuccess = { result ->
|
||||
isAllExpanded.value = false
|
||||
pageModel.handleListBean(result.toBaseListBean())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,6 +87,14 @@
|
||||
android:padding="2dp"
|
||||
android:src="@drawable/img_search" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="36dp"
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginStart="8dp"
|
||||
android:onClick="@{()-> viewModel.toggleAllExpand()}"
|
||||
android:padding="4dp"
|
||||
android:src="@drawable/ic_new_expand" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -19,12 +19,19 @@
|
||||
type="Integer" />
|
||||
</data>
|
||||
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/ll"
|
||||
<!-- 主列表项容器 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="15dp"
|
||||
android:layout_marginVertical="5dp"
|
||||
android:orientation="vertical">
|
||||
|
||||
<!-- 白色卡片主要内容区域 -->
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:id="@+id/ll"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/bg_item"
|
||||
android:orientation="horizontal"
|
||||
android:padding="10dp">
|
||||
@@ -275,4 +282,151 @@
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
<!-- 展开/折叠按钮(仅当有分单时显示) -->
|
||||
<ImageView
|
||||
android:id="@+id/iv_show"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:padding="5dp"
|
||||
android:src="@mipmap/img_down"
|
||||
visible="@{bean.haWbList != null && !bean.haWbList.empty}" />
|
||||
|
||||
<!-- 分单子列表容器(淡绿色背景) -->
|
||||
<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">
|
||||
|
||||
<!-- 表头 -->
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginVertical="10dp"
|
||||
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: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.0"
|
||||
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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<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" />
|
||||
|
||||
<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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<com.google.android.material.divider.MaterialDivider
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="1px"
|
||||
android:background="@color/c999999" />
|
||||
|
||||
<!-- 子列表 RecyclerView -->
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rv_sub"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
|
||||
134
module_gjj/src/main/res/layout/item_int_arr_air_manifest_sub.xml
Normal file
134
module_gjj/src/main/res/layout/item_int_arr_air_manifest_sub.xml
Normal file
@@ -0,0 +1,134 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:loadImage="http://schemas.android.com/tools">
|
||||
|
||||
<data>
|
||||
|
||||
<variable
|
||||
name="bean"
|
||||
type="com.lukouguoji.module_base.bean.GjjImportManifest" />
|
||||
|
||||
<variable
|
||||
name="position"
|
||||
type="Integer" />
|
||||
</data>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:paddingHorizontal="10dp"
|
||||
android:paddingVertical="8dp">
|
||||
|
||||
<!-- 选项(单选框) -->
|
||||
<ImageView
|
||||
android:id="@+id/iv_checkbox"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="20dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.5"
|
||||
loadImage="@{bean.checked.get() ? @drawable/radiobtn_checked_gray : @drawable/radiobtn_unchecked_gray}"
|
||||
android:src="@drawable/radiobtn_unchecked_gray" />
|
||||
|
||||
<!-- 分单号 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.hno ?? ``}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 件数 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf((int)bean.pc)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 重量 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf((int)bean.weight)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 申报状态 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.mftStatus ?? ``}"
|
||||
android:textColor="@color/colorPrimary"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 品名(中) -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="1.0"
|
||||
android:gravity="center"
|
||||
android:text="@{bean.goodsCn ?? ``}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 申报次数 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf((int)bean.mftSCount)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 申报费率 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(bean.mftSRate)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 删除次数 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf((int)bean.mftDCount)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<!-- 删除费率 -->
|
||||
<TextView
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(bean.mftDRate)}"
|
||||
android:textColor="@color/text_normal"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</layout>
|
||||
Reference in New Issue
Block a user