修复了部分问题

This commit is contained in:
zxj
2025-07-22 17:27:27 +08:00
parent 4c6fa31787
commit a2405a0992
8 changed files with 69 additions and 35 deletions
+3 -1
View File
@@ -15,7 +15,8 @@
返回值
supplierId 供应商id Integer
supplierName 供应商 String
receiveCode 收货单号 String
receiveCode 收货单号 String 废弃界面显示purCode
purCode 采购单号 String
goodCount 物品项 Integer
receiveDate 收货日期 Date
purchaseDate 采购日期 Date
@@ -130,6 +131,7 @@ https://vip.shuziweidao.com/shuwei-zhct/fileUpload/fileUpload
goodsPurId Integer
warehouseId 仓库id Integer
recUnitPriceTaxIn 收货单价 Float
newRecUnitPriceTaxIn 采购单价 Float
receiveCount 收货数量 Float
recPriceInItem 收货金额 Float
receivedNum 实际收货数量 Float
@@ -33,6 +33,12 @@ data class GoodsInfo(
// 单价 界面显示
var recUnitPriceTaxInTemp: String = "",
/**
* 新单价 部分收货需要
*/
var newRecUnitPriceTaxIn: Float? = null,
var newRecUnitPriceTaxInTemp: String = "",
/**
* 单位名称
*/
@@ -109,7 +115,18 @@ data class GoodsInfo(
get() {
if (receivedNum == null)
return "-"
return receivedNum?.toFormattedString() ?: "-"
return receivedNum?.toSafeString(unitName) ?: "-"
}
val dualCountStr: String
get() {
return if (receivedNum != null && receivedNum != 0f && receiveCount != null && receiveCount != 0f) {
"${receivedNum.toSafeString(unitName)}/${receiveCount.toSafeString(unitName)}"
} else if (receivedNum != null && receivedNum != 0f) {
"${receivedNum.toSafeString(unitName)}/-"
} else {
receiveCountListStr
}
}
val recUnitPriceTaxInStr: String
@@ -124,6 +141,12 @@ data class GoodsInfo(
return recUnitPriceTaxIn?.toFormattedString() ?: "-"
}
val newRecUnitPriceTaxInListStr: String
get() {
if (newRecUnitPriceTaxIn == 0f) return "-"
return newRecUnitPriceTaxIn?.toFormattedString() ?: "-"
}
val receiveCountStr: String
get() {
return when (receiveCount) {
@@ -204,7 +227,7 @@ data class GoodsInfo(
if (receivedNum == null || receivedNum == 0f) {
return "请输入收货数量或进行称重"
}
if (recUnitPriceTaxIn == null || recUnitPriceTaxIn == 0f) {
if (newRecUnitPriceTaxIn == null || newRecUnitPriceTaxIn == 0f) {
return "请输入收货单价"
}
if (recPriceExItem == null || recPriceExItem == 0f) {
@@ -309,7 +309,7 @@ fun AdjustedView(viewModel: ReceiptViewModel) {
) {
itemsIndexed(
items = purchaseAdjustList,
key = { index, it -> it.goodId!! + index }) { index, it ->
key = { index, it -> it.id ?: index }) { index, it ->
AdjustedViewItem(it, viewModel)
}
@@ -358,7 +358,7 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
.padding(horizontal = 30.dp)
) {
AdjustedRowInputLayout(
label = "单价", value = purchaseOrder.recUnitPriceTaxInStr,
label = "单价", value = purchaseOrder.newRecUnitPriceTaxInListStr,
onValueChange = {
viewModel.updatePurchaseItem(
purchaseOrder = purchaseOrder.copy(
@@ -593,7 +593,7 @@ private fun ReceiptProductEditView(
RowInputLayout(
label = "收货单价",
value = selectedItem!!.recUnitPriceTaxInTemp,
value = selectedItem!!.newRecUnitPriceTaxInTemp,
trailingLabel = "",
isInitUpdate = true,
onValueChange = { value ->
@@ -604,8 +604,8 @@ private fun ReceiptProductEditView(
selectedItem!!.copy(
recPriceExItemTemp = "",
recPriceExItem = 0f,
recUnitPriceTaxInTemp = value,
recUnitPriceTaxIn = value.toSafeFloat()
newRecUnitPriceTaxInTemp = value,
newRecUnitPriceTaxIn = value.toSafeFloat()
)
)
}
@@ -682,7 +682,7 @@ private fun ReceiptProductEditView(
return@clickable
}
val expectAmount =
selectedItem!!.receivedNum!!.times(selectedItem!!.recUnitPriceTaxIn!!)
selectedItem!!.receivedNum!!.times(selectedItem!!.newRecUnitPriceTaxIn!!)
.toSafeFloat()
Timber.d("金额判断:期望金额 = $expectAmount, 实际金额 = ${selectedItem!!.recPriceExItem}")
// if (expectAmount != selectedItem!!.recPriceExItem) {
@@ -72,7 +72,7 @@ fun ReceiptUnadjustedListView(
)
Spacer(modifier = Modifier.width(20.dp))
CustomSingleRightText(
modifier = Modifier.width(140.dp),
modifier = Modifier.width(200.dp),
text = "数量",
style = AppTypography.gray96a0aaTextStyle.bold()
)
@@ -93,7 +93,7 @@ fun ReceiptUnadjustedListView(
LazyColumn() {
itemsIndexed(
items = productList,
key = { index, it -> it.goodId!! + index }) { index, it ->
key = { index, it -> it.id ?: index }) { index, it ->
val checkedBg =
if (selectIndex == index) Gray_DCDCF0 else Color.Transparent
@@ -120,8 +120,8 @@ fun ReceiptUnadjustedListView(
)
Spacer(modifier = Modifier.width(20.dp))
CustomSingleRightText(
modifier = Modifier.width(140.dp),
text = "${it.receiveCountListStr}${it.unitNameStr}",
modifier = Modifier.width(200.dp),
text = "${it.dualCountStr}${it.unitNameStr}",
style = AppTypography.blackTextStyle
)
Spacer(modifier = Modifier.width(20.dp))
@@ -25,7 +25,6 @@ import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.model.request.PurchaseWarehouseParam
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.Gray_DCDCF0
/**
* 自采购 左侧列表
@@ -89,11 +88,9 @@ fun SelfProcurementListItem(
//// key = { it.goodsId }
// )
{ index, it ->
val checkedBg =
if (it.goodsId == checkedItem?.goodsId) Gray_DCDCF0 else Color.Transparent
Row(
modifier = Modifier
.background(color = checkedBg)
.background(color = Color.Transparent)
.padding(30.dp)
.clickable {
onItemCheckedClick(it)
@@ -144,7 +144,7 @@ fun ReceiptTipDialog(
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receivedNumListStr}${goods.unitNameStr}",
text = "${goods.receiveCountListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
color = Color(0xFF0032C8)
),
@@ -153,7 +153,7 @@ fun ReceiptTipDialog(
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receiveCountListStr}${goods.unitNameStr}",
text = "${goods.receivedNumListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
Color.Red
),
@@ -51,12 +51,12 @@ class ReceiptViewModel @Inject constructor(
// 已调整列表
val adjustedOrders: StateFlow<List<GoodsInfo>> = _orders
.map { orders -> orders.filter { it.isAdjusted && it.goodId != null } }
.map { orders -> orders.filter { it.isAdjusted } }
.stateIn(viewModelScope, SharingStarted.Lazily, emptyList())
// 未调整列表
val unadjustedOrders: StateFlow<List<GoodsInfo>> = _orders
.map { orders -> orders.filter { !it.isAdjusted && it.goodId != null } }
.map { orders -> orders.filter { !it.isAdjusted } }
.stateIn(viewModelScope, SharingStarted.Lazily, emptyList())
// 选中的商品
@@ -115,24 +115,24 @@ class ReceiptViewModel @Inject constructor(
fun updateSelectedItem(purchaseOrder: GoodsInfo?) {
if (purchaseOrder != null) {
if (purchaseOrder.receivedNum != null && purchaseOrder.receivedNum != 0f) {
if (purchaseOrder.recUnitPriceTaxInTemp.isNotEmpty()) { // 计算金额 单价不为空,并且金额没有手动输入
if (purchaseOrder.newRecUnitPriceTaxInTemp.isNotEmpty()) { // 计算金额 单价不为空,并且金额没有手动输入
val result =
purchaseOrder.receivedNum!!.times(purchaseOrder.recUnitPriceTaxIn!!)
purchaseOrder.receivedNum!!.times(purchaseOrder.newRecUnitPriceTaxIn!!)
purchaseOrder.recPriceExItem = result.toSafeFloat()
purchaseOrder.recPriceExItemTemp = result.toFormattedString()
} else if (purchaseOrder.recPriceExItemTemp.isNotEmpty()) { // 计算单价 金额不为空,并且单价没有手动输入
val result =
purchaseOrder.recPriceExItem!!.div(purchaseOrder.receivedNum!!)
purchaseOrder.recUnitPriceTaxIn = result.toSafeFloat()
purchaseOrder.recUnitPriceTaxInTemp = result.toFormattedString()
purchaseOrder.newRecUnitPriceTaxIn = result.toSafeFloat()
purchaseOrder.newRecUnitPriceTaxInTemp = result.toFormattedString()
}
} else {
if (_priceUserInput.value) {
purchaseOrder.recPriceExItem = 0f
purchaseOrder.recPriceExItemTemp = ""
} else if (_amountUserInput.value) {
purchaseOrder.recUnitPriceTaxIn = 0f
purchaseOrder.recUnitPriceTaxInTemp = ""
purchaseOrder.newRecUnitPriceTaxIn = 0f
purchaseOrder.newRecUnitPriceTaxInTemp = ""
}
}
} else {
@@ -176,7 +176,7 @@ class ReceiptViewModel @Inject constructor(
fun updatePurchaseItem(purchaseOrder: GoodsInfo) {
_orders.update { currentList ->
currentList.map { order ->
if (order.goodId == purchaseOrder.goodId) purchaseOrder else order
if (order.id == purchaseOrder.id) purchaseOrder else order
}
}
}
@@ -250,8 +250,14 @@ class ReceiptViewModel @Inject constructor(
)
return@startScale
}
val consumeValue = currentItem.consumeValue?.toDouble() ?: 1.0
val purchaseValue = currentItem.purchaseValue?.toDouble() ?: 1.0
var consumeValue = currentItem.consumeValue?.toDouble() ?: 1.0
var purchaseValue = currentItem.purchaseValue?.toDouble() ?: 1.0
if (consumeValue == 0.0) {
consumeValue = 1.0
}
if (purchaseValue == 0.0) {
purchaseValue = 1.0
}
val count =
weight * 1000 / consumeValue / purchaseValue
val finalCount = count.toSafeFloat(currentItem.unitName)
@@ -275,7 +281,7 @@ class ReceiptViewModel @Inject constructor(
}
_priceUserInput.value && !_amountUserInput.value -> {
finalCount.times(info.recUnitPriceTaxIn!!).toSafeFloat()
finalCount.times(info.newRecUnitPriceTaxIn!!).toSafeFloat()
}
else -> 0f
@@ -287,8 +293,8 @@ class ReceiptViewModel @Inject constructor(
receivedNumTemp = finalCount.toFormattedString(),
receivedNum = finalCount,
// 单价
recUnitPriceTaxIn = if (_priceUserInput.value) info.recUnitPriceTaxIn else finalPrice,
recUnitPriceTaxInTemp = if (_priceUserInput.value) info.recUnitPriceTaxInTemp else finalPrice.toFormattedString(),
newRecUnitPriceTaxIn = if (_priceUserInput.value) info.newRecUnitPriceTaxIn else finalPrice,
newRecUnitPriceTaxInTemp = if (_priceUserInput.value) info.newRecUnitPriceTaxInTemp else finalPrice.toFormattedString(),
// 金额
recPriceExItem = if (_amountUserInput.value) info.recPriceExItem else finalAmount,
recPriceExItemTemp = if (_amountUserInput.value) info.recPriceExItemTemp else finalAmount.toFormattedString(),
@@ -119,8 +119,14 @@ class SelfProcurementViewModel @Inject constructor(
// val selectUnitType = currentItem.selectUnitType
// if (selectUnitType == null) return@startScale
val consumeValue = selectUnitType.consumeValue?.toDouble() ?: 1.0
val purchaseValue = selectUnitType.purchaseValue?.toDouble() ?: 1.0
var consumeValue = selectUnitType.consumeValue?.toDouble() ?: 1.0
var purchaseValue = selectUnitType.purchaseValue?.toDouble() ?: 1.0
if (consumeValue == 0.0) {
consumeValue = 1.0
}
if (purchaseValue == 0.0) {
purchaseValue = 1.0
}
val count =
weight * 1000 / consumeValue / purchaseValue
val finalCount = count.toSafeDouble(currentItem.unitName)