feat: ui opt
This commit is contained in:
@@ -848,3 +848,5 @@ grep -A 5 "enum class DataLayoutType" module_base/src --include="*.kt"
|
|||||||
---
|
---
|
||||||
|
|
||||||
**签名配置**: `key.jks` / 密码: `123321` / 别名: `key`
|
**签名配置**: `key.jks` / 密码: `123321` / 别名: `key`
|
||||||
|
- 后面统一使用PadDataLayoutNew 而不是PadDataLayout 控件
|
||||||
|
- 当使用PadDataLayoutNew 控件的时候,titleLength 通常设置为5
|
||||||
@@ -130,6 +130,11 @@
|
|||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
android:screenOrientation="userLandscape" />
|
android:screenOrientation="userLandscape" />
|
||||||
|
<activity
|
||||||
|
android:name="com.lukouguoji.gjc.activity.GjcWeighingRecordDetailsActivity"
|
||||||
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
android:exported="false"
|
||||||
|
android:screenOrientation="userLandscape" />
|
||||||
<activity
|
<activity
|
||||||
android:name="com.lukouguoji.gjc.activity.GjcWeighingStartActivity"
|
android:name="com.lukouguoji.gjc.activity.GjcWeighingStartActivity"
|
||||||
android:configChanges="orientation|keyboardHidden"
|
android:configChanges="orientation|keyboardHidden"
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.lukouguoji.module_base.bean
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重记录明细Bean
|
||||||
|
* 用于:加载运单的所有计重记录 + 批量更新
|
||||||
|
* 对应API:
|
||||||
|
* - POST /IntExpCheckIn/listRecordByWh (加载)
|
||||||
|
* - POST /IntExpCheckIn/updateRecordList (保存)
|
||||||
|
*/
|
||||||
|
data class GjcCheckInRecord(
|
||||||
|
var id: Long = 0, // 收运记录id
|
||||||
|
var maWbId: Long = 0, // GJC_MAWB.MAWBID
|
||||||
|
var no: String = "", // 运单号
|
||||||
|
var prefix: String = "", // 运单前缀
|
||||||
|
var opDate: String = "", // 操作时间
|
||||||
|
var opId: String = "", // 操作员id
|
||||||
|
var pc: Long = 0, // 运抵件数
|
||||||
|
var weight: Double = 0.0, // 运抵重量
|
||||||
|
var volume: Double = 0.0, // 运抵体积
|
||||||
|
var whId: Long = 0 // GJC_WAREHOUSE.ID
|
||||||
|
)
|
||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.lukouguoji.module_base.bean
|
package com.lukouguoji.module_base.bean
|
||||||
|
|
||||||
|
import java.io.Serializable
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 国际出港计重记录-列表数据Bean
|
* 国际出港计重记录-列表数据Bean
|
||||||
* 对应API: IntExpCheckIn/checked/pageQuery
|
* 对应API: IntExpCheckIn/checked/pageQuery
|
||||||
* 对应API返回类型: GjcWarehouse
|
* 对应API返回类型: GjcWarehouse
|
||||||
*/
|
*/
|
||||||
class GjcWeighingRecordBean {
|
class GjcWeighingRecordBean : Serializable {
|
||||||
var whId: Long = 0 // 仓库主键ID
|
var whId: Long = 0 // 仓库主键ID
|
||||||
var no: String = "" // 运单号
|
var no: String = "" // 运单号
|
||||||
var prefix: String = "" // 运单前缀
|
var prefix: String = "" // 运单前缀
|
||||||
|
|||||||
@@ -354,5 +354,17 @@ interface Constant {
|
|||||||
|
|
||||||
// 运单主键ID
|
// 运单主键ID
|
||||||
const val MAWB_ID = "maWbId"
|
const val MAWB_ID = "maWbId"
|
||||||
|
|
||||||
|
// 运单前缀
|
||||||
|
const val PREFIX = "prefix"
|
||||||
|
|
||||||
|
// 运单号
|
||||||
|
const val NO = "no"
|
||||||
|
|
||||||
|
// 操作时间
|
||||||
|
const val OP_DATE = "opDate"
|
||||||
|
|
||||||
|
// Bean对象传递
|
||||||
|
const val BEAN = "bean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,7 @@ import com.lukouguoji.module_base.bean.GjcBoxAddInsertBean
|
|||||||
import com.lukouguoji.module_base.bean.GjcBoxAssembleBean
|
import com.lukouguoji.module_base.bean.GjcBoxAssembleBean
|
||||||
import com.lukouguoji.module_base.bean.GjcBoxDetailsBean
|
import com.lukouguoji.module_base.bean.GjcBoxDetailsBean
|
||||||
import com.lukouguoji.module_base.bean.GjcBoxWeighingStatisticsBean
|
import com.lukouguoji.module_base.bean.GjcBoxWeighingStatisticsBean
|
||||||
|
import com.lukouguoji.module_base.bean.GjcCheckInRecord
|
||||||
import com.lukouguoji.module_base.bean.GjcGoodsAddBean
|
import com.lukouguoji.module_base.bean.GjcGoodsAddBean
|
||||||
import com.lukouguoji.module_base.bean.GjcGoodsBean
|
import com.lukouguoji.module_base.bean.GjcGoodsBean
|
||||||
import com.lukouguoji.module_base.bean.GjcGoodsDetailsBean
|
import com.lukouguoji.module_base.bean.GjcGoodsDetailsBean
|
||||||
@@ -477,6 +478,22 @@ interface Api {
|
|||||||
@POST("IntExpCheckIn/completeCheckIn")
|
@POST("IntExpCheckIn/completeCheckIn")
|
||||||
suspend fun completeCheckIn(@Body data: RequestBody): BaseResultBean<Boolean>
|
suspend fun completeCheckIn(@Body data: RequestBody): BaseResultBean<Boolean>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重明细-根据运单号查询所有计重记录
|
||||||
|
* 接口路径: /IntExpCheckIn/listRecordByWh
|
||||||
|
* 参数: GjcWarehouse对象(prefix, no, opDate)
|
||||||
|
*/
|
||||||
|
@POST("IntExpCheckIn/listRecordByWh")
|
||||||
|
suspend fun getGjcCheckInRecordList(@Body data: RequestBody): BaseResultBean<List<GjcCheckInRecord>>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重明细-批量更新计重记录
|
||||||
|
* 接口路径: /IntExpCheckIn/updateRecordList
|
||||||
|
* 参数: List<GjcCheckInRecord>
|
||||||
|
*/
|
||||||
|
@POST("IntExpCheckIn/updateRecordList")
|
||||||
|
suspend fun updateGjcCheckInRecordList(@Body data: List<GjcCheckInRecord>): BaseResultBean<Boolean>
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// 国际进-电报解析
|
// 国际进-电报解析
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|||||||
@@ -122,6 +122,7 @@ object ARouterConstants {
|
|||||||
const val ACTIVITY_URL_GJC_WEIGHING_LIST = "/gjc/GjcWeighingListActivity" //国际出港模块 出港计重
|
const val ACTIVITY_URL_GJC_WEIGHING_LIST = "/gjc/GjcWeighingListActivity" //国际出港模块 出港计重
|
||||||
const val ACTIVITY_URL_GJC_WEIGHING_START = "/gjc/GjcWeighingStartActivity" //国际出港模块 开始计重
|
const val ACTIVITY_URL_GJC_WEIGHING_START = "/gjc/GjcWeighingStartActivity" //国际出港模块 开始计重
|
||||||
const val ACTIVITY_URL_GJC_WEIGHING_RECORD_LIST = "/gjc/GjcWeighingRecordListActivity" //国际出港模块 计重记录
|
const val ACTIVITY_URL_GJC_WEIGHING_RECORD_LIST = "/gjc/GjcWeighingRecordListActivity" //国际出港模块 计重记录
|
||||||
|
const val ACTIVITY_URL_GJC_WEIGHING_RECORD_DETAILS = "/gjc/GjcWeighingRecordDetailsActivity" //国际出港模块 计重明细
|
||||||
|
|
||||||
const val ACTIVITY_URL_GJC_WARE_HOUSE = "/gjc/GjcWareHouseActivity" //国际出港模块 仓库
|
const val ACTIVITY_URL_GJC_WARE_HOUSE = "/gjc/GjcWareHouseActivity" //国际出港模块 仓库
|
||||||
const val ACTIVITY_URL_GJC_WARE_HOUSE_INFO = "/gjc/GjcWareHouseInfoActivity" //国际出港模块 仓库详情
|
const val ACTIVITY_URL_GJC_WARE_HOUSE_INFO = "/gjc/GjcWareHouseInfoActivity" //国际出港模块 仓库详情
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
package com.lukouguoji.gjc.activity
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
|
import com.alibaba.android.arouter.facade.annotation.Route
|
||||||
|
import com.lukouguoji.gjc.R
|
||||||
|
import com.lukouguoji.gjc.databinding.ActivityGjcWeighingRecordDetailsBinding
|
||||||
|
import com.lukouguoji.gjc.holder.GjcCheckInRecordViewHolder
|
||||||
|
import com.lukouguoji.gjc.viewModel.GjcWeighingRecordDetailsViewModel
|
||||||
|
import com.lukouguoji.module_base.base.BaseBindingActivity
|
||||||
|
import com.lukouguoji.module_base.base.CommonAdapter
|
||||||
|
import com.lukouguoji.module_base.bean.GjcWeighingRecordBean
|
||||||
|
import com.lukouguoji.module_base.common.Constant
|
||||||
|
import com.lukouguoji.module_base.router.ARouterConstants
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重明细页
|
||||||
|
*/
|
||||||
|
@Route(path = ARouterConstants.ACTIVITY_URL_GJC_WEIGHING_RECORD_DETAILS)
|
||||||
|
class GjcWeighingRecordDetailsActivity :
|
||||||
|
BaseBindingActivity<ActivityGjcWeighingRecordDetailsBinding, GjcWeighingRecordDetailsViewModel>() {
|
||||||
|
|
||||||
|
private lateinit var adapter: CommonAdapter
|
||||||
|
|
||||||
|
override fun layoutId() = R.layout.activity_gjc_weighing_record_details
|
||||||
|
|
||||||
|
override fun viewModelClass() = GjcWeighingRecordDetailsViewModel::class.java
|
||||||
|
|
||||||
|
override fun initOnCreate(savedInstanceState: Bundle?) {
|
||||||
|
setBackArrow("计重明细")
|
||||||
|
|
||||||
|
binding.viewModel = viewModel
|
||||||
|
|
||||||
|
// 初始化RecyclerView
|
||||||
|
binding.recyclerView.layoutManager = LinearLayoutManager(this)
|
||||||
|
adapter = CommonAdapter(
|
||||||
|
this,
|
||||||
|
R.layout.item_gjc_check_in_record,
|
||||||
|
GjcCheckInRecordViewHolder::class.java
|
||||||
|
)
|
||||||
|
binding.recyclerView.adapter = adapter
|
||||||
|
|
||||||
|
// 监听数据变化更新RecyclerView
|
||||||
|
viewModel.recordList.observe(this) { records ->
|
||||||
|
adapter.refresh(records)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 监听编辑模式变化,更新所有ViewHolder的编辑状态
|
||||||
|
viewModel.isEditMode.observe(this) { isEditMode ->
|
||||||
|
val layoutManager = binding.recyclerView.layoutManager as? LinearLayoutManager
|
||||||
|
layoutManager?.let {
|
||||||
|
for (i in 0 until adapter.itemCount) {
|
||||||
|
val holder = binding.recyclerView.findViewHolderForAdapterPosition(i)
|
||||||
|
as? GjcCheckInRecordViewHolder
|
||||||
|
holder?.updateEditMode(isEditMode)
|
||||||
|
adapter.notifyItemChanged(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化数据
|
||||||
|
viewModel.initOnCreated(intent)
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
@JvmStatic
|
||||||
|
fun start(context: Context, bean: GjcWeighingRecordBean) {
|
||||||
|
val starter = Intent(context, GjcWeighingRecordDetailsActivity::class.java)
|
||||||
|
.putExtra(Constant.Key.BEAN, bean)
|
||||||
|
context.startActivity(starter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.lukouguoji.gjc.holder
|
||||||
|
|
||||||
|
import android.view.View
|
||||||
|
import com.lukouguoji.gjc.databinding.ItemGjcCheckInRecordBinding
|
||||||
|
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||||
|
import com.lukouguoji.module_base.bean.GjcCheckInRecord
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重明细列表 ViewHolder
|
||||||
|
*/
|
||||||
|
class GjcCheckInRecordViewHolder(view: View) :
|
||||||
|
BaseViewHolder<GjcCheckInRecord, ItemGjcCheckInRecordBinding>(view) {
|
||||||
|
|
||||||
|
private var isEditMode: Boolean = false
|
||||||
|
|
||||||
|
fun updateEditMode(editMode: Boolean) {
|
||||||
|
this.isEditMode = editMode
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onBind(item: Any?, position: Int) {
|
||||||
|
val record = getItemBean(item)!!
|
||||||
|
binding.record = record
|
||||||
|
binding.isEditMode = isEditMode
|
||||||
|
binding.position = position // 传入位置用于显示序号
|
||||||
|
|
||||||
|
// 设置refreshCallBack来捕获用户输入的变化
|
||||||
|
if (isEditMode) {
|
||||||
|
binding.padPc.refreshCallBack = {
|
||||||
|
val pcStr = binding.padPc.value
|
||||||
|
record.pc = pcStr.toLongOrNull() ?: 0L
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.padWeight.refreshCallBack = {
|
||||||
|
val weightStr = binding.padWeight.value
|
||||||
|
record.weight = weightStr.toDoubleOrNull() ?: 0.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
binding.executePendingBindings()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.lukouguoji.gjc.holder
|
package com.lukouguoji.gjc.holder
|
||||||
|
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import com.lukouguoji.gjc.activity.GjcWeighingRecordDetailsActivity
|
||||||
import com.lukouguoji.gjc.databinding.ItemGjcWeighingRecordBinding
|
import com.lukouguoji.gjc.databinding.ItemGjcWeighingRecordBinding
|
||||||
import com.lukouguoji.module_base.base.BaseViewHolder
|
import com.lukouguoji.module_base.base.BaseViewHolder
|
||||||
import com.lukouguoji.module_base.bean.GjcWeighingRecordBean
|
import com.lukouguoji.module_base.bean.GjcWeighingRecordBean
|
||||||
@@ -15,10 +16,9 @@ class GjcWeighingRecordViewHolder(view: View) :
|
|||||||
val bean = getItemBean(item)!!
|
val bean = getItemBean(item)!!
|
||||||
binding.bean = bean
|
binding.bean = bean
|
||||||
|
|
||||||
// 整行点击跳转到详情页(暂未实现)
|
// 整行点击跳转到计重明细页
|
||||||
binding.ll.setOnClickListener {
|
binding.ll.setOnClickListener {
|
||||||
// TODO: 跳转到详情页(待实现)
|
GjcWeighingRecordDetailsActivity.start(it.context, bean)
|
||||||
// GjcWeighingRecordDetailsActivity.start(it.context, bean.whId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,233 @@
|
|||||||
|
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.GjcCheckInRecord
|
||||||
|
import com.lukouguoji.module_base.bean.GjcWeighingRecordBean
|
||||||
|
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.showToast
|
||||||
|
import com.lukouguoji.module_base.ktx.toRequestBody
|
||||||
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 国际出港计重明细 ViewModel
|
||||||
|
* 严格按照设计图实现三个独立部分:运单信息、计重记录列表、底部统计与按钮
|
||||||
|
*/
|
||||||
|
class GjcWeighingRecordDetailsViewModel : BaseViewModel() {
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 数据字段
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// 运单信息Bean(从列表页传入)
|
||||||
|
val waybillBean = MutableLiveData<GjcWeighingRecordBean>()
|
||||||
|
|
||||||
|
// 编辑模式:false=只读,true=编辑
|
||||||
|
val isEditMode = MutableLiveData(false)
|
||||||
|
|
||||||
|
// 计重记录列表
|
||||||
|
val recordList = MutableLiveData<List<GjcCheckInRecord>>(emptyList())
|
||||||
|
|
||||||
|
// 备份数据(用于取消时恢复)
|
||||||
|
private var backupList: List<GjcCheckInRecord> = emptyList()
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 第一部分:运单信息字段(顶部显示区域)
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
val waybillNo = MutableLiveData("") // 运单号(prefix-no)
|
||||||
|
val prePc = MutableLiveData("") // 预配件数
|
||||||
|
val preWeight = MutableLiveData("") // 预配重量
|
||||||
|
val goodsName = MutableLiveData("") // 品名(中文)
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 第三部分:底部统计字段
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
val totalPc = MutableLiveData("0") // 总件数
|
||||||
|
val totalWeight = MutableLiveData("0.0") // 总重量
|
||||||
|
val weightError = MutableLiveData("0.0%") // 重量误差百分比
|
||||||
|
|
||||||
|
// 传递参数(用于API调用)
|
||||||
|
private var prefix = ""
|
||||||
|
private var no = ""
|
||||||
|
private var opDate = ""
|
||||||
|
|
||||||
|
init {
|
||||||
|
// 监听 recordList 变化,自动触发统计计算
|
||||||
|
recordList.observeForever {
|
||||||
|
calculateStatistics()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 初始化
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
fun initOnCreated(intent: Intent) {
|
||||||
|
// 接收传入的完整 Bean 对象
|
||||||
|
val bean = intent.getSerializableExtra(Constant.Key.BEAN) as? GjcWeighingRecordBean
|
||||||
|
bean?.let {
|
||||||
|
waybillBean.value = it
|
||||||
|
|
||||||
|
// 提取运单信息字段
|
||||||
|
waybillNo.value = "${it.prefix}-${it.no}"
|
||||||
|
prePc.value = it.pc.toString()
|
||||||
|
preWeight.value = it.weight.toString()
|
||||||
|
goodsName.value = it.goodsCn
|
||||||
|
|
||||||
|
// 保存参数用于API调用
|
||||||
|
prefix = it.prefix
|
||||||
|
no = it.no
|
||||||
|
opDate = it.opDate
|
||||||
|
|
||||||
|
// 加载计重记录数据
|
||||||
|
loadData()
|
||||||
|
} ?: run {
|
||||||
|
showToast("参数错误")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 数据加载
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
private fun loadData() {
|
||||||
|
val params = mapOf(
|
||||||
|
"prefix" to prefix,
|
||||||
|
"no" to no,
|
||||||
|
"opDate" to opDate
|
||||||
|
).toRequestBody()
|
||||||
|
|
||||||
|
launchLoadingCollect({ NetApply.api.getGjcCheckInRecordList(params) }) {
|
||||||
|
onSuccess = { result ->
|
||||||
|
val list = result.data ?: emptyList()
|
||||||
|
recordList.value = list
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
showToast("暂无计重记录")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFailed = { code, msg ->
|
||||||
|
showToast("加载失败:$msg")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 计算统计数据:总件数、总重量、重量误差
|
||||||
|
*/
|
||||||
|
private fun calculateStatistics() {
|
||||||
|
val records = recordList.value ?: emptyList()
|
||||||
|
|
||||||
|
// 计算总件数
|
||||||
|
val sumPc = records.sumOf { it.pc }
|
||||||
|
totalPc.value = sumPc.toString()
|
||||||
|
|
||||||
|
// 计算总重量
|
||||||
|
val sumWeight = records.sumOf { it.weight }
|
||||||
|
totalWeight.value = String.format("%.2f", sumWeight)
|
||||||
|
|
||||||
|
// 计算重量误差百分比
|
||||||
|
val preWeightValue = preWeight.value?.toDoubleOrNull() ?: 0.0
|
||||||
|
val error = if (preWeightValue > 0) {
|
||||||
|
((sumWeight - preWeightValue) / preWeightValue * 100)
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
weightError.value = String.format("%.1f%%", error)
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 按钮事件
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击"修改"按钮
|
||||||
|
*/
|
||||||
|
fun onModifyClick() {
|
||||||
|
// 备份当前数据(深拷贝)
|
||||||
|
backupList = recordList.value?.map { it.copy() } ?: emptyList()
|
||||||
|
// 进入编辑模式
|
||||||
|
isEditMode.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击"取消"按钮
|
||||||
|
*/
|
||||||
|
fun onCancelClick() {
|
||||||
|
// 恢复备份数据(深拷贝)
|
||||||
|
recordList.value = backupList.map { it.copy() }
|
||||||
|
// 退出编辑模式
|
||||||
|
isEditMode.value = false
|
||||||
|
// 重新计算统计(会自动触发)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 点击"保存"按钮
|
||||||
|
*/
|
||||||
|
fun onSaveClick() {
|
||||||
|
val records = recordList.value ?: return
|
||||||
|
|
||||||
|
// 验证数据
|
||||||
|
if (!validateRecords(records)) return
|
||||||
|
|
||||||
|
// 调用批量更新接口
|
||||||
|
saveRecords(records)
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// 业务逻辑
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 验证数据
|
||||||
|
*/
|
||||||
|
private fun validateRecords(records: List<GjcCheckInRecord>): Boolean {
|
||||||
|
records.forEachIndexed { index, record ->
|
||||||
|
if (record.pc <= 0) {
|
||||||
|
showToast("第${index + 1}条记录的件数必须大于0")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
if (record.weight <= 0.0) {
|
||||||
|
showToast("第${index + 1}条记录的重量必须大于0")
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量保存计重记录
|
||||||
|
*/
|
||||||
|
private fun saveRecords(records: List<GjcCheckInRecord>) {
|
||||||
|
launchLoadingCollect({
|
||||||
|
NetApply.api.updateGjcCheckInRecordList(records)
|
||||||
|
}) {
|
||||||
|
onSuccess = { result ->
|
||||||
|
if (result.data == true) {
|
||||||
|
showToast("保存成功")
|
||||||
|
// 退出编辑模式
|
||||||
|
isEditMode.value = false
|
||||||
|
// 发送刷新事件通知列表页
|
||||||
|
viewModelScope.launch {
|
||||||
|
FlowBus.with<String>(ConstantEvent.EVENT_REFRESH).emit("refresh")
|
||||||
|
}
|
||||||
|
// 关闭页面
|
||||||
|
getTopActivity().finish()
|
||||||
|
} else {
|
||||||
|
showToast("保存失败")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
onFailed = { code, msg ->
|
||||||
|
showToast("保存失败:$msg")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<import type="android.view.View" />
|
||||||
|
|
||||||
|
<import type="com.lukouguoji.module_base.ui.weight.data.layout.DataLayoutType" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="viewModel"
|
||||||
|
type="com.lukouguoji.gjc.viewModel.GjcWeighingRecordDetailsViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/color_f2"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<include layout="@layout/title_tool_bar" />
|
||||||
|
|
||||||
|
<!-- 第一部分:运单信息区域 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_margin="15dp"
|
||||||
|
android:background="@drawable/bg_white_radius_8"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="15dp">
|
||||||
|
|
||||||
|
<!-- 运单号(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`运单号:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.waybillNo}' />
|
||||||
|
|
||||||
|
<!-- 预配件数(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`预配件数:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.prePc}' />
|
||||||
|
|
||||||
|
<!-- 预配重量(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`预配重量:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.preWeight}' />
|
||||||
|
|
||||||
|
<!-- 品名(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`品名:`}'
|
||||||
|
titleLength="@{3}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.goodsName}' />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 第二部分:计重记录列表 -->
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recyclerView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingStart="15dp"
|
||||||
|
android:paddingEnd="15dp" />
|
||||||
|
|
||||||
|
<!-- 第三部分:底部统计与按钮区域 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:background="@drawable/bg_white_radius_8"
|
||||||
|
android:layout_margin="15dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:padding="15dp">
|
||||||
|
|
||||||
|
<!-- 统计信息行 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- 总件数(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`总件数:`}'
|
||||||
|
titleLength="@{4}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.totalPc}' />
|
||||||
|
|
||||||
|
<!-- 总重量(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`总重量:`}'
|
||||||
|
titleLength="@{4}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.totalWeight}' />
|
||||||
|
|
||||||
|
<!-- 重量误差(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`重量误差:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{viewModel.weightError}' />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<!-- 按钮行 -->
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="15dp"
|
||||||
|
android:gravity="end"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<!-- 修改按钮(只读模式显示) -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnModify"
|
||||||
|
style="@style/tv_bottom_btn"
|
||||||
|
android:onClick="@{() -> viewModel.onModifyClick()}"
|
||||||
|
android:text="修改"
|
||||||
|
android:visibility="@{viewModel.isEditMode ? View.GONE : View.VISIBLE}" />
|
||||||
|
|
||||||
|
<!-- 取消按钮(编辑模式显示) -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnCancel"
|
||||||
|
style="@style/tv_bottom_btn"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:onClick="@{() -> viewModel.onCancelClick()}"
|
||||||
|
android:text="取消"
|
||||||
|
android:visibility="@{viewModel.isEditMode ? View.VISIBLE : View.GONE}" />
|
||||||
|
|
||||||
|
<!-- 保存按钮(编辑模式显示) -->
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/btnSave"
|
||||||
|
style="@style/tv_bottom_btn"
|
||||||
|
android:onClick="@{() -> viewModel.onSaveClick()}"
|
||||||
|
android:text="保存"
|
||||||
|
android:visibility="@{viewModel.isEditMode ? View.VISIBLE : View.GONE}" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
96
module_gjc/src/main/res/layout/item_gjc_check_in_record.xml
Normal file
96
module_gjc/src/main/res/layout/item_gjc_check_in_record.xml
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
<?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.data.layout.DataLayoutType" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="record"
|
||||||
|
type="com.lukouguoji.module_base.bean.GjcCheckInRecord" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="isEditMode"
|
||||||
|
type="Boolean" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="position"
|
||||||
|
type="Integer" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="15dp"
|
||||||
|
android:background="@drawable/bg_white_radius_8"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:padding="15dp">
|
||||||
|
|
||||||
|
<!-- 序号(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{`序号`}'
|
||||||
|
title='@{`序号:`}'
|
||||||
|
titleLength="@{4}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{String.valueOf(position + 1)}' />
|
||||||
|
|
||||||
|
<!-- 件数(可编辑) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:id="@+id/padPc"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{isEditMode}"
|
||||||
|
hint='@{`请输入件数`}'
|
||||||
|
title='@{`件数:`}'
|
||||||
|
titleLength="@{4}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{String.valueOf(record.pc)}' />
|
||||||
|
|
||||||
|
<!-- 重量(可编辑) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:id="@+id/padWeight"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{isEditMode}"
|
||||||
|
hint='@{`请输入重量`}'
|
||||||
|
title='@{`重量:`}'
|
||||||
|
titleLength="@{4}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{String.valueOf(record.weight)}' />
|
||||||
|
|
||||||
|
<!-- 托盘自重(只读,固定显示0) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`托盘自重:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{`0`}' />
|
||||||
|
|
||||||
|
<!-- 计重时间(只读) -->
|
||||||
|
<com.lukouguoji.module_base.ui.weight.data.layout.PadDataLayoutNew
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:layout_weight="1.5"
|
||||||
|
enable="@{false}"
|
||||||
|
hint='@{``}'
|
||||||
|
title='@{`计重时间:`}'
|
||||||
|
titleLength="@{5}"
|
||||||
|
type="@{DataLayoutType.INPUT}"
|
||||||
|
value='@{record.opDate}' />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</layout>
|
||||||
Reference in New Issue
Block a user