feat: 国际出港 组装分配

This commit is contained in:
2025-12-11 19:06:06 +08:00
parent a81567f10b
commit 82fc593497
8 changed files with 205 additions and 32 deletions

View File

@@ -0,0 +1,19 @@
package com.lukouguoji.module_base.bean
import dev.utils.app.info.KeyValue
/**
* 组装公司Bean
* 用于组装分配时选择分配人
*/
data class AssembleCompanyBean(
val code: String = "", // 公司代码,例如 "ATR"
val name: String = "" // 公司名称,例如 "ATR:马道"
) {
/**
* 转换为 KeyValue 用于下拉列表
* @return KeyValue(显示文本, 实际值)
* 例如: KeyValue("ATR:马道", "ATR")
*/
fun toKeyValue() = KeyValue(name, code)
}

View File

@@ -5,6 +5,7 @@ import com.lukouguoji.module_base.bean.AccidentVisaBean
import com.lukouguoji.module_base.bean.AirportBean
import com.lukouguoji.module_base.bean.AppUpdateResponse
import com.lukouguoji.module_base.bean.AppUpdateResponseInfo
import com.lukouguoji.module_base.bean.AssembleCompanyBean
import com.lukouguoji.module_base.bean.BaseListBean
import com.lukouguoji.module_base.bean.BaseResultBean
import com.lukouguoji.module_base.bean.BoxDetailsForCarIdBean
@@ -496,6 +497,13 @@ interface Api {
@POST("IntExpAssemble/allocate")
suspend fun allocateAssemble(@Body params: RequestBody): BaseResultBean<Boolean>
/**
* 获取组装公司下拉列表
* 接口路径: /typeCode/assembleCompany
*/
@POST("typeCode/assembleCompany")
suspend fun getAssembleCompanyList(): BaseResultBean<List<AssembleCompanyBean>>
/**
* 国际出港板箱过磅-分页搜索
* 接口路径: /IntExpWeighting/pageQuery

View File

@@ -52,6 +52,9 @@ class GjcAssembleAllocateActivity :
binding.checkIcon.alpha = if (isAllChecked) 1.0f else 0.5f
}
// 初始化:获取分配人列表
viewModel.getAssembleCompanyList()
// 初始加载
viewModel.refresh()
}

View File

@@ -0,0 +1,41 @@
package com.lukouguoji.gjc.dialog
import android.content.Context
import androidx.lifecycle.MutableLiveData
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.databinding.DialogGjcAssembleAllocateBinding
import com.lukouguoji.module_base.base.BaseDialogModel
import com.lukouguoji.module_base.ktx.verifyNullOrEmpty
import dev.utils.app.info.KeyValue
/**
* 国际出港组装分配 - 分配人选择对话框
*/
class GjcAssembleAllocateDialogModel(
val flightInfo: String, // 航班信息(用于显示)
val assembleCompanyList: List<KeyValue>, // 分配人列表
private val callback: (GjcAssembleAllocateDialogModel) -> Unit
) : BaseDialogModel<DialogGjcAssembleAllocateBinding>(DIALOG_TYPE_CENTER) {
// 选中的分配人(存储的是 code例如 "ATR"
val allocator = MutableLiveData("")
override fun layoutId(): Int {
return R.layout.dialog_gjc_assemble_allocate
}
override fun onDialogCreated(context: Context) {
binding.model = this
}
/**
* 确认按钮点击
*/
fun onConfirmClick() {
if (allocator.value.verifyNullOrEmpty("请选择分配人")) {
return
}
dismiss()
callback(this)
}
}

View File

@@ -2,11 +2,14 @@ package com.lukouguoji.gjc.viewModel
import android.app.AlertDialog
import android.widget.EditText
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.viewModelScope
import com.lukouguoji.gjc.R
import com.lukouguoji.gjc.dialog.GjcAssembleAllocateDialogModel
import com.lukouguoji.gjc.holder.GjcAssembleAllocateViewHolder
import com.lukouguoji.module_base.base.BasePageViewModel
import com.lukouguoji.module_base.bean.AssembleCompanyBean
import com.lukouguoji.module_base.bean.GjcAssembleAllocate
import com.lukouguoji.module_base.common.ConstantEvent
import com.lukouguoji.module_base.http.net.NetApply
@@ -17,6 +20,7 @@ import com.lukouguoji.module_base.ktx.launchLoadingCollect
import com.lukouguoji.module_base.ktx.showToast
import com.lukouguoji.module_base.ktx.toRequestBody
import com.lukouguoji.module_base.util.CheckUtil
import dev.utils.app.info.KeyValue
import kotlinx.coroutines.launch
/**
@@ -43,6 +47,10 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
// 全选状态
val isAllChecked = MutableLiveData(false)
// 分配人列表(从接口获取,存储 KeyValue 格式)
private val _assembleCompanyList = MutableLiveData<List<KeyValue>>(emptyList())
val assembleCompanyList: LiveData<List<KeyValue>> = _assembleCompanyList
///////////////////////////////////////////////////////////////////////////
// 方法区
///////////////////////////////////////////////////////////////////////////
@@ -129,6 +137,19 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
updateCheckAllStatus()
}
/**
* 获取分配人列表
* 在 Activity 初始化时调用
*/
fun getAssembleCompanyList() {
launchCollect({ NetApply.api.getAssembleCompanyList() }) {
onSuccess = { result ->
val list = result.data?.map { it.toKeyValue() } ?: emptyList()
_assembleCompanyList.value = list
}
}
}
/**
* 分配按钮点击
*/
@@ -141,45 +162,45 @@ class GjcAssembleAllocateViewModel : BasePageViewModel() {
return
}
// 显示分配人输入对话框
showAllocatorInputDialog(selectedItems)
// 检查分配人列表是否为空
if (_assembleCompanyList.value.isNullOrEmpty()) {
showToast("分配人列表为空,请稍后重试")
return
}
// 显示分配人选择对话框
showAllocatorSelectDialog(selectedItems)
}
/**
* 显示分配人输入对话框
* 显示分配人选择对话框
*/
private fun showAllocatorInputDialog(items: List<GjcAssembleAllocate>) {
val activity = getTopActivity()
val editText = EditText(activity)
editText.hint = "请输入分配人姓名"
private fun showAllocatorSelectDialog(items: List<GjcAssembleAllocate>) {
// 构建航班信息字符串例如CA1234、MU5678
val flightInfo = items.joinToString("") { it.fno ?: "" }
AlertDialog.Builder(activity)
.setTitle("分配人员")
.setView(editText)
.setPositiveButton("确定") { dialog, _ ->
val allocatorName = editText.text.toString().trim()
if (allocatorName.isEmpty()) {
showToast("请输入分配人姓名")
} else {
performAllocate(items, allocatorName)
dialog.dismiss()
}
}
.setNegativeButton("取消") { dialog, _ ->
dialog.dismiss()
}
.show()
GjcAssembleAllocateDialogModel(
flightInfo = flightInfo,
assembleCompanyList = _assembleCompanyList.value ?: emptyList()
) { dialog ->
// 回调:用户点击确定后执行分配操作
// dialog.allocator.value 存储的是选中的 code例如 "ATR"
val allocatorCode = dialog.allocator.value ?: ""
performAllocate(items, allocatorCode)
}.show(getTopActivity())
}
/**
* 执行分配操作
* @param items 选中的航班列表
* @param allocatorCode 分配人代码(例如 "ATR",而非 "ATR:马道"
*/
private fun performAllocate(items: List<GjcAssembleAllocate>, allocatorName: String) {
private fun performAllocate(items: List<GjcAssembleAllocate>, allocatorCode: String) {
val fidList = items.mapNotNull { it.fid }
val requestData = mapOf(
"fidList" to fidList, // 航班ID列表
"acName" to allocatorName // 分配人姓名
"abId" to allocatorCode // 分配人代码(传递 code 而非 name
).toRequestBody()
launchLoadingCollect({ NetApply.api.allocateAssemble(requestData) }) {

View File

@@ -247,7 +247,6 @@
android:layout_height="wrap_content"
android:layout_weight="1"
enable="@{true}"
required="@{true}"
title='@{"耗材重量:"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"
@@ -351,7 +350,6 @@
android:layout_height="wrap_content"
android:layout_weight="1"
enable="@{true}"
required="@{true}"
title='@{"组装重量:"}'
titleLength="@{5}"
type="@{DataLayoutType.INPUT}"

View File

@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<import type="com.lukouguoji.module_base.ui.weight.search.layout.SearchLayoutType"/>
<variable
name="model"
type="com.lukouguoji.gjc.dialog.GjcAssembleAllocateDialogModel" />
</data>
<LinearLayout
android:layout_width="500dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_dialog_radius_10"
android:gravity="center_horizontal"
android:orientation="vertical">
<!-- 标题栏 -->
<TextView
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@drawable/bg_primary_radius_top_10"
android:gravity="center"
android:text="分配人员"
android:textColor="@color/white"
android:textSize="18sp"
android:textStyle="bold" />
<!-- 航班信息显示 -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginHorizontal="15dp"
android:layout_marginTop="15dp"
android:text='@{"航班:" + model.flightInfo}'
android:textColor="@color/text_normal"
android:textSize="16sp"
android:textStyle="bold" />
<!-- 分配人下拉选择 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="分配人:"
android:textSize="16sp" />
<com.lukouguoji.module_base.ui.weight.search.layout.PadSearchLayout
android:layout_width="240dp"
android:layout_height="wrap_content"
type="@{SearchLayoutType.SPINNER}"
list="@{model.assembleCompanyList}"
value="@={model.allocator}" />
</LinearLayout>
<!-- 底部按钮 -->
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="15dp">
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.dismiss()}"
android:text="取消" />
<TextView
style="@style/tv_bottom_btn"
android:onClick="@{()->model.onConfirmClick()}"
android:text="确定" />
</LinearLayout>
</LinearLayout>
</layout>

View File

@@ -58,7 +58,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@{bean.fdate}"
android:textColor="@color/colorPrimary"
tools:text="2025-09-05" />
</androidx.appcompat.widget.LinearLayoutCompat>
@@ -73,7 +72,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
completeSpace="@{5}"
android:text="航班号:" />
<TextView
@@ -95,7 +94,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
completeSpace="@{5}"
android:text="航程:" />
<TextView
@@ -124,7 +123,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
completeSpace="@{5}"
android:text="组装人:" />
<TextView
@@ -145,7 +144,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
completeSpace="@{4}"
completeSpace="@{5}"
android:text="分配人:" />
<TextView