feat: 实现国际进港电报详情页编辑与报文生成功能
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,7 +23,8 @@ class MsgReceivePool(
|
|||||||
var interfaceType: String = "" // 接口类型
|
var interfaceType: String = "" // 接口类型
|
||||||
) : BaseObservable(), ICheck {
|
) : BaseObservable(), ICheck {
|
||||||
|
|
||||||
// 选中状态
|
// 选中状态(UI状态,不参与序列化)
|
||||||
|
@Transient
|
||||||
val checked = ObservableBoolean(false)
|
val checked = ObservableBoolean(false)
|
||||||
|
|
||||||
override fun getCheckObservable() = checked
|
override fun getCheckObservable() = checked
|
||||||
|
|||||||
@@ -4,10 +4,12 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import com.alibaba.android.arouter.facade.annotation.Route
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
|
import com.google.gson.Gson
|
||||||
import com.lukouguoji.gjj.R
|
import com.lukouguoji.gjj.R
|
||||||
import com.lukouguoji.gjj.databinding.ActivityIntArrTelegramDetailsBinding
|
import com.lukouguoji.gjj.databinding.ActivityIntArrTelegramDetailsBinding
|
||||||
import com.lukouguoji.gjj.viewModel.IntArrTelegramDetailsViewModel
|
import com.lukouguoji.gjj.viewModel.IntArrTelegramDetailsViewModel
|
||||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
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.common.Constant
|
||||||
import com.lukouguoji.module_base.router.ARouterConstants
|
import com.lukouguoji.module_base.router.ARouterConstants
|
||||||
|
|
||||||
@@ -23,8 +25,6 @@ class IntArrTelegramDetailsActivity : BaseBindingActivity<ActivityIntArrTelegram
|
|||||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||||
setBackArrow("国际进港电报详情")
|
setBackArrow("国际进港电报详情")
|
||||||
binding.viewModel = viewModel
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
// 初始化数据
|
|
||||||
viewModel.initOnCreated(intent)
|
viewModel.initOnCreated(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,14 +32,14 @@ class IntArrTelegramDetailsActivity : BaseBindingActivity<ActivityIntArrTelegram
|
|||||||
/**
|
/**
|
||||||
* 启动电报详情页面
|
* 启动电报详情页面
|
||||||
* @param context 上下文
|
* @param context 上下文
|
||||||
* @param id 电报ID
|
* @param bean 电报Bean
|
||||||
* @param flow 流向(接收0、发送1)
|
* @param fid 航班ID
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun start(context: Context, id: String, flow: String) {
|
fun start(context: Context, bean: MsgReceivePool, fid: String) {
|
||||||
val starter = Intent(context, IntArrTelegramDetailsActivity::class.java)
|
val starter = Intent(context, IntArrTelegramDetailsActivity::class.java)
|
||||||
.putExtra(Constant.Key.ID, id)
|
.putExtra(Constant.Key.DATA, Gson().toJson(bean))
|
||||||
.putExtra(Constant.Key.FLOW, flow)
|
.putExtra("fid", fid)
|
||||||
context.startActivity(starter)
|
context.startActivity(starter)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,55 +2,74 @@ package com.lukouguoji.gjj.viewModel
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import androidx.lifecycle.MutableLiveData
|
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.base.BaseViewModel
|
||||||
import com.lukouguoji.module_base.bean.TelegramBean
|
import com.lukouguoji.module_base.bean.MsgReceivePool
|
||||||
import com.lukouguoji.module_base.common.Constant
|
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.http.net.NetApply
|
||||||
|
import com.lukouguoji.module_base.impl.FlowBus
|
||||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||||
import com.lukouguoji.module_base.ktx.showToast
|
import com.lukouguoji.module_base.ktx.showToast
|
||||||
|
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国际进港电报详情 ViewModel
|
* 国际进港电报详情 ViewModel
|
||||||
*/
|
*/
|
||||||
class IntArrTelegramDetailsViewModel : BaseViewModel() {
|
class IntArrTelegramDetailsViewModel : BaseViewModel() {
|
||||||
|
|
||||||
var id = ""
|
private var fid = ""
|
||||||
var flow = ""
|
private var msgBean: MsgReceivePool? = null
|
||||||
|
|
||||||
// 电报内容
|
// 电报内容(双向绑定)
|
||||||
val telegramContent = MutableLiveData<String>("")
|
val telegramContent = MutableLiveData("")
|
||||||
|
|
||||||
|
// 是否可编辑(未生成时可编辑)
|
||||||
|
val isEditable = MutableLiveData(false)
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化
|
|
||||||
*/
|
|
||||||
fun initOnCreated(intent: Intent) {
|
fun initOnCreated(intent: Intent) {
|
||||||
id = intent.getStringExtra(Constant.Key.ID) ?: ""
|
fid = intent.getStringExtra("fid") ?: ""
|
||||||
flow = intent.getStringExtra(Constant.Key.FLOW) ?: ""
|
val json = intent.getStringExtra(Constant.Key.DATA) ?: ""
|
||||||
if (id.isNotEmpty() && flow.isNotEmpty()) {
|
if (json.isNotEmpty()) {
|
||||||
getData()
|
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() {
|
fun onModifyClick() {
|
||||||
showToast("修改报文功能待实现")
|
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<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import androidx.lifecycle.viewModelScope
|
|||||||
import com.lukouguoji.gjj.R
|
import com.lukouguoji.gjj.R
|
||||||
import dev.utils.common.DateUtils
|
import dev.utils.common.DateUtils
|
||||||
import com.lukouguoji.module_base.ktx.formatDate
|
import com.lukouguoji.module_base.ktx.formatDate
|
||||||
|
import com.lukouguoji.gjj.activity.IntArrTelegramDetailsActivity
|
||||||
import com.lukouguoji.gjj.holder.IntImpMsgParseViewHolder
|
import com.lukouguoji.gjj.holder.IntImpMsgParseViewHolder
|
||||||
import com.lukouguoji.module_base.base.BasePageViewModel
|
import com.lukouguoji.module_base.base.BasePageViewModel
|
||||||
import com.lukouguoji.module_base.bean.FlightBean
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,31 +19,33 @@
|
|||||||
<include layout="@layout/title_tool_bar" />
|
<include layout="@layout/title_tool_bar" />
|
||||||
|
|
||||||
<!-- 电报内容区域 -->
|
<!-- 电报内容区域 -->
|
||||||
<ScrollView
|
<EditText
|
||||||
|
android:id="@+id/etContent"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="0dp"
|
android:layout_height="0dp"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:layout_margin="20dp"
|
android:layout_margin="20dp"
|
||||||
android:background="@color/white"
|
android:background="@color/white"
|
||||||
android:padding="20dp">
|
android:padding="20dp"
|
||||||
|
android:gravity="top|start"
|
||||||
<TextView
|
android:text="@={viewModel.telegramContent}"
|
||||||
android:id="@+id/tvContent"
|
android:enabled="@{viewModel.isEditable}"
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:text="@{viewModel.telegramContent}"
|
|
||||||
android:textColor="@color/black"
|
android:textColor="@color/black"
|
||||||
android:textSize="16sp"
|
android:textSize="16sp"
|
||||||
android:lineSpacingExtra="4dp" />
|
android:lineSpacingExtra="4dp"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
</ScrollView>
|
android:scrollbars="vertical"
|
||||||
|
android:overScrollMode="always" />
|
||||||
|
|
||||||
<!-- 底部按钮 -->
|
<!-- 底部按钮 -->
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_margin="20dp"
|
android:layout_marginStart="20dp"
|
||||||
android:gravity="center">
|
android:layout_marginEnd="20dp"
|
||||||
|
android:layout_marginBottom="20dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:visibility="@{viewModel.isEditable ? View.VISIBLE : View.GONE}">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="200dp"
|
android:layout_width="200dp"
|
||||||
|
|||||||
Reference in New Issue
Block a user