添加净值率判断
This commit is contained in:
@@ -383,10 +383,11 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
.width(474.dp),
|
||||
label = "净材率",
|
||||
value = goodsAddParam.netRateStr,
|
||||
inputType = InputType.Decimal,
|
||||
inputType = InputType.Percent,
|
||||
onValueChange = {
|
||||
viewModel.updateGoodsAddParam(goodsAddParam.copy(netRate = it.toSafeFloat()))
|
||||
})
|
||||
}, trailingLabel = "%"
|
||||
)
|
||||
ColumnInputText(
|
||||
modifier = Modifier.width(474.dp),
|
||||
value = goodsAddParam.unitIdStr,
|
||||
@@ -498,6 +499,9 @@ fun ColumnInputText(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加物品弹窗
|
||||
*/
|
||||
@Composable
|
||||
fun AddProductDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
|
||||
@@ -83,7 +83,8 @@ import timber.log.Timber
|
||||
enum class InputType {
|
||||
Text, // 字符串
|
||||
Number, // 数字
|
||||
Decimal // 浮点
|
||||
Decimal, // 浮点
|
||||
Percent, // 百分比
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,6 +148,14 @@ fun CustomTextField(
|
||||
}
|
||||
}
|
||||
|
||||
InputType.Percent -> {
|
||||
val range: ClosedFloatingPointRange<Float> = 0f..100f
|
||||
if (newValue.isEmpty() || (newValue.isValidFloat(1) && newValue.toFloat() in range)) {
|
||||
inputValue = newValue
|
||||
onEditingComplete(true)
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
inputValue = newValue
|
||||
onEditingComplete(true)
|
||||
|
||||
Reference in New Issue
Block a user