实现了部分收货UI。替换为张欢测试服务

This commit is contained in:
zxj
2025-07-18 08:49:06 +08:00
parent 5874e4ed9a
commit 4c6fa31787
22 changed files with 282 additions and 137 deletions
@@ -34,6 +34,7 @@ import androidx.hilt.navigation.compose.hiltViewModel
import androidx.navigation.NavController
import androidx.navigation.compose.rememberNavController
import com.sw.inbound.GlobalData
import com.sw.inbound.GlobalKey
import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.textAlign
@@ -41,6 +42,7 @@ import com.sw.inbound.ext.withSize
import com.sw.inbound.ui.Screen
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.utils.SPUtil
import com.sw.inbound.utils.ToastUtils
import com.sw.inbound.viewmodel.UserViewModel
import timber.log.Timber
@@ -51,13 +53,14 @@ fun LoginScreen(
controller: NavController = rememberNavController(),
viewModel: UserViewModel = hiltViewModel<UserViewModel>()
) {
var username by remember { mutableStateOf<String>("padAdmin") }
var password by remember { mutableStateOf<String>("123123") }
var username by remember { mutableStateOf<String>("") }
var password by remember { mutableStateOf<String>("") }
// val user by viewModel.user.collectAsState()
LaunchedEffect(Unit) {
Timber.d(" user =")
username = SPUtil.getInstance().get(GlobalKey.KEY_USER_NAME, "").toString()
viewModel.user.collect {
Timber.d(" user collect = ${it}")
if (it != null) {
@@ -233,7 +233,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
verticalArrangement = Arrangement.spacedBy(0.dp)
) {
Text(
text = product.supplierName,
text = product.supplierName ?: "-",
modifier = Modifier.padding(top = 25.dp),
maxLines = 1,
overflow = TextOverflow.Ellipsis,
@@ -245,7 +245,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
)
Spacer(modifier = Modifier.height(itemSpace))
Text(
text = "单号 ${product.receiveCode}",
text = "单号 ${product.purCode ?: "-"}",
maxLines = 1,
style = grayTextStyle
)
@@ -2,6 +2,7 @@ package com.sw.inbound.ui.page
import androidx.compose.foundation.Image
import androidx.compose.foundation.background
import androidx.compose.foundation.border
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
@@ -14,9 +15,10 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.Tab
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@@ -32,6 +34,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
@@ -44,6 +47,7 @@ import com.sw.inbound.GlobalData
import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.toSafeFloat
import com.sw.inbound.ext.withColor
import com.sw.inbound.ext.withSize
import com.sw.inbound.model.request.UploadInfo
import com.sw.inbound.model.response.DictType
@@ -52,6 +56,8 @@ import com.sw.inbound.sdk.SensorScaleUtils
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.AppTypography.black141428TextStyle
import com.sw.inbound.ui.theme.AppTypography.gray96a0aaTextStyle
import com.sw.inbound.ui.theme.Black_141428
import com.sw.inbound.ui.theme.Red_FF3232
import com.sw.inbound.ui.weight.BottomActionBar
import com.sw.inbound.ui.weight.CustomDropdownTextField
import com.sw.inbound.ui.weight.CustomSpinner
@@ -129,23 +135,26 @@ fun ReceiptProductScreen(
}
if (showDialog) {
ReceiptTipDialog(isWarn = viewModel.hasWrongCount(), onCancelClick = {
Timber.d("返回")
viewModel.updateReceiptDialog(false)
}, onConfirmClick = { isFull ->
Timber.d(if (isFull) "确认收货" else "部分收货")
viewModel.updateReceiptDialog(false)
val uploadInfo = UploadInfo(id = id)
if (isFull) {
uploadInfo.receiveGoodsInfos = orders
viewModel.confirmReceipt(uploadInfo)
} else {
uploadInfo.receiveGoodsInfoList = orders
uploadInfo.supplierId = supplierId
viewModel.partialReceipt(uploadInfo)
}
})
ReceiptTipDialog(
isWarn = viewModel.hasWrongCount(),
goodsList = orders.filter { it.receivedNum != it.receiveCount },
onCancelClick = {
Timber.d("返回")
viewModel.updateReceiptDialog(false)
},
onConfirmClick = { isFull ->
Timber.d(if (isFull) "确认收货" else "部分收货")
viewModel.updateReceiptDialog(false)
val uploadInfo = UploadInfo(id = id)
if (isFull) {
uploadInfo.receiveGoodsInfos = orders
viewModel.confirmReceipt(uploadInfo)
} else {
uploadInfo.receiveGoodsInfoList = orders
uploadInfo.supplierId = supplierId
viewModel.partialReceipt(uploadInfo)
}
})
}
}
@@ -284,7 +293,7 @@ fun UnadjustedView(purchaseOrderList: List<GoodsInfo>, viewModel: ReceiptViewMod
modifier = Modifier.padding(horizontal = 30.dp),
productList = purchaseOrderList,
checkedItem = checkedItem,
onItemCheckedClick = {
onItemCheckedClick = { index, it ->
viewModel.updateSelectedItemWithSwitch(it)
})
}
@@ -294,11 +303,14 @@ fun AdjustedView(viewModel: ReceiptViewModel) {
// 已调整view
val purchaseAdjustList by viewModel.adjustedOrders.collectAsState()
LazyColumn(
verticalArrangement = Arrangement.spacedBy(0.dp)
) {
items(items = purchaseAdjustList, key = { it.goodId!! }) {
// ReceiptItem(it)
itemsIndexed(
items = purchaseAdjustList,
key = { index, it -> it.goodId!! + index }) { index, it ->
AdjustedViewItem(it, viewModel)
}
}
@@ -306,9 +318,19 @@ fun AdjustedView(viewModel: ReceiptViewModel) {
@Composable
private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewModel) {
val warehouseTypeList = GlobalData.warehouseTypeList // viewModel.getStoreList()
val warehouseTypeList = GlobalData.warehouseTypeList
val isWarnItem = purchaseOrder.receivedNum != purchaseOrder.receiveCount
var modifier: Modifier // = Modifier.padding(horizontal = 30.dp)
if (isWarnItem) {
modifier = Modifier
.padding(horizontal = 30.dp)
.background(Color(0xffFAF1F9))
.border(width = 1.dp, color = Color.Red)
} else {
modifier = Modifier.padding(horizontal = 30.dp)
}
Column(modifier = Modifier.padding(horizontal = 30.dp)) {
Column(modifier = modifier) {
Spacer(modifier = Modifier.height(30.dp))
Row(
modifier = Modifier
@@ -316,7 +338,10 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
.padding(horizontal = 30.dp),
horizontalArrangement = Arrangement.SpaceBetween
) {
Text(purchaseOrder.goodNameStr, style = AppTypography.blackTextStyle)
Text(
purchaseOrder.goodNameStr,
style = if (isWarnItem) AppTypography.blackTextStyle.withColor(Color.Red) else AppTypography.blackTextStyle
)
Row {
Text("采购量:", style = gray96a0aaTextStyle)
Text(
@@ -348,7 +373,8 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
Text(text = "x", style = AppTypography.black141428TextStyle.bold())
Spacer(modifier = Modifier.width(50.dp))
AdjustedRowInputLayout(
label = "实收", value = purchaseOrder.receivedNumTemp,
label = "实收",
value = purchaseOrder.receivedNumTemp,
onValueChange = {
viewModel.updatePurchaseItem(
purchaseOrder = purchaseOrder.copy(
@@ -356,7 +382,9 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
receivedNum = it.toSafeFloat()
)
)
}, inputType = InputType.Decimal
},
inputType = InputType.Decimal,
inputTextColor = if (isWarnItem) Red_FF3232 else Black_141428
)
Spacer(modifier = Modifier.width(12.dp))
Text(text = purchaseOrder.unitNameStr, style = AppTypography.gray96a0aaTextStyle)
@@ -407,7 +435,8 @@ private fun AdjustedRowInputLayout(
textAlign: TextAlign = TextAlign.Center,
spinnerTextAlign: TextAlign = TextAlign.Start,
trailingLabel: String? = null,
inputType: InputType = InputType.Text
inputType: InputType = InputType.Text,
inputTextColor: Color = Black_141428
) {
Row(
modifier = Modifier
@@ -426,7 +455,13 @@ private fun AdjustedRowInputLayout(
value = value,
onValueChange = onValueChange,
textAlign = textAlign,
trailingLabel = trailingLabel, inputType = inputType
trailingLabel = trailingLabel, inputType = inputType,
textStyle = LocalTextStyle.current.copy(
color = inputTextColor,
fontSize = 24.sp,
fontWeight = FontWeight.Bold,
textAlign = textAlign
)
)
} else {
CustomDropdownTextField(
@@ -434,7 +469,7 @@ private fun AdjustedRowInputLayout(
value = value,
dropdownItems = dropdownItems,
onValueChange = onValueChange,
textAlign = spinnerTextAlign
textAlign = spinnerTextAlign,
)
}
}
@@ -696,7 +696,7 @@ private fun SelfProductEditView(
)
}
},
trailingLabel = selectedItem!!.unitName,
trailingLabel = selectedItem!!.unitName ?: "-",
)
RowInputLayout(
@@ -16,6 +16,13 @@ object AppTypography {
color = Color(0xFF96A0AA)
)
val gray999999TextStyle: TextStyle
@Composable get() = TextStyle(
fontSize = 24.sp,
fontWeight = FontWeight.Medium,
color = Color(0xFF999999)
)
val black141428TextStyle: TextStyle
@Composable get() = TextStyle(
fontSize = 24.sp,
@@ -38,6 +45,14 @@ object AppTypography {
fontWeight = FontWeight.Bold
)
val blackMediumTextStyle: TextStyle
@Composable
get() = TextStyle(
color = colorResource(R.color.black),
fontSize = 24.sp,
fontWeight = FontWeight.Medium
)
val BlueTextStyle: TextStyle
@Composable
get() = TextStyle(
@@ -18,4 +18,5 @@ val GrayDivider = Color(0XFFDCDCF0)
val Green_009632 = Color(0xFF009632)
val Blue_0032C8 = Color(0xFF0032C8)
val Red_FF3232 = Color(0xFFFF3232)
@@ -12,9 +12,13 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.HorizontalDivider
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
@@ -36,10 +40,12 @@ fun ReceiptUnadjustedListView(
modifier: Modifier = Modifier,
productList: List<GoodsInfo>,
checkedItem: GoodsInfo? = null,
onItemCheckedClick: (GoodsInfo) -> Unit = {},
onItemCheckedClick: (Int, GoodsInfo) -> Unit = { _, _ -> },
showClose: Boolean = false,
onCloseClick: (GoodsInfo) -> Unit = {},
) {
var selectIndex by remember { mutableIntStateOf(-1) }
Column(
modifier = modifier
// .padding(horizontal = 30.dp)
@@ -85,17 +91,20 @@ fun ReceiptUnadjustedListView(
// Spacer(modifier = Modifier.height(31.dp))
// 左侧列表
LazyColumn() {
items(items = productList, key = { it.goodId!! }) { it ->
itemsIndexed(
items = productList,
key = { index, it -> it.goodId!! + index }) { index, it ->
val checkedBg =
if (it.goodId == checkedItem?.goodId) Gray_DCDCF0 else Color.Transparent
if (selectIndex == index) Gray_DCDCF0 else Color.Transparent
Row(
modifier = Modifier
.background(color = checkedBg)
.height(80.dp)
.padding(horizontal = 60.dp)
.clickable {
onItemCheckedClick(it)
selectIndex = index
onItemCheckedClick(index, it)
}, verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
@@ -1,6 +1,7 @@
package com.sw.inbound.ui.weight.dialog
import androidx.compose.foundation.Image
import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
@@ -11,6 +12,8 @@ import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Surface
@@ -21,6 +24,7 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog
@@ -29,9 +33,12 @@ import com.sw.inbound.R
import com.sw.inbound.ext.bold
import com.sw.inbound.ext.withColor
import com.sw.inbound.ext.withSize
import com.sw.inbound.model.response.GoodsInfo
import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.GrayDivider
import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.ui.weight.CustomOutlinedButton
import com.sw.inbound.ui.weight.CustomSingleRightText
/**
* 收货确认弹窗
@@ -40,6 +47,7 @@ import com.sw.inbound.ui.weight.CustomOutlinedButton
fun ReceiptTipDialog(
modifier: Modifier = Modifier,
isWarn: Boolean = false,
goodsList: List<GoodsInfo>,
onCancelClick: () -> Unit,
onConfirmClick: (Boolean) -> Unit,
onDismiss: () -> Unit = {},
@@ -79,10 +87,83 @@ fun ReceiptTipDialog(
)
Spacer(modifier = Modifier.height(60.dp))
Text(
text = if (isWarn) "收货数量与采购量不一致" else "核对无误,确认收货",
text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货",
style = AppTypography.black141428TextStyle.bold().withSize(48.sp)
)
if (isWarn) {
Spacer(modifier = Modifier.height(60.dp))
Column(
modifier = Modifier
.height(257.dp)
.width(810.dp)
.border(width = 1.dp, color = GrayDivider)
) {
Row(
modifier = Modifier
.padding(start = 80.dp, top = 20.dp, end = 80.dp)
.height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "名称",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "采购量",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "实收",
style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center
)
}
LazyColumn {
itemsIndexed(items = goodsList) { index, goods ->
Row(
modifier = Modifier
.padding(horizontal = 80.dp)
.height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically
) {
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = goods.goodNameStr,
style = AppTypography.blackMediumTextStyle,
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receivedNumListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
color = Color(0xFF0032C8)
),
textAlign = TextAlign.Center
)
Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText(
modifier = Modifier.weight(1f),
text = "${goods.receiveCountListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor(
Color.Red
),
textAlign = TextAlign.Center
)
}
}
}
}
Spacer(modifier = Modifier.height(29.dp))
Text(
text = "请确认实际收货数量,或选择部分收货处理",