From 5874e4ed9a42aa3dcd9e8263a084d2f4ced5efc6 Mon Sep 17 00:00:00 2001 From: zxj <275873859@qq.com> Date: Tue, 15 Jul 2025 17:27:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E9=87=87=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=88=A0=E9=99=A4=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/sw/inbound/MainActivity.kt | 5 +++++ .../inbound/ui/page/ReceiptProductScreen.kt | 2 +- .../inbound/ui/page/SelfProcurementScreen.kt | 5 +++-- .../ui/weight/SelfProcurementListItem.kt | 19 ++++++++++--------- .../viewmodel/SelfProcurementViewModel.kt | 15 +++++++++++++-- 5 files changed, 32 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/sw/inbound/MainActivity.kt b/app/src/main/java/com/sw/inbound/MainActivity.kt index 817ae31..e23c952 100644 --- a/app/src/main/java/com/sw/inbound/MainActivity.kt +++ b/app/src/main/java/com/sw/inbound/MainActivity.kt @@ -1,6 +1,7 @@ package com.sw.inbound import android.os.Bundle +import android.view.WindowManager import androidx.activity.ComponentActivity import androidx.activity.compose.setContent import androidx.activity.enableEdgeToEdge @@ -14,6 +15,10 @@ class MainActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) enableEdgeToEdge() + window.setFlags( + WindowManager.LayoutParams.FLAG_FULLSCREEN, + WindowManager.LayoutParams.FLAG_FULLSCREEN + ) setContent { AppScreen(onBackRequest = { finish() diff --git a/app/src/main/java/com/sw/inbound/ui/page/ReceiptProductScreen.kt b/app/src/main/java/com/sw/inbound/ui/page/ReceiptProductScreen.kt index 8e60957..c0a5bf6 100644 --- a/app/src/main/java/com/sw/inbound/ui/page/ReceiptProductScreen.kt +++ b/app/src/main/java/com/sw/inbound/ui/page/ReceiptProductScreen.kt @@ -320,7 +320,7 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod Row { Text("采购量:", style = gray96a0aaTextStyle) Text( - "${purchaseOrder.receiveCountStr}${purchaseOrder.unitNameStr}", + "${purchaseOrder.receiveCountListStr}${purchaseOrder.unitNameStr}", style = black141428TextStyle ) } diff --git a/app/src/main/java/com/sw/inbound/ui/page/SelfProcurementScreen.kt b/app/src/main/java/com/sw/inbound/ui/page/SelfProcurementScreen.kt index 8212242..a404ac4 100644 --- a/app/src/main/java/com/sw/inbound/ui/page/SelfProcurementScreen.kt +++ b/app/src/main/java/com/sw/inbound/ui/page/SelfProcurementScreen.kt @@ -203,8 +203,9 @@ private fun ContentLeftView( .background( color = Color.White.copy(alpha = 0.37f), shape = RoundedCornerShape(10.dp) // 圆角背景 - ), productList = productList, showClose = true, onCloseClick = { - viewModel.removePurchaseOrder(it.goodsId) + ), productList = productList, showClose = true, onCloseClick = { index, it -> + + viewModel.removePurchaseOrderByIndex(index) }) } } diff --git a/app/src/main/java/com/sw/inbound/ui/weight/SelfProcurementListItem.kt b/app/src/main/java/com/sw/inbound/ui/weight/SelfProcurementListItem.kt index 1df65eb..19d9f5d 100644 --- a/app/src/main/java/com/sw/inbound/ui/weight/SelfProcurementListItem.kt +++ b/app/src/main/java/com/sw/inbound/ui/weight/SelfProcurementListItem.kt @@ -11,7 +11,7 @@ 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.ui.Alignment @@ -37,7 +37,7 @@ fun SelfProcurementListItem( checkedItem: PurchaseWarehouseParam? = null, onItemCheckedClick: (PurchaseWarehouseParam) -> Unit = {}, showClose: Boolean = false, - onCloseClick: (PurchaseWarehouseParam) -> Unit = {}, + onCloseClick: (Int, PurchaseWarehouseParam) -> Unit, ) { Column( modifier = modifier @@ -82,12 +82,13 @@ fun SelfProcurementListItem( // Spacer(modifier = Modifier.height(31.dp)) // 左侧列表 LazyColumn() { - items( - items = productList, - // 取消key,列表中可以插入同一物品 -// key = { it.goodsId } - ) { it -> - + itemsIndexed(items = productList) +// items( +// items = productList, +// // 取消key,列表中可以插入同一物品 +//// key = { it.goodsId } +// ) + { index, it -> val checkedBg = if (it.goodsId == checkedItem?.goodsId) Gray_DCDCF0 else Color.Transparent Row( @@ -127,7 +128,7 @@ fun SelfProcurementListItem( modifier = Modifier .size(48.dp) .clickable { - onCloseClick(it) + onCloseClick(index, it) }, painter = painterResource(R.mipmap.ic_delete), contentDescription = "删除" diff --git a/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt b/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt index 351dd13..6378fd4 100644 --- a/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt +++ b/app/src/main/java/com/sw/inbound/viewmodel/SelfProcurementViewModel.kt @@ -230,8 +230,19 @@ class SelfProcurementViewModel @Inject constructor( // 删除订单 fun removePurchaseOrder(orderId: Int) { - _purchaseList.update { current -> - current.filterNot { it.goodsId == orderId } + _purchaseList.update { currentList -> + currentList.filterNot { it.goodsId == orderId } + } + } + + /** + * 根据位置删除物品 + */ + fun removePurchaseOrderByIndex(index: Int) { + _purchaseList.update { currentList -> + currentList.toMutableList().apply { + removeAt(index) + } } }