refactor(inbound): 将净材相关功能调整为净菜入库功能

- 将界面中的"净材"文本全部替换为"净菜"
- 更新按钮ID命名从btnOrderPurchase改为btnCleanDishStore
- 更新毛菜按钮ID从btnOrderSelfProcurement改为btnRawDishStore
- 修改入库弹窗类注释说明,将净材改为净菜
- 更新storeType参数说明,将净材改为净菜
- 重构动态表单字段配置,统一字段提示文本为"请输入/请选择"格式
- 将净菜类型字段设置为固定类型并添加规格下拉选项
- 更新RecyclerView设置方式,优化代码结构
- 调整标题显示逻辑,根据入库类型动态显示净菜或毛菜入库
- 优化相机预览布局,隐藏图片背景视图
- 更新StoreActivity中关于净菜类型的注释说明
This commit is contained in:
2026-05-27 09:08:18 +08:00
parent 37289d43f3
commit 080f505c5d
4 changed files with 165 additions and 42 deletions
@@ -108,15 +108,15 @@ class HomeActivity : BaseActivity() {
}
}
// 净按钮点击提示
binding.btnOrderPurchase.setOnClickListener {
// 净按钮点击提示
binding.btnCleanDishStore.setOnClickListener {
startActivity<StoreActivity> {
putExtra(StoreActivity.EXTRA_STORE_TYPE, 0)
}
}
// 毛菜按钮点击提示
binding.btnOrderSelfProcurement.setOnClickListener {
binding.btnRawDishStore.setOnClickListener {
startActivity<StoreActivity> {
putExtra(StoreActivity.EXTRA_STORE_TYPE, 1)
}
@@ -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?) {
@@ -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
}
}
+4 -4
View File
@@ -115,14 +115,14 @@
android:gravity="center"
android:orientation="horizontal">
<!--入库入口 -->
<!--入库入口 -->
<Button
android:id="@+id/btnOrderPurchase"
android:id="@+id/btnCleanDishStore"
android:layout_width="595dp"
android:layout_height="477dp"
android:background="@drawable/bg_gradient_blue_btn"
android:foreground="?android:attr/selectableItemBackground"
android:text="净"
android:text="净"
android:textColor="@color/white"
android:textSize="100sp"
android:textStyle="bold"
@@ -134,7 +134,7 @@
<!-- 毛菜入库入口 -->
<Button
android:id="@+id/btnOrderSelfProcurement"
android:id="@+id/btnRawDishStore"
android:layout_width="595dp"
android:layout_height="477dp"
android:background="@drawable/bg_gradient_orange_btn"