自采入库同一物品可以添加多次

This commit is contained in:
zxj
2025-07-15 16:32:30 +08:00
parent bf8dc3f9b5
commit 84a337bae4
4 changed files with 31 additions and 13 deletions
@@ -111,6 +111,12 @@ data class GoodsInfo(
return recUnitPriceTaxIn?.toFormattedString() ?: ""
}
val recUnitPriceTaxInListStr: String
get() {
if (recUnitPriceTaxIn == 0f) return "-"
return recUnitPriceTaxIn?.toFormattedString() ?: "-"
}
val receiveCountStr: String
get() {
return when (receiveCount) {
@@ -118,6 +124,13 @@ data class GoodsInfo(
else -> receiveCount?.toSafeString(unitName) ?: ""
}
}
val receiveCountListStr: String
get() {
return when (receiveCount) {
0f -> "-"
else -> receiveCount?.toSafeString(unitName) ?: "-"
}
}
val recPriceExItemStr: String
get() {
@@ -126,6 +139,13 @@ data class GoodsInfo(
else -> recPriceExItem?.toFormattedString() ?: ""
}
}
val recPriceExItemListStr: String
get() {
return when (recPriceExItem) {
0f -> "-"
else -> recPriceExItem?.toFormattedString() ?: "-"
}
}
val unitNameStr: String
get() {
@@ -106,19 +106,19 @@ fun ReceiptUnadjustedListView(
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.width(120.dp),
text = it.recUnitPriceTaxInStr,
text = it.recUnitPriceTaxInListStr,
style = AppTypography.blackTextStyle
)
Spacer(modifier = Modifier.width(20.dp))
CustomSingleRightText(
modifier = Modifier.width(140.dp),
text = "${it.receiveCountStr}${it.unitNameStr}",
text = "${it.receiveCountListStr}${it.unitNameStr}",
style = AppTypography.blackTextStyle
)
Spacer(modifier = Modifier.width(20.dp))
CustomSingleRightText(
modifier = Modifier.width(120.dp),
text = it.recPriceExItemStr,
text = it.recPriceExItemListStr,
style = AppTypography.blackTextStyle
)
if (showClose) {
@@ -82,7 +82,11 @@ fun SelfProcurementListItem(
// Spacer(modifier = Modifier.height(31.dp))
// 左侧列表
LazyColumn() {
items(items = productList, key = { it.goodsId }) { it ->
items(
items = productList,
// 取消key,列表中可以插入同一物品
// key = { it.goodsId }
) { it ->
val checkedBg =
if (it.goodsId == checkedItem?.goodsId) Gray_DCDCF0 else Color.Transparent
@@ -213,17 +213,8 @@ class SelfProcurementViewModel @Inject constructor(
// 添加订单
fun addPurchaseItem(purchaseOrder: PurchaseWarehouseParam) {
if (_purchaseList.value.any { it.goodsId == purchaseOrder.goodsId }) {
ToastUtils.showToast("添加失败,当前物品已添加")
return
}
_purchaseList.update { currentList ->
// 当已经添加过则忽略
if (currentList.any { it.goodsId == purchaseOrder.goodsId }) {
currentList
} else {
currentList + purchaseOrder
}
}
updateSelectedItem(null)
}
@@ -355,6 +346,9 @@ class SelfProcurementViewModel @Inject constructor(
}
}
/**
* 物品提交入库
*/
fun addToWarehouse() {
if (_purchaseList.value.isEmpty()) {
ToastUtils.showToast("采购列表为空")