From 080f505c5de41a581787f1b0eeda9f662a46f8de Mon Sep 17 00:00:00 2001 From: lvmeng <848755140@qq.com> Date: Wed, 27 May 2026 09:08:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(inbound):=20=E5=B0=86=E5=87=80?= =?UTF-8?q?=E6=9D=90=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD=E8=B0=83=E6=95=B4?= =?UTF-8?q?=E4=B8=BA=E5=87=80=E8=8F=9C=E5=85=A5=E5=BA=93=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将界面中的"净材"文本全部替换为"净菜" - 更新按钮ID命名从btnOrderPurchase改为btnCleanDishStore - 更新毛菜按钮ID从btnOrderSelfProcurement改为btnRawDishStore - 修改入库弹窗类注释说明,将净材改为净菜 - 更新storeType参数说明,将净材改为净菜 - 重构动态表单字段配置,统一字段提示文本为"请输入/请选择"格式 - 将净菜类型字段设置为固定类型并添加规格下拉选项 - 更新RecyclerView设置方式,优化代码结构 - 调整标题显示逻辑,根据入库类型动态显示净菜或毛菜入库 - 优化相机预览布局,隐藏图片背景视图 - 更新StoreActivity中关于净菜类型的注释说明 --- .../com/sw/inbound/activity/HomeActivity.kt | 6 +- .../com/sw/inbound/activity/StoreActivity.kt | 2 +- .../inbound/dialog/InboundGoodsStoreDialog.kt | 191 ++++++++++++++---- app/src/main/res/layout/activity_home.xml | 8 +- 4 files changed, 165 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/sw/inbound/activity/HomeActivity.kt b/app/src/main/java/com/sw/inbound/activity/HomeActivity.kt index b032bbe..2a11c1c 100644 --- a/app/src/main/java/com/sw/inbound/activity/HomeActivity.kt +++ b/app/src/main/java/com/sw/inbound/activity/HomeActivity.kt @@ -108,15 +108,15 @@ class HomeActivity : BaseActivity() { } } - // 净材按钮点击提示 - binding.btnOrderPurchase.setOnClickListener { + // 净菜按钮点击提示 + binding.btnCleanDishStore.setOnClickListener { startActivity { putExtra(StoreActivity.EXTRA_STORE_TYPE, 0) } } // 毛菜按钮点击提示 - binding.btnOrderSelfProcurement.setOnClickListener { + binding.btnRawDishStore.setOnClickListener { startActivity { putExtra(StoreActivity.EXTRA_STORE_TYPE, 1) } 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 3a40c7d..4fe466b 100644 --- a/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt +++ b/app/src/main/java/com/sw/inbound/activity/StoreActivity.kt @@ -19,7 +19,7 @@ class StoreActivity : GoodsListActivity() { val storeViewModel: StoreViewModel by viewModels() - /** 0=净材,1=毛菜,由 HomeActivity 通过 Intent 传入 */ + /** 0=净菜,1=毛菜,由 HomeActivity 通过 Intent 传入 */ var storeType: Int = 0 override fun onCreate(savedInstanceState: Bundle?) { 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 08f1144..8714204 100644 --- a/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt +++ b/app/src/main/java/com/sw/inbound/dialog/InboundGoodsStoreDialog.kt @@ -29,7 +29,7 @@ import java.util.Date import java.util.Locale import kotlin.math.abs -/** 入库录入弹窗,使用 FlexboxLayoutManager 动态表单,根据 storeType 展示净材/毛菜对应字段 */ +/** 入库输入弹窗,使用 RecyclerView加载 动态表单,根据 storeType 展示净菜/毛菜对应字段 */ class InboundGoodsStoreDialog( context: Context, private val goods: GoodsSearchModel, @@ -41,7 +41,7 @@ class InboundGoodsStoreDialog( private var storeActivity: StoreActivity? = null - /** 0=净材,1=毛菜 */ + /** 0=净菜,1=毛菜 */ private var storeType: Int = 0 private var realWeight: Int = 0 @@ -92,25 +92,75 @@ class InboundGoodsStoreDialog( DictType(id = id, value = zone.zoneName) } return mutableListOf( - FormField("溯源码", FieldType.TEXT, apiKey = "traceCode", value = goods.traceCode, required = true, hint = "请录入溯源码"), - FormField("来源类型", FieldType.DROPDOWN, apiKey = "", options = listOf( - DictType("0", "手动录入"), DictType("1", "系统识别") - )), - FormField("食材名称", FieldType.FIXED, apiKey = "materialName", required = true, value = goods.materName), - FormField("供应商", FieldType.DROPDOWN, apiKey = "supplierId", required = true, - hint = "请选择供应商", options = supplierOptions, submitValueId = true), - FormField("入库规格", FieldType.TEXT, apiKey = "spec", required = true, hint = "请录入入库规格"), - FormField("入库数量", FieldType.NUMBER, apiKey = "quantity", required = true, hint = "请录入入库数量"), - FormField("入库时间", FieldType.DATE_PICKER, apiKey = "inboundTime", required = true, - hint = "请选择入库时间", submitValueId = true), - FormField("存放区域", FieldType.DROPDOWN, apiKey = "zoneId", required = true, - hint = "请选择存放区域", options = zoneOptions, submitValueId = true), - FormField("操作人", FieldType.TEXT, apiKey = "operator", value = GlobalData.user?.name ?: "") + FormField( + "溯源码", + FieldType.TEXT, + apiKey = "traceCode", + value = "", + required = true, + hint = "请输入溯源码" + ), + FormField( + "来源类型", FieldType.DROPDOWN, apiKey = "", options = listOf( + DictType("0", "外采"), DictType("1", "自产") + ) + ), + FormField( + "食材名称", + FieldType.DROPDOWN, + apiKey = "materialName", + required = true, + value = "", + hint = "请选择食材名称" + ), + FormField( + "供应商", FieldType.DROPDOWN, apiKey = "supplierId", required = true, + hint = "请选择供应商", options = supplierOptions, submitValueId = true + ), + FormField( + "入库规格", + FieldType.TEXT, + apiKey = "spec", + required = true, + hint = "请输入入库规格" + ), + FormField( + "入库数量", + FieldType.NUMBER, + apiKey = "quantity", + required = true, + hint = "请输入入库数量" + ), + FormField( + "入库时间", + FieldType.DATE_PICKER, + apiKey = "inboundTime", + required = true, + hint = "请选择入库时间", + submitValueId = true + ), + FormField( + "存放区域", + FieldType.DROPDOWN, + apiKey = "zoneId", + required = true, + hint = "请选择存放区域", + options = zoneOptions, + submitValueId = true + ), + FormField( + "操作人", + FieldType.TEXT, + apiKey = "operator", + value = GlobalData.user?.name ?: "", + required = true, + hint = "请输入操作人" + ) ) } /** - * 净材字段列表 + * 净菜字段列表 * 接口字段:traceCode, ingredientName, cleanType, spec, quantity, * weight(额外注入), inboundTime(额外注入当前时间), zoneId, operator, * expiryDate, storageTemp @@ -125,30 +175,94 @@ class InboundGoodsStoreDialog( DictType(id = id, value = zone.zoneName) } return mutableListOf( - FormField("溯源码", FieldType.TEXT, apiKey = "traceCode", value = goods.traceCode, required = true, hint = "请录入溯源码"), - FormField("食材名称", FieldType.FIXED, apiKey = "ingredientName", required = true, value = goods.materName), - FormField("净材类型", FieldType.DROPDOWN, apiKey = "cleanType", - required = cleanTypeOptions.isNotEmpty(), hint = "请选择净材类型", options = cleanTypeOptions), - FormField("入库规格", FieldType.TEXT, apiKey = "spec", required = true, hint = "请录入入库规格"), - FormField("入库数量", FieldType.NUMBER, apiKey = "quantity", required = true, hint = "请录入入库数量"), - FormField("保质期至", FieldType.DATE_PICKER, apiKey = "expiryDate", - hint = "请选择保质期", submitValueId = true), - FormField("存放区域", FieldType.DROPDOWN, apiKey = "zoneId", required = true, - hint = "请选择存放区域", options = zoneOptions, submitValueId = true), - FormField("存放温度(℃)", FieldType.NUMBER, apiKey = "storageTemp"), - FormField("操作人", FieldType.TEXT, apiKey = "operator", value = GlobalData.user?.name ?: "") + FormField( + "溯源码", + FieldType.TEXT, + apiKey = "traceCode", + value = goods.traceCode, + required = true, + hint = "请输入溯源码" + ), + FormField( + "食材名称", + FieldType.FIXED, + apiKey = "ingredientName", + required = true, + value = goods.materName + ), + FormField( + "净菜类型", + FieldType.FIXED, + required = true, + apiKey = "cleanType", + ), + FormField( + "入库规格", + FieldType.DROPDOWN, + apiKey = "spec", + required = true, + hint = "请选择入库规格", + options = listOf( + DictType("0", "袋装/500g"), + DictType("1", "袋装/300g"), + DictType("1", "瓶装/800ml"), + DictType("1", "瓶装/500ml"), + DictType("1", "其它"), + ), + ), + FormField( + "入库数量", + FieldType.NUMBER, + apiKey = "quantity", + required = true, + hint = "请输入入库数量" + ), + FormField( + "保质期至", + FieldType.DATE_PICKER, + apiKey = "expiryDate", + hint = "请选择保质期", + submitValueId = true + ), + FormField( + "存放区域", + FieldType.DROPDOWN, + apiKey = "zoneId", + required = true, + hint = "请选择存放区域", + options = zoneOptions, + submitValueId = true + ), + FormField( + "存放温度(℃)", + FieldType.NUMBER, + apiKey = "storageTemp" + ), + FormField( + "操作人", + FieldType.TEXT, + apiKey = "operator", + value = GlobalData.user?.name ?: "", + required = true, + hint = "请输入操作人" + ) ) } private fun setupRecyclerView() { - binding.rvFormFields.layoutManager = GridLayoutManager(context, 2) - binding.rvFormFields.adapter = FormFieldAdapter(storeActivity ?: context, fields) + binding.rvFormFields.run { + layoutManager = GridLayoutManager(context, 2) + adapter = FormFieldAdapter(storeActivity ?: context, fields) + } } private fun setupButtons() { binding.btnCancel.setOnClickListener { dismiss() } binding.btnConfirm.setOnClickListener { confirmInputData() } - binding.tvTitle.setOnClickListener { SensorScaleUtils.startScale(autoScale = true) } + binding.tvTitle.run { + text = if (storeType == 1) "毛菜入库" else "净菜入库" + setOnClickListener { SensorScaleUtils.startScale(autoScale = true) } + } binding.btnClearZero.setOnClickListener { SensorScaleUtils.tare() } } @@ -162,8 +276,16 @@ class InboundGoodsStoreDialog( private fun buildWeightSpannable(num: Int): SpannableStringBuilder { return buildSpannableString { - appendText(num.toString(), ForegroundColorSpan("#FF141428".toColorInt()), StyleSpan(Typeface.BOLD)) - appendText(" 克", ForegroundColorSpan("#FF000033".toColorInt()), StyleSpan(Typeface.BOLD)) + appendText( + num.toString(), + ForegroundColorSpan("#FF141428".toColorInt()), + StyleSpan(Typeface.BOLD) + ) + appendText( + " 克", + ForegroundColorSpan("#FF000033".toColorInt()), + StyleSpan(Typeface.BOLD) + ) } } @@ -255,6 +377,7 @@ class InboundGoodsStoreDialog( takePhotoBinding?.let { previewView = it.previewView it.flCameraPreview.visibility = View.VISIBLE + it.cvImageBg.visibility = View.GONE } } diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 1f49581..17791c3 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -115,14 +115,14 @@ android:gravity="center" android:orientation="horizontal"> - +