优化
This commit is contained in:
@@ -2,16 +2,23 @@ package com.sw.inbound.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.adapter.ReceiptGoodsAdapter
|
||||
import com.sw.inbound.model.response.DictType
|
||||
import com.sw.inbound.utils.ext.gone
|
||||
import com.sw.inbound.utils.ext.clickWithDebounce
|
||||
import com.sw.inbound.utils.ext.toJsonString
|
||||
import com.sw.inbound.utils.ext.toast
|
||||
import com.sw.inbound.utils.ext.visible
|
||||
|
||||
/**
|
||||
* 采购单入库
|
||||
*/
|
||||
class ReceiptActivity : GoodsListActivity() {
|
||||
|
||||
private val adapter by lazy {
|
||||
ReceiptGoodsAdapter(goodsList)
|
||||
ReceiptGoodsAdapter(this, goodsList).apply {
|
||||
//addOnItemChildClickListener(R.id.ivClear) { adapter, view, position -> }
|
||||
}
|
||||
}
|
||||
|
||||
override fun initRecyclerView() {
|
||||
@@ -24,41 +31,31 @@ class ReceiptActivity : GoodsListActivity() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun initView() {
|
||||
//initRvTestData()
|
||||
binding.tvConfirmNum.run {
|
||||
if (isNewReceipt) gone() else visible()
|
||||
binding.tvConfirmNum.visible()
|
||||
binding.tvNotConfirmNum.visible()
|
||||
binding.btnConfirmReceipt.clickWithDebounce {
|
||||
receiptSubmit()
|
||||
}
|
||||
binding.tvNotConfirmNum.run {
|
||||
if (isNewReceipt) gone() else visible()
|
||||
}
|
||||
binding.btnConfirmReceipt.setOnClickListener {
|
||||
if (isNewReceipt) {
|
||||
selfProcurementSubmit()
|
||||
//if (isReceiptPage.not()) {
|
||||
// getNetOrder()
|
||||
//} else {
|
||||
// binding.tvPurchaseNo.text = "新增收货"
|
||||
//}
|
||||
|
||||
val localGodsList = userViewModel.getGoodsList(localGoodsKey)
|
||||
if (localGodsList.isNullOrEmpty().not()) {
|
||||
val count = localGodsList.count { it.isLocalGoods }
|
||||
|
||||
if (count > 0) {
|
||||
//存在修改后的本地数据
|
||||
goodsList.clear()
|
||||
goodsList.addAll(localGodsList)
|
||||
adapter.notifyDataSetChanged()
|
||||
} else {
|
||||
receiptSubmit()
|
||||
}
|
||||
}
|
||||
if (isNewReceipt.not()) {
|
||||
receiptViewModel.getReceiveDetail(id) { detail ->
|
||||
runOnUiThread {
|
||||
if (detail == null) {
|
||||
toast("未查询到数据")
|
||||
return@runOnUiThread
|
||||
}
|
||||
binding.tvPurchaseNo.text = "采购单号:${detail.purCode}"
|
||||
val list = detail.receiveGoodsInfoList
|
||||
list.forEach { goodsInfo ->
|
||||
goodsInfo.recUnitPriceTaxInBak = goodsInfo.recUnitPriceTaxIn
|
||||
goodsInfo.recUnitPriceTaxIn = 0.0
|
||||
goodsInfo.unitNameBak = goodsInfo.unitName
|
||||
goodsInfo.receivedNumBak = goodsInfo.receivedNum
|
||||
}
|
||||
goodsList.addAll(list)
|
||||
adapter.notifyDataSetChanged()
|
||||
setConfirmNum()
|
||||
}
|
||||
getNetOrder()
|
||||
}
|
||||
} else {
|
||||
binding.tvPurchaseNo.text = "新增收货"
|
||||
getNetOrder()
|
||||
}
|
||||
|
||||
// lifecycleScope.launch {
|
||||
@@ -75,6 +72,29 @@ class ReceiptActivity : GoodsListActivity() {
|
||||
// }
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun getNetOrder() {
|
||||
receiptViewModel.getReceiveDetail(id) { detail ->
|
||||
runOnUiThread {
|
||||
if (detail == null) {
|
||||
toast("未查询到数据")
|
||||
return@runOnUiThread
|
||||
}
|
||||
binding.tvPurchaseNo.text = "采购单号:${detail.purCode}"
|
||||
val list = detail.receiveGoodsInfoList
|
||||
list.forEach { goodsInfo ->
|
||||
goodsInfo.recUnitPriceTaxInBak = goodsInfo.recUnitPriceTaxIn
|
||||
goodsInfo.recUnitPriceTaxIn = 0.0
|
||||
goodsInfo.unitNameBak = goodsInfo.unitName
|
||||
goodsInfo.receivedNumBak = goodsInfo.receivedNum
|
||||
}
|
||||
goodsList.addAll(list)
|
||||
adapter.notifyDataSetChanged()
|
||||
setConfirmNum()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getWarehouseList(): List<DictType> {
|
||||
return goodsList.filter {
|
||||
it.warehouseId.isNullOrBlank().not() && it.warehouseName.isNullOrBlank().not()
|
||||
|
||||
Reference in New Issue
Block a user