修改自采订单删除逻辑
This commit is contained in:
@@ -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()
|
||||
|
||||
@@ -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
|
||||
)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 = "删除"
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user