feat:称中页面

This commit is contained in:
dzc committed 2025-03-17 22:17:37 +08:00
1 parent de2f5e14b6
commit 16826ad5b2
6 files changed
+185 -55

No files matched your search

+1
View File
@@ -36,6 +36,7 @@ class RoutePages {
binding: BindingsBuilder(() {
Get.lazyPut(() => SelectPayTypeDialogController());
Get.lazyPut(() => PanelController());
Get.lazyPut(() => SteelyardController());
Get.lazyPut(() => SupermarketOrderController());
}),
),
+77 -43
View File
@@ -59,9 +59,11 @@ Widget orderAllPrice(
/// 商品选择面板
Widget orderSelectPanel(
BuildContext context, {
void Function(int, int)? onChange,
void Function(int, int)? onPlusChange,
void Function(double, int)? onWidgetChange,
String label = "",
int total = 1,
double widget = 0,
num price = 0,
int index = 0,
double height = 50,
@@ -79,48 +81,80 @@ Widget orderSelectPanel(
overflow: TextOverflow.ellipsis,
style: theme.typography.lg,
).width(maxWidth * 0.4),
<Widget>[
appPrice(context, price),
SizedBox(width: 10.w),
FIcon(
FAssets.icons.plus,
color: theme.colorScheme.secondary,
)
.width(height.w)
.height(double.infinity)
.decorated(color: theme.colorScheme.primary)
.onTap(() {
if (total < 100) {
if (onChange != null) {
onChange(total + 1, index);
}
}
}),
Text(
total.toString(),
style: theme.typography.lg,
).center().width(60.w).height(double.infinity).decorated(
color: theme.colorScheme.secondary,
borderRadius: theme.style.borderRadius / 2,
),
FIcon(
FAssets.icons.minus,
color: theme.colorScheme.secondary,
)
.width(height.w)
.height(double.infinity)
.decorated(color: theme.colorScheme.error)
.onTap(() {
if (total > 0) {
if (onChange != null) {
onChange(total - 1, index);
}
}
}),
]
.toRow(mainAxisAlignment: MainAxisAlignment.end)
.expanded()
.offstage(offstage: !showPlus),
showPlus
? <Widget>[
appPrice(context, price),
SizedBox(width: 10.w),
FIcon(
FAssets.icons.plus,
color: theme.colorScheme.secondary,
)
.width(height.w)
.height(double.infinity)
.decorated(color: theme.colorScheme.primary)
.onTap(
() {
if (total < 100) {
if (onPlusChange != null) {
onPlusChange(total + 1, index);
}
}
},
),
Text(
total.toString(),
style: theme.typography.lg,
).center().width(60.w).height(double.infinity).decorated(
color: theme.colorScheme.secondary,
borderRadius: theme.style.borderRadius / 2,
),
FIcon(
FAssets.icons.minus,
color: theme.colorScheme.secondary,
)
.width(height.w)
.height(double.infinity)
.decorated(color: theme.colorScheme.error)
.onTap(
() {
if (total > 0) {
if (onPlusChange != null) {
onPlusChange(total - 1, index);
}
}
},
),
].toRow(mainAxisAlignment: MainAxisAlignment.end).expanded()
: const SizedBox.shrink(),
showWidget
? <Widget>[
Text(
"称重",
style: theme.typography.base.copyWith(
height: 1,
color: theme.colorScheme.secondary,
),
)
.center()
.width(height.w * 1.5)
.height(double.infinity)
.decorated(color: theme.colorScheme.primary)
.onTap(
() {
if (onWidgetChange != null) {
onWidgetChange(widget, index);
}
},
),
Text(
"${widget.toString()} / kg",
style: theme.typography.lg,
).center().width(120.w).height(double.infinity).decorated(
color: theme.colorScheme.secondary,
borderRadius: theme.style.borderRadius / 2,
),
].toRow(mainAxisAlignment: MainAxisAlignment.end).expanded()
: const SizedBox.shrink(),
]
.toRow(mainAxisAlignment: MainAxisAlignment.center)
.height(height.h)
@@ -1,4 +1,6 @@
import 'package:common_utils/common_utils.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:forui/forui.dart';
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import 'package:pj_supermarket_cloud/common/index.dart';
@@ -22,7 +24,7 @@ class SteelyardController extends GetxController {
final app = Get.find<AppControl>();
// 称重商品
Rxn<CanteenSpuEntity?> _widgetProduct = Rxn(null);
SupermarketSpuEntity? _widgetProduct = null;
// 重量
RxDouble widget = RxDouble(0);
@@ -65,7 +67,7 @@ class SteelyardController extends GetxController {
}
// 打开称重
bool open(CanteenSpuEntity current) {
bool open(SupermarketSpuEntity current) {
final isOpen = _openSerial();
if (!isOpen) {
_closeStatus();
@@ -73,7 +75,7 @@ class SteelyardController extends GetxController {
}
_closeStatus();
logger.i("|$_tag|称重,商品uniqueCode:|${current.serviceUniqueCode}|");
_widgetProduct.value = current;
_widgetProduct = current;
return true;
}
@@ -84,7 +86,7 @@ class SteelyardController extends GetxController {
// 清除状态
_closeStatus() {
_widgetProduct.value = null;
_widgetProduct = null;
widget.value = 0;
callbackWidget.value = 0;
price.value = 0;
@@ -127,16 +129,77 @@ class SteelyardController extends GetxController {
interval(
callbackWidget,
(callback) {
if (_widgetProduct.value != null) {
if (_widgetProduct != null) {
widget.value = callbackWidget.value;
final p =
callbackWidget.value * _widgetProduct.value!.price / 100 * 100;
callbackWidget.value * _widgetProduct!.retailPrice / 100 * 100;
price.value = int.parse(p.toStringAsFixed(2));
logger.i(
"|$_tag|称重,重量:|${widget.value}|;价格:|${_widgetProduct.value!.price}|");
"|$_tag|称重,重量:|${widget.value}|;价格:|${_widgetProduct!.retailPrice}|");
}
},
time: const Duration(seconds: 1),
);
}
}
Widget steelyardEmpty(BuildContext context) {
final theme = FTheme.of(context);
return <Widget>[
<Widget>[
FIcon(
FAssets.icons.layers,
size: theme.typography.xl2.fontSize,
),
SizedBox(width: 10.w),
Text(
"请将商品放置到电子称中,点击开始称重",
style: theme.typography.xl,
),
].toRow(mainAxisAlignment: MainAxisAlignment.center),
SizedBox(height: 10.w),
Text(
"注意:请将电子称上的物品全部清空再点击开始称重",
style: theme.typography.base,
),
].toColumn(mainAxisAlignment: MainAxisAlignment.center);
}
Widget steelyardContainer(BuildContext context) {
final theme = FTheme.of(context);
final textStyle = theme.typography.xl.copyWith(
color: theme.colorScheme.secondary,
);
const textWidth = 180;
return GetBuilder<SteelyardController>(builder: (controller) {
return <Widget>[
Visibility(
visible: controller.isWidget.value,
replacement: steelyardEmpty(context),
child: steelyardEmpty(context),
).expanded(),
SizedBox(height: 100.h),
<Widget>[
FButton(
label: Text("开始称重", style: textStyle),
onPress: () => controller.weightStartCallback(),
).width(textWidth.w),
FButton(
label: Text("确定重量", style: textStyle),
onPress: () => controller.weightSubmitCallback(),
).width(textWidth.w),
FButton(
style: FButtonStyle.destructive,
label: Text("取消", style: textStyle),
onPress: () => controller.weightCancelCallback(),
).width(textWidth.w),
]
.toRowSpace(
space: 30.w,
mainAxisSize: MainAxisSize.max,
mainAxisAlignment: MainAxisAlignment.center,
)
.marginOnly(top: 20.h),
].toColumn(mainAxisAlignment: MainAxisAlignment.center);
});
}
+1 -1
View File
@@ -175,7 +175,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
total: current.productNumber,
index: index,
showPlus: true,
onChange: (number, i) =>
onPlusChange: (number, i) =>
controller.doComputedInputChange(number, i),
).marginOnly(bottom: 10.h);
},
@@ -17,6 +17,9 @@ class SupermarketOrderController extends GetxController with OrderMixin {
late SysSetting appSetting;
// 称重商品
Rxn<SupermarketSpuEntity?> widgetProduct = Rxn(null);
_initData() {
update(["supermarket_order"]);
}
@@ -132,6 +135,29 @@ class SupermarketOrderController extends GetxController with OrderMixin {
sendSubScreen();
}
// |购买商品|点击称重
void computedPanelWidget(double widget, int i) {
final current = shopCardList[i];
final targetProduct = supermarketSpuList.firstWhereOrNull((e) {
return e.serviceUniqueCode == current.productServiceUniqueCode;
});
if (targetProduct == null) return;
if (widgetProduct.value != null) {
if (widgetProduct.value!.serviceUniqueCode ==
current.productServiceUniqueCode) {
Toast.error(msg: "该商品已在称重");
return;
}
}
final supermarketC = Get.find<SteelyardController>();
final isOpen = supermarketC.open(targetProduct);
if (!isOpen) {
Toast.error(msg: "连接电子称错误");
return;
}
widgetProduct.value = targetProduct;
}
void _listenPayTypeSelectCallback() {
final payTypeSelect = Get.find<SelectPayTypeDialogController>();
// |支付方式|点击|开始识别|
+10 -4
View File
@@ -228,8 +228,10 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
index: index,
showPlus: current.nature == ProductNature.DEFAULT,
showWidget: current.nature == ProductNature.WEIGHT,
onChange: (number, i) =>
onPlusChange: (number, i) =>
controller.doComputedInputChange(number, i),
onWidgetChange: (widget, i) =>
controller.computedPanelWidget(widget, i),
).marginOnly(bottom: 10.h);
},
),
@@ -280,9 +282,13 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
final width = context.width;
final theme = FTheme.of(context);
return <Widget>[
SizedBox(width: 15.w),
_buildProductArea(context).expanded(),
SizedBox(width: 15.w),
Obx(
() => Visibility(
visible: controller.widgetProduct.value != null,
replacement: steelyardContainer(context),
child: _buildProductArea(context),
),
).marginSymmetric(horizontal: 15.w).expanded(),
_buildUser().width(width * 0.25).decorated(
border: Border.all(
color: theme.colorScheme.primary,