修改自采订单删除逻辑
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package com.sw.inbound
|
package com.sw.inbound
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
|
import android.view.WindowManager
|
||||||
import androidx.activity.ComponentActivity
|
import androidx.activity.ComponentActivity
|
||||||
import androidx.activity.compose.setContent
|
import androidx.activity.compose.setContent
|
||||||
import androidx.activity.enableEdgeToEdge
|
import androidx.activity.enableEdgeToEdge
|
||||||
@@ -14,6 +15,10 @@ class MainActivity : ComponentActivity() {
|
|||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
enableEdgeToEdge()
|
enableEdgeToEdge()
|
||||||
|
window.setFlags(
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN,
|
||||||
|
WindowManager.LayoutParams.FLAG_FULLSCREEN
|
||||||
|
)
|
||||||
setContent {
|
setContent {
|
||||||
AppScreen(onBackRequest = {
|
AppScreen(onBackRequest = {
|
||||||
finish()
|
finish()
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ private fun AdjustedViewItem(purchaseOrder: GoodsInfo, viewModel: ReceiptViewMod
|
|||||||
Row {
|
Row {
|
||||||
Text("采购量:", style = gray96a0aaTextStyle)
|
Text("采购量:", style = gray96a0aaTextStyle)
|
||||||
Text(
|
Text(
|
||||||
"${purchaseOrder.receiveCountStr}${purchaseOrder.unitNameStr}",
|
"${purchaseOrder.receiveCountListStr}${purchaseOrder.unitNameStr}",
|
||||||
style = black141428TextStyle
|
style = black141428TextStyle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -203,8 +203,9 @@ private fun ContentLeftView(
|
|||||||
.background(
|
.background(
|
||||||
color = Color.White.copy(alpha = 0.37f),
|
color = Color.White.copy(alpha = 0.37f),
|
||||||
shape = RoundedCornerShape(10.dp) // 圆角背景
|
shape = RoundedCornerShape(10.dp) // 圆角背景
|
||||||
), productList = productList, showClose = true, onCloseClick = {
|
), productList = productList, showClose = true, onCloseClick = { index, it ->
|
||||||
viewModel.removePurchaseOrder(it.goodsId)
|
|
||||||
|
viewModel.removePurchaseOrderByIndex(index)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import androidx.compose.foundation.layout.padding
|
|||||||
import androidx.compose.foundation.layout.size
|
import androidx.compose.foundation.layout.size
|
||||||
import androidx.compose.foundation.layout.width
|
import androidx.compose.foundation.layout.width
|
||||||
import androidx.compose.foundation.lazy.LazyColumn
|
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.material3.HorizontalDivider
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.ui.Alignment
|
import androidx.compose.ui.Alignment
|
||||||
@@ -37,7 +37,7 @@ fun SelfProcurementListItem(
|
|||||||
checkedItem: PurchaseWarehouseParam? = null,
|
checkedItem: PurchaseWarehouseParam? = null,
|
||||||
onItemCheckedClick: (PurchaseWarehouseParam) -> Unit = {},
|
onItemCheckedClick: (PurchaseWarehouseParam) -> Unit = {},
|
||||||
showClose: Boolean = false,
|
showClose: Boolean = false,
|
||||||
onCloseClick: (PurchaseWarehouseParam) -> Unit = {},
|
onCloseClick: (Int, PurchaseWarehouseParam) -> Unit,
|
||||||
) {
|
) {
|
||||||
Column(
|
Column(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
@@ -82,12 +82,13 @@ fun SelfProcurementListItem(
|
|||||||
// Spacer(modifier = Modifier.height(31.dp))
|
// Spacer(modifier = Modifier.height(31.dp))
|
||||||
// 左侧列表
|
// 左侧列表
|
||||||
LazyColumn() {
|
LazyColumn() {
|
||||||
items(
|
itemsIndexed(items = productList)
|
||||||
items = productList,
|
// items(
|
||||||
// 取消key,列表中可以插入同一物品
|
// items = productList,
|
||||||
// key = { it.goodsId }
|
// // 取消key,列表中可以插入同一物品
|
||||||
) { it ->
|
//// key = { it.goodsId }
|
||||||
|
// )
|
||||||
|
{ index, it ->
|
||||||
val checkedBg =
|
val checkedBg =
|
||||||
if (it.goodsId == checkedItem?.goodsId) Gray_DCDCF0 else Color.Transparent
|
if (it.goodsId == checkedItem?.goodsId) Gray_DCDCF0 else Color.Transparent
|
||||||
Row(
|
Row(
|
||||||
@@ -127,7 +128,7 @@ fun SelfProcurementListItem(
|
|||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.size(48.dp)
|
.size(48.dp)
|
||||||
.clickable {
|
.clickable {
|
||||||
onCloseClick(it)
|
onCloseClick(index, it)
|
||||||
},
|
},
|
||||||
painter = painterResource(R.mipmap.ic_delete),
|
painter = painterResource(R.mipmap.ic_delete),
|
||||||
contentDescription = "删除"
|
contentDescription = "删除"
|
||||||
|
|||||||
@@ -230,8 +230,19 @@ class SelfProcurementViewModel @Inject constructor(
|
|||||||
|
|
||||||
// 删除订单
|
// 删除订单
|
||||||
fun removePurchaseOrder(orderId: Int) {
|
fun removePurchaseOrder(orderId: Int) {
|
||||||
_purchaseList.update { current ->
|
_purchaseList.update { currentList ->
|
||||||
current.filterNot { it.goodsId == orderId }
|
currentList.filterNot { it.goodsId == orderId }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据位置删除物品
|
||||||
|
*/
|
||||||
|
fun removePurchaseOrderByIndex(index: Int) {
|
||||||
|
_purchaseList.update { currentList ->
|
||||||
|
currentList.toMutableList().apply {
|
||||||
|
removeAt(index)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user