优化收货状态

This commit is contained in:
mazengfei
2026-01-19 16:59:59 +08:00
parent cc22921e3e
commit 41d48a23af
@@ -68,9 +68,7 @@ import kotlinx.coroutines.flow.map
import timber.log.Timber import timber.log.Timber
@Preview( @Preview(
widthDp = 1920, widthDp = 1920, heightDp = 1080, showBackground = true
heightDp = 1080,
showBackground = true
) )
/** /**
* 采购订单-供应商列表 * 采购订单-供应商列表
@@ -103,13 +101,10 @@ fun PurchaseOrderScreen(
// 检测是否滚动到底部 // 检测是否滚动到底部
LaunchedEffect(lazyListState) { LaunchedEffect(lazyListState) {
snapshotFlow { lazyListState.layoutInfo } snapshotFlow { lazyListState.layoutInfo }.map { layoutInfo ->
.map { layoutInfo ->
val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull() val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull()
lastVisibleItem?.index == layoutInfo.totalItemsCount - 1 lastVisibleItem?.index == layoutInfo.totalItemsCount - 1
} }.distinctUntilChanged().collect { reachedEnd ->
.distinctUntilChanged()
.collect { reachedEnd ->
Timber.d("加载更多 reachedEnd = $reachedEnd, isMoreLoading = $isMoreLoading, canLoadMore = $canLoadMore") Timber.d("加载更多 reachedEnd = $reachedEnd, isMoreLoading = $isMoreLoading, canLoadMore = $canLoadMore")
if (reachedEnd && !isMoreLoading && canLoadMore) { if (reachedEnd && !isMoreLoading && canLoadMore) {
pageNum++ pageNum++
@@ -128,25 +123,20 @@ fun PurchaseOrderScreen(
Image( Image(
painter = painterResource(id = R.mipmap.bg_listview), painter = painterResource(id = R.mipmap.bg_listview),
contentDescription = "背景", contentDescription = "背景",
modifier = Modifier modifier = Modifier.fillMaxSize(),
.fillMaxSize(),
contentScale = ContentScale.FillBounds contentScale = ContentScale.FillBounds
) )
Box( Box(
modifier = Modifier.padding( modifier = Modifier.padding(
start = 30.dp, start = 30.dp, end = 30.dp, top = 30.dp, bottom = 90.dp
end = 30.dp,
top = 30.dp,
bottom = 90.dp
) )
) { ) {
if (products.isEmpty()) { if (products.isEmpty()) {
PurchaseEmptyItem() PurchaseEmptyItem()
} else { } else {
LazyRow( LazyRow(
modifier = modifier modifier = modifier.padding(10.dp),
.padding(10.dp),
state = lazyListState, state = lazyListState,
contentPadding = PaddingValues(16.dp), contentPadding = PaddingValues(16.dp),
horizontalArrangement = Arrangement.spacedBy(30.dp) horizontalArrangement = Arrangement.spacedBy(30.dp)
@@ -185,13 +175,13 @@ fun PurchaseOrderScreen(
} }
} }
BottomActionBar( BottomActionBar(modifier = Modifier, onLeftButtonClick = {
modifier = Modifier, onLeftButtonClick = {
navController.popBackStack() navController.popBackStack()
}, onRight2ButtonClick = { }, onRight2ButtonClick = {
//navController.navigate(Screen.SelfProcurement.route) //navController.navigate(Screen.SelfProcurement.route)
navController.context.startActivity<SelfProcurementActivity> { navController.context.startActivity<SelfProcurementActivity> {
putExtra(GoodsListActivity.IS_RECEIPT_PAGE, false)} putExtra(GoodsListActivity.IS_RECEIPT_PAGE, false)
}
//navController.context.startActivity<ReceiptActivity> { //navController.context.startActivity<ReceiptActivity> {
// //xtra(GoodsListActivity.ID,it!!.id) // //xtra(GoodsListActivity.ID,it!!.id)
// //xtra(GoodsListActivity.SUPPLIER_ID,it.supplierId) // //xtra(GoodsListActivity.SUPPLIER_ID,it.supplierId)
@@ -216,9 +206,7 @@ fun PurchaseEmptyItem() {
Spacer(modifier = Modifier.height(30.dp)) Spacer(modifier = Modifier.height(30.dp))
Text( Text(
text = "暂无数据", style = TextStyle( text = "暂无数据", style = TextStyle(
fontSize = 30.sp, fontSize = 30.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.title)
fontWeight = FontWeight.Bold,
color = colorResource(R.color.title)
) )
) )
} }
@@ -231,30 +219,36 @@ fun PurchaseEmptyItem() {
fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit) { fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit) {
val (receiptStatusStyle, statusLabel) = when (product.receiveStatus) { val (receiptStatusStyle, statusLabel) = when (product.receiveStatus) {
1 -> blackTextStyle to "已关闭" // 1 -> blackTextStyle to "已关闭"
2 -> blackTextStyle to "已完成" // 2 -> blackTextStyle to "已完成"
3 -> blackTextStyle.copy( // 3 -> blackTextStyle.copy(
// color = colorResource(R.color.red)
// ) to "未收货"
//
// 4 -> blackTextStyle.copy(
// color = colorResource(R.color.origin)
// ) to "部分收货"
1 -> blackTextStyle.copy(
color = colorResource(R.color.red) color = colorResource(R.color.red)
) to "收货" ) to "收货"
4 -> blackTextStyle.copy( 2 -> blackTextStyle.copy(
color = colorResource(R.color.origin) color = colorResource(R.color.origin)
) to "部分收货" ) to "收货"
else -> blackTextStyle to "已关闭" 3 -> blackTextStyle to "已关闭"
else -> blackTextStyle to "未知状态"
} }
val itemSpace = 29.dp val itemSpace = 29.dp
Box( Box(
modifier = Modifier modifier = Modifier
.background( .background(
color = Color.White.copy(alpha = 0.37f), color = Color.White.copy(alpha = 0.37f), shape = RoundedCornerShape(10.dp) // 圆角背景
shape = RoundedCornerShape(10.dp) // 圆角背景
) )
.clickable { .clickable {
onItemClick(product) onItemClick(product)
} }) {
) {
Column( Column(
modifier = Modifier modifier = Modifier
.width(580.dp) .width(580.dp)
@@ -275,24 +269,19 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
) )
Spacer(modifier = Modifier.height(itemSpace)) Spacer(modifier = Modifier.height(itemSpace))
Text( Text(
text = "单号 ${product.purCode ?: "-"}", text = "单号 ${product.purCode ?: "-"}", maxLines = 1, style = grayTextStyle
maxLines = 1,
style = grayTextStyle
) )
Spacer(modifier = Modifier.height(itemSpace)) Spacer(modifier = Modifier.height(itemSpace))
HorizontalDivider( HorizontalDivider(
thickness = 1.dp, thickness = 1.dp, color = colorResource(R.color.divider)
color = colorResource(R.color.divider)
) )
Spacer(modifier = Modifier.height(40.dp)) Spacer(modifier = Modifier.height(40.dp))
Text( Text(
text = "物品(项)", text = "物品(项)", style = grayTextStyle
style = grayTextStyle
) )
Spacer(modifier = Modifier.height(22.dp)) Spacer(modifier = Modifier.height(22.dp))
Text( Text(
text = product.goodCount.toFormattedString(), text = product.goodCount.toFormattedString(), style = TextStyle(
style = TextStyle(
color = colorResource(R.color.black), color = colorResource(R.color.black),
fontSize = 90.sp, fontSize = 90.sp,
fontWeight = FontWeight.Bold fontWeight = FontWeight.Bold
@@ -303,9 +292,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
modifier = Modifier modifier = Modifier
.fillMaxWidth() .fillMaxWidth()
.dashedBorder( .dashedBorder(
strokeWidth = 2.dp, strokeWidth = 2.dp, color = Color(0xFFBDC5CE), cornerRadiusDp = 10.dp
color = Color(0xFFBDC5CE),
cornerRadiusDp = 10.dp
) )
.padding(horizontal = 72.dp, vertical = 27.dp), .padding(horizontal = 72.dp, vertical = 27.dp),
horizontalArrangement = Arrangement.SpaceBetween horizontalArrangement = Arrangement.SpaceBetween
@@ -323,8 +310,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
} }
Spacer(modifier = Modifier.height(28.dp)) Spacer(modifier = Modifier.height(28.dp))
Row( Row(
modifier = Modifier.fillMaxWidth(), modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween
horizontalArrangement = Arrangement.SpaceBetween
) { ) {
Row { Row {
Text("收货状态:", style = grayTextStyle) Text("收货状态:", style = grayTextStyle)
@@ -348,7 +334,8 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit
colors = ButtonDefaults.buttonColors( colors = ButtonDefaults.buttonColors(
containerColor = Color(0xFF009632).copy(alpha = 1f), containerColor = Color(0xFF009632).copy(alpha = 1f),
contentColor = colorResource(R.color.white) contentColor = colorResource(R.color.white)
), onClick = { ),
onClick = {
onItemClick(product) onItemClick(product)
}) { }) {
Text( Text(