feat: 交接单 static ui
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
package com.lukouguoji.gjc.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ActivityGjcHandoverBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcHandoverViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国际出港货物交接单页面
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJC_HANDOVER)
|
||||
class GjcHandoverActivity :
|
||||
BaseBindingActivity<ActivityGjcHandoverBinding, GjcHandoverViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjc_handover
|
||||
|
||||
override fun viewModelClass() = GjcHandoverViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
setBackArrow("货物交接单")
|
||||
|
||||
binding.viewModel = viewModel
|
||||
}
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val starter = Intent(context, GjcHandoverActivity::class.java)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.lukouguoji.gjc.activity
|
||||
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.widget.TextView
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.lukouguoji.gjc.R
|
||||
import com.lukouguoji.gjc.databinding.ActivityGjcInspectionDetailsBinding
|
||||
import com.lukouguoji.gjc.viewModel.GjcInspectionDetailsViewModel
|
||||
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||
import com.lukouguoji.module_base.common.Constant
|
||||
import com.lukouguoji.module_base.router.ARouterConstants
|
||||
|
||||
/**
|
||||
* 国际出港收运检查详情页
|
||||
*/
|
||||
@Route(path = ARouterConstants.ACTIVITY_URL_GJC_INSPECTION_DETAILS)
|
||||
class GjcInspectionDetailsActivity :
|
||||
BaseBindingActivity<ActivityGjcInspectionDetailsBinding, GjcInspectionDetailsViewModel>() {
|
||||
|
||||
override fun layoutId() = R.layout.activity_gjc_inspection_details
|
||||
|
||||
override fun viewModelClass() = GjcInspectionDetailsViewModel::class.java
|
||||
|
||||
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||
// 自定义Toolbar设置
|
||||
val toolbar: androidx.appcompat.widget.Toolbar = findViewById(R.id.toolbar)
|
||||
setSupportActionBar(toolbar)
|
||||
supportActionBar?.setDisplayHomeAsUpEnabled(false)
|
||||
supportActionBar?.setDisplayShowTitleEnabled(false)
|
||||
|
||||
// 返回按钮点击事件
|
||||
findViewById<android.view.View>(R.id.tool_back).setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
// 右侧文档按钮点击事件
|
||||
findViewById<android.widget.ImageView>(R.id.ivDocument).setOnClickListener {
|
||||
GjcHandoverActivity.start(this)
|
||||
}
|
||||
|
||||
binding.viewModel = viewModel
|
||||
|
||||
// 初始化数据
|
||||
viewModel.initOnCreated(intent)
|
||||
|
||||
// 监听数据变化,动态创建附件列表
|
||||
viewModel.dataBean.observe(this) { bean ->
|
||||
binding.attachContainer.removeAllViews()
|
||||
|
||||
val attachList = bean.attachList
|
||||
if (attachList.isNullOrEmpty()) {
|
||||
// 无附件时显示提示文字
|
||||
val textView = TextView(this).apply {
|
||||
text = "无附件"
|
||||
textSize = 14f
|
||||
setTextColor(resources.getColor(R.color.text_gray_l, null))
|
||||
setPadding(0, 8.dp, 0, 8.dp)
|
||||
}
|
||||
binding.attachContainer.addView(textView)
|
||||
} else {
|
||||
// 有附件时动态创建TextView
|
||||
attachList.forEachIndexed { index, attach ->
|
||||
val textView = TextView(this).apply {
|
||||
text = attach.name
|
||||
textSize = 14f
|
||||
setTextColor(resources.getColor(R.color.text_blue, null))
|
||||
gravity = Gravity.CENTER_VERTICAL
|
||||
setPadding(0, 8.dp, 16.dp, 8.dp)
|
||||
setOnClickListener {
|
||||
viewModel.onAttachClick(attach)
|
||||
}
|
||||
}
|
||||
binding.attachContainer.addView(textView)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 扩展属性:dp转px
|
||||
private val Int.dp: Int
|
||||
get() = (this * (resources?.displayMetrics?.density ?: 3f)).toInt()
|
||||
|
||||
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context, maWbId: Long) {
|
||||
val starter = Intent(context, GjcInspectionDetailsActivity::class.java)
|
||||
.putExtra(Constant.Key.MAWB_ID, maWbId)
|
||||
context.startActivity(starter)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package com.lukouguoji.gjc.holder
|
||||
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import com.lukouguoji.gjc.activity.GjcInspectionDetailsActivity
|
||||
import com.lukouguoji.gjc.databinding.ItemGjcInspectionBinding
|
||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||
import com.lukouguoji.module_base.bean.GjcInspectionBean
|
||||
@@ -30,6 +31,11 @@ class GjcInspectionViewHolder(view: View) :
|
||||
}
|
||||
}
|
||||
|
||||
// 整行点击跳转到详情页
|
||||
binding.ll.setOnClickListener {
|
||||
GjcInspectionDetailsActivity.start(it.context, bean.maWbId)
|
||||
}
|
||||
|
||||
// 设置审核状态文本和颜色
|
||||
binding.tvStatus.text = bean.getReviewStatusName()
|
||||
binding.tvStatus.setTextColor(Color.parseColor(bean.getReviewStatusColor()))
|
||||
|
||||
@@ -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