feat: opt 出港组装 组装人
This commit is contained in:
@@ -53,6 +53,9 @@ class IntExpAssembleStartActivity :
|
|||||||
// 加载组装位置数据(从API)
|
// 加载组装位置数据(从API)
|
||||||
viewModel.loadAssemblePosition()
|
viewModel.loadAssemblePosition()
|
||||||
|
|
||||||
|
// 加载组装人列表
|
||||||
|
viewModel.loadAssemblerList()
|
||||||
|
|
||||||
// 观察数据变化
|
// 观察数据变化
|
||||||
observeData()
|
observeData()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,10 +8,13 @@ import com.lukouguoji.gjc.holder.AssembleWaybillViewHolder
|
|||||||
import com.lukouguoji.module_base.base.BaseViewModel
|
import com.lukouguoji.module_base.base.BaseViewModel
|
||||||
import com.lukouguoji.module_base.bean.*
|
import com.lukouguoji.module_base.bean.*
|
||||||
import com.lukouguoji.module_base.common.Constant
|
import com.lukouguoji.module_base.common.Constant
|
||||||
|
import com.lukouguoji.module_base.db.perference.SharedPreferenceUtil
|
||||||
import com.lukouguoji.module_base.http.net.NetApply
|
import com.lukouguoji.module_base.http.net.NetApply
|
||||||
|
import com.lukouguoji.module_base.ktx.launchCollect
|
||||||
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.model.ScanModel
|
import com.lukouguoji.module_base.model.ScanModel
|
||||||
|
import dev.utils.app.info.KeyValue
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国际出港-开始组装ViewModel(静态数据)
|
* 国际出港-开始组装ViewModel(静态数据)
|
||||||
@@ -45,6 +48,9 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
// ========== 运单信息 ==========
|
// ========== 运单信息 ==========
|
||||||
val waybillInfo = MutableLiveData(WaybillInfoBean())
|
val waybillInfo = MutableLiveData(WaybillInfoBean())
|
||||||
|
|
||||||
|
// ========== 组装人列表 ==========
|
||||||
|
val assemblerList = MutableLiveData<List<KeyValue>>(emptyList())
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 初始化模拟数据(已废弃)
|
* 初始化模拟数据(已废弃)
|
||||||
*/
|
*/
|
||||||
@@ -175,6 +181,34 @@ class IntExpAssembleStartViewModel : BaseViewModel() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载组装人列表
|
||||||
|
*/
|
||||||
|
fun loadAssemblerList() {
|
||||||
|
launchCollect({ NetApply.api.getIntExpAssemblerList() }) {
|
||||||
|
onSuccess = { result ->
|
||||||
|
val list = result.data ?: emptyList()
|
||||||
|
// 转换为 KeyValue 列表
|
||||||
|
val keyValueList = list.map { KeyValue(it, it) }
|
||||||
|
assemblerList.value = keyValueList
|
||||||
|
|
||||||
|
// 获取当前登录用户名
|
||||||
|
val currentUserName = SharedPreferenceUtil.getString(Constant.Share.userName)
|
||||||
|
|
||||||
|
// 如果当前用户名在列表中,设置为默认值;否则保持为空(显示 hint)
|
||||||
|
if (currentUserName.isNotEmpty() && list.contains(currentUserName)) {
|
||||||
|
waybillInfo.value?.operator = currentUserName
|
||||||
|
waybillInfo.value = waybillInfo.value // 触发LiveData更新
|
||||||
|
}
|
||||||
|
// 注意:不匹配时不需要显式设置为空,因为初始值已经是空字符串
|
||||||
|
}
|
||||||
|
onFailed = { code, message ->
|
||||||
|
showToast("加载组装人列表失败: $message")
|
||||||
|
assemblerList.value = emptyList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 卸货按钮点击
|
* 卸货按钮点击
|
||||||
|
|||||||
@@ -370,11 +370,12 @@
|
|||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
|
|
||||||
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
enable="@{false}"
|
|
||||||
required="@{false}"
|
required="@{false}"
|
||||||
title='@{"操作人:"}'
|
title='@{"组装人:"}'
|
||||||
titleLength="@{5}"
|
titleLength="@{5}"
|
||||||
type="@{DataLayoutType.INPUT}"
|
type="@{DataLayoutType.SPINNER}"
|
||||||
|
hint='@{"请选择组装人"}'
|
||||||
|
list="@{viewModel.assemblerList}"
|
||||||
value="@={viewModel.waybillInfo.operator}"
|
value="@={viewModel.waybillInfo.operator}"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|||||||
Reference in New Issue
Block a user