feat:交易记录、日期组建

This commit is contained in:
dzc committed 2025-03-11 18:04:58 +08:00
1 parent 08ad1c2d81
commit 88e73ad950
32 files changed
+672 -279

No files matched your search

+149 -9
View File
@@ -1,15 +1,155 @@
import 'package:common_utils/common_utils.dart';
import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:forui/forui.dart';
import 'package:get/get.dart';
import 'package:syncfusion_flutter_datepicker/datepicker.dart';
Widget appDatePicer(
BuildContext context,
) {
return FCalendar(
controller: FCalendarController.range(
initialSelection: (DateTime(2024, 7, 17), DateTime(2024, 7, 20)),
import 'package:pj_supermarket_cloud/common/index.dart';
Widget appDatePicker(
BuildContext context, {
required Function(List<DateTime>?) onChnage,
required List<DateTime>? datetimeRange,
}) {
final theme = FTheme.of(context);
String detail = "请选择";
if (!ObjectUtil.isEmpty(datetimeRange)) {
final sartStr = DateUtil.formatDate(
datetimeRange![0],
format: DateFormats.y_mo_d,
);
final endStr = DateUtil.formatDate(
datetimeRange[1],
format: DateFormats.y_mo_d,
);
detail = "$sartStr-$endStr";
}
return FTile(
prefixIcon: FIcon(
FAssets.icons.calendar,
size: theme.typography.xl.fontSize,
),
suffixIcon: FIcon(
FAssets.icons.chevronsUpDown,
size: theme.typography.sm.fontSize,
),
title: const SizedBox.shrink(),
details: Text(
detail,
style: theme.typography.base,
),
onPress: () async {
final result = await appShowDatePicker(
context,
datetimeRange: datetimeRange,
);
onChnage(result);
},
);
}
Future<List<DateTime>?> appShowDatePicker(
BuildContext context, {
List<DateTime>? datetimeRange,
}) async {
final theme = FTheme.of(context);
final width = context.width;
final height = context.height;
// 默认时间为当天
DateTime startTIme = DateTime.now();
DateTime endTime = DateTime.now().add(const Duration(days: 1));
if (!ObjectUtil.isEmptyList(datetimeRange)) {
startTIme = datetimeRange![0];
endTime = datetimeRange[1];
}
List<DateTime> slectDateTime = [];
return await showAdaptiveDialog<List<DateTime>?>(
context: context,
builder: (context) => FDialog(
style: theme.dialogStyle.copyWith(
insetPadding: EdgeInsets.zero,
maxWidth: width * 0.6,
minWidth: width * 0.6,
horizontalStyle: theme.dialogStyle.horizontalStyle.copyWith(
padding: EdgeInsets.all(20.w),
),
),
direction: Axis.horizontal,
title: const SizedBox.shrink(),
body: SfDateRangePicker(
onSelectionChanged: (date) {
if (date.value is PickerDateRange) {
final v = date.value as PickerDateRange;
if (v.startDate == null || v.endDate == null) {
return;
}
slectDateTime = [v.startDate!, v.endDate!];
}
},
initialSelectedDates: [startTIme, endTime],
selectionMode: DateRangePickerSelectionMode.range,
headerHeight: 60.h,
todayHighlightColor: theme.colorScheme.primary,
backgroundColor: theme.colorScheme.background,
headerStyle: DateRangePickerHeaderStyle(
textStyle: theme.typography.xl,
textAlign: TextAlign.center,
backgroundColor: theme.colorScheme.background,
),
selectionColor: theme.colorScheme.primary,
startRangeSelectionColor: theme.colorScheme.primary,
endRangeSelectionColor: theme.colorScheme.primary,
rangeSelectionColor: theme.colorScheme.mutedForeground,
selectionTextStyle: theme.typography.sm.copyWith(
color: theme.colorScheme.secondary,
),
rangeTextStyle: theme.typography.sm,
monthCellStyle: DateRangePickerMonthCellStyle(
textStyle: theme.typography.sm,
todayTextStyle: theme.typography.sm,
weekendTextStyle: theme.typography.sm,
),
monthViewSettings: DateRangePickerMonthViewSettings(
viewHeaderHeight: 50.h,
showWeekNumber: true,
weekNumberStyle: DateRangePickerWeekNumberStyle(
textStyle: theme.typography.sm,
backgroundColor: theme.colorScheme.mutedForeground,
),
viewHeaderStyle: DateRangePickerViewHeaderStyle(
textStyle: theme.typography.base,
),
),
).width(width).height(height * 0.6),
actions: [
FButton(
label: Text(
"确定",
style: theme.typography.xl.copyWith(
color: theme.colorScheme.secondary,
),
),
onPress: () {
if (ObjectUtil.isEmptyList(slectDateTime)) {
Toast.error(msg: "请选择日期范围");
return;
}
Navigator.of(context).pop(slectDateTime);
},
).width(200.w),
SizedBox(width: 30.w),
FButton(
style: FButtonStyle.destructive,
label: Text(
"取消",
style: theme.typography.xl.copyWith(
color: theme.colorScheme.secondary,
),
),
onPress: () => Navigator.of(context).pop(null),
).width(200.w),
],
),
start: DateTime(2024),
today: DateTime(2024, 7, 15),
end: DateTime(2030),
);
}
@@ -28,13 +28,14 @@ Future<bool> appMessageDialog(BuildContext context, String msg) async {
label: Text('取消', style: theme.typography.base),
onPress: () => Navigator.of(context).pop(false)),
FButton(
label: Text(
'确定',
style: theme.typography.base.copyWith(
color: theme.colorScheme.secondary,
),
label: Text(
'确定',
style: theme.typography.base.copyWith(
color: theme.colorScheme.secondary,
),
onPress: () => Navigator.of(context).pop(true)),
),
onPress: () => Navigator.of(context).pop(true),
),
],
),
);
+1 -1
View File
@@ -16,7 +16,7 @@ Widget appPage(
return <Widget>[
<Widget>[
Text(
"共 $total 条",
"每页$pageSize条,共$total条",
style: theme.typography.lg.copyWith(
fontWeight: theme.typography.xl8.fontWeight,
color: theme.colorScheme.primary,
@@ -122,9 +122,6 @@ mixin OrderMixin {
Future<void> getProduct({
String classifyCode = "-1",
}) async {
if (hourType.value != appController.hourType.value) {
hourType.value = appController.hourType.value;
}
final list = await appController.dataBase.getProductDao.getAll(
classifyCode,
hourType.value.code,
@@ -38,12 +38,17 @@ class SelectPayTypeDialogController extends GetxController {
final app = Get.find<AppControl>();
final payTypeRadioC = FRadioSelectGroupController<OrderPayDisplayType>();
Rxn<ServiceUser?> payUser = Rxn(null);
Rxn<OrderPayType> orderPayType = Rxn(OrderPayType.face);
Rxn<OrderPayDisplayType> orderPayDisplayType = Rxn(OrderPayDisplayType.face);
RxList<OrderPayDisplayType> usePayDisplayTypeList =
<OrderPayDisplayType>[].obs;
Rxn<OrderType> orderType = Rxn(OrderType.below);
RxBool isRecognition = RxBool(false);
@@ -59,6 +64,34 @@ class SelectPayTypeDialogController extends GetxController {
// 人脸识别回调锁
bool _faceCallbackLock = false;
@override
void onInit() async {
super.onInit();
final appSetting = await AppSettingTool.getSysSetting();
if (appSetting.defaultPayDisplayType != null) {
payTypeRadioC.value = {appSetting.defaultPayDisplayType!};
}
if (!ObjectUtil.isEmptyList(appSetting.usePayDisplayType)) {
usePayDisplayTypeList.value = appSetting.usePayDisplayType!;
}
// 监听支付方式变化
payTypeRadioC.addValueListener((v) {
final payType = OrderPayDisplayType.values.fromCode(
v.first.code,
);
if (payType == null || payType == orderPayDisplayType.value) {
return;
}
orderPayDisplayType.value = payType;
});
}
@override
void onClose() {
super.onClose();
payTypeRadioC.dispose();
}
_closeStatus() {
payUser.value = null;
isRecognition.value = false;
@@ -427,12 +460,6 @@ class SelectPayTypeDialogController extends GetxController {
Future<void> selectPayTypeDialog(BuildContext context) async {
final payTypeC = Get.find<SelectPayTypeDialogController>();
final payUser = payTypeC.payUser.value;
payTypeC.orderPayType.value = OrderPayType.face;
payTypeC.orderPayDisplayType.value = OrderPayDisplayType.face;
final controller = FRadioSelectGroupController<OrderPayDisplayType>(
value: payTypeC.orderPayDisplayType.value,
);
final theme = FTheme.of(context);
final screenWidth = context.screenWidth;
@@ -443,50 +470,59 @@ Future<void> selectPayTypeDialog(BuildContext context) async {
direction: Axis.vertical,
title: Text("选择支付方式", style: theme.typography.lg),
body: <Widget>[
FSelectGroup(
controller: controller,
style: theme.selectGroupStyle.copyWith(
labelLayoutStyle: theme.selectGroupStyle.labelLayoutStyle.copyWith(
childPadding: EdgeInsets.symmetric(
vertical: 10.h,
),
),
radioStyle: theme.selectGroupStyle.radioStyle.copyWith(
padding: EdgeInsets.symmetric(
vertical: 10.h,
),
),
),
items: OrderPayDisplayType.values
.map<FSelectGroupItem<OrderPayDisplayType>>(
(v) => FSelectGroupItem.radio(
value: v,
label: Text(
v.title,
style: theme.typography.xl,
),
Obx(
() => FSelectGroup(
controller: payTypeC.payTypeRadioC,
style: theme.selectGroupStyle.copyWith(
labelLayoutStyle:
theme.selectGroupStyle.labelLayoutStyle.copyWith(
childPadding: EdgeInsets.symmetric(
vertical: 10.h,
),
)
.toList(),
),
radioStyle: theme.selectGroupStyle.radioStyle.copyWith(
padding: EdgeInsets.symmetric(
vertical: 10.h,
),
),
),
items: payTypeC.usePayDisplayTypeList
.map<FSelectGroupItem<OrderPayDisplayType>>(
(v) => FSelectGroupItem.radio(
value: v,
label: Text(
v.title,
style: theme.typography.xl,
),
),
)
.toList(),
),
),
SizedBox(height: 20.h),
Obx(() {
final payTypeCode = payTypeC.orderPayDisplayType.value?.code;
if (payTypeCode == null) return const SizedBox.shrink();
final payType = payTypeC.orderPayDisplayType.value;
if (payType == null) return const SizedBox.shrink();
const baseMsg = "请点击开始识别按钮";
String msg = "";
SvgAsset icon = FAssets.icons.bird;
if (payTypeCode == "1") {
msg = "$baseMsg,并让用户扫描二维码";
icon = FAssets.icons.qrCode;
}
if (payTypeCode == "2") {
msg = "$baseMsg,并让用户刷饭卡";
icon = FAssets.icons.idCard;
}
if (payTypeCode == "3") {
msg = "$baseMsg,并让用户进行刷脸";
icon = FAssets.icons.scanFace;
switch (payType) {
case OrderPayDisplayType.qrCode:
msg = "$baseMsg,并让用户扫描二维码";
icon = FAssets.icons.qrCode;
break;
case OrderPayDisplayType.walletCard:
msg = "$baseMsg,并让用户刷饭卡";
icon = FAssets.icons.idCard;
break;
case OrderPayDisplayType.face:
msg = "$baseMsg,并让用户进行刷脸";
icon = FAssets.icons.scanFace;
break;
case OrderPayDisplayType.cash:
msg = "请打开钱箱,放入现金";
icon = FAssets.icons.circleDollarSign;
break;
}
return <Widget>[
FIcon(