屏蔽自采购清空

This commit is contained in:
zxj
2025-07-11 13:37:53 +08:00
parent a88321b7b6
commit 7459bd205a
3 changed files with 16 additions and 10 deletions
@@ -121,7 +121,7 @@ fun SelfProcurementScreen(
BottomActionBar(onLeftButtonClick = { BottomActionBar(onLeftButtonClick = {
Timber.d("点击后退 onDispose time = ${System.currentTimeMillis()}") Timber.d("点击后退 onDispose time = ${System.currentTimeMillis()}")
controller.popBackStack() controller.popBackStack()
}, showRight1Button = true, right1ButtonText = "清空物品", onRight1ButtonClick = { }, showRight1Button = false, right1ButtonText = "清空物品", onRight1ButtonClick = {
viewModel.clearPurchaseOrders() viewModel.clearPurchaseOrders()
ToastUtils.showToast("物品清空成功") ToastUtils.showToast("物品清空成功")
}, right2ButtonText = "提交入库", onRight2ButtonClick = { }, right2ButtonText = "提交入库", onRight2ButtonClick = {
@@ -232,6 +232,9 @@ fun ContentRightView(
} }
} }
/**
* 中间组件-菜品识别
*/
@Composable @Composable
fun ProductIdentification(viewModel: SelfProcurementViewModel) { fun ProductIdentification(viewModel: SelfProcurementViewModel) {
val searchResultList by viewModel.searchListItems.collectAsState() val searchResultList by viewModel.searchListItems.collectAsState()
@@ -258,24 +258,24 @@ class ReceiptViewModel @Inject constructor(
Timber.d("startSensorScale weight = $weight, count = $count, finalCount = $finalCount, consumeValue = $consumeValue, purchaseValue = $purchaseValue") Timber.d("startSensorScale weight = $weight, count = $count, finalCount = $finalCount, consumeValue = $consumeValue, purchaseValue = $purchaseValue")
// 计算单价 // 计算单价
val finalPrice = when { val finalPrice = when {
count == 0.0 -> { finalCount == 0f -> {
0f 0f
} }
_amountUserInput.value && !_priceUserInput.value -> { _amountUserInput.value && !_priceUserInput.value -> {
info.recPriceExItem!!.div(count).toSafeFloat() info.recPriceExItem!!.div(finalCount).toSafeFloat()
} }
else -> 0f else -> 0f
} }
// 计算金额 // 计算金额
val finalAmount = when { val finalAmount = when {
count == 0.0 -> { finalCount == 0f -> {
0f 0f
} }
_priceUserInput.value && !_amountUserInput.value -> { _priceUserInput.value && !_amountUserInput.value -> {
count.times(info.recUnitPriceTaxIn!!).toSafeFloat() finalCount.times(info.recUnitPriceTaxIn!!).toSafeFloat()
} }
else -> 0f else -> 0f
@@ -284,7 +284,7 @@ class ReceiptViewModel @Inject constructor(
_selectedItem.value = info.copy( _selectedItem.value = info.copy(
goodsWeight = weight.toSafeBigDecimal(), goodsWeight = weight.toSafeBigDecimal(),
// 收货数量 // 收货数量
receivedNumTemp = count.toFormattedString(), receivedNumTemp = finalCount.toFormattedString(),
receivedNum = finalCount, receivedNum = finalCount,
// 单价 // 单价
recUnitPriceTaxIn = if (_priceUserInput.value) info.recUnitPriceTaxIn else finalPrice, recUnitPriceTaxIn = if (_priceUserInput.value) info.recUnitPriceTaxIn else finalPrice,
@@ -84,6 +84,9 @@ class SelfProcurementViewModel @Inject constructor(
_globalWarehouse.value = dictType _globalWarehouse.value = dictType
} }
/**
* 开始称重
*/
fun startSensorScale() { fun startSensorScale() {
Timber.d("开始称重") Timber.d("开始称重")
SensorScaleUtils.startScale(callback = { weight -> SensorScaleUtils.startScale(callback = { weight ->
@@ -111,18 +114,18 @@ class SelfProcurementViewModel @Inject constructor(
Timber.d("startSensorScale goodsUnitPrice = ${info.goodsUnitPrice}, goodsPrice = ${info.goodsPrice} ") Timber.d("startSensorScale goodsUnitPrice = ${info.goodsUnitPrice}, goodsPrice = ${info.goodsPrice} ")
// 计算单价 金额不为空,数量也不为空, 不是数量输入 也不是单价输入 // 计算单价 金额不为空,数量也不为空, 不是数量输入 也不是单价输入
val finalPrice = val finalPrice =
if (count == 0.0) { if (finalCount == 0.0) {
0.0 0.0
} else if (_amountUserInput.value && !_priceUserInput.value) { } else if (_amountUserInput.value && !_priceUserInput.value) {
info.goodsPrice.div(count).toSafeDouble() info.goodsPrice.div(finalCount).toSafeDouble()
} else 0.0 } else 0.0
// 计算金额 单价不为空,不是数量输入 也不是金额输入 // 计算金额 单价不为空,不是数量输入 也不是金额输入
val finalAmount = val finalAmount =
if (count == 0.0) { if (finalCount == 0.0) {
0.0 0.0
} else if (_priceUserInput.value && !_amountUserInput.value) { } else if (_priceUserInput.value && !_amountUserInput.value) {
count.times(info.goodsUnitPrice).toSafeDouble() finalCount.times(info.goodsUnitPrice).toSafeDouble()
} else 0.0 } else 0.0
Timber.d("startSensorScale finalPrice = $finalPrice, finalAmount = $finalAmount ") Timber.d("startSensorScale finalPrice = $finalPrice, finalAmount = $finalAmount ")
_selectedItem.value = info.copy( _selectedItem.value = info.copy(