feat:称中页面
This commit is contained in:
1 parent
de2f5e14b6
commit
16826ad5b2
6 files changed
+185
-55
No files matched your search
@@ -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);
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user