采购单入库商品默认显示采购单信息;采集数据显示优化
This commit is contained in:
@@ -79,6 +79,7 @@ class CollectSearchDialog(
|
||||
it.setEnableLoadMore(false)
|
||||
it.setOnRefreshListener {
|
||||
pageNo = 1
|
||||
this@CollectSearchDialog.clickIndex = -1
|
||||
val searchName = binding.etInputGoods.text.toString().trim()
|
||||
getCollectGoods(searchName)
|
||||
}
|
||||
@@ -121,17 +122,13 @@ class CollectSearchDialog(
|
||||
private val searchAdapter by lazy {
|
||||
CollectSearchAdapter(list).apply {
|
||||
isStateViewEnable = true
|
||||
//setOnItemClickListener { _, _, position ->
|
||||
// this@CollectSearchDialog.clickIndex = position
|
||||
// if (list[position].isSelected) {
|
||||
// return@setOnItemClickListener
|
||||
// }
|
||||
// list.forEach { item ->
|
||||
// item.isSelected = false
|
||||
// }
|
||||
// list[position].isSelected = true
|
||||
// notifyDataSetChanged()
|
||||
//}
|
||||
setOnItemClickListener { _, _, position ->
|
||||
activity?.lifecycleScope?.launch {
|
||||
val goodsName = list[position].goodsName?:""
|
||||
val count = ObjectBox.count(goodsName)
|
||||
activity?.toast("已采集数据${count}条")
|
||||
}
|
||||
}
|
||||
addOnItemChildClickListener(R.id.ivDelete) { _, _, position ->
|
||||
this@CollectSearchDialog.clickIndex = position
|
||||
list.forEach { item ->
|
||||
@@ -139,7 +136,9 @@ class CollectSearchDialog(
|
||||
}
|
||||
list[position].isSelected = true
|
||||
notifyDataSetChanged()
|
||||
showDeleteDialog(position)
|
||||
showDeleteDialog(position) {
|
||||
this@CollectSearchDialog.clickIndex = -1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,7 +146,12 @@ class CollectSearchDialog(
|
||||
private fun showDeleteDialog(position: Int, deleteAction: () -> Unit = {}) {
|
||||
WarnDialog(
|
||||
context = context,
|
||||
content = "请确认是否删除物品:${list[position].goodsName}?",
|
||||
content = "请确认是否删除物品:${list[position].goodsName?.split("WP")?.get(0)}?",
|
||||
cancelBlock = {
|
||||
this@CollectSearchDialog.clickIndex = -1
|
||||
list[position].isSelected = false
|
||||
searchAdapter.notifyItemChanged(position)
|
||||
},
|
||||
confirmBlock = {
|
||||
// Thread {
|
||||
// }.start()
|
||||
|
||||
@@ -8,11 +8,9 @@ import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.sw.inbound.activity.GoodsListActivity
|
||||
import com.sw.inbound.adapter.RecognizeAdapter
|
||||
import com.sw.inbound.databinding.DialogGoodsRecognizeBinding
|
||||
import com.sw.inbound.databinding.LayoutEmptyRecognizeBinding
|
||||
import com.sw.inbound.model.response.SearchGoodsInfo
|
||||
import com.sw.inbound.utils.ext.clickWithDebounce
|
||||
import com.sw.inbound.utils.ext.gone
|
||||
import com.sw.inbound.utils.ext.toast
|
||||
import com.sw.inbound.utils.ext.visible
|
||||
import java.io.File
|
||||
|
||||
|
||||
@@ -114,28 +114,7 @@ class GoodsStoreDialog(
|
||||
) { dictType ->
|
||||
try {
|
||||
v.hideKeyboard()
|
||||
binding.tvProcurementUnit.run {
|
||||
text = dictType.value
|
||||
tag = dictType.id
|
||||
}
|
||||
val unit = dictType.value
|
||||
binding.tvCountUnit.text = unit
|
||||
binding.etProcurementCount.let {
|
||||
//it.isEnabled = true
|
||||
it.inputType = if (unit == "千克" || unit == "公斤" || unit == "斤") {
|
||||
InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL
|
||||
} else {
|
||||
InputType.TYPE_CLASS_NUMBER
|
||||
}
|
||||
}
|
||||
val first = goods.unitVoList!!.first { it.businessUnitId == dictType.id }
|
||||
val stringBuilder =
|
||||
StringBuilder().append("1").append(dictType.value).append("=")
|
||||
.append(first.purchaseValue!!.toInt().toString())
|
||||
.append(goods.kcUnitName).append(",").append("1")
|
||||
.append(goods.kcUnitName).append("=").append(first.consumeValue)
|
||||
.append("克")
|
||||
binding.tvUnitCalculate.text = stringBuilder.toString()
|
||||
loadDropdownMenu(dictType)
|
||||
//val count = getUnitCount(dictType.id!!)
|
||||
//if (count.isBlank() || "0" == count) {
|
||||
// //context.toast("入库数量不能为0")
|
||||
@@ -206,9 +185,60 @@ class GoodsStoreDialog(
|
||||
if (it.isNullOrBlank()) invisible() else visible()
|
||||
}
|
||||
}
|
||||
setPurchaseOrderInfo()
|
||||
addWeightListener()
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载下拉菜单
|
||||
*/
|
||||
private fun loadDropdownMenu(dictType: DictType) {
|
||||
binding.tvProcurementUnit.run {
|
||||
text = dictType.value
|
||||
tag = dictType.id
|
||||
}
|
||||
val unit = dictType.value
|
||||
binding.tvCountUnit.text = unit
|
||||
binding.etProcurementCount.let {
|
||||
//it.isEnabled = true
|
||||
it.inputType = if (unit == "千克" || unit == "公斤" || unit == "斤") {
|
||||
InputType.TYPE_CLASS_NUMBER or InputType.TYPE_NUMBER_FLAG_DECIMAL
|
||||
} else {
|
||||
InputType.TYPE_CLASS_NUMBER
|
||||
}
|
||||
}
|
||||
val first = goods.unitVoList!!.first { it.businessUnitId == dictType.id }
|
||||
val stringBuilder =
|
||||
StringBuilder().append("1").append(dictType.value).append("=")
|
||||
.append(first.purchaseValue!!.toInt().toString())
|
||||
.append(goods.kcUnitName).append(",").append("1")
|
||||
.append(goods.kcUnitName).append("=").append(first.consumeValue)
|
||||
.append("克")
|
||||
binding.tvUnitCalculate.text = stringBuilder.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置采购单信息
|
||||
*/
|
||||
private fun setPurchaseOrderInfo() {
|
||||
isLoadPurchaseOrderInfo = false
|
||||
val item = activity?.goodsList?.firstOrNull { it.goodId == goods.id }
|
||||
if (item == null || dropdownList.isEmpty()) return
|
||||
val unit = item.unitNameBak
|
||||
val price = item.recPriceExItemBak
|
||||
val amount = item.recUnitPriceTaxInBak
|
||||
val count = item.receiveCountBak
|
||||
|
||||
val dictType = dropdownList.firstOrNull { it.value == unit }
|
||||
if (dictType == null) return
|
||||
loadDropdownMenu(dictType)
|
||||
|
||||
count?.let { binding.etProcurementCount.setText("$count") }
|
||||
price?.let { binding.tvProcurementPrice.text = "$price" }
|
||||
amount?.let { binding.etProcurementAmount.setText("$amount") }
|
||||
isLoadPurchaseOrderInfo = true
|
||||
}
|
||||
private var isLoadPurchaseOrderInfo = true
|
||||
private fun addWeightListener() {
|
||||
activity?.readWeightInfo { weight ->
|
||||
if (abs(this.realWeight - weight) < 10 && binding.etProcurementCount.text.isNotBlank()) {
|
||||
@@ -217,7 +247,7 @@ class GoodsStoreDialog(
|
||||
}
|
||||
this.realWeight = weight
|
||||
binding.tvTotalWeight.text = getSpannable(weight)
|
||||
if (binding.etProcurementCount.isFocused) {
|
||||
if (isLoadPurchaseOrderInfo || binding.etProcurementCount.isFocused) {
|
||||
return@readWeightInfo
|
||||
}
|
||||
val unitTag = binding.tvProcurementUnit.tag
|
||||
@@ -334,10 +364,10 @@ class GoodsStoreDialog(
|
||||
collectGoodsVector(uri) {
|
||||
activity?.uploadImage(goods.id!!, goods.goodsName!!, imageFile)
|
||||
}
|
||||
binding.root.postDelayed({
|
||||
Loading.dismiss()
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}, 500)
|
||||
binding.root.postDelayed({
|
||||
Loading.dismiss()
|
||||
confirm(unitName, count, price, totalPrice)
|
||||
}, 500)
|
||||
}
|
||||
cameraUtils.addFailCallback {
|
||||
binding.root.postDelayed({
|
||||
@@ -350,7 +380,7 @@ class GoodsStoreDialog(
|
||||
}
|
||||
}
|
||||
|
||||
private fun confirm(unitName:String, count:Double, price:Double, totalPrice:Double?) {
|
||||
private fun confirm(unitName: String, count: Double, price: Double, totalPrice: Double?) {
|
||||
val id = binding.tvProcurementUnit.tag.toString()
|
||||
val unitVo = goods.unitVoList!!.first { it.businessUnitId == id }
|
||||
confirmBlock(
|
||||
@@ -464,7 +494,7 @@ class GoodsStoreDialog(
|
||||
private var imageFile: File? = null
|
||||
|
||||
// private var box: Box<Food>? = null
|
||||
private fun collectGoodsVector(imageUri:Uri, block: ()-> Unit = {}) {
|
||||
private fun collectGoodsVector(imageUri: Uri, block: () -> Unit = {}) {
|
||||
try {
|
||||
ImageUtil.uriToBitmap(context, imageUri)?.let { bitmap ->
|
||||
val cropBitmap = BitmapCropper.cropCenter(
|
||||
|
||||
Reference in New Issue
Block a user