feat: 交接单 static ui
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package com.lukouguoji.gjc.viewModel
|
||||
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
|
||||
/**
|
||||
* 国际出港货物交接单 ViewModel
|
||||
*/
|
||||
class GjcHandoverViewModel : BaseViewModel() {
|
||||
|
||||
// 暂时为静态页面,无业务逻辑
|
||||
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
package com.lukouguoji.gjc.viewModel
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.lukouguoji.module_base.base.BaseViewModel
|
||||
import com.lukouguoji.module_base.bean.ComAttach
|
||||
import com.lukouguoji.module_base.bean.FileBean
|
||||
import com.lukouguoji.module_base.bean.GjcInspectionBean
|
||||
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.impl.FlowBus
|
||||
import com.lukouguoji.module_base.ktx.launchLoadingCollect
|
||||
import com.lukouguoji.module_base.ktx.showConfirmDialog
|
||||
import com.lukouguoji.module_base.ktx.showToast
|
||||
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||
import com.lukouguoji.module_base.ui.page.preview.PreviewActivity
|
||||
import com.lukouguoji.module_base.util.MediaUtil
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
* 国际出港收运检查详情 ViewModel
|
||||
*/
|
||||
class GjcInspectionDetailsViewModel : BaseViewModel() {
|
||||
|
||||
// 运单主键ID
|
||||
var maWbId: Long = 0
|
||||
|
||||
// 详情数据
|
||||
val dataBean = MutableLiveData<GjcInspectionBean>()
|
||||
|
||||
/**
|
||||
* 初始化数据
|
||||
*/
|
||||
fun initOnCreated(intent: Intent) {
|
||||
maWbId = intent.getLongExtra(Constant.Key.MAWB_ID, 0)
|
||||
if (maWbId > 0) {
|
||||
getData()
|
||||
} else {
|
||||
showToast("参数错误")
|
||||
getTopActivity().finish()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取详情数据
|
||||
*/
|
||||
private fun getData() {
|
||||
launchLoadingCollect({
|
||||
NetApply.api.getGjcInspectionDetails(maWbId)
|
||||
}) {
|
||||
onSuccess = {
|
||||
dataBean.value = it.data ?: GjcInspectionBean()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过审核
|
||||
*/
|
||||
fun auditPass() {
|
||||
val bean = dataBean.value ?: return
|
||||
getTopActivity().showConfirmDialog("确定要通过该单证吗?") {
|
||||
performAudit(bean, true, "通过")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 退回
|
||||
*/
|
||||
fun auditReject() {
|
||||
val bean = dataBean.value ?: return
|
||||
getTopActivity().showConfirmDialog("确定要退回该单证吗?") {
|
||||
performAudit(bean, false, "退回")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行审核操作
|
||||
* @param bean 数据
|
||||
* @param isPass true:通过, false:退回
|
||||
* @param action 操作名称(用于提示)
|
||||
*/
|
||||
private fun performAudit(bean: GjcInspectionBean, isPass: Boolean, action: String) {
|
||||
// 构建请求参数:数组对象,包含 maWbId、wbNo、prefix、no、reviewStatus(必传)
|
||||
// 使用数据自身的 reviewStatus 值
|
||||
val requestData = listOf(
|
||||
mapOf(
|
||||
"maWbId" to bean.maWbId,
|
||||
"wbNo" to bean.wbNo,
|
||||
"prefix" to bean.prefix,
|
||||
"no" to bean.no,
|
||||
"reviewStatus" to bean.reviewStatus
|
||||
)
|
||||
).toRequestBody()
|
||||
|
||||
// 根据审核状态调用不同接口
|
||||
launchLoadingCollect({
|
||||
if (isPass) {
|
||||
NetApply.api.passGjcInspection(requestData)
|
||||
} else {
|
||||
NetApply.api.backGjcInspection(requestData)
|
||||
}
|
||||
}) {
|
||||
onSuccess = {
|
||||
showToast("${action}成功")
|
||||
// 发送刷新事件
|
||||
viewModelScope.launch {
|
||||
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||
}
|
||||
// 返回上一页
|
||||
getTopActivity().finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取附件名称列表(用于显示)
|
||||
*/
|
||||
fun getAttachNames(): String {
|
||||
val attachList = dataBean.value?.attachList
|
||||
return if (attachList.isNullOrEmpty()) {
|
||||
"无附件"
|
||||
} else {
|
||||
attachList.joinToString(" ") { it.name }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 附件点击处理
|
||||
* @param attach 附件对象
|
||||
*/
|
||||
fun onAttachClick(attach: ComAttach) {
|
||||
when {
|
||||
// 图片格式:使用PreviewActivity预览
|
||||
attach.name.endsWith(".jpg", true) ||
|
||||
attach.name.endsWith(".png", true) ||
|
||||
attach.name.endsWith(".jpeg", true) -> {
|
||||
val fileBean = FileBean(
|
||||
url = MediaUtil.fillUrl(attach.path),
|
||||
originalPic = attach.path
|
||||
)
|
||||
PreviewActivity.start(getTopActivity(), listOf(fileBean))
|
||||
}
|
||||
// PDF格式:提示暂不支持
|
||||
attach.name.endsWith(".pdf", true) -> {
|
||||
showToast("PDF文件预览功能开发中")
|
||||
}
|
||||
// 其他格式
|
||||
else -> {
|
||||
showToast("暂不支持该文件格式预览")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -157,7 +157,7 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("确定要通过选中的 ${filter.size} 条数据吗?") {
|
||||
performAudit(filter, "1", "通过")
|
||||
performAudit(filter, true, "通过")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -172,28 +172,32 @@ class GjcInspectionViewModel : BasePageViewModel() {
|
||||
return
|
||||
}
|
||||
getTopActivity().showConfirmDialog("确定要退回选中的 ${filter.size} 条数据吗?") {
|
||||
performAudit(filter, "2", "退回")
|
||||
performAudit(filter, false, "退回")
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行审核操作
|
||||
* @param items 选中的数据列表
|
||||
* @param status 审核状态(1:通过, 2:退回)
|
||||
* @param isPass true:通过, false:退回
|
||||
* @param action 操作名称(用于提示)
|
||||
*/
|
||||
private fun performAudit(items: List<GjcInspectionBean>, status: String, action: String) {
|
||||
// 构建请求参数:数组对象,包含 maWbId 和 wbNo
|
||||
private fun performAudit(items: List<GjcInspectionBean>, isPass: Boolean, action: String) {
|
||||
// 构建请求参数:数组对象,包含 maWbId、wbNo、prefix、no、reviewStatus(必传)
|
||||
// 使用数据自身的 reviewStatus 值
|
||||
val requestData = items.map {
|
||||
mapOf(
|
||||
"maWbId" to it.maWbId,
|
||||
"wbNo" to it.wbNo
|
||||
"wbNo" to it.wbNo,
|
||||
"prefix" to it.prefix,
|
||||
"no" to it.no,
|
||||
"reviewStatus" to it.reviewStatus
|
||||
)
|
||||
}.toRequestBody()
|
||||
|
||||
// 根据审核状态调用不同接口
|
||||
launchLoadingCollect({
|
||||
if (status == "1") {
|
||||
if (isPass) {
|
||||
NetApply.api.passGjcInspection(requestData)
|
||||
} else {
|
||||
NetApply.api.backGjcInspection(requestData)
|
||||
|
||||
Reference in New Issue
Block a user