refactor(servicing): 针对需求:234
- 司机现金收款界面,超限类型的只允许修改公里数,收款金额不允许修改 - 不论超限还是纯现金案件,在司机现金收款界面,全部填全程公里数,系统自动减去免拖公里数,计算出应收现金金额 - 司机现金收款界面,将“调整金额”字段名称改成“额外费用”
This commit is contained in:
@ -67,6 +67,7 @@ import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import coil.compose.AsyncImage
|
||||
import com.blankj.utilcode.util.ToastUtils
|
||||
import com.za.base.BaseActivity
|
||||
import com.za.base.theme.bgColor
|
||||
import com.za.base.theme.black90
|
||||
import com.za.base.view.CommonDialog
|
||||
import com.za.base.view.HeadView
|
||||
@ -98,11 +99,6 @@ class InputMoneyActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun PreviewInputMoneyScreen() {
|
||||
InputMoneyScreen(userOrderId = 1, taskId = 1)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun InputMoneyScreen(userOrderId : Int, taskId : Int, vm : InputMoneyVm = viewModel()) {
|
||||
@ -144,7 +140,7 @@ fun InputMoneyScreen(userOrderId : Int, taskId : Int, vm : InputMoneyVm = viewMo
|
||||
.padding(16.dp),
|
||||
tonalElevation = 8.dp,
|
||||
shadowElevation = 8.dp,
|
||||
color = backgroundColor,
|
||||
color = bgColor,
|
||||
shape = RoundedCornerShape(24.dp)) {
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
@ -162,7 +158,7 @@ fun InputMoneyScreen(userOrderId : Int, taskId : Int, vm : InputMoneyVm = viewMo
|
||||
contentColor = Color.White),
|
||||
elevation = ButtonDefaults.buttonElevation(4.dp),
|
||||
interactionSource = remember { MutableInteractionSource() }) {
|
||||
Text("无须收款", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
||||
Text("无需收款", fontSize = 12.sp, fontWeight = FontWeight.Medium)
|
||||
}
|
||||
|
||||
Button(onClick = {
|
||||
@ -418,3 +414,9 @@ private fun SuccessDialog(amount : String, onDismiss : () -> Unit) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview()
|
||||
@Composable
|
||||
fun PreviewInputMoneyScreen() {
|
||||
InputMoneyScreen(userOrderId = 1, taskId = 1)
|
||||
}
|
@ -25,14 +25,15 @@ import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.input.KeyboardType
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.za.base.theme.bgColor
|
||||
import com.za.base.theme.headBgColor
|
||||
import com.za.base.view.HeadView
|
||||
import com.za.ext.finish
|
||||
import com.za.ui.servicing.order_confirm.modify_money.ModifyMoneyViewModel
|
||||
import com.za.ui.servicing.order_confirm.receive_money.backgroundColor
|
||||
|
||||
|
||||
@Composable
|
||||
@ -48,7 +49,7 @@ fun ModifyMoneyScreen(userOrderId: Int, taskId: Int, vm: ModifyMoneyViewModel =
|
||||
context.finish()
|
||||
}
|
||||
|
||||
Scaffold(topBar = {
|
||||
Scaffold(containerColor = bgColor, topBar = {
|
||||
HeadView(title = "修改金额", onBack = { context.finish() })
|
||||
}) {
|
||||
Column(modifier = Modifier
|
||||
@ -69,104 +70,84 @@ fun ModifyMoneyScreen(userOrderId: Int, taskId: Int, vm: ModifyMoneyViewModel =
|
||||
label = "超限单价",
|
||||
suffix = "元/公里",
|
||||
hint = uiState.value.paymentInfoBean?.unitPrice?.toString() ?: "0",
|
||||
enabled = false
|
||||
)
|
||||
enabled = false)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
MoneyInputField(
|
||||
value = uiState.value.mileageText ?: "",
|
||||
MoneyInputField(value = uiState.value.mileageText ?: "",
|
||||
onValueChange = {
|
||||
vm.dispatch(ModifyMoneyViewModel.Action.ChangeMileage((it)))
|
||||
},
|
||||
label = "公里数",
|
||||
label = "全程公里数",
|
||||
hint = uiState.value.paymentInfoBean?.mileage?.toString() ?: "0",
|
||||
suffix = "公里"
|
||||
)
|
||||
suffix = "公里")
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
MoneyInputField(
|
||||
value = "${uiState.value.calculateAmount ?: 0}",
|
||||
MoneyInputField(value = "${uiState.value.calculateAmount ?: 0}",
|
||||
onValueChange = { },
|
||||
label = "计算金额",
|
||||
suffix = "元",
|
||||
hint = uiState.value.paymentInfoBean?.calculateAmount?.toString() ?: "0",
|
||||
enabled = false
|
||||
)
|
||||
enabled = false)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
|
||||
MoneyInputField(
|
||||
value = uiState.value.adjustAmountText ?: "",
|
||||
//超限类型只允许修改公里数,额外费用和超限单价不允许修改
|
||||
MoneyInputField(value = uiState.value.adjustAmountText ?: "",
|
||||
onValueChange = {
|
||||
vm.dispatch(ModifyMoneyViewModel.Action.ChangeAdjustAmount(it))
|
||||
},
|
||||
label = "调整金额",
|
||||
label = "额外费用",
|
||||
hint = uiState.value.paymentInfoBean?.adjustAmount?.toString() ?: "0",
|
||||
suffix = "元"
|
||||
)
|
||||
suffix = "元",
|
||||
enabled = uiState.value.paymentInfoBean?.payItem == 1)
|
||||
|
||||
Spacer(modifier = Modifier.height(12.dp))
|
||||
Spacer(modifier = Modifier.height(2.dp))
|
||||
|
||||
OutlinedTextField(
|
||||
value = uiState.value.adjustRemark,
|
||||
OutlinedTextField(value = uiState.value.adjustRemark,
|
||||
onValueChange = { vm.updateState(uiState.value.copy(adjustRemark = it)) },
|
||||
label = { Text("调整原因") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(80.dp)
|
||||
)
|
||||
.height(80.dp),
|
||||
enabled = uiState.value.paymentInfoBean?.payItem == 1)
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
// 替换原来的 Row 为新的底部布局
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
Surface(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(bottom = 16.dp),
|
||||
tonalElevation = 8.dp,
|
||||
shadowElevation = 8.dp,
|
||||
color = backgroundColor,
|
||||
shape = RoundedCornerShape(16.dp)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
color = Color.White,
|
||||
shape = RoundedCornerShape(16.dp)) {
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 20.dp, vertical = 16.dp),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
verticalAlignment = Alignment.CenterVertically) {
|
||||
Column {
|
||||
Text(
|
||||
text = "总金额",
|
||||
Text(text = "总金额",
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant
|
||||
)
|
||||
Text(
|
||||
text = "¥ ${uiState.value.totalMoney ?: 0}",
|
||||
color = MaterialTheme.colorScheme.onSurfaceVariant)
|
||||
Text(text = "¥ ${uiState.value.totalMoney ?: 0}",
|
||||
style = MaterialTheme.typography.headlineMedium,
|
||||
color = headBgColor,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
fontWeight = FontWeight.Bold)
|
||||
}
|
||||
|
||||
Button(
|
||||
onClick = { vm.dispatch(ModifyMoneyViewModel.Action.Save) },
|
||||
Button(onClick = { vm.dispatch(ModifyMoneyViewModel.Action.Save) },
|
||||
modifier = Modifier
|
||||
.height(48.dp)
|
||||
.width(120.dp),
|
||||
shape = RoundedCornerShape(24.dp),
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = headBgColor
|
||||
)
|
||||
) {
|
||||
Text(
|
||||
"保存",
|
||||
colors = ButtonDefaults.buttonColors(containerColor = headBgColor)) {
|
||||
Text("保存",
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
fontWeight = FontWeight.Medium
|
||||
)
|
||||
fontWeight = FontWeight.Medium)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -175,18 +156,15 @@ fun ModifyMoneyScreen(userOrderId: Int, taskId: Int, vm: ModifyMoneyViewModel =
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun MoneyInputField(
|
||||
value: String,
|
||||
private fun MoneyInputField(value : String,
|
||||
onValueChange : (String) -> Unit,
|
||||
label : String,
|
||||
suffix : String,
|
||||
hint : String,
|
||||
keyboardType : KeyboardType = KeyboardType.Decimal,
|
||||
enabled: Boolean = true
|
||||
) {
|
||||
enabled : Boolean = true) {
|
||||
val secondaryTextColor = Color(0xFF666666)
|
||||
OutlinedTextField(
|
||||
value = value,
|
||||
OutlinedTextField(value = value,
|
||||
placeholder = { Text(hint, color = secondaryTextColor) },
|
||||
onValueChange = onValueChange,
|
||||
label = { Text(label, color = secondaryTextColor) },
|
||||
@ -195,14 +173,19 @@ private fun MoneyInputField(
|
||||
.padding(vertical = 4.dp),
|
||||
enabled = enabled,
|
||||
keyboardOptions = KeyboardOptions(keyboardType = keyboardType),
|
||||
trailingIcon = { Text(suffix, modifier = Modifier.padding(end = 12.dp), color = secondaryTextColor) },
|
||||
colors = OutlinedTextFieldDefaults.colors(
|
||||
focusedBorderColor = headBgColor,
|
||||
trailingIcon = {
|
||||
Text(suffix, modifier = Modifier.padding(end = 12.dp), color = secondaryTextColor)
|
||||
},
|
||||
colors = OutlinedTextFieldDefaults.colors(focusedBorderColor = headBgColor,
|
||||
unfocusedBorderColor = Color(0xFFE0E0E0),
|
||||
focusedLabelColor = headBgColor,
|
||||
unfocusedLabelColor = secondaryTextColor,
|
||||
cursorColor = headBgColor
|
||||
),
|
||||
shape = RoundedCornerShape(8.dp)
|
||||
)
|
||||
cursorColor = headBgColor),
|
||||
shape = RoundedCornerShape(8.dp))
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun ModifyMoneyPre() {
|
||||
ModifyMoneyScreen(userOrderId = 0, taskId = 0)
|
||||
}
|
@ -64,7 +64,6 @@ class ModifyMoneyViewModel : BaseVm<Action, UiState>() {
|
||||
|
||||
private fun changeMileage(value: String?) {
|
||||
val mileage = value?.toFloatOrNull() ?: 0f
|
||||
if (uiState.value.paymentInfoBean?.payItem == 1) {
|
||||
val calculateAmount = if (mileage <= (uiState.value.paymentInfoBean?.limitedMileage
|
||||
?: 0)
|
||||
) {
|
||||
@ -76,11 +75,9 @@ class ModifyMoneyViewModel : BaseVm<Action, UiState>() {
|
||||
}
|
||||
updateState(uiState.value.copy(mileage = mileage, mileageText = value, calculateAmount = calculateAmount.toFloat(),
|
||||
totalMoney = calculateAmount.toFloat().plus(uiState.value.adjustAmount ?: 0f)))
|
||||
return
|
||||
}
|
||||
val calculateAmount = mileage.times(uiState.value.unitPrice ?: 0f)
|
||||
val totalMoney = calculateAmount + (uiState.value.paymentInfoBean?.adjustAmount ?: 0)
|
||||
updateState(uiState.value.copy(mileage = mileage, mileageText = value, calculateAmount = calculateAmount, totalMoney = totalMoney))
|
||||
// val calculateAmount = mileage.times(uiState.value.unitPrice ?: 0f)
|
||||
// val totalMoney = calculateAmount + (uiState.value.paymentInfoBean?.adjustAmount ?: 0)
|
||||
// updateState(uiState.value.copy(mileage = mileage, mileageText = value, calculateAmount = calculateAmount, totalMoney = totalMoney))
|
||||
}
|
||||
|
||||
private fun changeAdjustAmount(value: String?) {
|
||||
|
Reference in New Issue
Block a user