feat: opt ui
This commit is contained in:
@@ -41,8 +41,6 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
|
||||
|
||||
// 统计数据
|
||||
val totalCount = MutableLiveData("0") // 合计票数
|
||||
val totalPc = MutableLiveData("0") // 总件数
|
||||
val totalWeight = MutableLiveData("0") // 总重量
|
||||
|
||||
// 全选状态
|
||||
val isAllChecked = MutableLiveData(false)
|
||||
@@ -103,8 +101,6 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
|
||||
onSuccess = { result ->
|
||||
val data = result.data
|
||||
totalCount.value = (data?.wbNumber ?: 0).toString()
|
||||
totalPc.value = (data?.totalPc ?: 0).toString()
|
||||
totalWeight.value = (data?.totalWeight ?: 0.0).toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.GjcHandoverSheetBean
|
||||
import com.lukouguoji.module_base.bean.GjcMaWb
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.http.net.NetApply
|
||||
import com.lukouguoji.module_base.ktx.*
|
||||
import java.util.Date
|
||||
|
||||
/**
|
||||
* 国际出港货物交接单 ViewModel
|
||||
@@ -20,6 +22,21 @@ class GjcHandoverViewModel : BaseViewModel() {
|
||||
// 数据Bean
|
||||
val dataBean = MutableLiveData(GjcHandoverSheetBean())
|
||||
|
||||
// ========== 主单数据持有者 ==========
|
||||
val maWbData = MutableLiveData<GjcMaWb>(GjcMaWb())
|
||||
|
||||
// ========== 计算/格式化字段 ==========
|
||||
val displayAgentName = MutableLiveData<String>() // 托运人/交货单位/盖章单位
|
||||
val displayDeliveryDate = MutableLiveData<String>() // 交货日期(2025年12月03日)
|
||||
val displayFlightPlan = MutableLiveData<String>() // 计划班期(MU5555/2025-12-03/LAX)
|
||||
val displayWaybillNo = MutableLiveData<String>() // 货单号(834-91508524)
|
||||
val displayGoods = MutableLiveData<String>() // 品名(优先中文)
|
||||
val displayPc = MutableLiveData<String>() // 件数
|
||||
val displayWeight = MutableLiveData<String>() // 重量
|
||||
val displayVolume = MutableLiveData<String>() // 体积
|
||||
val displayChargeWeight = MutableLiveData<String>() // 计费重量
|
||||
val displayRemark = MutableLiveData<String>() // 备注
|
||||
|
||||
// ========== 跨境电商单选框 ==========
|
||||
val cbEcFlag = MutableLiveData("1") // 默认选中"是"
|
||||
|
||||
@@ -94,6 +111,12 @@ class GjcHandoverViewModel : BaseViewModel() {
|
||||
|
||||
dataBean.value = bean
|
||||
|
||||
// 填充主单数据
|
||||
maWbData.value = maWb ?: GjcMaWb()
|
||||
|
||||
// 计算格式化字段
|
||||
updateDisplayFields(maWb)
|
||||
|
||||
// 填充CheckBox状态
|
||||
updateCheckBoxState(bean)
|
||||
|
||||
@@ -302,4 +325,119 @@ class GjcHandoverViewModel : BaseViewModel() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新格式化/计算字段
|
||||
*/
|
||||
private fun updateDisplayFields(maWb: GjcMaWb?) {
|
||||
if (maWb == null) {
|
||||
displayAgentName.value = ""
|
||||
displayDeliveryDate.value = ""
|
||||
displayFlightPlan.value = ""
|
||||
displayWaybillNo.value = ""
|
||||
displayGoods.value = ""
|
||||
displayPc.value = "0"
|
||||
displayWeight.value = "0.0"
|
||||
displayVolume.value = "0.0"
|
||||
displayChargeWeight.value = "0.0"
|
||||
displayRemark.value = ""
|
||||
return
|
||||
}
|
||||
|
||||
// 1. 托运人/交货单位/盖章单位
|
||||
displayAgentName.value = maWb.agentName ?: ""
|
||||
|
||||
// 2. 交货日期格式化:Date → "2025年12月03日"
|
||||
displayDeliveryDate.value = formatDeliveryDate(maWb.opDate)
|
||||
|
||||
// 3. 计划班期拼接:航班号/日期/目的地
|
||||
displayFlightPlan.value = buildFlightPlan(maWb.fno, maWb.fdate, maWb.dest)
|
||||
|
||||
// 4. 货单号拼接:prefix-no
|
||||
displayWaybillNo.value = buildWaybillNo(maWb.prefix, maWb.no)
|
||||
|
||||
// 5. 品名(优先中文)
|
||||
displayGoods.value = maWb.goodsCn?.ifEmpty { maWb.goods } ?: maWb.goods ?: ""
|
||||
|
||||
// 6. 件数
|
||||
displayPc.value = (maWb.pc ?: 0L).toString()
|
||||
|
||||
// 7. 重量
|
||||
displayWeight.value = (maWb.weight ?: 0.0).toString()
|
||||
|
||||
// 8. 体积
|
||||
displayVolume.value = (maWb.volume ?: 0.0).toString()
|
||||
|
||||
// 9. 计费重量
|
||||
displayChargeWeight.value = (dataBean.value?.chargeWeight ?: 0.0).toString()
|
||||
|
||||
// 10. 备注
|
||||
displayRemark.value = maWb.remark ?: ""
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化交货日期:String → "2025年12月03日"
|
||||
*/
|
||||
private fun formatDeliveryDate(opDate: String?): String {
|
||||
if (opDate.isNullOrEmpty()) return ""
|
||||
try {
|
||||
// opDate格式: "2025-12-03 19:40:51" 或 "2025-12-03"
|
||||
val datePart = opDate.split(" ")[0] // 取日期部分
|
||||
val parts = datePart.split("-")
|
||||
if (parts.size == 3) {
|
||||
val year = parts[0]
|
||||
val month = parts[1]
|
||||
val day = parts[2]
|
||||
return "${year}年${month}月${day}日"
|
||||
}
|
||||
return ""
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建航班计划:航班号/日期/目的地
|
||||
*/
|
||||
private fun buildFlightPlan(fno: String?, fdate: Date?, dest: String?): String {
|
||||
val parts = mutableListOf<String>()
|
||||
|
||||
// 航班号
|
||||
if (!fno.isNullOrEmpty()) {
|
||||
parts.add(fno)
|
||||
}
|
||||
|
||||
// 日期(格式化为yyyy-MM-dd)
|
||||
if (fdate != null) {
|
||||
try {
|
||||
val calendar = java.util.Calendar.getInstance()
|
||||
calendar.time = fdate
|
||||
val year = calendar.get(java.util.Calendar.YEAR)
|
||||
val month = calendar.get(java.util.Calendar.MONTH) + 1
|
||||
val day = calendar.get(java.util.Calendar.DAY_OF_MONTH)
|
||||
parts.add(String.format("%d-%02d-%02d", year, month, day))
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
// 目的地
|
||||
if (!dest.isNullOrEmpty()) {
|
||||
parts.add(dest)
|
||||
}
|
||||
|
||||
return parts.joinToString("/")
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建货单号:prefix-no
|
||||
*/
|
||||
private fun buildWaybillNo(prefix: String?, no: String?): String {
|
||||
return if (!prefix.isNullOrEmpty() && !no.isNullOrEmpty()) {
|
||||
"$prefix-$no"
|
||||
} else {
|
||||
(prefix ?: "") + (no ?: "")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ class GjcQueryDetailsViewModel : BaseViewModel() {
|
||||
val prefix = maWb["prefix"] as? String ?: ""
|
||||
val no = maWb["no"] as? String ?: ""
|
||||
if (prefix.isNotEmpty() || no.isNotEmpty()) {
|
||||
mergedData["wbNo"] = "$prefix-$no"
|
||||
mergedData["wbNo"] = "$prefix$no"
|
||||
}
|
||||
|
||||
// 字段映射: cmdStatus -> customsCommand
|
||||
|
||||
@@ -162,26 +162,6 @@
|
||||
android:textStyle="bold"
|
||||
tools:text="合计:1票" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text='@{"总件数:"+viewModel.totalPc}'
|
||||
android:textColor="@color/bottom_tool_tips_text_color"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="总件数:100" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:text='@{"总重量:"+viewModel.totalWeight}'
|
||||
android:textColor="@color/bottom_tool_tips_text_color"
|
||||
android:textSize="16sp"
|
||||
android:textStyle="bold"
|
||||
tools:text="总重量:100" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<!-- 分配按钮 -->
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayAgentName}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -97,7 +98,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
tools:text="2025年12月20日"
|
||||
android:text="@{viewModel.displayDeliveryDate}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -144,6 +145,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayFlightPlan}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -170,6 +172,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayAgentName}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -189,6 +192,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayWaybillNo}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -215,6 +219,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayPc}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -234,6 +239,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayWeight}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -260,7 +266,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{String.valueOf(viewModel.dataBean.chargeWeight != null ? viewModel.dataBean.chargeWeight : 0.0d)}"
|
||||
android:text="@{viewModel.displayChargeWeight}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
|
||||
@@ -280,6 +286,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayVolume}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -306,6 +313,7 @@
|
||||
android:layout_weight="5"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayGoods}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -332,6 +340,7 @@
|
||||
android:layout_weight="5"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayRemark}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
</LinearLayout>
|
||||
@@ -477,6 +486,7 @@
|
||||
android:layout_weight="2"
|
||||
android:background="@drawable/bg_table_cell"
|
||||
android:gravity="center"
|
||||
android:text="@{viewModel.displayAgentName}"
|
||||
android:textColor="@color/color_33"
|
||||
android:textSize="14sp" />
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
android:layout_height="36dp"
|
||||
android:layout_marginLeft="16dp"
|
||||
android:onClick="@{()-> viewModel.filterClick()}"
|
||||
android:padding="2dp"
|
||||
android:padding="5dp"
|
||||
android:src="@drawable/img_filter" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
title='@{"代理人"}'
|
||||
titleLength="@{5}"
|
||||
type="@{DataLayoutType.INPUT}"
|
||||
value='@{(String)viewModel.maWbData.get("agentName")}' />
|
||||
value='@{(String)viewModel.maWbData.get("agentCode")}' />
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
android:layout_width="0dp"
|
||||
@@ -83,7 +83,7 @@
|
||||
title='@{"运单件数"}'
|
||||
titleLength="@{5}"
|
||||
type="@{DataLayoutType.INPUT}"
|
||||
value='@{viewModel.maWbData.get("pc") != null ? String.valueOf(viewModel.maWbData.get("pc")) : ``}' />
|
||||
value='@{viewModel.maWbData.get("pc") != null ? String.valueOf((int)Math.round(((Double)viewModel.maWbData.get("pc")))) : ``}' />
|
||||
|
||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||
android:layout_width="0dp"
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.2"
|
||||
android:layout_weight="1.1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -114,7 +114,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.0"
|
||||
android:layout_weight="1.2"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -135,7 +135,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.3"
|
||||
android:layout_weight="1.2"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -147,7 +147,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text='@{bean.opDate != null ? bean.opDate.toString() : ""}'
|
||||
android:text='@{bean.opDate ?? ""}'
|
||||
tools:text="2024-05-13 17:10:22" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
@@ -164,7 +164,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.2"
|
||||
android:layout_weight="1.1"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -206,7 +206,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0.7"
|
||||
android:layout_weight="0.8"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -227,7 +227,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.1"
|
||||
android:layout_weight="1.2"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -248,7 +248,7 @@
|
||||
<androidx.appcompat.widget.LinearLayoutCompat
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1.3"
|
||||
android:layout_weight="1.2"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
@@ -260,7 +260,7 @@
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text='@{bean.fclose != null ? bean.fclose.toString() : ""}'
|
||||
android:text='@{bean.fclose ?? ""}'
|
||||
tools:text="2024-05-13 17:10:22" />
|
||||
|
||||
</androidx.appcompat.widget.LinearLayoutCompat>
|
||||
|
||||
Reference in New Issue
Block a user