From 41d48a23af6bcfba007a8a58afecd18adcd54f01 Mon Sep 17 00:00:00 2001 From: mazengfei <331023091@qq.com> Date: Mon, 19 Jan 2026 16:59:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=94=B6=E8=B4=A7=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sw/inbound/ui/page/PurchaseOrderScreen.kt | 115 ++++++++---------- 1 file changed, 51 insertions(+), 64 deletions(-) diff --git a/app/src/main/java/com/sw/inbound/ui/page/PurchaseOrderScreen.kt b/app/src/main/java/com/sw/inbound/ui/page/PurchaseOrderScreen.kt index 0de57ee..dfee844 100644 --- a/app/src/main/java/com/sw/inbound/ui/page/PurchaseOrderScreen.kt +++ b/app/src/main/java/com/sw/inbound/ui/page/PurchaseOrderScreen.kt @@ -68,9 +68,7 @@ import kotlinx.coroutines.flow.map import timber.log.Timber @Preview( - widthDp = 1920, - heightDp = 1080, - showBackground = true + widthDp = 1920, heightDp = 1080, showBackground = true ) /** * 采购订单-供应商列表 @@ -103,13 +101,10 @@ fun PurchaseOrderScreen( // 检测是否滚动到底部 LaunchedEffect(lazyListState) { - snapshotFlow { lazyListState.layoutInfo } - .map { layoutInfo -> + snapshotFlow { lazyListState.layoutInfo }.map { layoutInfo -> val lastVisibleItem = layoutInfo.visibleItemsInfo.lastOrNull() lastVisibleItem?.index == layoutInfo.totalItemsCount - 1 - } - .distinctUntilChanged() - .collect { reachedEnd -> + }.distinctUntilChanged().collect { reachedEnd -> Timber.d("加载更多 reachedEnd = $reachedEnd, isMoreLoading = $isMoreLoading, canLoadMore = $canLoadMore") if (reachedEnd && !isMoreLoading && canLoadMore) { pageNum++ @@ -128,30 +123,25 @@ fun PurchaseOrderScreen( Image( painter = painterResource(id = R.mipmap.bg_listview), contentDescription = "背景", - modifier = Modifier - .fillMaxSize(), + modifier = Modifier.fillMaxSize(), contentScale = ContentScale.FillBounds ) Box( modifier = Modifier.padding( - start = 30.dp, - end = 30.dp, - top = 30.dp, - bottom = 90.dp + start = 30.dp, end = 30.dp, top = 30.dp, bottom = 90.dp ) ) { if (products.isEmpty()) { PurchaseEmptyItem() } else { LazyRow( - modifier = modifier - .padding(10.dp), + modifier = modifier.padding(10.dp), state = lazyListState, contentPadding = PaddingValues(16.dp), horizontalArrangement = Arrangement.spacedBy(30.dp) ) { - items(items = products, key = { it!!.id?:"" }) { product -> + items(items = products, key = { it!!.id ?: "" }) { product -> PurchaseOrderItem(product!!) { // navController.navigate( // Screen.ReceiptProduct.createRoute( @@ -160,10 +150,10 @@ fun PurchaseOrderScreen( // ) // ) navController.context.startActivity { - putExtra(GoodsListActivity.ID,product!!.id) - putExtra(GoodsListActivity.SUPPLIER_ID,product.supplierId) - putExtra(GoodsListActivity.IS_RECEIPT_PAGE,true) - putExtra(GoodsListActivity.IS_NEW_RECEIPT,false) + putExtra(GoodsListActivity.ID, product!!.id) + putExtra(GoodsListActivity.SUPPLIER_ID, product.supplierId) + putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true) + putExtra(GoodsListActivity.IS_NEW_RECEIPT, false) } } } @@ -185,20 +175,20 @@ fun PurchaseOrderScreen( } } - BottomActionBar( - modifier = Modifier, onLeftButtonClick = { - navController.popBackStack() - }, onRight2ButtonClick = { - //navController.navigate(Screen.SelfProcurement.route) - navController.context.startActivity { - putExtra(GoodsListActivity.IS_RECEIPT_PAGE, false)} - //navController.context.startActivity { - // //xtra(GoodsListActivity.ID,it!!.id) - // //xtra(GoodsListActivity.SUPPLIER_ID,it.supplierId) - // putExtra(GoodsListActivity.IS_RECEIPT_PAGE,true) - // putExtra(GoodsListActivity.IS_NEW_RECEIPT,true) - //} - }) + BottomActionBar(modifier = Modifier, onLeftButtonClick = { + navController.popBackStack() + }, onRight2ButtonClick = { + //navController.navigate(Screen.SelfProcurement.route) + navController.context.startActivity { + putExtra(GoodsListActivity.IS_RECEIPT_PAGE, false) + } + //navController.context.startActivity { + // //xtra(GoodsListActivity.ID,it!!.id) + // //xtra(GoodsListActivity.SUPPLIER_ID,it.supplierId) + // putExtra(GoodsListActivity.IS_RECEIPT_PAGE,true) + // putExtra(GoodsListActivity.IS_NEW_RECEIPT,true) + //} + }) } } @@ -216,9 +206,7 @@ fun PurchaseEmptyItem() { Spacer(modifier = Modifier.height(30.dp)) Text( text = "暂无数据", style = TextStyle( - fontSize = 30.sp, - fontWeight = FontWeight.Bold, - color = colorResource(R.color.title) + fontSize = 30.sp, fontWeight = FontWeight.Bold, color = colorResource(R.color.title) ) ) } @@ -231,30 +219,36 @@ fun PurchaseEmptyItem() { fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit) { val (receiptStatusStyle, statusLabel) = when (product.receiveStatus) { - 1 -> blackTextStyle to "已关闭" - 2 -> blackTextStyle to "已完成" - 3 -> blackTextStyle.copy( +// 1 -> blackTextStyle to "已关闭" +// 2 -> blackTextStyle to "已完成" +// 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) - ) to "未收货" + ) to "待收货" - 4 -> blackTextStyle.copy( + 2 -> blackTextStyle.copy( color = colorResource(R.color.origin) - ) to "部分收货" + ) to "已收货" - else -> blackTextStyle to "已关闭" + 3 -> blackTextStyle to "已关闭" + else -> blackTextStyle to "未知状态" } val itemSpace = 29.dp Box( modifier = Modifier .background( - color = Color.White.copy(alpha = 0.37f), - shape = RoundedCornerShape(10.dp) // 圆角背景 + color = Color.White.copy(alpha = 0.37f), shape = RoundedCornerShape(10.dp) // 圆角背景 ) .clickable { onItemClick(product) - } - ) { + }) { Column( modifier = Modifier .width(580.dp) @@ -275,24 +269,19 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit ) Spacer(modifier = Modifier.height(itemSpace)) Text( - text = "单号 ${product.purCode ?: "-"}", - maxLines = 1, - style = grayTextStyle + text = "单号 ${product.purCode ?: "-"}", maxLines = 1, style = grayTextStyle ) Spacer(modifier = Modifier.height(itemSpace)) HorizontalDivider( - thickness = 1.dp, - color = colorResource(R.color.divider) + thickness = 1.dp, color = colorResource(R.color.divider) ) Spacer(modifier = Modifier.height(40.dp)) Text( - text = "物品(项)", - style = grayTextStyle + text = "物品(项)", style = grayTextStyle ) Spacer(modifier = Modifier.height(22.dp)) Text( - text = product.goodCount.toFormattedString(), - style = TextStyle( + text = product.goodCount.toFormattedString(), style = TextStyle( color = colorResource(R.color.black), fontSize = 90.sp, fontWeight = FontWeight.Bold @@ -303,9 +292,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit modifier = Modifier .fillMaxWidth() .dashedBorder( - strokeWidth = 2.dp, - color = Color(0xFFBDC5CE), - cornerRadiusDp = 10.dp + strokeWidth = 2.dp, color = Color(0xFFBDC5CE), cornerRadiusDp = 10.dp ) .padding(horizontal = 72.dp, vertical = 27.dp), horizontalArrangement = Arrangement.SpaceBetween @@ -323,8 +310,7 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit } Spacer(modifier = Modifier.height(28.dp)) Row( - modifier = Modifier.fillMaxWidth(), - horizontalArrangement = Arrangement.SpaceBetween + modifier = Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween ) { Row { Text("收货状态:", style = grayTextStyle) @@ -348,7 +334,8 @@ fun PurchaseOrderItem(product: SupplierInfo, onItemClick: (SupplierInfo) -> Unit colors = ButtonDefaults.buttonColors( containerColor = Color(0xFF009632).copy(alpha = 1f), contentColor = colorResource(R.color.white) - ), onClick = { + ), + onClick = { onItemClick(product) }) { Text(