From 8b0f850d271b7209f00b562c9b85a48cf2d4fddb Mon Sep 17 00:00:00 2001 From: lvmeng <848755140@qq.com> Date: Wed, 27 May 2026 09:21:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(activity):=20StoreActivity=20=E8=BF=9B?= =?UTF-8?q?=E5=85=A5=E6=97=B6=E7=9B=B4=E6=8E=A5=E5=BC=B9=E5=87=BA=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E5=BC=B9=E7=AA=97=EF=BC=8C=E5=85=B3=E9=97=AD=E5=90=8E?= =?UTF-8?q?=E9=80=80=E5=87=BA=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - InboundGoodsStoreDialog.goods 改为可空类型,支持毛菜无需预搜索直接录入 - StoreActivity 根据 storeType 自动弹出对应弹窗(毛菜→录入弹窗,净菜→检索弹窗) - GoodsListActivity.recognizeFood 标记为 open,StoreActivity override 为空以关闭识别 - 修复相机预览被 cvImageBg 白色遮罩遮挡的问题 --- .../sw/inbound/activity/GoodsListActivity.kt | 2 +- .../com/sw/inbound/activity/StoreActivity.kt | 24 +++++++++++++++++++ .../inbound/dialog/InboundGoodsStoreDialog.kt | 8 +++---- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/sw/inbound/activity/GoodsListActivity.kt b/app/src/main/java/com/sw/inbound/activity/GoodsListActivity.kt index e5b3a5e..d664213 100644 --- a/app/src/main/java/com/sw/inbound/activity/GoodsListActivity.kt +++ b/app/src/main/java/com/sw/inbound/activity/GoodsListActivity.kt @@ -274,7 +274,7 @@ abstract class GoodsListActivity : BaseActivity() { } } - fun recognizeFood() { + open fun recognizeFood() { if (isShowRecognizeDialog.not()) { if (goodsRecognizeDialog == null) { isShowRecognizeDialog = true diff --git a/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt b/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt index 4fe466b..01d3bca 100644 --- a/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt +++ b/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt @@ -4,6 +4,7 @@ import android.os.Bundle import androidx.activity.viewModels import com.sw.inbound.GlobalData import com.sw.inbound.dialog.InboundGoodsSearchDialog +import com.sw.inbound.dialog.InboundGoodsStoreDialog import com.sw.inbound.model.response.DictType import com.sw.inbound.utils.ext.gone import com.sw.inbound.viewmodel.StoreViewModel @@ -22,6 +23,9 @@ class StoreActivity : GoodsListActivity() { /** 0=净菜,1=毛菜,由 HomeActivity 通过 Intent 传入 */ var storeType: Int = 0 + /** 防止 onResume 重复弹窗 */ + private var dialogShown = false + override fun onCreate(savedInstanceState: Bundle?) { storeType = intent.getIntExtra(EXTRA_STORE_TYPE, 0) super.onCreate(savedInstanceState) @@ -31,6 +35,23 @@ class StoreActivity : GoodsListActivity() { override fun onResume() { super.onResume() preloadInboundOptions() + if (!dialogShown) { + dialogShown = true + showEntryDialog() + } + } + + /** 根据 storeType 弹出对应入库弹窗,dismiss 时关闭页面 */ + private fun showEntryDialog() { + if (storeType == 1) { + InboundGoodsStoreDialog(this, null).apply { + setOnDismissListener { finish() } + }.show() + } else { + InboundGoodsSearchDialog(this).apply { + setOnDismissListener { finish() } + }.show() + } } /** 预加载供应商和仓库区域列表到 GlobalData,供弹窗直接使用 */ @@ -55,6 +76,9 @@ class StoreActivity : GoodsListActivity() { override fun initView() {} + /** 入库页面暂不需要识别功能 */ + override fun recognizeFood() {} + override fun getWarehouseList(): List = emptyList() /** 使用入库专用检索弹窗替代原有 GoodsSearchDialog */ diff --git a/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt b/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt index 8714204..9295906 100644 --- a/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt +++ b/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt @@ -32,7 +32,7 @@ import kotlin.math.abs /** 入库输入弹窗,使用 RecyclerView加载 动态表单,根据 storeType 展示净菜/毛菜对应字段 */ class InboundGoodsStoreDialog( context: Context, - private val goods: GoodsSearchModel, + private val goods: GoodsSearchModel?, private val confirmBlock: () -> Unit = {} ) : BaseDialog(context) { @@ -166,7 +166,7 @@ class InboundGoodsStoreDialog( * expiryDate, storageTemp */ private fun buildCleanFields(): MutableList { - val vegTypes = goods.vegTypeList() + val vegTypes = goods?.vegTypeList() ?: emptyList() val cleanTypeOptions = vegTypes.mapIndexed { index, type -> DictType(id = index.toString(), value = type) } @@ -179,7 +179,7 @@ class InboundGoodsStoreDialog( "溯源码", FieldType.TEXT, apiKey = "traceCode", - value = goods.traceCode, + value = goods?.traceCode ?: "", required = true, hint = "请输入溯源码" ), @@ -188,7 +188,7 @@ class InboundGoodsStoreDialog( FieldType.FIXED, apiKey = "ingredientName", required = true, - value = goods.materName + value = goods?.materName ?: "" ), FormField( "净菜类型",