diff --git a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjjHaWb.kt b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjjHaWb.kt index b5412b0..a802d11 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/bean/GjjHaWb.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/bean/GjjHaWb.kt @@ -16,6 +16,7 @@ data class GjjHaWb( var volume: Double = 0.0, var cashWeight: Double = 0.0, var goods: String = "", + var goodsCn: String = "", var spCode: String = "", var mftStatus: String = "", var lastMftStatus: String = "", diff --git a/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt b/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt index 9441887..662923b 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/http/net/Api.kt @@ -301,6 +301,12 @@ interface Api { @POST("typeCode/countryType") suspend fun getAreaTypeList(): DictListBean + /** + * 获取通讯方式类型 + */ + @POST("typeCode/communicateType") + suspend fun getCommunicateTypeList(): DictListBean + /** * 查询平板车信息 */ @@ -1814,7 +1820,7 @@ interface Api { * 国际进港舱单-分页查询 */ @POST("IntImpManifest/pageQuery") - suspend fun getIntImpManifestList(@Body data: RequestBody): BaseResultBean> + suspend fun getIntImpManifestList(@Body data: RequestBody): PageInfo /** * 国际进港舱单-分页合计 diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpManifestViewHolder.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpManifestViewHolder.kt index 395ba27..95c73a5 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpManifestViewHolder.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpManifestViewHolder.kt @@ -40,9 +40,14 @@ class IntImpManifestViewHolder(view: View) : clickListener?.onItemClick(position, 102) // 102=删除 } - // 展开按钮点击事件 + // 展开按钮点击事件 - 先加载分单数据,再切换展开状态 binding.ivShow.setOnClickListener { - bean.showMore.set(!bean.showMore.get()) + if (!bean.showMore.get() && bean.haWbList.isNullOrEmpty()) { + // 首次展开且无数据,通知 ViewModel 加载分单 + clickListener?.onItemClick(position, 103) // 103=加载分单 + } else { + bean.showMore.set(!bean.showMore.get()) + } } // 初始化分单子列表 RecyclerView diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt index 60c0ed0..82fd336 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntArrSupplementInfoViewModel.kt @@ -69,13 +69,18 @@ class IntArrSupplementInfoViewModel : BaseViewModel() { } /** - * 加载通讯方式下拉列表(本地固定值) + * 加载通讯方式下拉列表 */ private fun loadComTypeList() { - comTypeList.value = listOf( - KeyValue("电话(TE)", "TE"), - KeyValue("传真(FX)", "FX") - ) + launchCollect({ NetApply.api.getCommunicateTypeList() }) { + onSuccess = { result -> + comTypeList.value = result.data?.mapNotNull { bean -> + if (bean.code != null && bean.name != null) { + KeyValue(bean.name, bean.code) + } else null + } ?: emptyList() + } + } } /** diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpManifestViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpManifestViewModel.kt index 30d8cc0..65fe78a 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpManifestViewModel.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpManifestViewModel.kt @@ -34,12 +34,13 @@ class IntImpManifestViewModel : BasePageViewModel() { val flightNo = MutableLiveData("") // 航班号 val sendAddress = MutableLiveData("") // 始发站 val sendAddressList = MutableLiveData>(emptyList()) - val fdep = MutableLiveData("") // 目的站 + val fdest = MutableLiveData("") // 目的站 val waybillNo = MutableLiveData("") // 运单号 // ========== 航班级联查询 ========== private var lastQueriedFlight = "" private var fid = "" + private var fdep = "" // 航班始发港(用于列表查询参数) fun onFlightDateInputComplete() { lastQueriedFlight = "" @@ -72,7 +73,8 @@ class IntImpManifestViewModel : BasePageViewModel() { if (it.verifySuccess() && it.data != null) { val flight = it.data!! fid = flight.fid.noNull() - fdep.value = flight.fdest.noNull() + fdep = flight.fdep.noNull() + fdest.value = flight.fdest.noNull() // 构建始发站下拉列表:fdep + jtz(经停港) val list = mutableListOf( @@ -85,7 +87,8 @@ class IntImpManifestViewModel : BasePageViewModel() { sendAddress.value = flight.fdep.noNull() } else { fid = "" - fdep.value = "" + fdep = "" + fdest.value = "" sendAddressList.value = emptyList() sendAddress.value = "" showToast(it.msg.noNull("获取航班信息失败")) @@ -94,7 +97,8 @@ class IntImpManifestViewModel : BasePageViewModel() { onFailed = { _, _ -> fid = "" - fdep.value = "" + fdep = "" + fdest.value = "" sendAddressList.value = emptyList() sendAddress.value = "" } @@ -153,7 +157,8 @@ class IntImpManifestViewModel : BasePageViewModel() { if (it.verifySuccess() && it.data != null) { val flight = it.data!! fid = flight.fid.noNull() - fdep.value = flight.fdest.noNull() + fdep = flight.fdep.noNull() + fdest.value = flight.fdest.noNull() val list = mutableListOf( KeyValue(flight.fdep.noNull(), flight.fdep.noNull()), ) @@ -164,7 +169,8 @@ class IntImpManifestViewModel : BasePageViewModel() { sendAddress.value = flight.fdep.noNull() } else { fid = "" - fdep.value = "" + fdep = "" + fdest.value = "" sendAddressList.value = emptyList() sendAddress.value = "" showToast(it.msg.noNull("获取航班信息失败")) @@ -173,7 +179,8 @@ class IntImpManifestViewModel : BasePageViewModel() { } onFailed = { _, _ -> fid = "" - fdep.value = "" + fdep = "" + fdest.value = "" sendAddressList.value = emptyList() sendAddress.value = "" refresh() @@ -184,6 +191,7 @@ class IntImpManifestViewModel : BasePageViewModel() { } } else { fid = "" + fdep = "" refresh() } } @@ -212,10 +220,19 @@ class IntImpManifestViewModel : BasePageViewModel() { val shouldExpand = !isAllExpanded.value!! isAllExpanded.value = shouldExpand val list = pageModel.rv?.commonAdapter()?.items as? List ?: return - list.forEach { - if (!it.haWbList.isNullOrEmpty()) { - it.showMore.set(shouldExpand) + + if (shouldExpand) { + // 展开:对没有分单数据的项按需加载 + list.forEach { bean -> + if (bean.haWbList.isNullOrEmpty()) { + loadHaWbList(bean) + } else { + bean.showMore.set(true) + } } + } else { + // 收起 + list.forEach { it.showMore.set(false) } } pageModel.rv?.commonAdapter()?.notifyDataSetChanged() } @@ -235,7 +252,7 @@ class IntImpManifestViewModel : BasePageViewModel() { context = getTopActivity(), fid = fid, dep = sendAddress.value ?: "", - dest = fdep.value ?: "" + dest = fdest.value ?: "" ) } @@ -254,6 +271,10 @@ class IntImpManifestViewModel : BasePageViewModel() { // 删除 deleteManifest(bean) } + 103 -> { + // 展开 - 加载分单数据 + loadHaWbList(bean) + } } } @@ -314,7 +335,7 @@ class IntImpManifestViewModel : BasePageViewModel() { .withString("fdate", flightDate.value ?: "") .withString("fno", flightNo.value ?: "") .withString("sendAddress", sendAddress.value ?: "") - .withString("fdest", fdep.value ?: "") + .withString("fdest", fdest.value ?: "") .navigation() } @@ -333,8 +354,7 @@ class IntImpManifestViewModel : BasePageViewModel() { // 构建搜索条件(使用FID代替fdate/fno) val filterParams = mapOf( "fid" to fid.ifEmpty { null }, - "sendAddress" to sendAddress.value?.ifEmpty { null }, - "fdep" to fdep.value?.ifEmpty { null }, + "fdep" to fdep.ifEmpty { null }, "wbNo" to waybillNo.value?.ifEmpty { null } ) @@ -350,15 +370,7 @@ class IntImpManifestViewModel : BasePageViewModel() { // 获取列表(带Loading) launchLoadingCollect({ NetApply.api.getIntImpManifestList(listParams) }) { onSuccess = { result -> - pageModel.handleListBean(result.data?.toBaseListBean()) - - // 列表加载完成后,加载分单数据 - val items = pageModel.rv?.commonAdapter()?.items as? List - items?.forEach { bean -> - if (bean.haWbNum > 0) { - loadHaWbList(bean) - } - } + pageModel.handleListBean(result.toBaseListBean()) } } @@ -374,18 +386,21 @@ class IntImpManifestViewModel : BasePageViewModel() { } /** - * 加载主单下的分单列表 + * 加载主单下的分单列表(按需加载,加载完成后自动展开) */ private fun loadHaWbList(bean: GjjManifest) { val params = mapOf( "mfId" to bean.mfId ).toRequestBody() - launchCollect({ NetApply.api.getIntImpManifestHaWbList(params) }) { + launchLoadingCollect({ NetApply.api.getIntImpManifestHaWbList(params) }) { onSuccess = { result -> if (result.verifySuccess() && !result.data.isNullOrEmpty()) { bean.haWbList = result.data + bean.showMore.set(true) pageModel.rv?.commonAdapter()?.notifyDataSetChanged() + } else { + showToast("暂无分单数据") } } } diff --git a/module_gjj/src/main/res/layout/activity_int_imp_manifest.xml b/module_gjj/src/main/res/layout/activity_int_imp_manifest.xml index 071065c..34cab76 100644 --- a/module_gjj/src/main/res/layout/activity_int_imp_manifest.xml +++ b/module_gjj/src/main/res/layout/activity_int_imp_manifest.xml @@ -66,7 +66,7 @@ hint='@{"目的站"}' enable="@{false}" type="@{SearchLayoutType.INPUT}" - value="@={viewModel.fdep}" + value="@={viewModel.fdest}" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" /> diff --git a/module_gjj/src/main/res/layout/item_int_imp_manifest.xml b/module_gjj/src/main/res/layout/item_int_imp_manifest.xml index bd153b4..297edcf 100644 --- a/module_gjj/src/main/res/layout/item_int_imp_manifest.xml +++ b/module_gjj/src/main/res/layout/item_int_imp_manifest.xml @@ -22,20 +22,26 @@ android:layout_marginBottom="10dp" android:orientation="vertical"> - + + android:layout_height="wrap_content" + android:background="@drawable/bg_white_radius_8" + android:orientation="vertical"> - - + android:layout_height="wrap_content"> - + + + + - - + + android:layout_height="wrap_content"> - - - - - - - - - - - + + android:layout_weight="1.0" + android:gravity="center_vertical"> + + + + + + + + + @@ -108,20 +110,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -133,20 +134,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -158,20 +158,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -183,30 +182,27 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + - - + + android:layout_marginTop="10dp"> - + android:layout_weight="1.0" + android:gravity="center_vertical"> @@ -218,20 +214,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -243,20 +238,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -268,20 +262,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -293,30 +286,19 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - - - - - - + - + android:layout_weight="0.8" + android:gravity="center_vertical"> @@ -328,21 +310,21 @@ android:textColor="@color/text_normal" android:textSize="16sp" /> - + - + - + + - - + - + - - + + + + @@ -48,6 +50,8 @@ android:layout_gravity="center_vertical" android:layout_weight="1.0" android:gravity="center" + android:maxLines="1" + android:ellipsize="end" android:text="@{bean.hno ?? ``}" android:textColor="@color/text_normal" android:textSize="14sp" /> @@ -57,8 +61,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_weight="0.8" + android:layout_weight="0.6" android:gravity="center" + android:maxLines="1" + android:ellipsize="end" android:text="@{String.valueOf((int)bean.pc)}" android:textColor="@color/text_normal" android:textSize="14sp" /> @@ -68,8 +74,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_weight="0.8" + android:layout_weight="0.6" android:gravity="center" + android:maxLines="1" + android:ellipsize="end" android:text="@{String.valueOf((int)bean.weight)}" android:textColor="@color/text_normal" android:textSize="14sp" /> @@ -79,8 +87,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_weight="0.8" + android:layout_weight="0.6" android:gravity="center" + android:maxLines="1" + android:ellipsize="end" android:text="@{bean.mftStatus ?? ``}" android:textColor="@color/colorPrimary" android:textSize="14sp" /> @@ -90,8 +100,10 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_weight="0.8" + android:layout_weight="0.6" android:gravity="center" + android:maxLines="1" + android:ellipsize="end" android:text="@{bean.lastMftStatus ?? ``}" android:textColor="@color/colorPrimary" android:textSize="14sp" /> @@ -101,9 +113,11 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" - android:layout_weight="1.0" + android:layout_weight="1.8" android:gravity="center" - android:text="@{bean.goods ?? ``}" + android:maxLines="1" + android:ellipsize="end" + android:text='@{bean.goodsCn != null && !bean.goodsCn.isEmpty() ? bean.goodsCn : (bean.goods ?? ``)}' android:textColor="@color/text_normal" android:textSize="14sp" />