From b2cc0059b359a2b454de287d1acdaf2dc6ef17d1 Mon Sep 17 00:00:00 2001 From: YANGJIANKUAN Date: Thu, 5 Mar 2026 16:13:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=9E=E7=8E=B0=E5=9B=BD=E9=99=85?= =?UTF-8?q?=E8=BF=9B=E6=B8=AF=E7=94=B5=E6=8A=A5=E8=AF=A6=E6=83=85=E9=A1=B5?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=8E=E6=8A=A5=E6=96=87=E7=94=9F=E6=88=90?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 --- .../module_base/bean/MsgReceivePool.kt | 3 +- .../activity/IntArrTelegramDetailsActivity.kt | 14 ++-- .../IntArrTelegramDetailsViewModel.kt | 75 ++++++++++++------- .../gjj/viewModel/IntImpMsgParseViewModel.kt | 9 +++ .../activity_int_arr_telegram_details.xml | 32 ++++---- 5 files changed, 82 insertions(+), 51 deletions(-) diff --git a/module_base/src/main/java/com/lukouguoji/module_base/bean/MsgReceivePool.kt b/module_base/src/main/java/com/lukouguoji/module_base/bean/MsgReceivePool.kt index 7a71808..03bb1f1 100644 --- a/module_base/src/main/java/com/lukouguoji/module_base/bean/MsgReceivePool.kt +++ b/module_base/src/main/java/com/lukouguoji/module_base/bean/MsgReceivePool.kt @@ -23,7 +23,8 @@ class MsgReceivePool( var interfaceType: String = "" // 接口类型 ) : BaseObservable(), ICheck { - // 选中状态 + // 选中状态(UI状态,不参与序列化) + @Transient val checked = ObservableBoolean(false) override fun getCheckObservable() = checked diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntArrTelegramDetailsActivity.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntArrTelegramDetailsActivity.kt index a0c7695..fbe7beb 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntArrTelegramDetailsActivity.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/activity/IntArrTelegramDetailsActivity.kt @@ -4,10 +4,12 @@ import android.content.Context import android.content.Intent import android.os.Bundle import com.alibaba.android.arouter.facade.annotation.Route +import com.google.gson.Gson import com.lukouguoji.gjj.R import com.lukouguoji.gjj.databinding.ActivityIntArrTelegramDetailsBinding import com.lukouguoji.gjj.viewModel.IntArrTelegramDetailsViewModel import com.lukouguoji.module_base.base.BaseBindingActivity +import com.lukouguoji.module_base.bean.MsgReceivePool import com.lukouguoji.module_base.common.Constant import com.lukouguoji.module_base.router.ARouterConstants @@ -23,8 +25,6 @@ class IntArrTelegramDetailsActivity : BaseBindingActivity("") + // 电报内容(双向绑定) + val telegramContent = MutableLiveData("") + + // 是否可编辑(未生成时可编辑) + val isEditable = MutableLiveData(false) - /** - * 初始化 - */ fun initOnCreated(intent: Intent) { - id = intent.getStringExtra(Constant.Key.ID) ?: "" - flow = intent.getStringExtra(Constant.Key.FLOW) ?: "" - if (id.isNotEmpty() && flow.isNotEmpty()) { - getData() + fid = intent.getStringExtra("fid") ?: "" + val json = intent.getStringExtra(Constant.Key.DATA) ?: "" + if (json.isNotEmpty()) { + val bean = Gson().fromJson(json, MsgReceivePool::class.java) + msgBean = bean + telegramContent.value = bean.teleContent + isEditable.value = !bean.isGenerated() } } /** - * 获取电报详情 + * 修改报文按钮点击 — 调用报文生成接口 */ - private fun getData() { - launchLoadingCollect({ NetApply.api.getTelegramDetails(flow, id) }) { - onSuccess = { result -> - val data = result.data - if (data is TelegramBean) { - telegramContent.value = data.teleContent - } else if (data is Map<*, *>) { - telegramContent.value = data["teleContent"]?.toString() ?: "" + fun onModifyClick() { + val bean = msgBean ?: return + val content = telegramContent.value ?: "" + if (content.isEmpty()) { + showToast("报文内容不能为空") + return + } + + // 更新报文内容 + bean.teleContent = content + + val requestData = mapOf( + "fid" to fid.toLongOrNull(), + "msgList" to listOf(bean) + ).toRequestBody() + + launchLoadingCollect({ NetApply.api.analyseMsg(requestData) }) { + onSuccess = { + showToast("报文生成成功") + // 更新状态为已生成 + bean.anaStatus = "1" + isEditable.value = false + // 通知列表刷新 + viewModelScope.launch { + FlowBus.with(ConstantEvent.EVENT_REFRESH).emit("refresh") } } } } - - /** - * 修改报文按钮点击 - */ - fun onModifyClick() { - showToast("修改报文功能待实现") - } } diff --git a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpMsgParseViewModel.kt b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpMsgParseViewModel.kt index 902ecf0..3c7bed1 100644 --- a/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpMsgParseViewModel.kt +++ b/module_gjj/src/main/java/com/lukouguoji/gjj/viewModel/IntImpMsgParseViewModel.kt @@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope import com.lukouguoji.gjj.R import dev.utils.common.DateUtils import com.lukouguoji.module_base.ktx.formatDate +import com.lukouguoji.gjj.activity.IntArrTelegramDetailsActivity import com.lukouguoji.gjj.holder.IntImpMsgParseViewHolder import com.lukouguoji.module_base.base.BasePageViewModel import com.lukouguoji.module_base.bean.FlightBean @@ -215,4 +216,12 @@ class IntImpMsgParseViewModel : BasePageViewModel() { } } } + + /** + * 列表项点击 — 跳转电报详情页 + */ + override fun onItemClick(position: Int, type: Int) { + val bean = pageModel.rv?.commonAdapter()?.getItem(position) as? MsgReceivePool ?: return + IntArrTelegramDetailsActivity.start(getTopActivity(), bean, fid) + } } diff --git a/module_gjj/src/main/res/layout/activity_int_arr_telegram_details.xml b/module_gjj/src/main/res/layout/activity_int_arr_telegram_details.xml index 3463716..58e0065 100644 --- a/module_gjj/src/main/res/layout/activity_int_arr_telegram_details.xml +++ b/module_gjj/src/main/res/layout/activity_int_arr_telegram_details.xml @@ -19,31 +19,33 @@ - - - - - + android:padding="20dp" + android:gravity="top|start" + android:text="@={viewModel.telegramContent}" + android:enabled="@{viewModel.isEditable}" + android:textColor="@color/black" + android:textSize="16sp" + android:lineSpacingExtra="4dp" + android:inputType="textMultiLine" + android:scrollbars="vertical" + android:overScrollMode="always" /> + android:layout_marginStart="20dp" + android:layout_marginEnd="20dp" + android:layout_marginBottom="20dp" + android:gravity="center" + android:visibility="@{viewModel.isEditable ? View.VISIBLE : View.GONE}">