This commit is contained in:
2026-02-10 09:36:18 +08:00
parent 038a325b3d
commit 3d29e17225
18 changed files with 977 additions and 493 deletions
@@ -61,6 +61,9 @@ import okhttp3.RequestBody.Companion.toRequestBody
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
/**
* 采集菜品
*/
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
@AndroidEntryPoint @AndroidEntryPoint
class FoodCollectionActivity : ComponentActivity() { class FoodCollectionActivity : ComponentActivity() {
@@ -41,6 +41,7 @@ import com.sw.inbound.objbox.FoodModule
import com.sw.inbound.sdk.SensorScaleUtils import com.sw.inbound.sdk.SensorScaleUtils
import com.sw.inbound.utils.BitmapCropper import com.sw.inbound.utils.BitmapCropper
import com.sw.inbound.utils.CameraUtils import com.sw.inbound.utils.CameraUtils
import com.sw.inbound.utils.DateTimeUtils
import com.sw.inbound.utils.ImageUtil import com.sw.inbound.utils.ImageUtil
import com.sw.inbound.utils.PreciseDelayHandler import com.sw.inbound.utils.PreciseDelayHandler
import com.sw.inbound.utils.ext.dp import com.sw.inbound.utils.ext.dp
@@ -58,6 +59,7 @@ import okhttp3.RequestBody
import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.RequestBody.Companion.toRequestBody
import timber.log.Timber import timber.log.Timber
import java.io.File import java.io.File
import java.util.Date
import kotlin.math.abs import kotlin.math.abs
import kotlin.math.min import kotlin.math.min
@@ -72,14 +74,15 @@ abstract class GoodsListActivity : ComponentActivity() {
public const val SUPPLIER_ID = "supplierId" public const val SUPPLIER_ID = "supplierId"
public const val IS_RECEIPT_PAGE = "isReceiptPage" 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 const val PAGE_SIZE = 10
private const val DELAY_TIME: Long = 3 * 1000 private const val DELAY_TIME: Long = 3 * 1000
} }
var isReceiptPage: Boolean = false var isReceiptPage: Boolean = false
var isNewReceipt: Boolean = false
// var isNewReceipt: Boolean = false
var id: String = "" var id: String = ""
var supplierId: String = "" var supplierId: String = ""
lateinit var binding: ActivityGoodsListBinding lateinit var binding: ActivityGoodsListBinding
@@ -103,7 +106,7 @@ abstract class GoodsListActivity : ComponentActivity() {
setContentView(binding.root) setContentView(binding.root)
initBackDispatcher() initBackDispatcher()
isReceiptPage = intent.getBooleanExtra(IS_RECEIPT_PAGE, true) 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) ?: "" id = intent.getStringExtra(ID) ?: ""
supplierId = intent.getStringExtra(SUPPLIER_ID) ?: "" supplierId = intent.getStringExtra(SUPPLIER_ID) ?: ""
cameraUtils.initCamera() cameraUtils.initCamera()
@@ -406,7 +409,8 @@ abstract class GoodsListActivity : ComponentActivity() {
private fun replaceIncludeContent() { private fun replaceIncludeContent() {
binding.flContainer.removeAllViews() binding.flContainer.removeAllViews()
if (isReceiptPage) { //isReceiptPage
if (this is ReceiptActivity) {
val tempBinding = val tempBinding =
ListItemReceiptGoodsBinding.inflate(layoutInflater, binding.flContainer, false) ListItemReceiptGoodsBinding.inflate(layoutInflater, binding.flContainer, false)
binding.flContainer.addView(tempBinding.root) binding.flContainer.addView(tempBinding.root)
@@ -445,10 +449,20 @@ abstract class GoodsListActivity : ComponentActivity() {
return (this ?: 0.0) + (value ?: 0.0) 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) { fun addGoods(goods: GoodsInfo) {
if (!isReceiptPage) { //!isReceiptPage
if (this is SelfProcurementActivity) {
goods.isSelected = true goods.isSelected = true
goodsList.add(goods) goodsList.add(goods)
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1) binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1)
return return
} }
@@ -457,7 +471,11 @@ abstract class GoodsListActivity : ComponentActivity() {
//不存在物品或者物品单位不同 //不存在物品或者物品单位不同
goods.isSelected = true goods.isSelected = true
goodsList.add(goods) goodsList.add(goods)
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1) binding.rvGoodsList.adapter?.notifyItemInserted(goodsList.size - 1)
if (this is ReceiptActivity) {
this.setConfirmNum()
}
return return
} }
item.isSelected = true item.isSelected = true
@@ -472,6 +490,7 @@ abstract class GoodsListActivity : ComponentActivity() {
recPriceInItem = finalAmount.roundedDecimalPlace(2) recPriceInItem = finalAmount.roundedDecimalPlace(2)
goodsWeight = finalWeight.toBigDecimal() goodsWeight = finalWeight.toBigDecimal()
} }
userViewModel.putGoodsData(localGoodsKey, goodsList.toJsonString())
binding.rvGoodsList.adapter?.notifyItemChanged(goodsList.indexOf(item)) binding.rvGoodsList.adapter?.notifyItemChanged(goodsList.indexOf(item))
if (this is ReceiptActivity) { if (this is ReceiptActivity) {
this.setConfirmNum() this.setConfirmNum()
@@ -540,6 +559,7 @@ abstract class GoodsListActivity : ComponentActivity() {
content = "存在未收货的物品,请确认是否放弃收货,若放弃则数据不会保存?" content = "存在未收货的物品,请确认是否放弃收货,若放弃则数据不会保存?"
) { ) {
//onBackPressedDispatcher.onBackPressed() //onBackPressedDispatcher.onBackPressed()
userViewModel.deleteKey(localGoodsKey)
finish() finish()
}.show() }.show()
} else { } else {
@@ -575,6 +595,7 @@ abstract class GoodsListActivity : ComponentActivity() {
receiptViewModel.confirmReceipt(uploadInfo) { success -> receiptViewModel.confirmReceipt(uploadInfo) { success ->
hideWaitingDialog() hideWaitingDialog()
if (success) { if (success) {
userViewModel.deleteKey(localGoodsKey)
toast("确认收货成功") toast("确认收货成功")
binding.root.postDelayed({ binding.root.postDelayed({
finish() finish()
@@ -616,6 +637,7 @@ abstract class GoodsListActivity : ComponentActivity() {
if (success) { if (success) {
toast("提交入库成功") toast("提交入库成功")
binding.root.postDelayed({ binding.root.postDelayed({
userViewModel.deleteKey(localGoodsKey)
finish() finish()
}, 200) }, 200)
} else { } 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 android.annotation.SuppressLint
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.sw.inbound.R
import com.sw.inbound.adapter.ReceiptGoodsAdapter import com.sw.inbound.adapter.ReceiptGoodsAdapter
import com.sw.inbound.model.response.DictType 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.toast
import com.sw.inbound.utils.ext.visible import com.sw.inbound.utils.ext.visible
/**
* 采购单入库
*/
class ReceiptActivity : GoodsListActivity() { class ReceiptActivity : GoodsListActivity() {
private val adapter by lazy { private val adapter by lazy {
ReceiptGoodsAdapter(goodsList) ReceiptGoodsAdapter(this, goodsList).apply {
//addOnItemChildClickListener(R.id.ivClear) { adapter, view, position -> }
}
} }
override fun initRecyclerView() { override fun initRecyclerView() {
@@ -24,41 +31,31 @@ class ReceiptActivity : GoodsListActivity() {
@SuppressLint("NotifyDataSetChanged") @SuppressLint("NotifyDataSetChanged")
override fun initView() { override fun initView() {
//initRvTestData() //initRvTestData()
binding.tvConfirmNum.run { binding.tvConfirmNum.visible()
if (isNewReceipt) gone() else visible() binding.tvNotConfirmNum.visible()
binding.btnConfirmReceipt.clickWithDebounce {
receiptSubmit()
} }
binding.tvNotConfirmNum.run { //if (isReceiptPage.not()) {
if (isNewReceipt) gone() else visible() // getNetOrder()
} //} else {
binding.btnConfirmReceipt.setOnClickListener { // binding.tvPurchaseNo.text = "新增收货"
if (isNewReceipt) { //}
selfProcurementSubmit()
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 { } else {
receiptSubmit() getNetOrder()
}
}
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()
}
} }
} else { } else {
binding.tvPurchaseNo.text = "新增收货" getNetOrder()
} }
// lifecycleScope.launch { // 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> { override fun getWarehouseList(): List<DictType> {
return goodsList.filter { return goodsList.filter {
it.warehouseId.isNullOrBlank().not() && it.warehouseName.isNullOrBlank().not() it.warehouseId.isNullOrBlank().not() && it.warehouseName.isNullOrBlank().not()
@@ -1,17 +1,16 @@
package com.sw.inbound.activity package com.sw.inbound.activity
import android.util.Log import android.annotation.SuppressLint
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.sw.inbound.R import com.sw.inbound.R
import com.sw.inbound.adapter.SelfProcurementAdapter import com.sw.inbound.adapter.SelfProcurementAdapter
import com.sw.inbound.dialog.WarnDialog import com.sw.inbound.dialog.WarnDialog
import com.sw.inbound.model.request.PurchaseWarehouseParam
import com.sw.inbound.model.response.DictType import com.sw.inbound.model.response.DictType
import com.sw.inbound.utils.ext.toJsonString import com.sw.inbound.utils.ext.toJsonString
import com.sw.inbound.utils.ext.toast
import timber.log.Timber
import kotlin.getValue
/**
* 自采入库
*/
class SelfProcurementActivity : GoodsListActivity() { class SelfProcurementActivity : GoodsListActivity() {
private val adapter by lazy { private val adapter by lazy {
@@ -26,12 +25,13 @@ class SelfProcurementActivity : GoodsListActivity() {
///删除行数据弹窗 ///删除行数据弹窗
showWarnDialog(content = "请确认是否删除该条入库数据,删除后将无法恢复?") { showWarnDialog(content = "请确认是否删除该条入库数据,删除后将无法恢复?") {
removeAt(position) 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() WarnDialog(context = this, content = content, confirmBlock = callback).show()
} }
@@ -42,11 +42,19 @@ class SelfProcurementActivity : GoodsListActivity() {
} }
} }
@SuppressLint("NotifyDataSetChanged")
override fun initView() { override fun initView() {
binding.tvPurchaseNo.text = "自采入库" binding.tvPurchaseNo.text = "自采入库"
binding.btnConfirmReceipt.setOnClickListener { binding.btnConfirmReceipt.setOnClickListener {
selfProcurementSubmit() selfProcurementSubmit()
} }
val localGodsList = userViewModel.getGoodsList(localGoodsKey)
if (localGodsList.isNullOrEmpty().not()) {
//本地数据为空则加载本地数据
goodsList.addAll(localGodsList)
adapter.notifyDataSetChanged()
}
} }
override fun getWarehouseList(): List<DictType> { override fun getWarehouseList(): List<DictType> {
@@ -0,0 +1,29 @@
//package com.sw.inbound.adapter
//
//import android.content.Context
//import android.view.LayoutInflater
//import android.view.ViewGroup
//import com.chad.library.adapter4.BaseQuickAdapter
//import com.chad.library.adapter4.viewholder.QuickViewHolder
//import com.sw.inbound.databinding.ListItemCollectSearchBinding
//import com.sw.inbound.databinding.ListItemPurchaseOrderBinding
//import com.sw.inbound.model.response.SearchGoodsInfo
//import com.sw.inbound.model.response.SupplierInfo
//
////List<SupplierInfo?>
//class PurchaseOrderAdapter:BaseQuickAdapter<SupplierInfo, > {
//
// inner class VH(var binding: ListItemCollectSearchBinding) : QuickViewHolder(binding.root)
//
// override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): VH {
// val inflater = LayoutInflater.from(context)
// val binding = ListItemPurchaseOrderBinding.inflate(inflater, parent, false)
// return VH(binding)
// }
//
// override fun onBindViewHolder(holder: VH, position: Int, item: SupplierInfo) {
//
//
// }
//
//}
@@ -1,5 +1,6 @@
package com.sw.inbound.adapter package com.sw.inbound.adapter
import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.text.InputType import android.text.InputType
import android.view.LayoutInflater import android.view.LayoutInflater
@@ -14,23 +15,23 @@ import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter4.BaseQuickAdapter import com.chad.library.adapter4.BaseQuickAdapter
import com.chad.library.adapter4.viewholder.QuickViewHolder import com.chad.library.adapter4.viewholder.QuickViewHolder
import com.sw.inbound.R import com.sw.inbound.R
import com.sw.inbound.activity.ReceiptActivity
import com.sw.inbound.databinding.ListItemReceiptGoodsBinding import com.sw.inbound.databinding.ListItemReceiptGoodsBinding
import com.sw.inbound.dialog.WarnDialog import com.sw.inbound.dialog.WarnDialog
import com.sw.inbound.ext.toFormattedString import com.sw.inbound.ext.toFormattedString
import com.sw.inbound.ext.toSafeDouble
import com.sw.inbound.model.response.GoodsInfo import com.sw.inbound.model.response.GoodsInfo
import com.sw.inbound.utils.ext.dp import com.sw.inbound.utils.ext.dp
import com.sw.inbound.utils.ext.gone import com.sw.inbound.utils.ext.gone
import com.sw.inbound.utils.ext.hideKeyboard import com.sw.inbound.utils.ext.hideKeyboard
import com.sw.inbound.utils.ext.ifNullOrBlank import com.sw.inbound.utils.ext.ifNullOrBlank
import com.sw.inbound.utils.ext.ifNullOrZero
import com.sw.inbound.utils.ext.roundedDecimalPlace import com.sw.inbound.utils.ext.roundedDecimalPlace
import com.sw.inbound.utils.ext.setShapeDrawable import com.sw.inbound.utils.ext.setShapeDrawable
import com.sw.inbound.utils.ext.toJsonString
import com.sw.inbound.utils.ext.toast import com.sw.inbound.utils.ext.toast
import com.sw.inbound.utils.ext.visible import com.sw.inbound.utils.ext.visible
import com.sw.inbound.utils.removeTrailingZeros import com.sw.inbound.utils.removeTrailingZeros
class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) : class ReceiptGoodsAdapter(var receiptActivity: ReceiptActivity, var list: MutableList<GoodsInfo>) :
BaseQuickAdapter<GoodsInfo, ReceiptGoodsAdapter.VH>(list) { BaseQuickAdapter<GoodsInfo, ReceiptGoodsAdapter.VH>(list) {
inner class VH(var binding: ListItemReceiptGoodsBinding) : QuickViewHolder(binding.root) inner class VH(var binding: ListItemReceiptGoodsBinding) : QuickViewHolder(binding.root)
@@ -41,6 +42,7 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
return VH(binding) return VH(binding)
} }
@SuppressLint("NotifyDataSetChanged")
override fun onBindViewHolder(holder: VH, position: Int, item: GoodsInfo?) { override fun onBindViewHolder(holder: VH, position: Int, item: GoodsInfo?) {
holder.binding.run { holder.binding.run {
root.updateLayoutParams<RecyclerView.LayoutParams> { root.updateLayoutParams<RecyclerView.LayoutParams> {
@@ -63,8 +65,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
) )
tvGoodsName.text = item.goodName.ifNullOrBlank("-") tvGoodsName.text = item.goodName.ifNullOrBlank("-")
tvProcurementUnit.text = item.unitName.ifNullOrBlank("-") tvProcurementUnit.text = item.unitName.ifNullOrBlank("-")
val realCount = item.receiveCount?:0.toDouble() val realCount = item.receiveCount ?: 0.toDouble()
tvProcurementCount.text = if (realCount == 0.toDouble()) "-" else realCount.removeTrailingZeros() tvProcurementCount.text =
if (realCount == 0.toDouble()) "-" else realCount.removeTrailingZeros()
//tvProcurementPrice.text = item.recUnitPriceTaxInBak.toSafeDouble(2).ifNullOrZero("-") //tvProcurementPrice.text = item.recUnitPriceTaxInBak.toSafeDouble(2).ifNullOrZero("-")
//tvProcurementAmount.text = item.recPriceExItem.toSafeDouble(2).ifNullOrZero("-") //tvProcurementAmount.text = item.recPriceExItem.toSafeDouble(2).ifNullOrZero("-")
//tvReceiptCount.text = item.receivedNum.toSafeDouble(2).ifNullOrZero("-") //tvReceiptCount.text = item.receivedNum.toSafeDouble(2).ifNullOrZero("-")
@@ -87,7 +90,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
setImageResource( setImageResource(
if (item.isSelected.not()) R.mipmap.ic_receipt_no if (item.isSelected.not()) R.mipmap.ic_receipt_no
else if (item.isLocalGoods) R.mipmap.ic_receipt_local else if (item.isLocalGoods) R.mipmap.ic_receipt_local
else if ((item.receivedNum?:0.toDouble()) < (item.receiveCount?:0.toDouble())) R.mipmap.ic_receipt_part else if ((item.receivedNum ?: 0.toDouble()) < (item.receiveCount
?: 0.toDouble())
) R.mipmap.ic_receipt_part
else R.mipmap.ic_receipt_all else R.mipmap.ic_receipt_all
) )
} }
@@ -113,7 +118,7 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
setText("-") setText("-")
} }
} }
etReceiptAmount.run { etReceiptAmount.run {
isEnabled = item.recPriceInItem != null && item.recPriceInItem != 0.toDouble() isEnabled = item.recPriceInItem != null && item.recPriceInItem != 0.toDouble()
updateLayoutParams<LinearLayout.LayoutParams> { updateLayoutParams<LinearLayout.LayoutParams> {
topMargin = if (isEnabled) 20.dp else 0 topMargin = if (isEnabled) 20.dp else 0
@@ -159,6 +164,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
showWarnDialog(content = "请确认是否删除该条采购数据,删除后不可恢复?") { showWarnDialog(content = "请确认是否删除该条采购数据,删除后不可恢复?") {
list.removeAt(position) list.removeAt(position)
notifyDataSetChanged() notifyDataSetChanged()
receiptActivity.run {
userViewModel.putGoodsData(localGoodsKey, list.toJsonString())
}
} }
return@setOnClickListener return@setOnClickListener
} }
@@ -169,13 +177,16 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
item.recUnitPriceTaxIn = 0.0 item.recUnitPriceTaxIn = 0.0
item.unitName = item.unitNameBak item.unitName = item.unitNameBak
notifyItemChanged(position) notifyItemChanged(position)
receiptActivity.run {
userViewModel.putGoodsData(localGoodsKey, list.toJsonString())
}
} }
} }
} }
} }
} }
private fun showWarnDialog(content:String, callback:()-> Unit) { private fun showWarnDialog(content: String, callback: () -> Unit) {
WarnDialog(context = context, content = content, confirmBlock = callback).show() WarnDialog(context = context, content = content, confirmBlock = callback).show()
} }
@@ -213,8 +224,8 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
} }
} }
private fun doubleFormat(num:Double?): String{ private fun doubleFormat(num: Double?): String {
val realNum = num?:0.toDouble() val realNum = num ?: 0.toDouble()
return if (realNum == 0.toDouble()) "-" else realNum.toFormattedString(2) return if (realNum == 0.toDouble()) "-" else realNum.toFormattedString(2)
} }
@@ -16,8 +16,8 @@ import com.sw.inbound.utils.ext.hideKeyboard
abstract class BaseDialog( abstract class BaseDialog(
context: Context, context: Context,
var defWidth: Int = 1500.dp, var defWidth: Int = 1500.dp,
var defHeight: Int = 900.dp // var defHeight: Int = 900.dp
// var defHeight: Int = 750.dp var defHeight: Int = 750.dp
) : Dialog(context, R.style.DialogTheme) { ) : Dialog(context, R.style.DialogTheme) {
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
@@ -0,0 +1,10 @@
package com.sw.inbound.ext
import android.app.Activity
import android.util.DisplayMetrics
fun Activity.getScreenWidth(): Int {
val displayMetrics = DisplayMetrics()
windowManager.defaultDisplay.getMetrics(displayMetrics)
return displayMetrics.widthPixels
}
@@ -156,7 +156,7 @@ fun PurchaseOrderScreen(
putExtra(GoodsListActivity.ID, product!!.id) putExtra(GoodsListActivity.ID, product!!.id)
putExtra(GoodsListActivity.SUPPLIER_ID, product.supplierId) putExtra(GoodsListActivity.SUPPLIER_ID, product.supplierId)
putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true) putExtra(GoodsListActivity.IS_RECEIPT_PAGE, true)
putExtra(GoodsListActivity.IS_NEW_RECEIPT, false) //putExtra(GoodsListActivity.IS_NEW_RECEIPT, false)
} }
} }
} }
@@ -1,101 +1,101 @@
package com.sw.inbound.ui.weight.dialog //package com.sw.inbound.ui.weight.dialog
//
import androidx.compose.foundation.layout.Arrangement //import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box //import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column //import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row //import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer //import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize //import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth //import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height //import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding //import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width //import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize //import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape //import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface //import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable //import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment //import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier //import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color //import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource //import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp //import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp //import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog //import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties //import androidx.compose.ui.window.DialogProperties
import com.sw.inbound.R //import com.sw.inbound.R
import com.sw.inbound.ui.weight.CustomButton //import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.ui.weight.CustomOutlinedButton //import com.sw.inbound.ui.weight.CustomOutlinedButton
import com.sw.inbound.utils.ToastUtils //import com.sw.inbound.utils.ToastUtils
//
/** ///**
* 添加物品弹窗 // * 添加物品弹窗
*/ // */
@Composable //@Composable
fun AddProductDialog( //fun AddProductDialog(
modifier: Modifier = Modifier, // modifier: Modifier = Modifier,
onCancelClick: () -> Unit, // onCancelClick: () -> Unit,
onConfirmClick: () -> Unit, // onConfirmClick: () -> Unit,
onDismiss: () -> Unit, // onDismiss: () -> Unit,
content: @Composable () -> Unit // content: @Composable () -> Unit
) { //) {
Dialog( // Dialog(
onDismissRequest = onDismiss, // onDismissRequest = onDismiss,
properties = DialogProperties( // properties = DialogProperties(
usePlatformDefaultWidth = false, // 不使用平台默认宽度 // usePlatformDefaultWidth = false, // 不使用平台默认宽度
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面 // decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
) // )
) { // ) {
//
Surface( // Surface(
modifier = Modifier // modifier = Modifier
.padding(start = 60.dp, end = 60.dp, bottom = 40.dp) // 设置弹窗距离边框60dp // .padding(start = 60.dp, end = 60.dp, bottom = 40.dp) // 设置弹窗距离边框60dp
.wrapContentSize(), // .wrapContentSize(),
shape = RoundedCornerShape(30.dp), // shape = RoundedCornerShape(30.dp),
color = Color.White, // color = Color.White,
shadowElevation = 0.dp // shadowElevation = 0.dp
) { // ) {
Column( // Column(
modifier = Modifier // modifier = Modifier
.fillMaxSize() // .fillMaxSize()
.padding(start = 152.dp, end = 152.dp, top = 56.dp, bottom = 30.dp), // .padding(start = 152.dp, end = 152.dp, top = 56.dp, bottom = 30.dp),
) { // ) {
// 主要内容区域 // // 主要内容区域
Box( // Box(
modifier = Modifier // modifier = Modifier
.fillMaxWidth() // .fillMaxWidth()
.weight(1f) // .weight(1f)
) { // ) {
content() // content()
} // }
Spacer(modifier = Modifier.height(30.dp)) // Spacer(modifier = Modifier.height(30.dp))
Row( // Row(
modifier = Modifier.fillMaxWidth(), // modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically, // verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End // horizontalArrangement = Arrangement.End
) { // ) {
CustomOutlinedButton( // CustomOutlinedButton(
modifier = modifier // modifier = modifier
.width(300.dp) // .width(300.dp)
.height(100.dp), // .height(100.dp),
text = "取消", // text = "取消",
fontSize = 36.sp, // fontSize = 36.sp,
onClick = onCancelClick // onClick = onCancelClick
) // )
Spacer(modifier = Modifier.width(20.dp)) // Spacer(modifier = Modifier.width(20.dp))
//
CustomButton( // CustomButton(
modifier = modifier // modifier = modifier
.width(300.dp) // .width(300.dp)
.height(100.dp), // .height(100.dp),
text = "确定", // text = "确定",
onClick = onConfirmClick, // onClick = onConfirmClick,
borderColor = colorResource(R.color.blue), // borderColor = colorResource(R.color.blue),
textColor = colorResource(R.color.white), // textColor = colorResource(R.color.white),
fontSize = 36.sp // fontSize = 36.sp
) // )
} // }
} // }
ToastUtils.ToastComposable() // ToastUtils.ToastComposable()
} // }
} // }
} //}
@@ -1,103 +1,103 @@
package com.sw.inbound.ui.weight.dialog //package com.sw.inbound.ui.weight.dialog
//
import androidx.compose.foundation.layout.Arrangement //import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box //import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column //import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row //import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer //import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize //import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth //import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height //import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding //import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width //import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize //import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.shape.RoundedCornerShape //import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.Surface //import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable //import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment //import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier //import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color //import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource //import androidx.compose.ui.res.colorResource
import androidx.compose.ui.unit.dp //import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp //import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog //import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties //import androidx.compose.ui.window.DialogProperties
import com.sw.inbound.R //import com.sw.inbound.R
import com.sw.inbound.ui.weight.CustomButton //import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.ui.weight.CustomOutlinedButton //import com.sw.inbound.ui.weight.CustomOutlinedButton
import com.sw.inbound.utils.ToastUtils //import com.sw.inbound.utils.ToastUtils
//
/** ///**
* 添加物品弹窗 // * 添加物品弹窗
*/ // */
@Composable //@Composable
fun AddPurchaseUnitDialog( //fun AddPurchaseUnitDialog(
modifier: Modifier = Modifier, // modifier: Modifier = Modifier,
onCancelClick: () -> Unit, // onCancelClick: () -> Unit,
onConfirmClick: () -> Unit, // onConfirmClick: () -> Unit,
onDismiss: () -> Unit, // onDismiss: () -> Unit,
content: @Composable () -> Unit // content: @Composable () -> Unit
) { //) {
Dialog( // Dialog(
onDismissRequest = onDismiss, // onDismissRequest = onDismiss,
properties = DialogProperties( // properties = DialogProperties(
usePlatformDefaultWidth = false, // 不使用平台默认宽度 // usePlatformDefaultWidth = false, // 不使用平台默认宽度
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面 // decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
) // )
) { // ) {
//
Surface( // Surface(
modifier = Modifier // modifier = Modifier
.width(1190.dp) // .width(1190.dp)
.height(840.dp) // .height(840.dp)
.wrapContentSize(), // .wrapContentSize(),
shape = RoundedCornerShape(30.dp), // shape = RoundedCornerShape(30.dp),
color = Color.White, // color = Color.White,
shadowElevation = 0.dp // shadowElevation = 0.dp
) { // ) {
Column( // Column(
modifier = Modifier // modifier = Modifier
.fillMaxSize() // .fillMaxSize()
.padding(30.dp), // .padding(30.dp),
) { // ) {
// 主要内容区域 // // 主要内容区域
Box( // Box(
modifier = Modifier // modifier = Modifier
.fillMaxWidth() // .fillMaxWidth()
.padding(horizontal = 164.dp) // .padding(horizontal = 164.dp)
.weight(1f) // .weight(1f)
) { // ) {
content() // content()
} // }
Spacer(modifier = Modifier.height(30.dp)) // Spacer(modifier = Modifier.height(30.dp))
Row( // Row(
modifier = Modifier.fillMaxWidth(), // modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically, // verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End // horizontalArrangement = Arrangement.End
) { // ) {
CustomOutlinedButton( // CustomOutlinedButton(
modifier = modifier // modifier = modifier
.width(300.dp) // .width(300.dp)
.height(100.dp), // .height(100.dp),
text = "取消", // text = "取消",
fontSize = 36.sp, // fontSize = 36.sp,
onClick = onCancelClick // onClick = onCancelClick
) // )
Spacer(modifier = Modifier.width(20.dp)) // Spacer(modifier = Modifier.width(20.dp))
//
CustomButton( // CustomButton(
modifier = modifier // modifier = modifier
.width(300.dp) // .width(300.dp)
.height(100.dp), // .height(100.dp),
text = "确定", // text = "确定",
onClick = onConfirmClick, // onClick = onConfirmClick,
borderColor = colorResource(R.color.blue), // borderColor = colorResource(R.color.blue),
textColor = colorResource(R.color.white), // textColor = colorResource(R.color.white),
fontSize = 36.sp // fontSize = 36.sp
) // )
} // }
} // }
ToastUtils.ToastComposable() // ToastUtils.ToastComposable()
} // }
} // }
} //}
@@ -1,228 +1,228 @@
package com.sw.inbound.ui.weight.dialog //package com.sw.inbound.ui.weight.dialog
//
import androidx.compose.foundation.Image //import androidx.compose.foundation.Image
import androidx.compose.foundation.border //import androidx.compose.foundation.border
import androidx.compose.foundation.layout.Arrangement //import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column //import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row //import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.Spacer //import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxSize //import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth //import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height //import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding //import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.width //import androidx.compose.foundation.layout.width
import androidx.compose.foundation.layout.wrapContentSize //import androidx.compose.foundation.layout.wrapContentSize
import androidx.compose.foundation.lazy.LazyColumn //import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed //import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape //import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.HorizontalDivider //import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Surface //import androidx.compose.material3.Surface
import androidx.compose.material3.Text //import androidx.compose.material3.Text
import androidx.compose.runtime.Composable //import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment //import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier //import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color //import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.colorResource //import androidx.compose.ui.res.colorResource
import androidx.compose.ui.res.painterResource //import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.style.TextAlign //import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp //import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp //import androidx.compose.ui.unit.sp
import androidx.compose.ui.window.Dialog //import androidx.compose.ui.window.Dialog
import androidx.compose.ui.window.DialogProperties //import androidx.compose.ui.window.DialogProperties
import com.sw.inbound.R //import com.sw.inbound.R
import com.sw.inbound.ext.bold //import com.sw.inbound.ext.bold
import com.sw.inbound.ext.withColor //import com.sw.inbound.ext.withColor
import com.sw.inbound.ext.withSize //import com.sw.inbound.ext.withSize
import com.sw.inbound.model.response.GoodsInfo //import com.sw.inbound.model.response.GoodsInfo
import com.sw.inbound.ui.theme.AppTypography //import com.sw.inbound.ui.theme.AppTypography
import com.sw.inbound.ui.theme.GrayDivider //import com.sw.inbound.ui.theme.GrayDivider
import com.sw.inbound.ui.weight.CustomButton //import com.sw.inbound.ui.weight.CustomButton
import com.sw.inbound.ui.weight.CustomOutlinedButton //import com.sw.inbound.ui.weight.CustomOutlinedButton
import com.sw.inbound.ui.weight.CustomSingleRightText //import com.sw.inbound.ui.weight.CustomSingleRightText
import com.sw.inbound.utils.ToastUtils //import com.sw.inbound.utils.ToastUtils
//
/** ///**
* 收货确认弹窗 // * 收货确认弹窗
*/ // */
@Composable //@Composable
fun ReceiptTipDialog( //fun ReceiptTipDialog(
modifier: Modifier = Modifier, // modifier: Modifier = Modifier,
isWarn: Boolean = false, // isWarn: Boolean = false,
goodsList: List<GoodsInfo>, // goodsList: List<GoodsInfo>,
onCancelClick: () -> Unit, // onCancelClick: () -> Unit,
onConfirmClick: (Boolean) -> Unit, // onConfirmClick: (Boolean) -> Unit,
onDismiss: () -> Unit = {}, // onDismiss: () -> Unit = {},
) { //) {
Dialog( // Dialog(
onDismissRequest = onDismiss, // onDismissRequest = onDismiss,
properties = DialogProperties( // properties = DialogProperties(
usePlatformDefaultWidth = false, // 不使用平台默认宽度 // usePlatformDefaultWidth = false, // 不使用平台默认宽度
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面 // decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
) // )
) { // ) {
Surface( // Surface(
modifier = Modifier // modifier = Modifier
.width(1190.dp) // .width(1190.dp)
.height(840.dp) // .height(840.dp)
.wrapContentSize(), // .wrapContentSize(),
shape = RoundedCornerShape(30.dp), // shape = RoundedCornerShape(30.dp),
color = Color.White, // color = Color.White,
shadowElevation = 0.dp // shadowElevation = 0.dp
) { // ) {
Column( // Column(
modifier = Modifier // modifier = Modifier
.fillMaxSize() // .fillMaxSize()
.padding(30.dp), // .padding(30.dp),
) { // ) {
Column( // Column(
modifier = Modifier // modifier = Modifier
.fillMaxWidth() // .fillMaxWidth()
.weight(1f), // .weight(1f),
horizontalAlignment = Alignment.CenterHorizontally, // horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center, // verticalArrangement = Arrangement.Center,
) { // ) {
Image( // Image(
painter = if (isWarn) painterResource(R.mipmap.ic_tip_warn) else painterResource( // painter = if (isWarn) painterResource(R.mipmap.ic_tip_warn) else painterResource(
R.mipmap.ic_tip_success // R.mipmap.ic_tip_success
), contentDescription = "提示" // ), contentDescription = "提示"
) // )
Spacer(modifier = Modifier.height(60.dp)) // Spacer(modifier = Modifier.height(60.dp))
Text( // Text(
text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货", // text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货",
style = AppTypography.black141428TextStyle.bold().withSize(48.sp) // style = AppTypography.black141428TextStyle.bold().withSize(48.sp)
) // )
if (isWarn) { // if (isWarn) {
Spacer(modifier = Modifier.height(60.dp)) // Spacer(modifier = Modifier.height(60.dp))
Column( // Column(
modifier = Modifier // modifier = Modifier
.height(257.dp) // .height(257.dp)
.width(810.dp) // .width(810.dp)
.border(width = 1.dp, color = GrayDivider) // .border(width = 1.dp, color = GrayDivider)
) { // ) {
Row( // Row(
modifier = Modifier // modifier = Modifier
.padding(start = 80.dp, top = 20.dp, end = 80.dp) // .padding(start = 80.dp, top = 20.dp, end = 80.dp)
.height(50.dp), // .height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly, // horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically // verticalAlignment = Alignment.CenterVertically
) { // ) {
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = "名称", // text = "名称",
style = AppTypography.gray999999TextStyle, // style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
Spacer(modifier = Modifier.width(10.dp)) // Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = "采购量", // text = "采购量",
style = AppTypography.gray999999TextStyle, // style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
Spacer(modifier = Modifier.width(10.dp)) // Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = "实收", // text = "实收",
style = AppTypography.gray999999TextStyle, // style = AppTypography.gray999999TextStyle,
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
} // }
LazyColumn { // LazyColumn {
itemsIndexed(items = goodsList) { index, goods -> // itemsIndexed(items = goodsList) { index, goods ->
Row( // Row(
modifier = Modifier // modifier = Modifier
.padding(horizontal = 80.dp) // .padding(horizontal = 80.dp)
.height(50.dp), // .height(50.dp),
horizontalArrangement = Arrangement.SpaceEvenly, // horizontalArrangement = Arrangement.SpaceEvenly,
verticalAlignment = Alignment.CenterVertically // verticalAlignment = Alignment.CenterVertically
) { // ) {
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = goods.goodNameStr, // text = goods.goodNameStr,
style = AppTypography.blackMediumTextStyle, // style = AppTypography.blackMediumTextStyle,
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
Spacer(modifier = Modifier.width(10.dp)) // Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = "${goods.receiveCountListStr}${goods.unitNameStr}", // text = "${goods.receiveCountListStr}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor( // style = AppTypography.blackMediumTextStyle.withColor(
color = Color(0xFF0032C8) // color = Color(0xFF0032C8)
), // ),
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
Spacer(modifier = Modifier.width(10.dp)) // Spacer(modifier = Modifier.width(10.dp))
CustomSingleRightText( // CustomSingleRightText(
modifier = Modifier.weight(1f), // modifier = Modifier.weight(1f),
text = "${goods.receivedNumCount}${goods.unitNameStr}", // text = "${goods.receivedNumCount}${goods.unitNameStr}",
style = AppTypography.blackMediumTextStyle.withColor( // style = AppTypography.blackMediumTextStyle.withColor(
Color.Red // Color.Red
), // ),
textAlign = TextAlign.Center // textAlign = TextAlign.Center
) // )
} // }
} // }
} // }
} // }
//
Spacer(modifier = Modifier.height(29.dp)) // Spacer(modifier = Modifier.height(29.dp))
Text( // Text(
text = "请确认实际收货数量,或选择部分收货处理", // text = "请确认实际收货数量,或选择部分收货处理",
style = AppTypography.black141428TextStyle.withColor( // style = AppTypography.black141428TextStyle.withColor(
color = Color(0xFF999999) // color = Color(0xFF999999)
) // )
) // )
} // }
} // }
HorizontalDivider(thickness = 1.dp, color = colorResource(R.color.divider)) // HorizontalDivider(thickness = 1.dp, color = colorResource(R.color.divider))
Spacer(modifier = Modifier.height(30.dp)) // Spacer(modifier = Modifier.height(30.dp))
Row( // Row(
modifier = Modifier.fillMaxWidth(), // modifier = Modifier.fillMaxWidth(),
verticalAlignment = Alignment.CenterVertically, // verticalAlignment = Alignment.CenterVertically,
horizontalArrangement = Arrangement.End // horizontalArrangement = Arrangement.End
) { // ) {
CustomOutlinedButton( // CustomOutlinedButton(
modifier = modifier // modifier = modifier
.width(180.dp) // .width(180.dp)
.height(90.dp), // .height(90.dp),
text = "返回", // text = "返回",
fontSize = 36.sp, // fontSize = 36.sp,
onClick = onCancelClick // onClick = onCancelClick
) // )
Spacer(modifier = Modifier.width(12.dp)) // Spacer(modifier = Modifier.width(12.dp))
//
if (isWarn) { // if (isWarn) {
CustomButton( // CustomButton(
modifier = modifier // modifier = modifier
.width(260.dp) // .width(260.dp)
.height(90.dp), // .height(90.dp),
text = "部分收货", // text = "部分收货",
onClick = { // onClick = {
onConfirmClick(false) // onConfirmClick(false)
}, // },
borderColor = colorResource(R.color.green), // borderColor = colorResource(R.color.green),
textColor = colorResource(R.color.white), // textColor = colorResource(R.color.white),
fontSize = 36.sp // fontSize = 36.sp
) // )
//
Spacer(modifier = Modifier.width(12.dp)) // Spacer(modifier = Modifier.width(12.dp))
} // }
//
CustomButton( // CustomButton(
modifier = modifier // modifier = modifier
.width(260.dp) // .width(260.dp)
.height(90.dp), // .height(90.dp),
text = "确定收货", // text = "确定收货",
onClick = { // onClick = {
onConfirmClick(true) // onConfirmClick(true)
}, // },
borderColor = colorResource(R.color.blue), // borderColor = colorResource(R.color.blue),
textColor = colorResource(R.color.white), // textColor = colorResource(R.color.white),
fontSize = 36.sp // fontSize = 36.sp
) // )
} // }
} // }
ToastUtils.ToastComposable() // ToastUtils.ToastComposable()
} // }
} // }
} //}
@@ -11,6 +11,13 @@ import java.util.Locale
*/ */
object DateTimeUtils { object DateTimeUtils {
const val YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss"
const val YYYY_MM_DD = "yyyy-MM-dd"
fun formatDateTime(date: Date, pattern: String = YYYY_MM_DD_HH_MM_SS): String {
return SimpleDateFormat(pattern, Locale.CHINA).format(date)
}
/** /**
* 获取完整中文日期格式(示例:2025年6月11日 星期三) * 获取完整中文日期格式(示例:2025年6月11日 星期三)
*/ */
@@ -3,6 +3,7 @@ package com.sw.inbound.viewmodel
import android.net.Uri import android.net.Uri
import androidx.lifecycle.ViewModel import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope import androidx.lifecycle.viewModelScope
import com.google.gson.reflect.TypeToken
import com.sw.inbound.GlobalData import com.sw.inbound.GlobalData
import com.sw.inbound.model.response.ApiResponse import com.sw.inbound.model.response.ApiResponse
import com.sw.inbound.model.response.DictType import com.sw.inbound.model.response.DictType
@@ -12,7 +13,9 @@ import com.sw.inbound.model.response.SearchGoodsInfo
import com.sw.inbound.network.LoadingState import com.sw.inbound.network.LoadingState
import com.sw.inbound.objbox.FoodModule import com.sw.inbound.objbox.FoodModule
import com.sw.inbound.repository.RemoteRepository import com.sw.inbound.repository.RemoteRepository
import com.sw.inbound.utils.SPUtil
import com.sw.inbound.utils.ToastUtils import com.sw.inbound.utils.ToastUtils
import com.sw.inbound.utils.ext.toType
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow import kotlinx.coroutines.flow.StateFlow
@@ -201,19 +204,19 @@ abstract class BaseViewModel(
} }
fun recognizeGoodsList( fun recognizeGoodsList(
nameList: List<String>?=null, nameList: List<String>? = null,
scoreList: List<FoodModule.IdNameScore>?=null, scoreList: List<FoodModule.IdNameScore>? = null,
callback: (List<SearchGoodsInfo.Record>) -> Unit callback: (List<SearchGoodsInfo.Record>) -> Unit
) { ) {
launch { launch {
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
val response = repository.recognizeGoodsList(paramList) val response = repository.recognizeGoodsList(paramList)
val list = if (parseResponse(response)) response.data?:listOf() else listOf() val list = if (parseResponse(response)) response.data ?: listOf() else listOf()
if (scoreList.isNullOrEmpty().not()) { if (scoreList.isNullOrEmpty().not()) {
list.forEach { record -> list.forEach { record ->
val item = scoreList.firstOrNull { it.name == record.goodsName } val item = scoreList.firstOrNull { it.name == record.goodsName }
record.score = ((1 - (item?.score?:0.0)) * 10000).roundToInt() record.score = ((1 - (item?.score ?: 0.0)) * 10000).roundToInt()
} }
} }
callback(list) callback(list)
@@ -333,4 +336,42 @@ abstract class BaseViewModel(
// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!! // GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
GlobalData.restId = equipmentInfo.canteenId!! GlobalData.restId = equipmentInfo.canteenId!!
} }
val goodsKey = "goods"
fun putGoodsData(key: String, jsonData: String) {
try {
SPUtil.getInstance(spName = goodsKey).put(key, jsonData)
} catch (e: Exception) {
e.printStackTrace()
}
}
fun getGoodsData(key: String):String? {
try {
return SPUtil.getInstance(spName = goodsKey).get<String>(key)
} catch (e: Exception) {
e.printStackTrace()
}
return ""
}
fun getGoodsList(key:String):List<GoodsInfo>? {
try {
val jsonData = getGoodsData(key)
return jsonData?.toType(typeToken=object:TypeToken<List<GoodsInfo>?>(){})
} catch (e: Exception) {
e.printStackTrace()
}
return emptyList()
}
fun deleteKey(key:String) {
try {
SPUtil.getInstance(spName = goodsKey).remove(key)
} catch (e: Exception) {
e.printStackTrace()
}
}
} }
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp" />
<stroke
android:width="2dp"
android:color="#FFBDC5CE"
android:dashWidth="10dp"
android:dashGap="3dp" />
</shape>
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@mipmap/bg"
android:orientation="vertical"
tools:ignore="HardcodedText">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="40dp"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="出入库管理"
android:textColor="#141428"
android:textSize="36sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvUserName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:gravity="center_vertical"
android:textColor="#141428"
android:textSize="24sp"
android:textStyle="bold"
tools:text="冯厨子"
android:visibility="gone"/>
<ImageView
android:id="@+id/ivLogout"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_marginEnd="40dp"
android:paddingHorizontal="20dp"
android:src="@mipmap/ic_logout"
tools:ignore="ContentDescription"
android:visibility="gone"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginHorizontal="20dp"
android:layout_weight="1"
android:background="@drawable/bg_white_alpha40_radius6"
android:orientation="vertical"
android:padding="0dp">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvOrderList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
android:orientation="horizontal"
android:layout_marginHorizontal="10dp"
tools:listitem="@layout/list_item_purchase_order"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:itemCount="8" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="130dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<FrameLayout
android:id="@+id/btnBack"
android:layout_width="270dp"
android:layout_height="90dp"
android:layout_marginStart="20dp"
android:background="@drawable/bg_blue_ripple">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawableStart="@mipmap/ic_back_white2"
android:drawablePadding="32dp"
android:gravity="center"
android:text="返回"
android:textColor="@color/white"
android:textSize="36sp"
android:textStyle="bold"
tools:ignore="UseCompatTextViewDrawableXml" />
</FrameLayout>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<TextView
android:id="@+id/btnAddReceipt"
android:layout_width="270dp"
android:layout_height="90dp"
android:layout_gravity="center"
android:layout_marginEnd="20dp"
android:background="@drawable/bg_blue_ripple"
android:gravity="center"
android:text="新增收货"
android:textColor="@color/white"
android:textSize="36sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxWidth="600dp"
android:maxHeight="750dp"
android:layout_marginVertical="20dp"
android:layout_marginHorizontal="10dp"
app:cardBackgroundColor="@color/white"
app:cardCornerRadius="6dp"
app:cardElevation="0dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="@+id/tvEnterPriseName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center"
android:maxLines="1"
android:layout_marginHorizontal="20dp"
android:layout_marginTop="50dp"
android:textColor="@color/black"
android:textSize="30sp"
android:textStyle="bold"
tools:text="山东蔬农农业有限公司" />
<TextView
android:id="@+id/tvOrderNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginVertical="26dp"
android:textColor="#ff78788c"
android:textSize="24sp"
android:textStyle="bold"
android:layout_marginHorizontal="20dp"
tools:text="单号 CG202505271711504865817002" />
<View
android:id="@+id/dividerLine"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="20dp"
android:background="#FFDCDCF0" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="物品(项)"
android:layout_marginTop="2dp"
android:textColor="#ff78788c"
android:textSize="24sp"
android:textStyle="bold" />
<TextView
android:id="@+id/tvGoodsNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20sp"
android:textColor="@color/black"
android:textSize="90sp"
android:textStyle="bold"
tools:text="5" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="20dp"
android:background="@drawable/shape_dash_border"
android:orientation="horizontal"
android:paddingVertical="26dp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF78788C"
android:textSize="24sp"
android:textStyle="bold"
tools:text="采购日期" />
<TextView
android:id="@+id/tvSendGoodsDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="@color/black"
android:textSize="24sp"
android:textStyle="bold"
tools:text="2025-05-29" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FF78788C"
android:textSize="24sp"
android:textStyle="bold"
tools:text="到货日期" />
<TextView
android:id="@+id/tvReceiveGoodsDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:textColor="@color/black"
android:textSize="24sp"
android:textStyle="bold"
tools:text="2025-06-11" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_marginVertical="30dp"
android:layout_marginHorizontal="20dp"
android:orientation="horizontal">
<TextView
android:id="@+id/tvReceiveState"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ff78788c"
android:textSize="24sp"
android:textStyle="bold"
tools:text="收货状态:部分收货" />
<TextView
android:id="@+id/tvPurchaseMan"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end|center_vertical"
android:textColor="#ff78788c"
android:textSize="24sp"
android:textStyle="bold"
tools:text="采购人:冯厨子" />
</LinearLayout>
<androidx.appcompat.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="80dp"
android:background="@drawable/bg_green_ripple"
android:text="收货"
android:textSize="30sp"
android:layout_marginBottom="20dp"
android:layout_marginHorizontal="20dp"
android:gravity="center"
android:textColor="@color/white"
android:textStyle="bold"/>
</LinearLayout>
</androidx.cardview.widget.CardView>