diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index cfe6128..b382fdf 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -98,12 +98,6 @@ android:exported="true" tools:replace="android:exported" /> - - - - - (bean.haWbList.orEmpty()) - IntExpArriveSupplementActivity.start(this, bean.wbNo.orEmpty(), list) - } - override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveSupplementActivity.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveSupplementActivity.kt deleted file mode 100644 index 1d510b2..0000000 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/activity/IntExpArriveSupplementActivity.kt +++ /dev/null @@ -1,41 +0,0 @@ -package com.lukouguoji.gjc.activity - -import android.content.Context -import android.content.Intent -import android.os.Bundle -import com.lukouguoji.gjc.R -import com.lukouguoji.gjc.databinding.ActivityIntExpArriveSupplementBinding -import com.lukouguoji.gjc.viewModel.IntExpArriveSupplementViewModel -import com.lukouguoji.module_base.base.BaseBindingActivity -import com.lukouguoji.module_base.bean.GjcHaWb -import com.lukouguoji.module_base.common.Constant - -/** - * 国际出港运抵-补充信息页(5.5寸手机版专属新页,平板端无对应页面) - * - * 参照 Pad 端国际进港「收发货人信息」补充页的批量应用模式:对该运单整个 haWbList 批量应用 - * 同一份收发货人表单。后端暂无保存接口,见 IntExpArriveSupplementViewModel 顶部注释。 - * 对应设计稿 documents/5.5寸手持端设计文件/04_出港运抵/supplement.html。 - */ -class IntExpArriveSupplementActivity : - BaseBindingActivity() { - - override fun layoutId() = R.layout.activity_int_exp_arrive_supplement - override fun viewModelClass() = IntExpArriveSupplementViewModel::class.java - - override fun initOnCreate(savedInstanceState: Bundle?) { - setBackArrow("补充信息") - binding.viewModel = viewModel - viewModel.initOnCreated(intent) - } - - companion object { - @JvmStatic - fun start(context: Context, wbNo: String, haWbList: ArrayList) { - val starter = Intent(context, IntExpArriveSupplementActivity::class.java) - .putExtra(Constant.Key.CODE, wbNo) - .putExtra(Constant.Key.DATA, haWbList) - context.startActivity(starter) - } - } -} diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveSupplementViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveSupplementViewModel.kt deleted file mode 100644 index eff362a..0000000 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveSupplementViewModel.kt +++ /dev/null @@ -1,119 +0,0 @@ -package com.lukouguoji.gjc.viewModel - -import android.content.Intent -import androidx.lifecycle.MutableLiveData -import com.lukouguoji.module_base.base.BaseViewModel -import com.lukouguoji.module_base.bean.GjcHaWb -import com.lukouguoji.module_base.common.Constant -import com.lukouguoji.module_base.http.net.NetApply -import com.lukouguoji.module_base.ktx.launchCollect -import com.lukouguoji.module_base.ktx.launchLoadingCollect -import com.lukouguoji.module_base.ktx.showToast -import com.lukouguoji.module_base.ktx.toRequestBody -import com.lukouguoji.module_base.ktx.verifyNullOrEmpty -import dev.utils.app.info.KeyValue - -/** - * 国际出港运抵-补充信息 ViewModel(5.5寸手机版专属新页) - * - * 参照 Pad 端国际进港 [com.lukouguoji.gjj.viewModel.IntArrSupplementInfoViewModel] 的 - * 「单一表单批量复制到选中列表」模式:对该运单的整个 haWbList 批量应用同一份收发货人信息。 - * - * ⚠️ 后端暂无保存接口,见 [com.lukouguoji.module_base.http.net.Api.supplementArriveHaWb] 注释 - * 与 documents/后端接口对接问题清单.xlsx。 - */ -class IntExpArriveSupplementViewModel : BaseViewModel() { - - // 表单编辑用数据对象(取首个分单填充,让用户看到已有数据) - val dataBean = MutableLiveData(GjcHaWb()) - - // 批量应用的目标分单列表 - private var haWbList: List = emptyList() - - // 国家代码下拉列表 - val countryCodeList = MutableLiveData>(emptyList()) - - // 通讯方式下拉列表 - val comTypeList = MutableLiveData>(emptyList()) - - @Suppress("UNCHECKED_CAST") - fun initOnCreated(intent: Intent) { - val list = intent.getSerializableExtra(Constant.Key.DATA) as? ArrayList - // .copy() 补上被 Java 序列化跳过的 @Transient 字段(checked 等),见分单明细页同款注释 - haWbList = (list ?: emptyList()).map { it.copy() } - dataBean.value = haWbList.firstOrNull()?.copy() ?: GjcHaWb() - - loadCountryCodeList() - loadComTypeList() - } - - private fun loadCountryCodeList() { - launchCollect({ NetApply.api.getCountryCodeList() }) { - onSuccess = { result -> - countryCodeList.value = result.data?.mapNotNull { bean -> - if (bean.code != null && bean.name != null) KeyValue(bean.name, bean.code) else null - } ?: emptyList() - } - } - } - - private fun loadComTypeList() { - 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() - } - } - } - - fun cancel() { - getTopActivity().finish() - } - - /** - * 保存按钮点击 - 将表单信息复制到该运单的所有分单,批量提交。 - */ - fun save() { - val formBean = dataBean.value ?: return - - if (formBean.consigneeName.verifyNullOrEmpty("收货人名称不能为空")) return - if (formBean.consigneeCountryCode.verifyNullOrEmpty("收货人国家代码不能为空")) return - if (formBean.consigneeComType.verifyNullOrEmpty("收货人通讯方式不能为空")) return - if (formBean.consigneePnum.verifyNullOrEmpty("收货人联系号码不能为空")) return - if (formBean.consignorName.verifyNullOrEmpty("发货人名称不能为空")) return - if (formBean.consignorCountryCode.verifyNullOrEmpty("发货人国家代码不能为空")) return - if (formBean.consignorComType.verifyNullOrEmpty("发货人通讯方式不能为空")) return - if (formBean.consignorPnum.verifyNullOrEmpty("发货人联系号码不能为空")) return - - if (haWbList.isEmpty()) { - showToast("无可保存的分单数据") - return - } - - val updatedList = haWbList.map { haWb -> - haWb.copy( - consigneeName = formBean.consigneeName, - consigneeCountryCode = formBean.consigneeCountryCode, - consigneeComType = formBean.consigneeComType, - consigneePnum = formBean.consigneePnum, - consigneeAddress = formBean.consigneeAddress, - consignorName = formBean.consignorName, - consignorCountryCode = formBean.consignorCountryCode, - consignorComType = formBean.consignorComType, - consignorPnum = formBean.consignorPnum, - consignorAddress = formBean.consignorAddress - ) - } - - launchLoadingCollect({ NetApply.api.supplementArriveHaWb(updatedList.toRequestBody()) }) { - onSuccess = { - showToast("保存成功") - getTopActivity().finish() - } - onFailed = { code, msg -> - showToast("保存失败:$msg(后端接口暂未支持,见接口问题清单)") - } - } - } -} diff --git a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveViewModel.kt b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveViewModel.kt index 4f52294..d20f910 100644 --- a/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveViewModel.kt +++ b/module_gjc/src/main/java/com/lukouguoji/gjc/viewModel/IntExpArriveViewModel.kt @@ -56,7 +56,7 @@ class IntExpArriveViewModel : BasePageViewModel() { // ========== 5.5寸手机版专属(平板布局不引用,零影响) ========== - /** 当前 Tab:"pending"(待运抵) / "shipped"(已运抵)。接口无申报状态查询参数,Tab 由客户端对已加载数据拆分 */ + /** 当前 Tab:"pending"(待运抵) / "shipped"(已运抵)。查询时映射为入参 arrivalStatus=0/1(与平板端运抵状态筛选一致) */ val currentTab = MutableLiveData("pending") /** Tab 配置 */ @@ -64,7 +64,7 @@ class IntExpArriveViewModel : BasePageViewModel() { listOf(KeyValue("待运抵", "pending"), KeyValue("已运抵", "shipped")) ) - /** 两个 Tab 的角标计数(当前已加载数据的客户端统计,非全量,见接口问题清单) */ + /** 两个 Tab 的角标计数(同条件 + arrivalStatus=0/1 各调一次 pageQueryTotal 取 wbNumber,全量口径) */ val arriveTabCounts = MutableLiveData(listOf("0", "0")) /** 手机版空态(当前 Tab 过滤后无数据时显示,对应设计稿 empty-pending) */ @@ -77,61 +77,51 @@ class IntExpArriveViewModel : BasePageViewModel() { /** 手机版已选数量(底部操作条「已选 N 项」) */ val selectedCountPhone = MutableLiveData("0") - /** 手机版筛选弹层「代理」(后端 pageQuery 支持 agentCode 入参,复用既有 agentCode 语义查询) */ - val agentCodePhone = MutableLiveData("") - val agentListPhone = MutableLiveData>(emptyList()) - private var phoneExtrasEnabled = false /** - * 完整已加载列表(跨分页累计,未按 Tab 过滤)。 - * - * ⚠️ RecyclerView/LinearLayoutManager 不会像普通 ViewGroup 那样让 `View.GONE` 的子项 - * 自动塌陷为 0 高度——它仍按子项的测量高度参与滚动区域计算,导致"隐藏"的卡片在列表里 - * 留下一段空白(已实机截图验证)。因此 Tab 切换不能靠给 item 加 visibility 绑定, - * 必须真正地把适配器的数据集替换成过滤后的子集([applyTabFilterPhone])。 - */ - private var allLoadedList: List = emptyList() - - /** - * 开启手机版专属数据:加载「代理」筛选下拉。仅由手机形态的 Activity 调用。 + * 开启手机版专属数据:Tab(arrivalStatus)与角标统计。仅由手机形态的 Activity 调用。 + * 筛选弹层与平板端查询参数一致(航班日期/航班号),agentCode 内网实测被后端忽略,已移除「代理」。 */ fun initPhoneExtras() { phoneExtrasEnabled = true - launchCollect({ NetApply.api.getIntExpAgentList() }) { - onSuccess = { result -> - agentListPhone.postValue( - listOf(KeyValue("全部", "")) + (result.data ?: emptyList()).map { KeyValue(it.name ?: "", it.code ?: "") } - ) - } - } } /** - * 手机版 Tab 切换:将适配器数据集替换为过滤后的子集(不重新请求)。 + * 手机版 Tab 切换:按 arrivalStatus 重新查询(服务端过滤,分页与角标均为全量口径)。 * 由 Activity 在 [com.lukouguoji.module_base.ui.weight.phone.PhoneStatusTab] 的 * 双向绑定写入 currentTab 后调用。 */ fun onTabChangedPhone() { - applyTabFilterPhone() + refresh() } - private fun applyTabFilterPhone() { - val isPendingTab = currentTab.value == "pending" - val filtered = allLoadedList.filter { it.isPending == isPendingTab } - pageModel.rv?.commonAdapter()?.refresh(filtered) - emptyVisiblePhone.value = filtered.isEmpty() + /** 当前 Tab 对应的运抵状态入参:待运抵=0 / 已运抵=1 */ + private fun currentArrivalStatus(): String = + if (currentTab.value == "shipped") "1" else "0" + + /** 列表加载完成后刷新空态文案(服务端已按 Tab 过滤,adapter 即当前 Tab 数据) */ + private fun updateEmptyStatePhone() { + val isPendingTab = currentTab.value != "shipped" + emptyVisiblePhone.value = pageModel.rv?.commonAdapter()?.items.isNullOrEmpty() emptyTextPhone.value = if (isPendingTab) "暂无待运抵的运单" else "暂无已运抵的运单" - updateCheckAllStatusPhone() } /** - * 根据完整已加载列表重新计算 Tab 角标计数(每次数据变化后调用)。 + * 加载 Tab 角标:同条件 + arrivalStatus=0/1 各调一次 pageQueryTotal,取 wbNumber。 */ - private fun updatePhoneTabCounts() { - val pending = allLoadedList.count { it.isPending }.toString() - val shipped = allLoadedList.count { !it.isPending }.toString() - arriveTabCounts.value = listOf(pending, shipped) + private fun loadPhoneTabCounts(filterParams: Map) { + listOf("0", "1").forEachIndexed { index, status -> + launchCollect({ + NetApply.api.getIntExpArriveTotal((filterParams + mapOf("arrivalStatus" to status)).toRequestBody()) + }) { + onSuccess = { result -> + val current = arriveTabCounts.value?.toMutableList() ?: mutableListOf("0", "0") + current[index] = (result.data?.wbNumber ?: 0).toString() + arriveTabCounts.value = current + } + } + } } /** @@ -439,33 +429,30 @@ class IntExpArriveViewModel : BasePageViewModel() { filterParams["wbNo"] = null filterParams["likeNo"] = key } - filterParams["agentCode"] = agentCodePhone.value?.ifEmpty { null } } + // 手机版 Tab 维度(运抵状态),角标需在不含该条件的基础上分别统计 + val tabParams = if (phoneExtrasEnabled) { + filterParams + mapOf("arrivalStatus" to currentArrivalStatus()) + } else filterParams + // 列表参数 (含分页) - val listParams = (filterParams + mapOf( + val listParams = (tabParams + mapOf( "pageNum" to pageModel.page, "pageSize" to pageModel.limit )).toRequestBody() // 统计参数 (无分页) - val totalParams = filterParams.toRequestBody() + val totalParams = tabParams.toRequestBody() // 获取列表 (带Loading) launchLoadingCollect({ NetApply.api.getIntExpArriveList(listParams) }) { onSuccess = { result -> - // 手机版:自行维护完整累计列表(不依赖 adapter.items 的历史状态,见 allLoadedList 注释) - if (phoneExtrasEnabled) { - val newPageItems = result.list ?: emptyList() - allLoadedList = if (pageModel.page <= 1) newPageItems else allLoadedList + newPageItems - } - pageModel.handleListBean(result) { updateCheckAllStatus() if (phoneExtrasEnabled) { - // 用完整列表强制覆盖 adapter 数据集为当前 Tab 的过滤子集 - applyTabFilterPhone() - updatePhoneTabCounts() + updateEmptyStatePhone() + updateCheckAllStatusPhone() } } // 数据加载完成后,重置全局展开状态为收起 @@ -482,5 +469,10 @@ class IntExpArriveViewModel : BasePageViewModel() { totalWeight.value = (data?.totalWeight ?: 0.0).toString() } } + + // 手机版 Tab 角标(平板不触发) + if (phoneExtrasEnabled) { + loadPhoneTabCounts(filterParams) + } } } diff --git a/module_gjc/src/main/res/layout/activity_int_exp_arrive.xml b/module_gjc/src/main/res/layout/activity_int_exp_arrive.xml index c59a272..0e389bb 100644 --- a/module_gjc/src/main/res/layout/activity_int_exp_arrive.xml +++ b/module_gjc/src/main/res/layout/activity_int_exp_arrive.xml @@ -177,15 +177,6 @@ type="@{com.lukouguoji.module_base.ui.weight.phone.PhoneDataLayoutType.INPUT}" value="@={viewModel.flightNo}" /> - - diff --git a/module_gjc/src/main/res/layout/activity_int_exp_arrive_supplement.xml b/module_gjc/src/main/res/layout/activity_int_exp_arrive_supplement.xml deleted file mode 100644 index 32bc29e..0000000 --- a/module_gjc/src/main/res/layout/activity_int_exp_arrive_supplement.xml +++ /dev/null @@ -1,219 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/module_gjc/src/main/res/layout/item_int_exp_arrive.xml b/module_gjc/src/main/res/layout/item_int_exp_arrive.xml index af4e1f8..620404a 100644 --- a/module_gjc/src/main/res/layout/item_int_exp_arrive.xml +++ b/module_gjc/src/main/res/layout/item_int_exp_arrive.xml @@ -217,19 +217,6 @@ android:gravity="center" android:orientation="horizontal"> - - -