修复了消耗值为空字符串时重量不显示的问题
修复了相机未初始化或已关闭时调用拍照报错问题 调整了未确认列表允许收货 调整了重量大于1kg时显示kg
This commit is contained in:
@@ -90,7 +90,7 @@ data class PurchaseWarehouseParam(
|
|||||||
if (goodsWeight == null) return ""
|
if (goodsWeight == null) return ""
|
||||||
|
|
||||||
// 小于10 kg 显示 g
|
// 小于10 kg 显示 g
|
||||||
if (goodsWeight!!.toInt() < 10) {
|
if (goodsWeight!!.toInt() < 1) {
|
||||||
return goodsWeight!!.multiply(BigDecimal(1000)).toString()
|
return goodsWeight!!.multiply(BigDecimal(1000)).toString()
|
||||||
}
|
}
|
||||||
return goodsWeight?.toFormattedString() ?: ""
|
return goodsWeight?.toFormattedString() ?: ""
|
||||||
@@ -98,7 +98,7 @@ data class PurchaseWarehouseParam(
|
|||||||
|
|
||||||
val goodsWeightUnitStr: String
|
val goodsWeightUnitStr: String
|
||||||
get() {
|
get() {
|
||||||
return if (goodsWeight == null || goodsWeight!!.toInt() < 10) {
|
return if (goodsWeight == null || goodsWeight!!.toInt() < 1) {
|
||||||
"克"
|
"克"
|
||||||
} else {
|
} else {
|
||||||
"千克"
|
"千克"
|
||||||
|
|||||||
@@ -118,6 +118,14 @@ data class GoodsInfo(
|
|||||||
return receivedNum?.toSafeString(unitName) ?: "-"
|
return receivedNum?.toSafeString(unitName) ?: "-"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val receivedNumCount: String
|
||||||
|
get() {
|
||||||
|
if (receivedNum == null || receivedNum == 0f)
|
||||||
|
return "0"
|
||||||
|
|
||||||
|
return receivedNum?.toSafeString(unitName) ?: "0"
|
||||||
|
}
|
||||||
|
|
||||||
val dualCountStr: String
|
val dualCountStr: String
|
||||||
get() {
|
get() {
|
||||||
return if (receivedNum != null && receivedNum != 0f && receiveCount != null && receiveCount != 0f) {
|
return if (receivedNum != null && receivedNum != 0f && receiveCount != null && receiveCount != 0f) {
|
||||||
@@ -188,7 +196,7 @@ data class GoodsInfo(
|
|||||||
if (goodsWeight == null) return ""
|
if (goodsWeight == null) return ""
|
||||||
|
|
||||||
// 小于10 kg 显示 g
|
// 小于10 kg 显示 g
|
||||||
if (goodsWeight!!.toInt() < 10) {
|
if (goodsWeight!!.toInt() < 1) {
|
||||||
return goodsWeight!!.multiply(BigDecimal(1000)).toString()
|
return goodsWeight!!.multiply(BigDecimal(1000)).toString()
|
||||||
}
|
}
|
||||||
return goodsWeight?.toFormattedString() ?: ""
|
return goodsWeight?.toFormattedString() ?: ""
|
||||||
@@ -196,7 +204,7 @@ data class GoodsInfo(
|
|||||||
|
|
||||||
val goodsWeightUnitStr: String
|
val goodsWeightUnitStr: String
|
||||||
get() {
|
get() {
|
||||||
return if (goodsWeight == null || goodsWeight!!.toInt() < 10) {
|
return if (goodsWeight == null || goodsWeight!!.toInt() < 1) {
|
||||||
"克"
|
"克"
|
||||||
} else {
|
} else {
|
||||||
"千克"
|
"千克"
|
||||||
|
|||||||
@@ -94,7 +94,7 @@ fun ReceiptProductScreen(
|
|||||||
|
|
||||||
LaunchedEffect(receiptResult) {
|
LaunchedEffect(receiptResult) {
|
||||||
if (receiptResult) {
|
if (receiptResult) {
|
||||||
ToastUtils.showToast("收货成功")
|
// ToastUtils.showToast("收货成功")
|
||||||
controller.popBackStack()
|
controller.popBackStack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import androidx.compose.ui.Alignment
|
|||||||
import androidx.compose.ui.Modifier
|
import androidx.compose.ui.Modifier
|
||||||
import androidx.compose.ui.platform.LocalContext
|
import androidx.compose.ui.platform.LocalContext
|
||||||
import androidx.compose.ui.unit.dp
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.lifecycle.compose.LocalLifecycleOwner
|
import androidx.lifecycle.compose.LocalLifecycleOwner
|
||||||
import com.sw.inbound.ext.medium
|
import com.sw.inbound.ext.medium
|
||||||
import com.sw.inbound.model.request.PurchaseWarehouseParam
|
import com.sw.inbound.model.request.PurchaseWarehouseParam
|
||||||
@@ -75,6 +76,7 @@ fun IdentityView(
|
|||||||
searchList
|
searchList
|
||||||
}
|
}
|
||||||
val debouncer = remember { Debouncer(2000) }
|
val debouncer = remember { Debouncer(2000) }
|
||||||
|
var isCameraReady by remember { mutableStateOf(false) }
|
||||||
|
|
||||||
// CameraX 控制器
|
// CameraX 控制器
|
||||||
val cameraController = remember {
|
val cameraController = remember {
|
||||||
@@ -113,7 +115,10 @@ fun IdentityView(
|
|||||||
// 绑定生命周期
|
// 绑定生命周期
|
||||||
DisposableEffect(lifecycleOwner) {
|
DisposableEffect(lifecycleOwner) {
|
||||||
cameraController.bindToLifecycle(lifecycleOwner)
|
cameraController.bindToLifecycle(lifecycleOwner)
|
||||||
onDispose { /* 清理资源 */ }
|
onDispose {
|
||||||
|
cameraController.unbind()
|
||||||
|
isCameraReady = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LaunchedEffect(weightInfo) {
|
LaunchedEffect(weightInfo) {
|
||||||
@@ -132,13 +137,28 @@ fun IdentityView(
|
|||||||
Timber.d("LaunchedEffect canIdentity = $canIdentity")
|
Timber.d("LaunchedEffect canIdentity = $canIdentity")
|
||||||
if (canIdentity) {
|
if (canIdentity) {
|
||||||
debouncer.debounce {
|
debouncer.debounce {
|
||||||
|
Timber.d("LaunchedEffect isCameraReady = $isCameraReady")
|
||||||
|
if (isCameraReady) {
|
||||||
takePhoto()
|
takePhoto()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
lastWeight = weightInfo
|
lastWeight = weightInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 监听相机初始化
|
||||||
|
LaunchedEffect(Unit) {
|
||||||
|
try {
|
||||||
|
cameraController.initializationFuture.addListener({
|
||||||
|
isCameraReady = true
|
||||||
|
Timber.d("Camera initialized successfully")
|
||||||
|
}, ContextCompat.getMainExecutor(context))
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.d("Camera initialized error = ${e.message}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Column(
|
Column(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxSize(),
|
.fillMaxSize(),
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ fun ReceiptTipDialog(
|
|||||||
Spacer(modifier = Modifier.width(10.dp))
|
Spacer(modifier = Modifier.width(10.dp))
|
||||||
CustomSingleRightText(
|
CustomSingleRightText(
|
||||||
modifier = Modifier.weight(1f),
|
modifier = Modifier.weight(1f),
|
||||||
text = "${goods.receivedNumListStr}${goods.unitNameStr}",
|
text = "${goods.receivedNumCount}${goods.unitNameStr}",
|
||||||
style = AppTypography.blackMediumTextStyle.withColor(
|
style = AppTypography.blackMediumTextStyle.withColor(
|
||||||
Color.Red
|
Color.Red
|
||||||
),
|
),
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.sw.inbound.viewmodel
|
|||||||
import androidx.lifecycle.viewModelScope
|
import androidx.lifecycle.viewModelScope
|
||||||
import com.sw.inbound.ext.toFormattedString
|
import com.sw.inbound.ext.toFormattedString
|
||||||
import com.sw.inbound.ext.toSafeBigDecimal
|
import com.sw.inbound.ext.toSafeBigDecimal
|
||||||
|
import com.sw.inbound.ext.toSafeDouble
|
||||||
import com.sw.inbound.ext.toSafeFloat
|
import com.sw.inbound.ext.toSafeFloat
|
||||||
import com.sw.inbound.model.request.UploadInfo
|
import com.sw.inbound.model.request.UploadInfo
|
||||||
import com.sw.inbound.model.response.DictType
|
import com.sw.inbound.model.response.DictType
|
||||||
@@ -91,10 +92,10 @@ class ReceiptViewModel @Inject constructor(
|
|||||||
ToastUtils.showToast("订单为空或包含异常数据")
|
ToastUtils.showToast("订单为空或包含异常数据")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!unadjustedOrders.value.isEmpty()) {
|
// if (!unadjustedOrders.value.isEmpty()) {
|
||||||
ToastUtils.showToast("请先确认物品信息")
|
// ToastUtils.showToast("请先确认物品信息")
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
_showReceiptDialog.value = showDialog
|
_showReceiptDialog.value = showDialog
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +254,7 @@ class ReceiptViewModel @Inject constructor(
|
|||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var consumeValue = currentItem.consumeValue?.toDouble() ?: 1.0
|
var consumeValue = currentItem.consumeValue?.toSafeDouble() ?: 1.0
|
||||||
var purchaseValue = currentItem.purchaseValue?.toDouble() ?: 1.0
|
var purchaseValue = currentItem.purchaseValue?.toDouble() ?: 1.0
|
||||||
if (consumeValue == 0.0) {
|
if (consumeValue == 0.0) {
|
||||||
consumeValue = 1.0
|
consumeValue = 1.0
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ class SelfProcurementViewModel @Inject constructor(
|
|||||||
// val selectUnitType = currentItem.selectUnitType
|
// val selectUnitType = currentItem.selectUnitType
|
||||||
// if (selectUnitType == null) return@startScale
|
// if (selectUnitType == null) return@startScale
|
||||||
|
|
||||||
var consumeValue = selectUnitType.consumeValue?.toDouble() ?: 1.0
|
var consumeValue = selectUnitType.consumeValue?.toSafeDouble() ?: 1.0
|
||||||
var purchaseValue = selectUnitType.purchaseValue?.toDouble() ?: 1.0
|
var purchaseValue = selectUnitType.purchaseValue?.toDouble() ?: 1.0
|
||||||
if (consumeValue == 0.0) {
|
if (consumeValue == 0.0) {
|
||||||
consumeValue = 1.0
|
consumeValue = 1.0
|
||||||
|
|||||||
Reference in New Issue
Block a user