fix: 国际进港舱单新增/编辑页航程不再随始发站目的站联动
航程改为仅由航班信息决定:航班查询成功取航班起始站-目的站, 编辑模式取舱单 fdep-fdest,从列表页带入时取传入的航班始发/目的站; 用户手动修改始发站、目的站时航程保持不变 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -2,7 +2,6 @@ package com.lukouguoji.gjj.viewModel
|
|||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import androidx.lifecycle.MediatorLiveData
|
|
||||||
import androidx.lifecycle.MutableLiveData
|
import androidx.lifecycle.MutableLiveData
|
||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
@@ -103,10 +102,12 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
fid = flight.fid.noNull()
|
fid = flight.fid.noNull()
|
||||||
departure.value = flight.fdep.noNull()
|
departure.value = flight.fdep.noNull()
|
||||||
destination.value = flight.fdest.noNull()
|
destination.value = flight.fdest.noNull()
|
||||||
|
range.value = flight.getHangCheng()
|
||||||
} else {
|
} else {
|
||||||
fid = ""
|
fid = ""
|
||||||
departure.value = ""
|
departure.value = ""
|
||||||
destination.value = ""
|
destination.value = ""
|
||||||
|
range.value = ""
|
||||||
showToast(it.msg.noNull("获取航班信息失败"))
|
showToast(it.msg.noNull("获取航班信息失败"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -114,6 +115,7 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
fid = ""
|
fid = ""
|
||||||
departure.value = ""
|
departure.value = ""
|
||||||
destination.value = ""
|
destination.value = ""
|
||||||
|
range.value = ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,15 +144,15 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
// 目的港
|
// 目的港
|
||||||
val destination = MutableLiveData("")
|
val destination = MutableLiveData("")
|
||||||
|
|
||||||
// 航程(自动拼接:始发站-目的站)
|
// 航程(航班起始站-航班目的站,仅随航班信息变化,不随用户修改始发站/目的站联动)
|
||||||
val range = MediatorLiveData<String>().apply {
|
val range = MutableLiveData("")
|
||||||
val update = {
|
|
||||||
val dep = departure.value ?: ""
|
/**
|
||||||
val dest = destination.value ?: ""
|
* 按航班起始站/目的站拼接航程,起始站为空时返回空
|
||||||
value = if (dep.isNotEmpty() || dest.isNotEmpty()) "$dep-$dest" else ""
|
*/
|
||||||
}
|
private fun buildRange(fdep: String?, fdest: String?): String {
|
||||||
addSource(departure) { update() }
|
if (fdep.isNullOrEmpty()) return ""
|
||||||
addSource(destination) { update() }
|
return "$fdep-${fdest ?: ""}"
|
||||||
}
|
}
|
||||||
|
|
||||||
// 品名(中)
|
// 品名(中)
|
||||||
@@ -204,6 +206,8 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
fid = intent.getStringExtra(Constant.Key.ID).noNull()
|
fid = intent.getStringExtra(Constant.Key.ID).noNull()
|
||||||
departure.value = intent.getStringExtra(Constant.Key.DEPARTURE).noNull()
|
departure.value = intent.getStringExtra(Constant.Key.DEPARTURE).noNull()
|
||||||
destination.value = intent.getStringExtra(Constant.Key.DESTINATION).noNull()
|
destination.value = intent.getStringExtra(Constant.Key.DESTINATION).noNull()
|
||||||
|
// 列表页传入的是航班的始发站/目的站,用于初始化航程
|
||||||
|
range.value = buildRange(departure.value, destination.value)
|
||||||
|
|
||||||
// 回填航班日期和航班号(从列表页传入)
|
// 回填航班日期和航班号(从列表页传入)
|
||||||
val passedFlightDate = intent.getStringExtra("flightDate").noNull()
|
val passedFlightDate = intent.getStringExtra("flightDate").noNull()
|
||||||
@@ -317,6 +321,7 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
billingWeight.value = manifest.cashWeight.toString()
|
billingWeight.value = manifest.cashWeight.toString()
|
||||||
departure.value = manifest.origin
|
departure.value = manifest.origin
|
||||||
destination.value = manifest.dest
|
destination.value = manifest.dest
|
||||||
|
range.value = buildRange(manifest.fdep, manifest.fdest)
|
||||||
goodsNameCn.value = manifest.goodsCn
|
goodsNameCn.value = manifest.goodsCn
|
||||||
goodsNameEn.value = manifest.goods
|
goodsNameEn.value = manifest.goods
|
||||||
unNumber.value = manifest.unNumber
|
unNumber.value = manifest.unNumber
|
||||||
@@ -362,6 +367,7 @@ class GjjManifestAddViewModel : BaseViewModel(), IOnItemClickListener {
|
|||||||
actualWeight.value = manifest.weight.toString()
|
actualWeight.value = manifest.weight.toString()
|
||||||
departure.value = manifest.origin
|
departure.value = manifest.origin
|
||||||
destination.value = manifest.dest
|
destination.value = manifest.dest
|
||||||
|
range.value = buildRange(manifest.fdep, manifest.fdest)
|
||||||
goodsNameCn.value = manifest.goodsCn
|
goodsNameCn.value = manifest.goodsCn
|
||||||
goodsNameEn.value = manifest.goods
|
goodsNameEn.value = manifest.goods
|
||||||
unNumber.value = manifest.unNumber
|
unNumber.value = manifest.unNumber
|
||||||
|
|||||||
Reference in New Issue
Block a user