From ab9ea614d58172df334e02c08f645880f470ec10 Mon Sep 17 00:00:00 2001 From: dzc <2388224167@qq.com> Date: Thu, 10 Apr 2025 14:56:17 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=BB=9F=E8=AE=A1=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../models/database/database_enum_models.dart | 15 +++ lib/common/models/page/panel_page_models.dart | 1 + lib/common/routers/names.dart | 3 + lib/common/routers/pages.dart | 8 ++ lib/pages/canteen_order_total/controller.dart | 27 ++++ lib/pages/canteen_order_total/index.dart | 4 + lib/pages/canteen_order_total/view.dart | 122 ++++++++++++++++++ lib/pages/index.dart | 1 + lib/pages/panel/controller.dart | 6 + 9 files changed, 187 insertions(+) create mode 100644 lib/pages/canteen_order_total/controller.dart create mode 100644 lib/pages/canteen_order_total/index.dart create mode 100644 lib/pages/canteen_order_total/view.dart diff --git a/lib/common/models/database/database_enum_models.dart b/lib/common/models/database/database_enum_models.dart index 2f21c56..dbe6eeb 100644 --- a/lib/common/models/database/database_enum_models.dart +++ b/lib/common/models/database/database_enum_models.dart @@ -1,3 +1,4 @@ +import 'package:forui/forui.dart'; import 'package:pj_supermarket_cloud/common/index.dart'; /// 设备类型 @@ -109,6 +110,20 @@ enum ProductHourType implements BaseEnum { @override final String title; +// 使用 getter 方法动态获取图标 + SvgAsset get icon { + switch (this) { + case ProductHourType.TOTAL: + return FAssets.icons.calendar; + case ProductHourType.MORNING: + return FAssets.icons.sunrise; + case ProductHourType.NOON: + return FAssets.icons.sun; + case ProductHourType.NIGHT: + return FAssets.icons.sunMoon; + } + } + const ProductHourType(this.code, this.title); } diff --git a/lib/common/models/page/panel_page_models.dart b/lib/common/models/page/panel_page_models.dart index 62053e2..fddc512 100644 --- a/lib/common/models/page/panel_page_models.dart +++ b/lib/common/models/page/panel_page_models.dart @@ -17,6 +17,7 @@ enum PanelType implements BaseEnum { canteenReserve("25", "预定"), takeFood("30", "取餐"), orderHistory("40", "交易查询"), + canteenOrderTotal("45", "交易查询"), setting("50", "设置"), cardActive("60", "开卡管理"), printer("70", "打印测试"), diff --git a/lib/common/routers/names.dart b/lib/common/routers/names.dart index 398e161..67cddb6 100644 --- a/lib/common/routers/names.dart +++ b/lib/common/routers/names.dart @@ -20,6 +20,9 @@ class RouteNames { /// 食堂预定 static const canteenReserve = '/canteen_reserve'; + /// 食堂交易统计 + static const canteenOrderTotal = '/canteen_order_total'; + /// 交易查询 static const orderHistory = '/order_history'; diff --git a/lib/common/routers/pages.dart b/lib/common/routers/pages.dart index 60102af..3cec8aa 100644 --- a/lib/common/routers/pages.dart +++ b/lib/common/routers/pages.dart @@ -57,6 +57,14 @@ class RoutePages { Get.lazyPut(() => TakeFoodController()); }), ), + GetPage( + name: RouteNames.canteenOrderTotal, + page: () => const CanteenOrderTotalPage(), + binding: BindingsBuilder(() { + Get.lazyPut(() => PanelController()); + Get.lazyPut(() => CanteenOrderTotalController()); + }), + ), GetPage( name: RouteNames.orderHistory, page: () => const OrderHistoryPage(), diff --git a/lib/pages/canteen_order_total/controller.dart b/lib/pages/canteen_order_total/controller.dart new file mode 100644 index 0000000..a32b777 --- /dev/null +++ b/lib/pages/canteen_order_total/controller.dart @@ -0,0 +1,27 @@ +import 'package:get/get.dart'; + +class CanteenOrderTotalController extends GetxController { + CanteenOrderTotalController(); + + _initData() { + update(["canteen_order_total"]); + } + + void onTap() {} + + @override + void onInit() { + super.onInit(); + } + + @override + void onReady() { + super.onReady(); + _initData(); + } + + @override + void onClose() { + super.onClose(); + } +} diff --git a/lib/pages/canteen_order_total/index.dart b/lib/pages/canteen_order_total/index.dart new file mode 100644 index 0000000..e9ab46a --- /dev/null +++ b/lib/pages/canteen_order_total/index.dart @@ -0,0 +1,4 @@ +library canteen_order_total; + +export './controller.dart'; +export './view.dart'; diff --git a/lib/pages/canteen_order_total/view.dart b/lib/pages/canteen_order_total/view.dart new file mode 100644 index 0000000..a4f4d59 --- /dev/null +++ b/lib/pages/canteen_order_total/view.dart @@ -0,0 +1,122 @@ +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:pj_supermarket_cloud/common/index.dart'; + +import 'index.dart'; + +class CanteenOrderTotalPage extends GetView { + const CanteenOrderTotalPage({super.key}); + + // 主视图 + Widget _buildView(BuildContext context) { + return [ + _buildHeaderTotal(context), + _buildCharts(context), + ].toColumn(); + } + + // headerTotal + Widget _buildHeaderTotal(BuildContext context) { + return [ + _buildHeaderTotalItem(context, title: "本日交易统计"), + _buildHeaderTotalItem(context, title: "本周交易统计"), + _buildHeaderTotalItem(context, title: "本月交易统计"), + _buildHeaderTotalItem(context, title: "本年易统计"), + ].toRow(mainAxisAlignment: MainAxisAlignment.spaceAround); + } + + // headerTotalItem + Widget _buildHeaderTotalItem( + BuildContext context, { + required String title, + }) { + final theme = FTheme.of(context); + return [ + Text(title, style: theme.typography.xl.copyWith(height: 1)), + SizedBox(height: 15.h), + ProductHourType.values + .map((v) { + if (v.code == "-1") return const SizedBox.shrink(); + return [ + FIcon( + v.icon, + size: theme.typography.xl2.fontSize, + ), + SizedBox(width: 5.w), + Text( + v.title, + maxLines: 1, + style: theme.typography.xl.copyWith(height: 1), + ), + FDivider( + axis: Axis.vertical, + style: theme.dividerStyles.verticalStyle.copyWith( + color: theme.colorScheme.primary, + padding: EdgeInsets.zero, + ), + ), + SizedBox(width: 5.w), + Text( + "共用餐", + maxLines: 1, + style: theme.typography.xl.copyWith(height: 1), + ), + Text( + "次", + maxLines: 1, + style: theme.typography.xl.copyWith(height: 1), + ), + SizedBox(width: 5.w), + Text( + "总金额", + maxLines: 1, + style: theme.typography.xl.copyWith(height: 1), + ), + ] + .toRow() + .paddingSymmetric(horizontal: 10.w, vertical: 5.w) + .marginSymmetric(vertical: 10.h) + .decorated( + border: Border.all( + color: theme.colorScheme.border, + width: 1, + ), + color: theme.colorScheme.background, + borderRadius: theme.style.borderRadius, + ) + .marginSymmetric(vertical: 10.h); + }) + .toList() + .toColumn(), + ].toColumn().paddingSymmetric(horizontal: 20.w, vertical: 15.w).decorated( + border: Border.all( + color: theme.colorScheme.border, + width: 1, + ), + color: theme.colorScheme.secondary, + borderRadius: theme.style.borderRadius / 2, + ); + } + + Widget _buildCharts(BuildContext context) { + return SizedBox.shrink(); + } + + @override + Widget build(BuildContext context) { + return GetBuilder( + init: CanteenOrderTotalController(), + id: "canteen_order_total", + builder: (_) { + return FScaffold( + header: appDefaultNav(context, title: "交易统计"), + content: _buildView(context).marginOnly(top: 20.h), + resizeToAvoidBottomInset: false, + ); + }, + ); + } +} diff --git a/lib/pages/index.dart b/lib/pages/index.dart index 0241825..aeac3b9 100644 --- a/lib/pages/index.dart +++ b/lib/pages/index.dart @@ -1,5 +1,6 @@ library; +export './canteen_order_total/index.dart'; export './canteen_product/index.dart'; export './canteen_reserve/index.dart'; export './card_active/index.dart'; diff --git a/lib/pages/panel/controller.dart b/lib/pages/panel/controller.dart index bb45ece..caee2a1 100644 --- a/lib/pages/panel/controller.dart +++ b/lib/pages/panel/controller.dart @@ -17,6 +17,7 @@ class PanelController extends GetxController { PanelItem(title: "预定", visible: false, type: PanelType.canteenReserve), PanelItem(title: "取餐", visible: false, type: PanelType.takeFood), PanelItem(title: "交易查询", visible: true, type: PanelType.orderHistory), + PanelItem(title: "交易统计", visible: false, type: PanelType.canteenOrderTotal), PanelItem(title: "开卡管理", visible: true, type: PanelType.cardActive), PanelItem(title: "设置", visible: true, type: PanelType.setting), PanelItem(title: "退出登录", visible: true, type: PanelType.logout), @@ -27,6 +28,7 @@ class PanelController extends GetxController { PanelType.canteenOrder, PanelType.takeFood, PanelType.canteenReserve, + PanelType.canteenOrderTotal, ]; final supermarketMenus = [ @@ -103,6 +105,10 @@ class PanelController extends GetxController { if (!await _checkIsBind()) return; Get.toNamed(RouteNames.orderHistory); break; + case PanelType.canteenOrderTotal: + if (!await _checkIsBind()) return; + Get.toNamed(RouteNames.canteenOrderTotal); + break; case PanelType.setting: if (AppSysTool.isProd()) { final flag = await settingPasswordDialog(Get.context!);