调整了添加物品及采购单位弹窗布局
This commit is contained in:
@@ -11,17 +11,7 @@ data class GoodsPurchaseUnitParam(
|
||||
* 库存与克的转换值
|
||||
*/
|
||||
var consumeValue: String = "",
|
||||
val consumeValueTemp: String = "",
|
||||
) {
|
||||
|
||||
val consumeValueTempValue: String
|
||||
get() {
|
||||
if (consumeValue.isNotEmpty()) {
|
||||
return consumeValue
|
||||
}
|
||||
return consumeValueTemp
|
||||
}
|
||||
|
||||
val unitIdStr: String
|
||||
get() {
|
||||
if (unitId == 0) return ""
|
||||
@@ -48,10 +38,9 @@ data class GoodsPurchaseUnitParam(
|
||||
if (purchaseValue == null || purchaseValue == 0f) {
|
||||
return "请输入采购单位对应的库存数量"
|
||||
}
|
||||
if (consumeValueTemp.isEmpty()) {
|
||||
if (consumeValue.isEmpty()) {
|
||||
return "请输入库存单位对应的消耗值"
|
||||
}
|
||||
consumeValue = consumeValueTemp
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,7 +361,6 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
|
||||
ColumnInputText(
|
||||
modifier = Modifier
|
||||
.weight(1f)
|
||||
.width(474.dp),
|
||||
label = "净材率",
|
||||
value = goodsAddParam.netRateStr,
|
||||
@@ -410,7 +409,6 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.spacedBy(60.dp)
|
||||
) {
|
||||
|
||||
ColumnInputText(
|
||||
modifier = Modifier.width(474.dp),
|
||||
value = goodsAddParam.unitIdStr,
|
||||
@@ -425,6 +423,41 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
},
|
||||
)
|
||||
|
||||
Column {
|
||||
Text(text = "消耗单位", style = AppTypography.black141428TextStyle)
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(60.dp)
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(234.dp),
|
||||
value = goodsAddParam.consumeValue,
|
||||
placeholderValue = "请录入",
|
||||
isInitUpdate = true,
|
||||
onValueChange = {
|
||||
viewModel.updateGoodsAddParam(goodsAddParam.copy(consumeValue = it))
|
||||
}, inputType = InputType.Decimal, hasNext = true
|
||||
)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("克", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(text = "=", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(120.dp),
|
||||
value = goodsAddParam.unitIdStr,
|
||||
isInitUpdate = true,
|
||||
placeholderValue = "-",
|
||||
enabled = false,
|
||||
textAlign = TextAlign.Center,
|
||||
onValueChange = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -481,45 +514,12 @@ private fun DialogRightEditView(viewModel: SelfProcurementViewModel) {
|
||||
if (it.isValidAmount()) {
|
||||
viewModel.updateGoodsAddParam(goodsAddParam.copy(purchasePrice = it.toSafeBigDecimal()))
|
||||
}
|
||||
}, inputType = InputType.Decimal, hasNext = true
|
||||
}, inputType = InputType.Decimal, hasNext = false
|
||||
)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("元", style = AppTypography.gray96a0aaTextStyle)
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
Text(text = "消耗单位", style = AppTypography.black141428TextStyle)
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(92.dp)
|
||||
.fillMaxWidth()
|
||||
.dashedBorder()
|
||||
.padding(vertical = 16.dp, horizontal = 26.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("1", style = AppTypography.black141428TextStyle.bold())
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(goodsAddParam.unitIdStr, style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(text = "=", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(200.dp),
|
||||
value = goodsAddParam.consumeValue,
|
||||
placeholderValue = "请录入",
|
||||
isInitUpdate = true,
|
||||
onValueChange = {
|
||||
viewModel.updateGoodsAddParam(goodsAddParam.copy(consumeValue = it))
|
||||
}, inputType = InputType.Decimal, hasNext = false
|
||||
)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("克", style = AppTypography.gray96a0aaTextStyle)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(24.dp))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -555,7 +555,8 @@ private fun AddPurchaseUnitDialogContentView(
|
||||
private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
val unitTypeList = GlobalData.unitTypeList
|
||||
val goodsAddUnitParam by viewModel.goodsAddUnitParam.collectAsState()
|
||||
val canChange by viewModel.dropdownTextChange.collectAsState()
|
||||
val canChangeKcUnit by viewModel.canChangeKcUnit.collectAsState()
|
||||
val canChangeConsumeValue by viewModel.canChangeConsumeValue.collectAsState()
|
||||
|
||||
Column(
|
||||
modifier = Modifier
|
||||
@@ -569,10 +570,10 @@ private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
horizontalArrangement = Arrangement.spacedBy(60.dp)
|
||||
) {
|
||||
ColumnInputText(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
modifier = Modifier.width(370.dp),
|
||||
value = goodsAddUnitParam.unitIdStr,
|
||||
label = "库存单位",
|
||||
enabled = canChange,
|
||||
enabled = canChangeKcUnit,
|
||||
dropdownItems = unitTypeList,
|
||||
onValueChange = { value ->
|
||||
viewModel.updateGoodsPurchaseUnit(
|
||||
@@ -582,6 +583,42 @@ private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
)
|
||||
},
|
||||
)
|
||||
Column {
|
||||
Text(text = "消耗单位", style = AppTypography.black141428TextStyle)
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(60.dp)
|
||||
.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(158.dp),
|
||||
value = goodsAddUnitParam.consumeValue,
|
||||
placeholderValue = "请录入",
|
||||
enabled = canChangeConsumeValue,
|
||||
isInitUpdate = true,
|
||||
onValueChange = {
|
||||
viewModel.updateGoodsPurchaseUnit(goodsAddUnitParam.copy(consumeValue = it))
|
||||
}, inputType = InputType.Decimal, hasNext = true
|
||||
)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("克", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(text = "=", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(120.dp),
|
||||
value = goodsAddUnitParam.unitIdStr,
|
||||
isInitUpdate = true,
|
||||
placeholderValue = "-",
|
||||
enabled = false,
|
||||
textAlign = TextAlign.Center,
|
||||
onValueChange = {}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
@@ -594,7 +631,7 @@ private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
.dashedBorder()
|
||||
.padding(vertical = 16.dp, horizontal = 26.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
horizontalArrangement = Arrangement.Start
|
||||
) {
|
||||
Text("1", style = AppTypography.black141428TextStyle.bold())
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
@@ -612,9 +649,9 @@ private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
)
|
||||
)
|
||||
})
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Spacer(modifier = Modifier.width(44.dp))
|
||||
Text(text = "=", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Spacer(modifier = Modifier.width(44.dp))
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(260.dp),
|
||||
value = goodsAddUnitParam.purchaseValue.toSafeString(goodsAddUnitParam.unitIdStr),
|
||||
@@ -628,44 +665,12 @@ private fun DialogAddPurchaseUnitEditView(viewModel: SelfProcurementViewModel) {
|
||||
Text(goodsAddUnitParam.unitIdStr, style = AppTypography.gray96a0aaTextStyle)
|
||||
}
|
||||
}
|
||||
|
||||
Column {
|
||||
Text(text = "消耗单位", style = AppTypography.black141428TextStyle)
|
||||
Spacer(modifier = Modifier.height(20.dp))
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.height(92.dp)
|
||||
.fillMaxWidth()
|
||||
.dashedBorder()
|
||||
.padding(vertical = 16.dp, horizontal = 26.dp),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.SpaceBetween
|
||||
) {
|
||||
Text("1", style = AppTypography.black141428TextStyle.bold())
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(goodsAddUnitParam.unitIdStr, style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text(text = "=", style = AppTypography.gray96a0aaTextStyle)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
CustomTextField(
|
||||
modifier = Modifier.width(260.dp),
|
||||
value = goodsAddUnitParam.consumeValueTempValue,
|
||||
isInitUpdate = true,
|
||||
placeholderValue = "请录入",
|
||||
enabled = goodsAddUnitParam.consumeValue.isEmpty(),
|
||||
onValueChange = {
|
||||
viewModel.updateGoodsPurchaseUnit(goodsAddUnitParam.copy(consumeValueTemp = it))
|
||||
}, inputType = InputType.Decimal, hasNext = false
|
||||
)
|
||||
Spacer(modifier = Modifier.width(24.dp))
|
||||
Text("克", style = AppTypography.gray96a0aaTextStyle)
|
||||
}
|
||||
}
|
||||
|
||||
Column(
|
||||
verticalArrangement = Arrangement.Center,
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier.fillMaxSize()
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(top = 12.dp)
|
||||
) {
|
||||
Text(
|
||||
text = "完善更多单位信息请登录后台维护,建议及时操作以确保信息准确",
|
||||
|
||||
@@ -68,9 +68,13 @@ class SelfProcurementViewModel @Inject constructor(
|
||||
val showAddPurchaseUnitDialog: StateFlow<Boolean> = _showAddPurchaseUnitDialog
|
||||
|
||||
|
||||
// 是否可以下拉
|
||||
private val _dropdownTextChange = MutableStateFlow<Boolean>(false)
|
||||
val dropdownTextChange: StateFlow<Boolean> = _dropdownTextChange
|
||||
// 是否可以修改库存单位
|
||||
private val _canChangeKcUnit = MutableStateFlow<Boolean>(false)
|
||||
val canChangeKcUnit: StateFlow<Boolean> = _canChangeKcUnit
|
||||
|
||||
// 是否可以修改消耗值
|
||||
private val _canChangeConsumeValue = MutableStateFlow<Boolean>(false)
|
||||
val canChangeConsumeValue: StateFlow<Boolean> = _canChangeConsumeValue
|
||||
|
||||
/**
|
||||
* 数量是否是用户输入的值
|
||||
@@ -327,10 +331,13 @@ class SelfProcurementViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun updateAddPurchaseUnitDialog(show: Boolean) {
|
||||
if (_selectedItem.value == null) return
|
||||
_showAddPurchaseUnitDialog.value = show
|
||||
if (show) {
|
||||
val hasUnitId = GlobalData.unitTypeList.any { it.id == _selectedItem.value?.kcUnitId }
|
||||
_dropdownTextChange.value = !hasUnitId
|
||||
val hasUnitId = GlobalData.unitTypeList.any { it.id == _selectedItem.value!!.kcUnitId }
|
||||
_canChangeKcUnit.value = !hasUnitId
|
||||
_canChangeConsumeValue.value =
|
||||
_selectedItem.value!!.consumeValue.trim().isEmpty() == true
|
||||
} else {
|
||||
_goodsAddUnitParam.value = GoodsPurchaseUnitParam()
|
||||
}
|
||||
@@ -345,7 +352,7 @@ class SelfProcurementViewModel @Inject constructor(
|
||||
}
|
||||
|
||||
fun updateDropdownTextChange(canChange: Boolean) {
|
||||
_dropdownTextChange.value == canChange
|
||||
_canChangeKcUnit.value == canChange
|
||||
}
|
||||
|
||||
fun addGoodsPurchaseUnit() {
|
||||
|
||||
Reference in New Issue
Block a user