优化
This commit is contained in:
@@ -61,6 +61,9 @@ import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* 采集菜品
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@AndroidEntryPoint
|
||||
class FoodCollectionActivity : ComponentActivity() {
|
||||
|
||||
@@ -41,6 +41,7 @@ import com.sw.inbound.objbox.FoodModule
|
||||
import com.sw.inbound.sdk.SensorScaleUtils
|
||||
import com.sw.inbound.utils.BitmapCropper
|
||||
import com.sw.inbound.utils.CameraUtils
|
||||
import com.sw.inbound.utils.DateTimeUtils
|
||||
import com.sw.inbound.utils.ImageUtil
|
||||
import com.sw.inbound.utils.PreciseDelayHandler
|
||||
import com.sw.inbound.utils.ext.dp
|
||||
@@ -58,6 +59,7 @@ import okhttp3.RequestBody
|
||||
import okhttp3.RequestBody.Companion.toRequestBody
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.min
|
||||
|
||||
@@ -72,14 +74,15 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
public const val SUPPLIER_ID = "supplierId"
|
||||
|
||||
public const val IS_RECEIPT_PAGE = "isReceiptPage"
|
||||
public const val IS_NEW_RECEIPT = "isNewReceipt"
|
||||
// public const val IS_NEW_RECEIPT = "isNewReceipt"
|
||||
|
||||
const val PAGE_SIZE = 10
|
||||
private const val DELAY_TIME: Long = 3 * 1000
|
||||
}
|
||||
|
||||
var isReceiptPage: Boolean = false
|
||||
var isNewReceipt: Boolean = false
|
||||
|
||||
// var isNewReceipt: Boolean = false
|
||||
var id: String = ""
|
||||
var supplierId: String = ""
|
||||
lateinit var binding: ActivityGoodsListBinding
|
||||
@@ -103,7 +106,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
setContentView(binding.root)
|
||||
initBackDispatcher()
|
||||
isReceiptPage = intent.getBooleanExtra(IS_RECEIPT_PAGE, true)
|
||||
isNewReceipt = intent.getBooleanExtra(IS_NEW_RECEIPT, false)
|
||||
//isNewReceipt = intent.getBooleanExtra(IS_NEW_RECEIPT, false)
|
||||
id = intent.getStringExtra(ID) ?: ""
|
||||
supplierId = intent.getStringExtra(SUPPLIER_ID) ?: ""
|
||||
cameraUtils.initCamera()
|
||||
@@ -406,7 +409,8 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
|
||||
private fun replaceIncludeContent() {
|
||||
binding.flContainer.removeAllViews()
|
||||
if (isReceiptPage) {
|
||||
//isReceiptPage
|
||||
if (this is ReceiptActivity) {
|
||||
val tempBinding =
|
||||
ListItemReceiptGoodsBinding.inflate(layoutInflater, binding.flContainer, false)
|
||||
binding.flContainer.addView(tempBinding.root)
|
||||
@@ -445,10 +449,20 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
return (this ?: 0.0) + (value ?: 0.0)
|
||||
}
|
||||
|
||||
val todayKey by lazy {
|
||||
DateTimeUtils.formatDateTime(date = Date(), pattern = DateTimeUtils.YYYY_MM_DD)
|
||||
}
|
||||
|
||||
val localGoodsKey by lazy {
|
||||
"${todayKey}_${if (isReceiptPage) id else "SelfProcurement"}_${todayKey}"
|
||||
}
|
||||
|
||||
fun addGoods(goods: GoodsInfo) {
|
||||
if (!isReceiptPage) {
|
||||
//!isReceiptPage
|
||||
if (this is SelfProcurementActivity) {
|
||||
goods.isSelected = true
|
||||
goodsList.add(goods)
|
||||
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
|
||||
binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1)
|
||||
return
|
||||
}
|
||||
@@ -457,7 +471,11 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
//不存在物品或者物品单位不同
|
||||
goods.isSelected = true
|
||||
goodsList.add(goods)
|
||||
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
|
||||
binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1)
|
||||
if (this is ReceiptActivity) {
|
||||
this.setConfirmNum()
|
||||
}
|
||||
return
|
||||
}
|
||||
item.isSelected = true
|
||||
@@ -472,6 +490,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
recPriceInItem = finalAmount.roundedDecimalPlace(2)
|
||||
goodsWeight = finalWeight.toBigDecimal()
|
||||
}
|
||||
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
|
||||
binding.rvGoodsList.adapter?.notifyItemChanged(goodsList.indexOf(item))
|
||||
if (this is ReceiptActivity) {
|
||||
this.setConfirmNum()
|
||||
@@ -540,6 +559,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
content = "存在未收货的物品,请确认是否放弃收货,若放弃则数据不会保存?"
|
||||
) {
|
||||
//onBackPressedDispatcher.onBackPressed()
|
||||
userViewModel.deleteKey(localGoodsKey)
|
||||
finish()
|
||||
}.show()
|
||||
} else {
|
||||
@@ -575,6 +595,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
receiptViewModel.confirmReceipt(uploadInfo) { success ->
|
||||
hideWaitingDialog()
|
||||
if (success) {
|
||||
userViewModel.deleteKey(localGoodsKey)
|
||||
toast("确认收货成功")
|
||||
binding.root.postDelayed({
|
||||
finish()
|
||||
@@ -616,6 +637,7 @@ abstract class GoodsListActivity : ComponentActivity() {
|
||||
if (success) {
|
||||
toast("提交入库成功")
|
||||
binding.root.postDelayed({
|
||||
userViewModel.deleteKey(localGoodsKey)
|
||||
finish()
|
||||
}, 200)
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.sw.inbound.activity
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
/**
|
||||
* 采购单列表
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class PurchaseOrderActivity : ComponentActivity(){
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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()
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.sw.inbound.activity
|
||||
|
||||
import android.util.Log
|
||||
import android.annotation.SuppressLint
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.adapter.SelfProcurementAdapter
|
||||
import com.sw.inbound.dialog.WarnDialog
|
||||
import com.sw.inbound.model.request.PurchaseWarehouseParam
|
||||
import com.sw.inbound.model.response.DictType
|
||||
import com.sw.inbound.utils.ext.toJsonString
|
||||
import com.sw.inbound.utils.ext.toast
|
||||
import timber.log.Timber
|
||||
import kotlin.getValue
|
||||
|
||||
/**
|
||||
* 自采入库
|
||||
*/
|
||||
class SelfProcurementActivity : GoodsListActivity() {
|
||||
|
||||
private val adapter by lazy {
|
||||
@@ -26,12 +25,13 @@ class SelfProcurementActivity : GoodsListActivity() {
|
||||
///删除行数据弹窗
|
||||
showWarnDialog(content = "请确认是否删除该条入库数据,删除后将无法恢复?") {
|
||||
removeAt(position)
|
||||
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun showWarnDialog(content:String, callback:()-> Unit) {
|
||||
private fun showWarnDialog(content: String, callback: () -> Unit) {
|
||||
WarnDialog(context = this, content = content, confirmBlock = callback).show()
|
||||
}
|
||||
|
||||
@@ -42,11 +42,19 @@ class SelfProcurementActivity : GoodsListActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun initView() {
|
||||
binding.tvPurchaseNo.text = "自采入库"
|
||||
binding.btnConfirmReceipt.setOnClickListener {
|
||||
selfProcurementSubmit()
|
||||
}
|
||||
|
||||
val localGodsList = userViewModel.getGoodsList(localGoodsKey)
|
||||
if (localGodsList.isNullOrEmpty().not()) {
|
||||
//本地数据为空则加载本地数据
|
||||
goodsList.addAll(localGodsList)
|
||||
adapter.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getWarehouseList(): List<DictType> {
|
||||
|
||||
Reference in New Issue
Block a user