优化
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> {
|
||||
|
||||
@@ -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
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.text.InputType
|
||||
import android.view.LayoutInflater
|
||||
@@ -14,23 +15,23 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.activity.ReceiptActivity
|
||||
import com.sw.inbound.databinding.ListItemReceiptGoodsBinding
|
||||
import com.sw.inbound.dialog.WarnDialog
|
||||
import com.sw.inbound.ext.toFormattedString
|
||||
import com.sw.inbound.ext.toSafeDouble
|
||||
import com.sw.inbound.model.response.GoodsInfo
|
||||
import com.sw.inbound.utils.ext.dp
|
||||
import com.sw.inbound.utils.ext.gone
|
||||
import com.sw.inbound.utils.ext.hideKeyboard
|
||||
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.setShapeDrawable
|
||||
import com.sw.inbound.utils.ext.toJsonString
|
||||
import com.sw.inbound.utils.ext.toast
|
||||
import com.sw.inbound.utils.ext.visible
|
||||
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) {
|
||||
|
||||
inner class VH(var binding: ListItemReceiptGoodsBinding) : QuickViewHolder(binding.root)
|
||||
@@ -41,6 +42,7 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
return VH(binding)
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: GoodsInfo?) {
|
||||
holder.binding.run {
|
||||
root.updateLayoutParams<RecyclerView.LayoutParams> {
|
||||
@@ -63,8 +65,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
)
|
||||
tvGoodsName.text = item.goodName.ifNullOrBlank("-")
|
||||
tvProcurementUnit.text = item.unitName.ifNullOrBlank("-")
|
||||
val realCount = item.receiveCount?:0.toDouble()
|
||||
tvProcurementCount.text = if (realCount == 0.toDouble()) "-" else realCount.removeTrailingZeros()
|
||||
val realCount = item.receiveCount ?: 0.toDouble()
|
||||
tvProcurementCount.text =
|
||||
if (realCount == 0.toDouble()) "-" else realCount.removeTrailingZeros()
|
||||
//tvProcurementPrice.text = item.recUnitPriceTaxInBak.toSafeDouble(2).ifNullOrZero("-")
|
||||
//tvProcurementAmount.text = item.recPriceExItem.toSafeDouble(2).ifNullOrZero("-")
|
||||
//tvReceiptCount.text = item.receivedNum.toSafeDouble(2).ifNullOrZero("-")
|
||||
@@ -87,7 +90,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
setImageResource(
|
||||
if (item.isSelected.not()) R.mipmap.ic_receipt_no
|
||||
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
|
||||
)
|
||||
}
|
||||
@@ -113,7 +118,7 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
setText("-")
|
||||
}
|
||||
}
|
||||
etReceiptAmount.run {
|
||||
etReceiptAmount.run {
|
||||
isEnabled = item.recPriceInItem != null && item.recPriceInItem != 0.toDouble()
|
||||
updateLayoutParams<LinearLayout.LayoutParams> {
|
||||
topMargin = if (isEnabled) 20.dp else 0
|
||||
@@ -159,6 +164,9 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
showWarnDialog(content = "请确认是否删除该条采购数据,删除后不可恢复?") {
|
||||
list.removeAt(position)
|
||||
notifyDataSetChanged()
|
||||
receiptActivity.run {
|
||||
userViewModel.putGoodsData(localGoodsKey, list.toJsonString())
|
||||
}
|
||||
}
|
||||
return@setOnClickListener
|
||||
}
|
||||
@@ -169,13 +177,16 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
item.recUnitPriceTaxIn = 0.0
|
||||
item.unitName = item.unitNameBak
|
||||
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()
|
||||
}
|
||||
|
||||
@@ -213,8 +224,8 @@ class ReceiptGoodsAdapter(var list: MutableList<GoodsInfo>) :
|
||||
}
|
||||
}
|
||||
|
||||
private fun doubleFormat(num:Double?): String{
|
||||
val realNum = num?:0.toDouble()
|
||||
private fun doubleFormat(num: Double?): String {
|
||||
val realNum = num ?: 0.toDouble()
|
||||
return if (realNum == 0.toDouble()) "-" else realNum.toFormattedString(2)
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ import com.sw.inbound.utils.ext.hideKeyboard
|
||||
abstract class BaseDialog(
|
||||
context: Context,
|
||||
var defWidth: Int = 1500.dp,
|
||||
var defHeight: Int = 900.dp
|
||||
// var defHeight: Int = 750.dp
|
||||
// var defHeight: Int = 900.dp
|
||||
var defHeight: Int = 750.dp
|
||||
) : Dialog(context, R.style.DialogTheme) {
|
||||
|
||||
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.SUPPLIER_ID, product.supplierId)
|
||||
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
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.ui.weight.CustomButton
|
||||
import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
|
||||
/**
|
||||
* 添加物品弹窗
|
||||
*/
|
||||
@Composable
|
||||
fun AddProductDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
onCancelClick: () -> Unit,
|
||||
onConfirmClick: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(
|
||||
usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
)
|
||||
) {
|
||||
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.padding(start = 60.dp, end = 60.dp, bottom = 40.dp) // 设置弹窗距离边框60dp
|
||||
.wrapContentSize(),
|
||||
shape = RoundedCornerShape(30.dp),
|
||||
color = Color.White,
|
||||
shadowElevation = 0.dp
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(start = 152.dp, end = 152.dp, top = 56.dp, bottom = 30.dp),
|
||||
) {
|
||||
// 主要内容区域
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f)
|
||||
) {
|
||||
content()
|
||||
}
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
CustomOutlinedButton(
|
||||
modifier = modifier
|
||||
.width(300.dp)
|
||||
.height(100.dp),
|
||||
text = "取消",
|
||||
fontSize = 36.sp,
|
||||
onClick = onCancelClick
|
||||
)
|
||||
Spacer(modifier = Modifier.width(20.dp))
|
||||
|
||||
CustomButton(
|
||||
modifier = modifier
|
||||
.width(300.dp)
|
||||
.height(100.dp),
|
||||
text = "确定",
|
||||
onClick = onConfirmClick,
|
||||
borderColor = colorResource(R.color.blue),
|
||||
textColor = colorResource(R.color.white),
|
||||
fontSize = 36.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
ToastUtils.ToastComposable()
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.sw.inbound.ui.weight.dialog
|
||||
//
|
||||
//import androidx.compose.foundation.layout.Arrangement
|
||||
//import androidx.compose.foundation.layout.Box
|
||||
//import androidx.compose.foundation.layout.Column
|
||||
//import androidx.compose.foundation.layout.Row
|
||||
//import androidx.compose.foundation.layout.Spacer
|
||||
//import androidx.compose.foundation.layout.fillMaxSize
|
||||
//import androidx.compose.foundation.layout.fillMaxWidth
|
||||
//import androidx.compose.foundation.layout.height
|
||||
//import androidx.compose.foundation.layout.padding
|
||||
//import androidx.compose.foundation.layout.width
|
||||
//import androidx.compose.foundation.layout.wrapContentSize
|
||||
//import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
//import androidx.compose.material3.Surface
|
||||
//import androidx.compose.runtime.Composable
|
||||
//import androidx.compose.ui.Alignment
|
||||
//import androidx.compose.ui.Modifier
|
||||
//import androidx.compose.ui.graphics.Color
|
||||
//import androidx.compose.ui.res.colorResource
|
||||
//import androidx.compose.ui.unit.dp
|
||||
//import androidx.compose.ui.unit.sp
|
||||
//import androidx.compose.ui.window.Dialog
|
||||
//import androidx.compose.ui.window.DialogProperties
|
||||
//import com.sw.inbound.R
|
||||
//import com.sw.inbound.ui.weight.CustomButton
|
||||
//import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
//import com.sw.inbound.utils.ToastUtils
|
||||
//
|
||||
///**
|
||||
// * 添加物品弹窗
|
||||
// */
|
||||
//@Composable
|
||||
//fun AddProductDialog(
|
||||
// modifier: Modifier = Modifier,
|
||||
// onCancelClick: () -> Unit,
|
||||
// onConfirmClick: () -> Unit,
|
||||
// onDismiss: () -> Unit,
|
||||
// content: @Composable () -> Unit
|
||||
//) {
|
||||
// Dialog(
|
||||
// onDismissRequest = onDismiss,
|
||||
// properties = DialogProperties(
|
||||
// usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
// decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
// )
|
||||
// ) {
|
||||
//
|
||||
// Surface(
|
||||
// modifier = Modifier
|
||||
// .padding(start = 60.dp, end = 60.dp, bottom = 40.dp) // 设置弹窗距离边框60dp
|
||||
// .wrapContentSize(),
|
||||
// shape = RoundedCornerShape(30.dp),
|
||||
// color = Color.White,
|
||||
// shadowElevation = 0.dp
|
||||
// ) {
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .fillMaxSize()
|
||||
// .padding(start = 152.dp, end = 152.dp, top = 56.dp, bottom = 30.dp),
|
||||
// ) {
|
||||
// // 主要内容区域
|
||||
// Box(
|
||||
// modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
// .weight(1f)
|
||||
// ) {
|
||||
// content()
|
||||
// }
|
||||
// Spacer(modifier = Modifier.height(30.dp))
|
||||
// Row(
|
||||
// modifier = Modifier.fillMaxWidth(),
|
||||
// verticalAlignment = Alignment.CenterVertically,
|
||||
// horizontalArrangement = Arrangement.End
|
||||
// ) {
|
||||
// CustomOutlinedButton(
|
||||
// modifier = modifier
|
||||
// .width(300.dp)
|
||||
// .height(100.dp),
|
||||
// text = "取消",
|
||||
// fontSize = 36.sp,
|
||||
// onClick = onCancelClick
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(20.dp))
|
||||
//
|
||||
// CustomButton(
|
||||
// modifier = modifier
|
||||
// .width(300.dp)
|
||||
// .height(100.dp),
|
||||
// text = "确定",
|
||||
// onClick = onConfirmClick,
|
||||
// borderColor = colorResource(R.color.blue),
|
||||
// textColor = colorResource(R.color.white),
|
||||
// fontSize = 36.sp
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// ToastUtils.ToastComposable()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,103 +1,103 @@
|
||||
package com.sw.inbound.ui.weight.dialog
|
||||
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.ui.weight.CustomButton
|
||||
import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
|
||||
/**
|
||||
* 添加物品弹窗
|
||||
*/
|
||||
@Composable
|
||||
fun AddPurchaseUnitDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
onCancelClick: () -> Unit,
|
||||
onConfirmClick: () -> Unit,
|
||||
onDismiss: () -> Unit,
|
||||
content: @Composable () -> Unit
|
||||
) {
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(
|
||||
usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
)
|
||||
) {
|
||||
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.width(1190.dp)
|
||||
.height(840.dp)
|
||||
.wrapContentSize(),
|
||||
shape = RoundedCornerShape(30.dp),
|
||||
color = Color.White,
|
||||
shadowElevation = 0.dp
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(30.dp),
|
||||
) {
|
||||
// 主要内容区域
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(horizontal = 164.dp)
|
||||
.weight(1f)
|
||||
) {
|
||||
content()
|
||||
}
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
CustomOutlinedButton(
|
||||
modifier = modifier
|
||||
.width(300.dp)
|
||||
.height(100.dp),
|
||||
text = "取消",
|
||||
fontSize = 36.sp,
|
||||
onClick = onCancelClick
|
||||
)
|
||||
Spacer(modifier = Modifier.width(20.dp))
|
||||
|
||||
CustomButton(
|
||||
modifier = modifier
|
||||
.width(300.dp)
|
||||
.height(100.dp),
|
||||
text = "确定",
|
||||
onClick = onConfirmClick,
|
||||
borderColor = colorResource(R.color.blue),
|
||||
textColor = colorResource(R.color.white),
|
||||
fontSize = 36.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
ToastUtils.ToastComposable()
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.sw.inbound.ui.weight.dialog
|
||||
//
|
||||
//import androidx.compose.foundation.layout.Arrangement
|
||||
//import androidx.compose.foundation.layout.Box
|
||||
//import androidx.compose.foundation.layout.Column
|
||||
//import androidx.compose.foundation.layout.Row
|
||||
//import androidx.compose.foundation.layout.Spacer
|
||||
//import androidx.compose.foundation.layout.fillMaxSize
|
||||
//import androidx.compose.foundation.layout.fillMaxWidth
|
||||
//import androidx.compose.foundation.layout.height
|
||||
//import androidx.compose.foundation.layout.padding
|
||||
//import androidx.compose.foundation.layout.width
|
||||
//import androidx.compose.foundation.layout.wrapContentSize
|
||||
//import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
//import androidx.compose.material3.Surface
|
||||
//import androidx.compose.runtime.Composable
|
||||
//import androidx.compose.ui.Alignment
|
||||
//import androidx.compose.ui.Modifier
|
||||
//import androidx.compose.ui.graphics.Color
|
||||
//import androidx.compose.ui.res.colorResource
|
||||
//import androidx.compose.ui.unit.dp
|
||||
//import androidx.compose.ui.unit.sp
|
||||
//import androidx.compose.ui.window.Dialog
|
||||
//import androidx.compose.ui.window.DialogProperties
|
||||
//import com.sw.inbound.R
|
||||
//import com.sw.inbound.ui.weight.CustomButton
|
||||
//import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
//import com.sw.inbound.utils.ToastUtils
|
||||
//
|
||||
///**
|
||||
// * 添加物品弹窗
|
||||
// */
|
||||
//@Composable
|
||||
//fun AddPurchaseUnitDialog(
|
||||
// modifier: Modifier = Modifier,
|
||||
// onCancelClick: () -> Unit,
|
||||
// onConfirmClick: () -> Unit,
|
||||
// onDismiss: () -> Unit,
|
||||
// content: @Composable () -> Unit
|
||||
//) {
|
||||
// Dialog(
|
||||
// onDismissRequest = onDismiss,
|
||||
// properties = DialogProperties(
|
||||
// usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
// decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
// )
|
||||
// ) {
|
||||
//
|
||||
// Surface(
|
||||
// modifier = Modifier
|
||||
// .width(1190.dp)
|
||||
// .height(840.dp)
|
||||
// .wrapContentSize(),
|
||||
// shape = RoundedCornerShape(30.dp),
|
||||
// color = Color.White,
|
||||
// shadowElevation = 0.dp
|
||||
// ) {
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .fillMaxSize()
|
||||
// .padding(30.dp),
|
||||
// ) {
|
||||
// // 主要内容区域
|
||||
// Box(
|
||||
// modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
// .padding(horizontal = 164.dp)
|
||||
// .weight(1f)
|
||||
// ) {
|
||||
// content()
|
||||
// }
|
||||
// Spacer(modifier = Modifier.height(30.dp))
|
||||
// Row(
|
||||
// modifier = Modifier.fillMaxWidth(),
|
||||
// verticalAlignment = Alignment.CenterVertically,
|
||||
// horizontalArrangement = Arrangement.End
|
||||
// ) {
|
||||
// CustomOutlinedButton(
|
||||
// modifier = modifier
|
||||
// .width(300.dp)
|
||||
// .height(100.dp),
|
||||
// text = "取消",
|
||||
// fontSize = 36.sp,
|
||||
// onClick = onCancelClick
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(20.dp))
|
||||
//
|
||||
// CustomButton(
|
||||
// modifier = modifier
|
||||
// .width(300.dp)
|
||||
// .height(100.dp),
|
||||
// text = "确定",
|
||||
// onClick = onConfirmClick,
|
||||
// borderColor = colorResource(R.color.blue),
|
||||
// textColor = colorResource(R.color.white),
|
||||
// fontSize = 36.sp
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// ToastUtils.ToastComposable()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -1,228 +1,228 @@
|
||||
package com.sw.inbound.ui.weight.dialog
|
||||
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.border
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.width
|
||||
import androidx.compose.foundation.layout.wrapContentSize
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.itemsIndexed
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.res.colorResource
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import com.sw.inbound.R
|
||||
import com.sw.inbound.ext.bold
|
||||
import com.sw.inbound.ext.withColor
|
||||
import com.sw.inbound.ext.withSize
|
||||
import com.sw.inbound.model.response.GoodsInfo
|
||||
import com.sw.inbound.ui.theme.AppTypography
|
||||
import com.sw.inbound.ui.theme.GrayDivider
|
||||
import com.sw.inbound.ui.weight.CustomButton
|
||||
import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
import com.sw.inbound.ui.weight.CustomSingleRightText
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
|
||||
/**
|
||||
* 收货确认弹窗
|
||||
*/
|
||||
@Composable
|
||||
fun ReceiptTipDialog(
|
||||
modifier: Modifier = Modifier,
|
||||
isWarn: Boolean = false,
|
||||
goodsList: List<GoodsInfo>,
|
||||
onCancelClick: () -> Unit,
|
||||
onConfirmClick: (Boolean) -> Unit,
|
||||
onDismiss: () -> Unit = {},
|
||||
) {
|
||||
Dialog(
|
||||
onDismissRequest = onDismiss,
|
||||
properties = DialogProperties(
|
||||
usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
)
|
||||
) {
|
||||
Surface(
|
||||
modifier = Modifier
|
||||
.width(1190.dp)
|
||||
.height(840.dp)
|
||||
.wrapContentSize(),
|
||||
shape = RoundedCornerShape(30.dp),
|
||||
color = Color.White,
|
||||
shadowElevation = 0.dp
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxSize()
|
||||
.padding(30.dp),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.weight(1f),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
verticalArrangement = Arrangement.Center,
|
||||
) {
|
||||
Image(
|
||||
painter = if (isWarn) painterResource(R.mipmap.ic_tip_warn) else painterResource(
|
||||
R.mipmap.ic_tip_success
|
||||
), contentDescription = "提示"
|
||||
)
|
||||
Spacer(modifier = Modifier.height(60.dp))
|
||||
Text(
|
||||
text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货",
|
||||
style = AppTypography.black141428TextStyle.bold().withSize(48.sp)
|
||||
)
|
||||
if (isWarn) {
|
||||
Spacer(modifier = Modifier.height(60.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.height(257.dp)
|
||||
.width(810.dp)
|
||||
.border(width = 1.dp, color = GrayDivider)
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(start = 80.dp, top = 20.dp, end = 80.dp)
|
||||
.height(50.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = "名称",
|
||||
style = AppTypography.gray999999TextStyle,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = "采购量",
|
||||
style = AppTypography.gray999999TextStyle,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = "实收",
|
||||
style = AppTypography.gray999999TextStyle,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
LazyColumn {
|
||||
itemsIndexed(items = goodsList) { index, goods ->
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 80.dp)
|
||||
.height(50.dp),
|
||||
horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = goods.goodNameStr,
|
||||
style = AppTypography.blackMediumTextStyle,
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = "${goods.receiveCountListStr}${goods.unitNameStr}",
|
||||
style = AppTypography.blackMediumTextStyle.withColor(
|
||||
color = Color(0xFF0032C8)
|
||||
),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
Spacer(modifier = Modifier.width(10.dp))
|
||||
CustomSingleRightText(
|
||||
modifier = Modifier.weight(1f),
|
||||
text = "${goods.receivedNumCount}${goods.unitNameStr}",
|
||||
style = AppTypography.blackMediumTextStyle.withColor(
|
||||
Color.Red
|
||||
),
|
||||
textAlign = TextAlign.Center
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.height(29.dp))
|
||||
Text(
|
||||
text = "请确认实际收货数量,或选择部分收货处理",
|
||||
style = AppTypography.black141428TextStyle.withColor(
|
||||
color = Color(0xFF999999)
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
HorizontalDivider(thickness = 1.dp, color = colorResource(R.color.divider))
|
||||
Spacer(modifier = Modifier.height(30.dp))
|
||||
Row(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
horizontalArrangement = Arrangement.End
|
||||
) {
|
||||
CustomOutlinedButton(
|
||||
modifier = modifier
|
||||
.width(180.dp)
|
||||
.height(90.dp),
|
||||
text = "返回",
|
||||
fontSize = 36.sp,
|
||||
onClick = onCancelClick
|
||||
)
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
|
||||
if (isWarn) {
|
||||
CustomButton(
|
||||
modifier = modifier
|
||||
.width(260.dp)
|
||||
.height(90.dp),
|
||||
text = "部分收货",
|
||||
onClick = {
|
||||
onConfirmClick(false)
|
||||
},
|
||||
borderColor = colorResource(R.color.green),
|
||||
textColor = colorResource(R.color.white),
|
||||
fontSize = 36.sp
|
||||
)
|
||||
|
||||
Spacer(modifier = Modifier.width(12.dp))
|
||||
}
|
||||
|
||||
CustomButton(
|
||||
modifier = modifier
|
||||
.width(260.dp)
|
||||
.height(90.dp),
|
||||
text = "确定收货",
|
||||
onClick = {
|
||||
onConfirmClick(true)
|
||||
},
|
||||
borderColor = colorResource(R.color.blue),
|
||||
textColor = colorResource(R.color.white),
|
||||
fontSize = 36.sp
|
||||
)
|
||||
}
|
||||
}
|
||||
ToastUtils.ToastComposable()
|
||||
}
|
||||
}
|
||||
}
|
||||
//package com.sw.inbound.ui.weight.dialog
|
||||
//
|
||||
//import androidx.compose.foundation.Image
|
||||
//import androidx.compose.foundation.border
|
||||
//import androidx.compose.foundation.layout.Arrangement
|
||||
//import androidx.compose.foundation.layout.Column
|
||||
//import androidx.compose.foundation.layout.Row
|
||||
//import androidx.compose.foundation.layout.Spacer
|
||||
//import androidx.compose.foundation.layout.fillMaxSize
|
||||
//import androidx.compose.foundation.layout.fillMaxWidth
|
||||
//import androidx.compose.foundation.layout.height
|
||||
//import androidx.compose.foundation.layout.padding
|
||||
//import androidx.compose.foundation.layout.width
|
||||
//import androidx.compose.foundation.layout.wrapContentSize
|
||||
//import androidx.compose.foundation.lazy.LazyColumn
|
||||
//import androidx.compose.foundation.lazy.itemsIndexed
|
||||
//import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
//import androidx.compose.material3.HorizontalDivider
|
||||
//import androidx.compose.material3.Surface
|
||||
//import androidx.compose.material3.Text
|
||||
//import androidx.compose.runtime.Composable
|
||||
//import androidx.compose.ui.Alignment
|
||||
//import androidx.compose.ui.Modifier
|
||||
//import androidx.compose.ui.graphics.Color
|
||||
//import androidx.compose.ui.res.colorResource
|
||||
//import androidx.compose.ui.res.painterResource
|
||||
//import androidx.compose.ui.text.style.TextAlign
|
||||
//import androidx.compose.ui.unit.dp
|
||||
//import androidx.compose.ui.unit.sp
|
||||
//import androidx.compose.ui.window.Dialog
|
||||
//import androidx.compose.ui.window.DialogProperties
|
||||
//import com.sw.inbound.R
|
||||
//import com.sw.inbound.ext.bold
|
||||
//import com.sw.inbound.ext.withColor
|
||||
//import com.sw.inbound.ext.withSize
|
||||
//import com.sw.inbound.model.response.GoodsInfo
|
||||
//import com.sw.inbound.ui.theme.AppTypography
|
||||
//import com.sw.inbound.ui.theme.GrayDivider
|
||||
//import com.sw.inbound.ui.weight.CustomButton
|
||||
//import com.sw.inbound.ui.weight.CustomOutlinedButton
|
||||
//import com.sw.inbound.ui.weight.CustomSingleRightText
|
||||
//import com.sw.inbound.utils.ToastUtils
|
||||
//
|
||||
///**
|
||||
// * 收货确认弹窗
|
||||
// */
|
||||
//@Composable
|
||||
//fun ReceiptTipDialog(
|
||||
// modifier: Modifier = Modifier,
|
||||
// isWarn: Boolean = false,
|
||||
// goodsList: List<GoodsInfo>,
|
||||
// onCancelClick: () -> Unit,
|
||||
// onConfirmClick: (Boolean) -> Unit,
|
||||
// onDismiss: () -> Unit = {},
|
||||
//) {
|
||||
// Dialog(
|
||||
// onDismissRequest = onDismiss,
|
||||
// properties = DialogProperties(
|
||||
// usePlatformDefaultWidth = false, // 不使用平台默认宽度
|
||||
// decorFitsSystemWindows = false // 允许内容延伸到系统窗口后面
|
||||
// )
|
||||
// ) {
|
||||
// Surface(
|
||||
// modifier = Modifier
|
||||
// .width(1190.dp)
|
||||
// .height(840.dp)
|
||||
// .wrapContentSize(),
|
||||
// shape = RoundedCornerShape(30.dp),
|
||||
// color = Color.White,
|
||||
// shadowElevation = 0.dp
|
||||
// ) {
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .fillMaxSize()
|
||||
// .padding(30.dp),
|
||||
// ) {
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
// .weight(1f),
|
||||
// horizontalAlignment = Alignment.CenterHorizontally,
|
||||
// verticalArrangement = Arrangement.Center,
|
||||
// ) {
|
||||
// Image(
|
||||
// painter = if (isWarn) painterResource(R.mipmap.ic_tip_warn) else painterResource(
|
||||
// R.mipmap.ic_tip_success
|
||||
// ), contentDescription = "提示"
|
||||
// )
|
||||
// Spacer(modifier = Modifier.height(60.dp))
|
||||
// Text(
|
||||
// text = if (isWarn) "收货数量与采购量存在差异" else "核对无误,确认收货",
|
||||
// style = AppTypography.black141428TextStyle.bold().withSize(48.sp)
|
||||
// )
|
||||
// if (isWarn) {
|
||||
// Spacer(modifier = Modifier.height(60.dp))
|
||||
// Column(
|
||||
// modifier = Modifier
|
||||
// .height(257.dp)
|
||||
// .width(810.dp)
|
||||
// .border(width = 1.dp, color = GrayDivider)
|
||||
// ) {
|
||||
// Row(
|
||||
// modifier = Modifier
|
||||
// .padding(start = 80.dp, top = 20.dp, end = 80.dp)
|
||||
// .height(50.dp),
|
||||
// horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
// verticalAlignment = Alignment.CenterVertically
|
||||
// ) {
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = "名称",
|
||||
// style = AppTypography.gray999999TextStyle,
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(10.dp))
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = "采购量",
|
||||
// style = AppTypography.gray999999TextStyle,
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(10.dp))
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = "实收",
|
||||
// style = AppTypography.gray999999TextStyle,
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// }
|
||||
// LazyColumn {
|
||||
// itemsIndexed(items = goodsList) { index, goods ->
|
||||
// Row(
|
||||
// modifier = Modifier
|
||||
// .padding(horizontal = 80.dp)
|
||||
// .height(50.dp),
|
||||
// horizontalArrangement = Arrangement.SpaceEvenly,
|
||||
// verticalAlignment = Alignment.CenterVertically
|
||||
// ) {
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = goods.goodNameStr,
|
||||
// style = AppTypography.blackMediumTextStyle,
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(10.dp))
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = "${goods.receiveCountListStr}${goods.unitNameStr}",
|
||||
// style = AppTypography.blackMediumTextStyle.withColor(
|
||||
// color = Color(0xFF0032C8)
|
||||
// ),
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(10.dp))
|
||||
// CustomSingleRightText(
|
||||
// modifier = Modifier.weight(1f),
|
||||
// text = "${goods.receivedNumCount}${goods.unitNameStr}",
|
||||
// style = AppTypography.blackMediumTextStyle.withColor(
|
||||
// Color.Red
|
||||
// ),
|
||||
// textAlign = TextAlign.Center
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// Spacer(modifier = Modifier.height(29.dp))
|
||||
// Text(
|
||||
// text = "请确认实际收货数量,或选择部分收货处理",
|
||||
// style = AppTypography.black141428TextStyle.withColor(
|
||||
// color = Color(0xFF999999)
|
||||
// )
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// HorizontalDivider(thickness = 1.dp, color = colorResource(R.color.divider))
|
||||
// Spacer(modifier = Modifier.height(30.dp))
|
||||
// Row(
|
||||
// modifier = Modifier.fillMaxWidth(),
|
||||
// verticalAlignment = Alignment.CenterVertically,
|
||||
// horizontalArrangement = Arrangement.End
|
||||
// ) {
|
||||
// CustomOutlinedButton(
|
||||
// modifier = modifier
|
||||
// .width(180.dp)
|
||||
// .height(90.dp),
|
||||
// text = "返回",
|
||||
// fontSize = 36.sp,
|
||||
// onClick = onCancelClick
|
||||
// )
|
||||
// Spacer(modifier = Modifier.width(12.dp))
|
||||
//
|
||||
// if (isWarn) {
|
||||
// CustomButton(
|
||||
// modifier = modifier
|
||||
// .width(260.dp)
|
||||
// .height(90.dp),
|
||||
// text = "部分收货",
|
||||
// onClick = {
|
||||
// onConfirmClick(false)
|
||||
// },
|
||||
// borderColor = colorResource(R.color.green),
|
||||
// textColor = colorResource(R.color.white),
|
||||
// fontSize = 36.sp
|
||||
// )
|
||||
//
|
||||
// Spacer(modifier = Modifier.width(12.dp))
|
||||
// }
|
||||
//
|
||||
// CustomButton(
|
||||
// modifier = modifier
|
||||
// .width(260.dp)
|
||||
// .height(90.dp),
|
||||
// text = "确定收货",
|
||||
// onClick = {
|
||||
// onConfirmClick(true)
|
||||
// },
|
||||
// borderColor = colorResource(R.color.blue),
|
||||
// textColor = colorResource(R.color.white),
|
||||
// fontSize = 36.sp
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// ToastUtils.ToastComposable()
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
@@ -11,6 +11,13 @@ import java.util.Locale
|
||||
*/
|
||||
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日 星期三)
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.sw.inbound.viewmodel
|
||||
import android.net.Uri
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.sw.inbound.GlobalData
|
||||
import com.sw.inbound.model.response.ApiResponse
|
||||
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.objbox.FoodModule
|
||||
import com.sw.inbound.repository.RemoteRepository
|
||||
import com.sw.inbound.utils.SPUtil
|
||||
import com.sw.inbound.utils.ToastUtils
|
||||
import com.sw.inbound.utils.ext.toType
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
@@ -201,19 +204,19 @@ abstract class BaseViewModel(
|
||||
}
|
||||
|
||||
fun recognizeGoodsList(
|
||||
nameList: List<String>?=null,
|
||||
scoreList: List<FoodModule.IdNameScore>?=null,
|
||||
nameList: List<String>? = null,
|
||||
scoreList: List<FoodModule.IdNameScore>? = null,
|
||||
callback: (List<SearchGoodsInfo.Record>) -> Unit
|
||||
) {
|
||||
launch {
|
||||
if (nameList.isNullOrEmpty() && scoreList.isNullOrEmpty()) return@launch
|
||||
val paramList = if (nameList.isNullOrEmpty()) scoreList!!.map { it.name } else nameList
|
||||
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()) {
|
||||
list.forEach { record ->
|
||||
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)
|
||||
@@ -333,4 +336,42 @@ abstract class BaseViewModel(
|
||||
// GlobalData.activeKey = equipmentInfo.arcsoftActiveKey!!
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user