diff --git a/lib/common/models/api/product_api_models.dart b/lib/common/models/api/product_api_models.dart index 7f23f24..b2fa71f 100644 --- a/lib/common/models/api/product_api_models.dart +++ b/lib/common/models/api/product_api_models.dart @@ -301,7 +301,7 @@ class ServiceSupermarketSkuPackage { /// 零售价/单位分 int? retailPrice; - /// 促销价 + /// 促销价/单位分 int? promotionPrice; ServiceSupermarketSkuPackage({ diff --git a/lib/common/services/database/dao/supermarket_sku_dao.dart b/lib/common/services/database/dao/supermarket_sku_dao.dart index 16222db..b680803 100644 --- a/lib/common/services/database/dao/supermarket_sku_dao.dart +++ b/lib/common/services/database/dao/supermarket_sku_dao.dart @@ -25,4 +25,48 @@ abstract class SupermarketSkuDao { @insert Future batchSave(List changeList); + + @Query(""" + SELECT DISTINCT COUNT(0) FROM supermarket_sku + INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0 + """) + Future getCount(); + + @Query(''' + SELECT + supermarket_sku.id, + supermarket_sku.serviceUniqueCode, + supermarket_sku.spuId, + supermarket_spu.productCode, + supermarket_spu.classifyServiceUniqueCode, + supermarket_spu.productName, + supermarket_spu.picUrl, + supermarket_spu.productNature, + supermarket_spu.salesCount, + supermarket_spu.stock, + supermarket_spu.sort, + supermarket_spu.createTime, + supermarket_spu.updateTime, + supermarket_spu.delFlag, + supermarket_sku.barCode, + supermarket_sku.promotionPrice, + supermarket_sku.purchasePrice, + supermarket_sku.retailPrice, + supermarket_sku.spec, + supermarket_sku.packageNum, + supermarket_sku.unit, + supermarket_sku.packageNum + FROM supermarket_sku + INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0 + WHERE + 1 = 1 + AND (:barCode = '-1' OR supermarket_sku.barCode = :barCode) + ORDER BY supermarket_sku.spuId + LIMIT :pageSize OFFSET :offset + ''') + Future> getAllPage( + String barCode, + int pageSize, + int offset, + ); } diff --git a/lib/common/services/database/database.g.dart b/lib/common/services/database/database.g.dart index 335cd42..4176e64 100644 --- a/lib/common/services/database/database.g.dart +++ b/lib/common/services/database/database.g.dart @@ -122,7 +122,7 @@ class _$AppDatabase extends AppDatabase { await database.execute( 'CREATE TABLE IF NOT EXISTS `supermarket_sku` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `spuId` TEXT NOT NULL, `barCode` TEXT NOT NULL, `spec` TEXT NOT NULL, `unit` TEXT NOT NULL, `packageNum` INTEGER NOT NULL, `purchasePrice` INTEGER NOT NULL, `retailPrice` INTEGER NOT NULL, `promotionPrice` INTEGER NOT NULL)'); await database.execute( - 'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `productCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productNature` TEXT NOT NULL, `unit` TEXT NOT NULL, `spec` TEXT NOT NULL, `picUrl` TEXT, `stock` REAL, `salesCount` REAL, `retailPrice` INTEGER NOT NULL, `promotionPrice` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)'); + 'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `productCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productNature` TEXT NOT NULL, `barCode` TEXT, `packageNum` INTEGER NOT NULL, `unit` TEXT NOT NULL, `spec` TEXT NOT NULL, `picUrl` TEXT, `stock` REAL, `salesCount` REAL, `purchasePrice` INTEGER NOT NULL, `retailPrice` INTEGER NOT NULL, `promotionPrice` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)'); await database.execute( 'CREATE TABLE IF NOT EXISTS `supermarket_code` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `spuId` TEXT NOT NULL, `unitId` TEXT NOT NULL, `barCode` TEXT NOT NULL)'); await database.execute( @@ -638,7 +638,8 @@ class _$SupermarketSkuDao extends SupermarketSkuDao { _$SupermarketSkuDao( this.database, this.changeListener, - ) : _supermarketSkuEntityInsertionAdapter = InsertionAdapter( + ) : _queryAdapter = QueryAdapter(database), + _supermarketSkuEntityInsertionAdapter = InsertionAdapter( database, 'supermarket_sku', (SupermarketSkuEntity item) => { @@ -658,9 +659,30 @@ class _$SupermarketSkuDao extends SupermarketSkuDao { final StreamController changeListener; + final QueryAdapter _queryAdapter; + final InsertionAdapter _supermarketSkuEntityInsertionAdapter; + @override + Future getCount() async { + return _queryAdapter.query( + 'SELECT DISTINCT COUNT(0) FROM supermarket_sku INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0', + mapper: (Map row) => row.values.first as int); + } + + @override + Future> getAllPage( + String barCode, + int pageSize, + int offset, + ) async { + return _queryAdapter.queryList( + 'SELECT supermarket_sku.id, supermarket_sku.serviceUniqueCode, supermarket_sku.spuId, supermarket_spu.productCode, supermarket_spu.classifyServiceUniqueCode, supermarket_spu.productName, supermarket_spu.picUrl, supermarket_spu.productNature, supermarket_spu.salesCount, supermarket_spu.stock, supermarket_spu.sort, supermarket_spu.createTime, supermarket_spu.updateTime, supermarket_spu.delFlag, supermarket_sku.barCode, supermarket_sku.promotionPrice, supermarket_sku.purchasePrice, supermarket_sku.retailPrice, supermarket_sku.spec, supermarket_sku.packageNum, supermarket_sku.unit, supermarket_sku.packageNum FROM supermarket_sku INNER JOIN supermarket_spu ON supermarket_sku.spuId = supermarket_spu.serviceUniqueCode AND supermarket_spu.delFlag = 0 WHERE 1 = 1 AND (?1 = \'-1\' OR supermarket_sku.barCode = ?1) ORDER BY supermarket_sku.spuId LIMIT ?2 OFFSET ?3', + mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + arguments: [barCode, pageSize, offset]); + } + @override Future batchSave(List changeList) async { await _supermarketSkuEntityInsertionAdapter.insertList( @@ -684,11 +706,14 @@ class _$SupermarketSpuDao extends SupermarketSpuDao { 'productName': item.productName, 'productNature': _supermarketNatureConverter.encode(item.productNature), + 'barCode': item.barCode, + 'packageNum': item.packageNum, 'unit': item.unit, 'spec': item.spec, 'picUrl': item.picUrl, 'stock': item.stock, 'salesCount': item.salesCount, + 'purchasePrice': item.purchasePrice, 'retailPrice': item.retailPrice, 'promotionPrice': item.promotionPrice, 'sort': item.sort, @@ -708,11 +733,14 @@ class _$SupermarketSpuDao extends SupermarketSpuDao { 'productName': item.productName, 'productNature': _supermarketNatureConverter.encode(item.productNature), + 'barCode': item.barCode, + 'packageNum': item.packageNum, 'unit': item.unit, 'spec': item.spec, 'picUrl': item.picUrl, 'stock': item.stock, 'salesCount': item.salesCount, + 'purchasePrice': item.purchasePrice, 'retailPrice': item.retailPrice, 'promotionPrice': item.promotionPrice, 'sort': item.sort, @@ -737,7 +765,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao { String classifyServiceUniqueCode) async { return _queryAdapter.queryList( 'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE supermarket_spu.delFlag = 0 AND (?1 = \'-1\' OR supermarket_spu.classifyServiceUniqueCode = ?1) ORDER BY classify.sort', - mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), arguments: [classifyServiceUniqueCode]); } @@ -756,7 +784,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao { ) async { return _queryAdapter.queryList( 'SELECT supermarket_spu.* FROM supermarket_spu LEFT JOIN classify ON supermarket_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE supermarket_spu.delFlag = 0 AND (?1 = \'-1\' OR supermarket_spu.classifyServiceUniqueCode = ?1) ORDER BY classify.sort LIMIT ?2 OFFSET ?3', - mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), arguments: [classifyServiceUniqueCode, pageSize, offset]); } @@ -764,7 +792,7 @@ class _$SupermarketSpuDao extends SupermarketSpuDao { Future getByCode(String code) async { return _queryAdapter.query( 'SELECT * FROM supermarket_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1', - mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), + mapper: (Map row) => SupermarketSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, productCode: row['productCode'] as String, productName: row['productName'] as String, productNature: _supermarketNatureConverter.decode(row['productNature'] as String), barCode: row['barCode'] as String?, packageNum: row['packageNum'] as int, unit: row['unit'] as String, spec: row['spec'] as String, picUrl: row['picUrl'] as String?, stock: row['stock'] as double?, salesCount: row['salesCount'] as double?, purchasePrice: row['purchasePrice'] as int, retailPrice: row['retailPrice'] as int, promotionPrice: row['promotionPrice'] as int, sort: row['sort'] as int, createTime: _dateTimeConverter.decode(row['createTime'] as String), updateTime: _dateTimeConverter.decode(row['updateTime'] as String), delFlag: _boolConverter.decode(row['delFlag'] as int)), arguments: [code]); } diff --git a/lib/common/services/database/entity/supermarket_spu_entity.dart b/lib/common/services/database/entity/supermarket_spu_entity.dart index f9d06ed..eb9c790 100644 --- a/lib/common/services/database/entity/supermarket_spu_entity.dart +++ b/lib/common/services/database/entity/supermarket_spu_entity.dart @@ -26,6 +26,12 @@ class SupermarketSpuEntity { /// 商品性质(字典) SupermarketNature productNature; + /// 条码 + String? barCode; + + /// 内装数量 + int packageNum; + /// 单位 String unit; @@ -41,10 +47,13 @@ class SupermarketSpuEntity { /// 销量 double? salesCount; - /// 零售价 + /// 进价/单位分 + int purchasePrice; + + /// 零售价/单位分 int retailPrice; - /// 促销价 + /// 促销价/单位分 int promotionPrice; /// 排序 倒序排列 @@ -66,11 +75,14 @@ class SupermarketSpuEntity { required this.productCode, required this.productName, required this.productNature, + this.barCode, + required this.packageNum, required this.unit, required this.spec, required this.picUrl, required this.stock, required this.salesCount, + required this.purchasePrice, required this.retailPrice, required this.promotionPrice, required this.sort, diff --git a/lib/common/services/database/entity/supermarket_spu_entity.g.dart b/lib/common/services/database/entity/supermarket_spu_entity.g.dart index 36d4676..ddd1b45 100644 --- a/lib/common/services/database/entity/supermarket_spu_entity.g.dart +++ b/lib/common/services/database/entity/supermarket_spu_entity.g.dart @@ -16,11 +16,14 @@ SupermarketSpuEntity _$SupermarketSpuEntityFromJson( productName: json['productName'] as String, productNature: $enumDecode(_$SupermarketNatureEnumMap, json['productNature']), + barCode: json['barCode'] as String?, + packageNum: (json['packageNum'] as num).toInt(), unit: json['unit'] as String, spec: json['spec'] as String, picUrl: json['picUrl'] as String?, stock: (json['stock'] as num?)?.toDouble(), salesCount: (json['salesCount'] as num?)?.toDouble(), + purchasePrice: (json['purchasePrice'] as num).toInt(), retailPrice: (json['retailPrice'] as num).toInt(), promotionPrice: (json['promotionPrice'] as num).toInt(), sort: (json['sort'] as num).toInt(), @@ -38,11 +41,14 @@ Map _$SupermarketSpuEntityToJson( 'productCode': instance.productCode, 'productName': instance.productName, 'productNature': _$SupermarketNatureEnumMap[instance.productNature]!, + 'barCode': instance.barCode, + 'packageNum': instance.packageNum, 'unit': instance.unit, 'spec': instance.spec, 'picUrl': instance.picUrl, 'stock': instance.stock, 'salesCount': instance.salesCount, + 'purchasePrice': instance.purchasePrice, 'retailPrice': instance.retailPrice, 'promotionPrice': instance.promotionPrice, 'sort': instance.sort, diff --git a/lib/common/utils/sync/sync_product_tool.dart b/lib/common/utils/sync/sync_product_tool.dart index 6408a6e..a5dd916 100644 --- a/lib/common/utils/sync/sync_product_tool.dart +++ b/lib/common/utils/sync/sync_product_tool.dart @@ -353,12 +353,15 @@ abstract class SyncProductTool { productName: v.productCode ?? "", productNature: SupermarketNature.values.fromCode(v.productNature) ?? SupermarketNature.DEFAULT, + barCode: "", + packageNum: 0, unit: v.productCode ?? "", spec: v.productCode ?? "", picUrl: v.picUrl ?? "", stock: v.stock ?? 0, salesCount: v.salesCount != null ? double.tryParse(v.salesCount.toString()) : 0, + purchasePrice: 0, retailPrice: v.retailPrice ?? 0, promotionPrice: v.promotionPrice ?? 0, sort: 0, diff --git a/lib/common/widgets/app/app_img.dart b/lib/common/widgets/app/app_img.dart index f30b80d..3e7e3b5 100644 --- a/lib/common/widgets/app/app_img.dart +++ b/lib/common/widgets/app/app_img.dart @@ -26,7 +26,7 @@ Widget appNetworkImg( FAssets.icons.globeLock, color: theme.colorScheme.error, size: theme.typography.base.fontSize, - ).width(imgWidth * 0.5).height(imgHeight * 0.5); + ).center().width(imgWidth).height(imgWidth); }, ); } @@ -49,7 +49,7 @@ Widget appFileImg( FAssets.icons.globeLock, color: theme.colorScheme.error, size: theme.typography.base.fontSize, - ).width(imgWidth * 0.5).height(imgHeight * 0.5); + ).center().width(imgWidth).height(imgHeight); }, ); } diff --git a/lib/common/widgets/index.dart b/lib/common/widgets/index.dart index dcd03d8..d768376 100644 --- a/lib/common/widgets/index.dart +++ b/lib/common/widgets/index.dart @@ -20,7 +20,9 @@ export './card/card_common.dart'; export './order/mixin/order_mixin.dart'; export './order/select_pay_type_dialog.dart'; export './order/steelyard_container.dart'; -export 'order/order_common.dart'; +export './order/order_caneen_common.dart'; +export './order/order_common.dart'; +export './order/order_supermarket_common.dart'; export './setting/setting_password_dialog.dart'; diff --git a/lib/common/widgets/order/order_caneen_common.dart b/lib/common/widgets/order/order_caneen_common.dart new file mode 100644 index 0000000..0396685 --- /dev/null +++ b/lib/common/widgets/order/order_caneen_common.dart @@ -0,0 +1,30 @@ +import 'package:ducafe_ui_core/ducafe_ui_core.dart'; +import 'package:flutter/material.dart'; +import 'package:forui/forui.dart'; + +import 'package:pj_supermarket_cloud/common/index.dart'; + +/// 商品卡片 +Widget orderCaneenSpuCard( + BuildContext context, { + String? image = "", + String name = "", + num price = 0.0, +}) { + final theme = FTheme.of(context); + return FCard( + style: theme.cardStyle.copyWith( + contentStyle: theme.cardStyle.contentStyle.copyWith( + padding: EdgeInsets.all(0), + ), + ), + image: appImg(image, width: double.infinity, height: 150.h), + subtitle: [ + Text(name, style: theme.typography.lg), + SizedBox(height: 5.h), + appPrice(context, price), + ] + .toColumn(crossAxisAlignment: CrossAxisAlignment.center) + .width(double.infinity), + ).width(double.infinity); +} diff --git a/lib/common/widgets/order/order_common.dart b/lib/common/widgets/order/order_common.dart index 63038de..329633b 100644 --- a/lib/common/widgets/order/order_common.dart +++ b/lib/common/widgets/order/order_common.dart @@ -4,31 +4,6 @@ import 'package:forui/forui.dart'; import 'package:pj_supermarket_cloud/common/index.dart'; -/// 商品卡片 -Widget orderProductCard( - BuildContext context, { - String? image = "", - String name = "", - num price = 0.0, -}) { - final theme = FTheme.of(context); - return FCard( - style: theme.cardStyle.copyWith( - contentStyle: theme.cardStyle.contentStyle.copyWith( - padding: EdgeInsets.all(0), - ), - ), - image: appImg(image, width: double.infinity, height: 150.h), - subtitle: [ - Text(name, style: theme.typography.lg), - SizedBox(height: 5.h), - appPrice(context, price), - ] - .toColumn(crossAxisAlignment: CrossAxisAlignment.center) - .width(double.infinity), - ).width(double.infinity); -} - /// 菜品总价 /// 额外支付 /// 实际扣款 diff --git a/lib/common/widgets/order/order_supermarket_common.dart b/lib/common/widgets/order/order_supermarket_common.dart new file mode 100644 index 0000000..04728d5 --- /dev/null +++ b/lib/common/widgets/order/order_supermarket_common.dart @@ -0,0 +1,61 @@ +import 'package:ducafe_ui_core/ducafe_ui_core.dart'; +import 'package:flutter/material.dart'; +import 'package:forui/forui.dart'; + +import 'package:pj_supermarket_cloud/common/index.dart'; + +Widget orderSupermarketSpuCard( + BuildContext context, { + required SupermarketSpuEntity supermarketSpu, +}) { + final theme = FTheme.of(context); + final textStyle = theme.typography.sm.copyWith( + color: theme.colorScheme.primary, + ); + return FCard( + style: theme.cardStyle.copyWith( + contentStyle: theme.cardStyle.contentStyle.copyWith( + padding: EdgeInsets.all(0), + ), + ), + image: appImg(supermarketSpu.picUrl, width: double.infinity, height: 100.h), + subtitle: [ + Text(supermarketSpu.productName, style: theme.typography.xl), + SizedBox(height: 5.h), + FBadge( + style: FBadgeStyle.secondary, + label: Text( + supermarketSpu.productNature.title, + style: textStyle, + ), + ), + [ + Text("零售价:", style: textStyle), + appPrice(context, supermarketSpu.retailPrice), + ].toRow(mainAxisAlignment: MainAxisAlignment.center), + [ + Text("促销价:", style: textStyle), + appPrice(context, supermarketSpu.promotionPrice), + ].toRow(mainAxisAlignment: MainAxisAlignment.center), + [ + Text("货号:", style: textStyle), + Text(supermarketSpu.productCode, style: textStyle), + ].toRow(mainAxisAlignment: MainAxisAlignment.center), + [ + Text("辅助条码:", style: textStyle), + Text(supermarketSpu.barCode ?? "", style: textStyle), + ].toRow(mainAxisAlignment: MainAxisAlignment.center), + [ + Text("包装单位:", style: textStyle), + Text("${supermarketSpu.packageNum}", style: textStyle), + Text("/"), + Text(supermarketSpu.unit, style: textStyle), + ].toRow(mainAxisAlignment: MainAxisAlignment.center), + ] + .toColumn( + crossAxisAlignment: CrossAxisAlignment.center, + ) + .padding(horizontal: 10.w) + .width(double.infinity), + ).width(double.infinity); +} diff --git a/lib/pages/canteen_product/view.dart b/lib/pages/canteen_product/view.dart index 7a78f3d..f59e06a 100644 --- a/lib/pages/canteen_product/view.dart +++ b/lib/pages/canteen_product/view.dart @@ -115,7 +115,7 @@ class CanteenProductPage extends GetView { : const SizedBox.shrink(), productList .map( - (v) => orderProductCard( + (v) => orderCaneenSpuCard( context, image: v.image, name: v.name, diff --git a/lib/pages/card_active/view.dart b/lib/pages/card_active/view.dart index 3db7488..6429f64 100644 --- a/lib/pages/card_active/view.dart +++ b/lib/pages/card_active/view.dart @@ -21,7 +21,7 @@ class CardActivePage extends GetView { height: height, onTap: () => Get.offAndToNamed(RouteNames.panel), ), - Spacer(), + const Spacer(), FButton( prefix: FIcon( FAssets.icons.idCard, diff --git a/lib/pages/setting/view.dart b/lib/pages/setting/view.dart index 8ca1b85..13d59ee 100644 --- a/lib/pages/setting/view.dart +++ b/lib/pages/setting/view.dart @@ -132,18 +132,19 @@ class SettingPage extends GetView { id: "setting", builder: (_) { return FScaffold( - header: FHeader.nested( - title: Text("设置"), - prefixActions: [ - FHeaderAction.back(onPress: Get.back), - ], - style: theme.headerStyle.nestedStyle.copyWith( - titleTextStyle: theme.typography.lg, - actionStyle: theme.headerStyle.nestedStyle.actionStyle.copyWith( - size: theme.typography.xl2.fontSize, - ), - ), - ).height(height * 0.1), + // header: FHeader.nested( + // title: Text("设置"), + // prefixActions: [ + // FHeaderAction.back(onPress: Get.back), + // ], + // style: theme.headerStyle.nestedStyle.copyWith( + // titleTextStyle: theme.typography.lg, + // actionStyle: theme.headerStyle.nestedStyle.actionStyle.copyWith( + // size: theme.typography.xl2.fontSize, + // ), + // ), + // ).height(height * 0.1), + header: SizedBox(height: 40.h), content: _buildView(), contentPad: true, resizeToAvoidBottomInset: false, diff --git a/lib/pages/setting/widgets/setting_face.dart b/lib/pages/setting/widgets/setting_face.dart index 6154f19..a001e94 100644 --- a/lib/pages/setting/widgets/setting_face.dart +++ b/lib/pages/setting/widgets/setting_face.dart @@ -149,6 +149,8 @@ class FaceManageController extends GetxController { Future doPage({int? page}) async { if (page != null) currentPage.value = page; + // 收起键盘 + FocusManager.instance.primaryFocus?.unfocus(); await getFaceList(isLoading: true); } @@ -182,55 +184,52 @@ Widget buildFaceSearch(BuildContext context) { final faceC = Get.find(); final theme = FTheme.of(context); return [ - [ - FTextField( - controller: faceC.usernameC, - hint: '请输入姓名', - maxLines: 1, - ).width(300.w), - FButton( - label: Text( - '搜索', - style: theme.typography.base.copyWith( - color: theme.colorScheme.secondary, - ), + const Spacer(), + FTextField( + controller: faceC.usernameC, + hint: '请输入姓名', + maxLines: 1, + ).width(300.w), + FButton( + label: Text( + '搜索', + style: theme.typography.base.copyWith( + color: theme.colorScheme.secondary, ), - onPress: () => faceC.doPage(), ), - ].toRowSpace(space: 10.w).expanded(), - [ - FButton( - label: Text( - '删除全部人脸', - style: theme.typography.base.copyWith( - color: theme.colorScheme.secondary, - ), + onPress: () => faceC.doPage(), + ), + FButton( + label: Text( + '删除全部人脸', + style: theme.typography.base.copyWith( + color: theme.colorScheme.secondary, ), - style: FButtonStyle.destructive, - onPress: () => faceC.delAllFace(), ), - FButton( - label: Text( - '同步本部门人脸', - style: theme.typography.base.copyWith( - color: theme.colorScheme.primary, - ), + style: FButtonStyle.destructive, + onPress: () => faceC.delAllFace(), + ), + FButton( + label: Text( + '同步本部门人脸', + style: theme.typography.base.copyWith( + color: theme.colorScheme.primary, ), - style: FButtonStyle.outline, - onPress: () => faceC.asyncFace(isAll: false), ), - FButton( - label: Text( - '同步全部人脸', - style: theme.typography.base.copyWith( - color: theme.colorScheme.primary, - ), + style: FButtonStyle.outline, + onPress: () => faceC.asyncFace(isAll: false), + ), + FButton( + label: Text( + '同步全部人脸', + style: theme.typography.base.copyWith( + color: theme.colorScheme.primary, ), - style: FButtonStyle.outline, - onPress: () => faceC.asyncFace(isAll: true), ), - ].toRowSpace(space: 10.w), - ].toRow(); + style: FButtonStyle.outline, + onPress: () => faceC.asyncFace(isAll: true), + ), + ].toRowSpace(space: 20.w); } /// 列表 diff --git a/lib/pages/setting/widgets/setting_product.dart b/lib/pages/setting/widgets/setting_product.dart index 6ec8d08..eae12fc 100644 --- a/lib/pages/setting/widgets/setting_product.dart +++ b/lib/pages/setting/widgets/setting_product.dart @@ -23,9 +23,12 @@ class ProductManageController extends GetxController { ProductHourType hourType = ProductHourType.MORNING; + // 自编码 + final selfCodeC = TextEditingController(); + RxInt currentPage = RxInt(1); RxInt totalPage = RxInt(0); - RxInt pageSize = RxInt(24); + RxInt pageSize = RxInt(18); final hourTypeC = FRadioSelectGroupController( value: ProductHourType.MORNING.code, @@ -51,6 +54,7 @@ class ProductManageController extends GetxController { void onClose() { super.onClose(); hourTypeC.dispose(); + selfCodeC.dispose(); } // 更新商品和分类 @@ -81,7 +85,7 @@ class ProductManageController extends GetxController { if (sysType == SysType.SUPERMARKET) { // 超市 - final supermarketSpuDao = appC.dataBase.getSupermarketSpuDao; + final supermarketSpuDao = appC.dataBase.getSupermarketSkuDao; final findCount = await supermarketSpuDao.getCount(); totalPage.value = findCount ?? 0; final list = await supermarketSpuDao.getAllPage( @@ -117,6 +121,17 @@ class ProductManageController extends GetxController { /// 搜索 Future doPage({int? page}) async { if (page != null) currentPage.value = page; + // 收起键盘 + FocusManager.instance.primaryFocus?.unfocus(); + await getProductList(isLoading: true); + } + + /// 重置 + Future doReset() async { + currentPage.value = 1; + selfCodeC.clear(); + // 收起键盘 + FocusManager.instance.primaryFocus?.unfocus(); await getProductList(isLoading: true); } @@ -160,8 +175,30 @@ Widget _buildSearch(BuildContext context) { ).offstage( offstage: productC.sysType.value != SysType.CANTEEN, ), - ).width(300.w) + ).width(300.w), ].toRow().expanded(), + Obx( + () => FTextField( + controller: productC.selfCodeC, + hint: '请输入自编码', + maxLines: 1, + ).offstage( + offstage: productC.sysType.value != SysType.SUPERMARKET, + ), + ).width(300.w), + FButton( + prefix: FIcon( + FAssets.icons.ban, + size: theme.typography.base.fontSize, + ), + label: Text( + '重置', + style: theme.typography.base.copyWith( + color: theme.colorScheme.secondary, + ), + ), + onPress: () => productC.doReset(), + ), FButton( prefix: FIcon( FAssets.icons.search, @@ -175,7 +212,6 @@ Widget _buildSearch(BuildContext context) { ), onPress: () => productC.doPage(), ), - SizedBox(width: 20.w), FButton( label: Text( '更新商品和分类', @@ -185,7 +221,7 @@ Widget _buildSearch(BuildContext context) { ), onPress: () => productC.updateProductAndClassify(), ), - ].toRow(); + ].toRowSpace(space: 20.w); } // 食堂列表 @@ -235,7 +271,7 @@ Widget _buildSupermarketList(BuildContext context) { return Obx( () => GridView.builder( gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( - crossAxisCount: 8, + crossAxisCount: 6, mainAxisSpacing: 10.w, crossAxisSpacing: 10.w, childAspectRatio: 0.7, @@ -243,6 +279,7 @@ Widget _buildSupermarketList(BuildContext context) { itemCount: productC.supermarketSpuList.length, itemBuilder: (BuildContext context, int index) { final v = productC.supermarketSpuList[index]; + return orderSupermarketSpuCard(context, supermarketSpu: v); }, ), ); @@ -269,6 +306,6 @@ Widget settingProduct(BuildContext context) { total: productC.totalPage.value, onPageChanged: (pageNo) => productC.doPage(page: pageNo), ), - ), + ) ].toColumnSpace(space: 10.h); } diff --git a/lib/pages/supermarket_order/view.dart b/lib/pages/supermarket_order/view.dart index b41a1a2..4815d82 100644 --- a/lib/pages/supermarket_order/view.dart +++ b/lib/pages/supermarket_order/view.dart @@ -173,7 +173,7 @@ class SupermarketOrderPage extends GetView { style: theme.typography.xl2, ).alignLeft(), ].toColumn(), - Spacer(), + const Spacer(), [ Obx( () => orderAllPrice(