feat:超市数据库

This commit is contained in:
dzc committed 2025-03-17 12:07:11 +08:00
1 parent 9a98ac8e1c
commit fa4bb78f8b
25 files changed
+307 -185

No files matched your search

+3 -3
View File
@@ -121,7 +121,7 @@ class CanteenProductController extends GetxController with OrderMixin {
}
// 点击商品
void doProduct(ProductEntity current) async {
void doProduct(CanteenSpuEntity current) async {
final target = shopCardList.firstWhereOrNull((e) {
return e.productServiceUniqueCode == current.serviceUniqueCode;
});
@@ -248,12 +248,12 @@ class CanteenProductController extends GetxController with OrderMixin {
Future<void> _getDefaultProduct() async {
final sysType = appSetting.sysType.name;
final productDao = appC.dataBase.getProductDao;
List<ProductEntity> list = await productDao.getDefault(
List<CanteenSpuEntity> list = await productDao.getDefault(
sysType,
hourType.value.code,
);
if (ObjectUtil.isEmptyList(list)) return;
for (final ProductEntity v in list) {
for (final CanteenSpuEntity v in list) {
final shopCard = shopCardList.firstWhereOrNull((i) {
return int.tryParse(i.productServiceUniqueCode) == v.id;
});
+37 -20
View File
@@ -17,21 +17,39 @@ class CanteenProductPage extends GetView<CanteenProductController> {
final context = Get.context!;
final theme = FTheme.of(context);
return <Widget>[
appBack(
context,
height: headerHeight,
onTap: () => Get.offAndToNamed(RouteNames.panel),
),
Obx(
() => orderRowClassify(
<Widget>[
appBack(
context,
classifyList: controller.classifyList,
currentTabIndex: controller.currentTabIndex,
onChange: (tabIndex) => controller.doTab(tabIndex),
height: headerHeight,
onTap: () => Get.offAndToNamed(RouteNames.panel),
),
).scrollable(scrollDirection: Axis.horizontal).expanded(),
appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w),
].toRow();
Obx(
() => orderRowClassify(
context,
classifyList: controller.classifyList,
currentTabIndex: controller.currentTabIndex,
onChange: (tabIndex) => controller.doTab(tabIndex),
),
).scrollable(scrollDirection: Axis.horizontal).expanded(),
appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w),
].toRow(),
FDivider(
style: theme.dividerStyles.horizontalStyle.copyWith(
padding: EdgeInsets.zero,
),
),
].toColumn().decorated(
color: theme.colorScheme.background,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 2),
blurRadius: 6,
spreadRadius: 0,
),
],
);
;
}
// 商品
@@ -47,13 +65,13 @@ class CanteenProductPage extends GetView<CanteenProductController> {
return Obx(
() => ListView.builder(
padding: EdgeInsets.zero,
itemCount: controller.productClassifyList.length,
itemCount: controller.classifyList.length,
itemBuilder: (context, index) {
if (ObjectUtil.isEmpty(controller.productClassifyList) ||
if (ObjectUtil.isEmpty(controller.classifyList) ||
ObjectUtil.isEmpty(controller.productList)) {
return const SizedBox.shrink();
}
final current = controller.productClassifyList[index];
final current = controller.classifyList[index].serviceUniqueCode;
final currentStr = controller.classifyList
.firstWhereOrNull((v) => v.serviceUniqueCode == current);
final currentList = controller.productList
@@ -79,7 +97,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
/// 商品项
Widget _buildProductItem(
BuildContext context, {
required List<ProductEntity> productList,
required List<CanteenSpuEntity> productList,
required double productSpacing,
required Size productSize,
String? title = "",
@@ -212,6 +230,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
final width = context.width;
final theme = FTheme.of(context);
return <Widget>[
SizedBox(width: 15.w),
_buildProduct().expanded(),
SizedBox(width: 15.w),
_buildUser().width(width * 0.25).decorated(
@@ -232,9 +251,7 @@ class CanteenProductPage extends GetView<CanteenProductController> {
id: "canteen_product",
builder: (_) {
return FScaffold(
header: _buildHeader(height.h)
.height(height.h)
.padding(vertical: 30.h, horizontal: 10.w),
header: _buildHeader(height.h).height(height.h).paddingVertical(30.h),
content: _buildView(),
contentPad: true,
resizeToAvoidBottomInset: false,
+1 -1
View File
@@ -22,7 +22,7 @@ class FaceManageController extends GetxController {
RxInt pageSize = RxInt(15);
final TextEditingController usernameC = TextEditingController();
final usernameC = TextEditingController();
late StreamSubscription mqUpdateListen;
@@ -10,7 +10,7 @@ import 'package:pj_supermarket_cloud/common/index.dart';
class ProductManageController extends GetxController {
static const _tag = "商品管理 Controller";
RxList<ProductEntity> productList = <ProductEntity>[].obs;
RxList<CanteenSpuEntity> productList = <CanteenSpuEntity>[].obs;
ProductHourType hourType = ProductHourType.MORNING;
@@ -110,7 +110,7 @@ class ProductManageController extends GetxController {
}
// 切换是否默认
Future<void> trigger(ProductEntity v) async {
Future<void> trigger(CanteenSpuEntity v) async {
try {
final isSure = await appMessageDialog(
Get.context!,
@@ -123,7 +123,7 @@ class ProductManageController extends GetxController {
);
final app = Get.find<AppControl>();
final productDao = app.dataBase.getProductDao;
final editObj = ProductEntity.fromJson(v.toJson());
final editObj = CanteenSpuEntity.fromJson(v.toJson());
editObj.isDefault = !editObj.isDefault;
await productDao.edit(
editObj.isDefault,
@@ -1,4 +1,5 @@
import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_subscreen_plugin/flutter_subscreen_plugin.dart';
import 'package:get/get.dart';
@@ -12,6 +13,8 @@ class SupermarketOrderController extends GetxController with OrderMixin {
final appC = Get.find<AppControl>();
final selfCodeC = TextEditingController();
late SysSetting appSetting;
RxInt currentPage = RxInt(1);
@@ -43,6 +46,7 @@ class SupermarketOrderController extends GetxController with OrderMixin {
// 读卡器
appC.serialCardManage.readerClose();
appC.serialCardManage.close();
selfCodeC.dispose();
}
Future<void> _initState() async {
@@ -54,6 +58,7 @@ class SupermarketOrderController extends GetxController with OrderMixin {
// 打开副屏
SubScreenPlugin.sendMsgToViceScreen(SubScreenAction.jumpSubPage.name);
// 组件初始化
hourType.value = ProductHourType.TOTAL;
sysType = SysType.SUPERMARKET;
_listenPayTypeSelectCallback();
// 获取分类和商品
+38 -8
View File
@@ -33,7 +33,38 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
onChange: (tabIndex) => controller.doTab(tabIndex),
),
).scrollable(scrollDirection: Axis.horizontal).expanded(),
].toRow();
<Widget>[
FTextField(
controller: controller.selfCodeC,
hint: '请输入自编码',
maxLines: 1,
).width(300.w),
SizedBox(width: 10.w),
FButton(
prefix: FIcon(
FAssets.icons.search,
size: theme.typography.base.fontSize,
),
label: Text(
'搜索',
style: theme.typography.base.copyWith(
color: theme.colorScheme.secondary,
),
),
onPress: () => controller.doPage(),
),
].toRow().padding(horizontal: 10.w),
].toRow(crossAxisAlignment: CrossAxisAlignment.center).decorated(
color: theme.colorScheme.background,
boxShadow: [
BoxShadow(
color: Colors.black.withOpacity(0.1),
offset: const Offset(0, 2),
blurRadius: 6,
spreadRadius: 0,
),
],
);
}
// **************************************************************************
@@ -46,7 +77,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
Widget _buildProductItem(
BuildContext context, {
required List<ProductEntity> productList,
required List<CanteenSpuEntity> productList,
required double productSpacing,
required Size productSize,
String? title = "",
@@ -65,13 +96,13 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
double itemHeight = (maxHeight - (runSpacing + 30) * 3) / 3;
return ListView.builder(
padding: EdgeInsets.zero,
itemCount: controller.productClassifyList.length,
itemCount: controller.classifyList.length,
itemBuilder: (context, index) {
if (ObjectUtil.isEmpty(controller.productClassifyList) ||
if (ObjectUtil.isEmpty(controller.classifyList) ||
ObjectUtil.isEmpty(controller.productList)) {
return const SizedBox.shrink();
}
final current = controller.productClassifyList[index];
final current = controller.classifyList[index].serviceUniqueCode;
final currentStr = controller.classifyList
.firstWhereOrNull((v) => v.serviceUniqueCode == current);
final currentList = controller.productList
@@ -188,6 +219,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
final width = context.width;
final theme = FTheme.of(context);
return <Widget>[
SizedBox(width: 15.w),
_buildProductArea().expanded(),
SizedBox(width: 15.w),
_buildUser().width(width * 0.25).decorated(
@@ -208,9 +240,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
id: "supermarket_order",
builder: (_) {
return FScaffold(
header: _buildHeader(height.h)
.height(height.h)
.padding(vertical: 30.h, horizontal: 10.w),
header: _buildHeader(height.h).height(height.h).paddingVertical(30.h),
content: _buildView(context),
contentPad: true,
resizeToAvoidBottomInset: false,