From f04cf81ff29b91f7ffc84e753c3ef8690617a6aa Mon Sep 17 00:00:00 2001 From: YANGJIANKUAN Date: Thu, 12 Mar 2026 15:51:22 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9B=BD=E9=99=85=E8=BF=9B=E6=B8=AF?= =?UTF-8?q?=E8=A3=85=E6=9C=BA=E5=8D=95=E7=BC=96=E8=BE=91=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E5=8F=8A=E5=88=97=E8=A1=A8=E4=BE=A7=E6=BB=91=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增装机单编辑页面(Activity/ViewModel/布局) - 装机单列表项添加侧滑编辑按钮,点击跳转编辑页 - 修复舱单列表项侧滑按钮未覆盖展开按钮的问题 - 修复装机单列表项两行同列completeSpace不一致 Co-Authored-By: Claude Opus 4.6 --- app/src/main/AndroidManifest.xml | 7 + .../lukouguoji/module_base/http/net/Api.kt | 6 + .../activity/IntImpLoadingListEditActivity.kt | 37 ++ .../gjj/holder/IntImpLoadingListViewHolder.kt | 6 + .../IntImpLoadingListEditViewModel.kt | 86 +++ .../viewModel/IntImpLoadingListViewModel.kt | 17 +- .../activity_int_imp_loading_list_edit.xml | 216 +++++++ .../res/layout/item_int_imp_loading_list.xml | 525 ++++++++-------- .../main/res/layout/item_int_imp_manifest.xml | 558 +++++++++--------- 9 files changed, 928 insertions(+), 530 deletions(-) create mode 100644 module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntImpLoadingListEditActivity.kt create mode 100644 module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListEditViewModel.kt create mode 100644 module_gjj/src/main/res/layout/activity_int_imp_loading_list_edit.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8139ed8..98337de 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -432,6 +432,13 @@ android:exported="false" android:screenOrientation="userLandscape" /> + + + + /** + * 国际进港舱单-分拣理货(装机单)-修改装机单 + */ + @POST("IntImpManifest/modifyManifestAir") + suspend fun modifyIntImpLoadingList(@Body data: RequestBody): BaseResultBean + /** * 国际进港理货报告-分页查询 */ diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntImpLoadingListEditActivity.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntImpLoadingListEditActivity.kt new file mode 100644 index 0000000..ebfec73 --- /dev/null +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntImpLoadingListEditActivity.kt @@ -0,0 +1,37 @@ +package com.lukouguoji.gjj.activity + +import android.content.Context +import android.content.Intent +import android.os.Bundle +import com.google.gson.Gson +import com.lukouguoji.gjj.R +import com.lukouguoji.gjj.databinding.ActivityIntImpLoadingListEditBinding +import com.lukouguoji.gjj.viewModel.IntImpLoadingListEditViewModel +import com.lukouguoji.module_base.base.BaseBindingActivity +import com.lukouguoji.module_base.bean.GjjManifest +import com.lukouguoji.module_base.common.Constant + +/** + * 国际进港-装机单编辑页面 + */ +class IntImpLoadingListEditActivity : + BaseBindingActivity() { + + override fun layoutId() = R.layout.activity_int_imp_loading_list_edit + override fun viewModelClass() = IntImpLoadingListEditViewModel::class.java + + override fun initOnCreate(savedInstanceState: Bundle?) { + setBackArrow("装机单编辑") + binding.viewModel = viewModel + viewModel.initOnCreated(intent) + } + + companion object { + @JvmStatic + fun start(context: Context, bean: GjjManifest) { + val starter = Intent(context, IntImpLoadingListEditActivity::class.java) + .putExtra(Constant.Key.DATA, Gson().toJson(bean)) + context.startActivity(starter) + } + } +} diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpLoadingListViewHolder.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpLoadingListViewHolder.kt index 42fb679..bfbdfc6 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpLoadingListViewHolder.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/holder/IntImpLoadingListViewHolder.kt @@ -22,5 +22,11 @@ class IntImpLoadingListViewHolder(view: View) : bean.checked.set(!bean.checked.get()) binding.executePendingBindings() } + + // 侧滑菜单 - 编辑按钮 + binding.btnEdit.setOnClickListener { + binding.swipeMenu.quickClose() + clickListener?.onItemClick(position, 2000) + } } } diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListEditViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListEditViewModel.kt new file mode 100644 index 0000000..6ba9f4e --- /dev/null +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListEditViewModel.kt @@ -0,0 +1,86 @@ +package com.lukouguoji.gjj.viewModel + +import android.content.Intent +import androidx.lifecycle.MutableLiveData +import androidx.lifecycle.viewModelScope +import com.google.gson.Gson +import com.lukouguoji.module_base.base.BaseViewModel +import com.lukouguoji.module_base.bean.GjjManifest +import com.lukouguoji.module_base.common.Constant +import com.lukouguoji.module_base.common.ConstantEvent +import com.lukouguoji.module_base.http.net.NetApply +import com.lukouguoji.module_base.impl.FlowBus +import com.lukouguoji.module_base.ktx.launchLoadingCollect +import com.lukouguoji.module_base.ktx.showToast +import com.lukouguoji.module_base.ktx.toRequestBody +import kotlinx.coroutines.launch + +/** + * 国际进港装机单编辑 ViewModel + */ +class IntImpLoadingListEditViewModel : BaseViewModel() { + + val dataBean = MutableLiveData(GjjManifest()) + + // 可编辑数值字段(String 用于双向绑定) + val location = MutableLiveData("") + val totalPcStr = MutableLiveData("") + val pcStr = MutableLiveData("") + val weightStr = MutableLiveData("") + val cashWeightStr = MutableLiveData("") + + fun initOnCreated(intent: Intent) { + val jsonData = intent.getStringExtra(Constant.Key.DATA) ?: "" + if (jsonData.isNotEmpty()) { + try { + val bean = Gson().fromJson(jsonData, GjjManifest::class.java) + dataBean.value = bean + // 初始化可编辑字段 + location.value = bean.location + totalPcStr.value = bean.totalPc.toString() + pcStr.value = bean.pc.toString() + weightStr.value = bean.weight.toString() + cashWeightStr.value = bean.cashWeight.toString() + } catch (e: Exception) { + showToast("数据解析失败") + getTopActivity().finish() + } + } else { + showToast("未接收到数据") + getTopActivity().finish() + } + } + + /** + * 保存修改 + */ + fun submit() { + val bean = dataBean.value ?: return + + // 同步可编辑字段回 bean + bean.location = location.value ?: "" + bean.totalPc = totalPcStr.value?.toLongOrNull() ?: 0 + bean.pc = pcStr.value?.toLongOrNull() ?: 0 + bean.weight = weightStr.value?.toDoubleOrNull() ?: 0.0 + bean.cashWeight = cashWeightStr.value?.toDoubleOrNull() ?: 0.0 + + launchLoadingCollect({ + NetApply.api.modifyIntImpLoadingList(bean.toRequestBody()) + }) { + onSuccess = { + showToast("修改成功") + viewModelScope.launch { + FlowBus.with(ConstantEvent.EVENT_REFRESH).emit("refresh") + } + getTopActivity().finish() + } + } + } + + /** + * 取消 + */ + fun cancel() { + getTopActivity().finish() + } +} diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListViewModel.kt index 87b85ac..5269b87 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListViewModel.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpLoadingListViewModel.kt @@ -10,6 +10,7 @@ import com.lukouguoji.module_base.common.Constant import com.lukouguoji.module_base.common.ConstantEvent import com.lukouguoji.module_base.http.net.NetApply import com.lukouguoji.module_base.impl.FlowBus +import com.lukouguoji.module_base.interfaces.IOnItemClickListener import com.lukouguoji.module_base.ktx.commonAdapter import com.lukouguoji.module_base.ktx.launchCollect import com.lukouguoji.module_base.ktx.launchLoadingCollect @@ -23,7 +24,7 @@ import kotlinx.coroutines.launch /** * 国际进港装机单 ViewModel */ -class IntImpLoadingListViewModel : BasePageViewModel() { +class IntImpLoadingListViewModel : BasePageViewModel(), IOnItemClickListener { // ========== 搜索条件 ========== val flightDate = MutableLiveData("") // 航班日期 @@ -278,6 +279,20 @@ class IntImpLoadingListViewModel : BasePageViewModel() { } } + /** + * 列表项点击回调(侧滑菜单) + */ + override fun onItemClick(position: Int, type: Int) { + when (type) { + 2000 -> { + // 编辑操作 + val list = pageModel.rv?.commonAdapter()?.items as? List ?: return + val bean = list.getOrNull(position) ?: return + com.lukouguoji.gjj.activity.IntImpLoadingListEditActivity.start(getTopActivity(), bean) + } + } + } + /** * 获取数据(重写BasePageViewModel) * 查询参数与父页面(国际进港舱单)保持一致:使用FID和FDGP diff --git a/module_gjj/src/main/res/layout/activity_int_imp_loading_list_edit.xml b/module_gjj/src/main/res/layout/activity_int_imp_loading_list_edit.xml new file mode 100644 index 0000000..7eb4d01 --- /dev/null +++ b/module_gjj/src/main/res/layout/activity_int_imp_loading_list_edit.xml @@ -0,0 +1,216 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/module_gjj/src/main/res/layout/item_int_imp_loading_list.xml b/module_gjj/src/main/res/layout/item_int_imp_loading_list.xml index e616f75..5cb31a8 100644 --- a/module_gjj/src/main/res/layout/item_int_imp_loading_list.xml +++ b/module_gjj/src/main/res/layout/item_int_imp_loading_list.xml @@ -15,297 +15,305 @@ type="Integer" /> - + android:layout_marginBottom="10dp"> - - - - + + android:background="@drawable/bg_white_radius_8" + android:orientation="horizontal" + android:padding="15dp" + android:gravity="center_vertical"> - + + + + + android:layout_marginLeft="15dp" + android:layout_weight="1" + android:orientation="vertical"> - + - + + android:layout_weight="1.5" + android:gravity="center_vertical" + android:orientation="horizontal"> - + + + + + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - + + android:layout_weight="1.5" + android:gravity="center_vertical" + android:orientation="horizontal"> - + + + + + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - - + - + + + + android:layout_weight="1.5" + android:gravity="center_vertical" + android:orientation="horizontal"> - + + + + + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - - + - + + + + android:layout_weight="1" + android:gravity="center_vertical" + android:orientation="horizontal"> - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -313,6 +321,21 @@ - + + + + + + + + + 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 297edcf..190e5d8 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,16 +22,18 @@ android:layout_marginBottom="10dp" android:orientation="vertical"> - - + + android:layout_height="wrap_content"> - + + android:layout_height="wrap_content" + android:background="@drawable/bg_white_radius_8" + android:orientation="vertical"> - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + android:layout_marginLeft="10dp" + android:layout_weight="1" + android:orientation="vertical"> - + + android:layout_width="match_parent" + android:layout_height="wrap_content"> - + + android:layout_weight="1.0" + android:gravity="center_vertical"> - + + + + + + + + android:layout_weight="0.8" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + android:layout_marginTop="10dp"> - + + android:layout_weight="1.0" + android:gravity="center_vertical"> - + + + + + + + + android:layout_weight="0.8" + android:gravity="center_vertical"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + 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" /> - + - - - - - - +