diff --git a/lib/common/api/product_api.dart b/lib/common/api/product_api.dart index cc0c813..0da0bce 100644 --- a/lib/common/api/product_api.dart +++ b/lib/common/api/product_api.dart @@ -34,7 +34,7 @@ abstract class ProductApi { dynamic pa, ) async { final res = await HttpManage().dio.get( - "/supermarket-classify", + "/supermarket/supermarketCategory/simpleAll", queryParameters: pa, ); if (res.data == null) return null; @@ -46,7 +46,7 @@ abstract class ProductApi { /// 超市商品 static Future?> supermarketProduct(dynamic pa) async { final res = await HttpManage().dio.get( - "/supermarket-product", + "supermarket/supermarketSpu/ad/selectListAll", queryParameters: pa, ); if (res.data == null) return null; diff --git a/lib/common/services/database/dao/product_dao.dart b/lib/common/services/database/dao/canteen_spu_dao.dart similarity index 52% rename from lib/common/services/database/dao/product_dao.dart rename to lib/common/services/database/dao/canteen_spu_dao.dart index 6aa54d0..6cc7fe5 100644 --- a/lib/common/services/database/dao/product_dao.dart +++ b/lib/common/services/database/dao/canteen_spu_dao.dart @@ -7,10 +7,10 @@ import 'package:pj_supermarket_cloud/common/index.dart'; @dao abstract class ProductDao { @insert - Future save(ProductEntity entity); + Future save(CanteenSpuEntity entity); @insert - Future batchSave(List entitys); + Future batchSave(List entitys); Future delByIds(List codes) async { if (ObjectUtil.isEmptyList(codes)) return -1; @@ -18,26 +18,22 @@ abstract class ProductDao { final database = app.dataBase.database; final placeholders = List.generate(codes.length, (index) => '?').join(', '); final sql = ''' - UPDATE product SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders) + UPDATE canteen_spu SET delFlag = 1 WHERE serviceUniqueCode IN ($placeholders) AND (sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) '''; return await database.rawUpdate(sql, [...codes]); } @Query(''' - DELETE FROM product - WHERE - (:sysType = '-1' OR sysType = :sysType) + DELETE FROM canteen_spu ''') - Future delAllByType( - String sysType, - ); + Future delAllByType(); @delete - Future batchDel(List entitys); + Future batchDel(List entitys); @Query(""" - UPDATE product SET isDefault = :isDefault + UPDATE canteen_spu SET isDefault = :isDefault WHERE delFlag = 0 AND serviceUniqueCode = :uniqueCode AND hourType = :hourType @@ -46,10 +42,10 @@ abstract class ProductDao { Future edit(bool isDefault, String uniqueCode, String hourType); @update - Future batchEdit(List entitys); + Future batchEdit(List entitys); @Query(""" - SELECT DISTINCT COUNT(0) FROM product + SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE delFlag = 0 AND (:sysType = '-1' OR sysType = :sysType) @@ -62,42 +58,42 @@ abstract class ProductDao { ); @Query(''' - SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = :code + SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = :code ''') - Future getByCode(String code); + Future getByCode(String code); @Query(''' - SELECT product.* - FROM product - LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode + SELECT canteen_spu.* + FROM canteen_spu + LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE - product.delFlag = 0 AND - (:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND + canteen_spu.delFlag = 0 AND + (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND (:hourType = '-1' OR INSTR(',' || hourType || ',', ',' || :hourType || ',') > 0) AND - (:sysType = '-1' OR product.sysType = :sysType) - ORDER BY classify.sort, product.price + (:sysType = '-1' OR canteen_spu.sysType = :sysType) + ORDER BY classify.sort, canteen_spu.price ''') - Future> getAll( + Future> getAll( String classifyServiceUniqueCode, String hourType, String sysType, ); - // GROUP BY product.serviceUniqueCode + // GROUP BY canteen_spu.serviceUniqueCode @Query(''' - SELECT product.* - FROM product - LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode + SELECT canteen_spu.* + FROM canteen_spu + LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE - product.delFlag = 0 AND - (:classifyServiceUniqueCode = '-1' OR product.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND - (:hourType = '-1' OR INSTR(',' || product.hourType || ',', ',' || :hourType || ',') > 0) AND - (:sysType = '-1' OR product.sysType = :sysType) AND - (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', product.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) - ORDER BY classify.sort, classify.id, product.price + canteen_spu.delFlag = 0 AND + (:classifyServiceUniqueCode = '-1' OR canteen_spu.classifyServiceUniqueCode = :classifyServiceUniqueCode) AND + (:hourType = '-1' OR INSTR(',' || canteen_spu.hourType || ',', ',' || :hourType || ',') > 0) AND + (:sysType = '-1' OR canteen_spu.sysType = :sysType) AND + (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', canteen_spu.saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) + ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT :pageSize OFFSET :offset ''') - Future> getAllPage( + Future> getAllPage( String classifyServiceUniqueCode, String hourType, String sysType, @@ -106,7 +102,7 @@ abstract class ProductDao { ); @Query(''' - SELECT * FROM product + SELECT * FROM canteen_spu WHERE delFlag = 0 AND isDefault = 1 @@ -114,5 +110,5 @@ abstract class ProductDao { AND (:hourType = '-1' OR hourType = :hourType) AND (:sysType = 'CANTEEN' OR strftime('%Y-%m-%d', saleDate) = strftime('%Y-%m-%d', 'now', 'localtime')) ''') - Future> getDefault(String sysType, String hourType); + Future> getDefault(String sysType, String hourType); } diff --git a/lib/common/services/database/dao/supermarket_sku_dao.dart b/lib/common/services/database/dao/supermarket_sku_dao.dart new file mode 100644 index 0000000..fbd010b --- /dev/null +++ b/lib/common/services/database/dao/supermarket_sku_dao.dart @@ -0,0 +1,6 @@ +import 'package:floor/floor.dart'; + +import 'package:pj_supermarket_cloud/common/index.dart'; + +@dao +abstract class SupermarketSkuDao {} diff --git a/lib/common/services/database/dao/supermarket_spu_dao.dart b/lib/common/services/database/dao/supermarket_spu_dao.dart new file mode 100644 index 0000000..6a6639f --- /dev/null +++ b/lib/common/services/database/dao/supermarket_spu_dao.dart @@ -0,0 +1,6 @@ +import 'package:floor/floor.dart'; + +import 'package:pj_supermarket_cloud/common/index.dart'; + +@dao +abstract class SupermarketSpuDao {} diff --git a/lib/common/services/database/database.dart b/lib/common/services/database/database.dart index e4f4dbd..879e30e 100644 --- a/lib/common/services/database/database.dart +++ b/lib/common/services/database/database.dart @@ -9,7 +9,9 @@ part 'database.g.dart'; const entities = [ OrderEntity, - ProductEntity, + CanteenSpuEntity, + SupermarketSkuEntity, + SupermarketSpuEntity, ShopCardEntity, ClassifyEntity, PrintHistoryEntity, diff --git a/lib/common/services/database/database.g.dart b/lib/common/services/database/database.g.dart index 38e5f1b..bad8aad 100644 --- a/lib/common/services/database/database.g.dart +++ b/lib/common/services/database/database.g.dart @@ -112,7 +112,11 @@ class _$AppDatabase extends AppDatabase { await database.execute( 'CREATE TABLE IF NOT EXISTS `order_record` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `uniqueCode` TEXT NOT NULL, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `userCode` TEXT NOT NULL, `username` TEXT, `hourType` TEXT, `price` INTEGER NOT NULL, `extraPrice` INTEGER NOT NULL, `payPrice` INTEGER NOT NULL, `walletId` TEXT, `orderSourceTypeId` TEXT, `type` TEXT NOT NULL, `status` TEXT NOT NULL, `payType` TEXT NOT NULL, `productDesc` TEXT, `count` INTEGER NOT NULL, `weight` REAL NOT NULL, `payTime` TEXT, `createTime` TEXT NOT NULL)'); await database.execute( - 'CREATE TABLE IF NOT EXISTS `product` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `sysType` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` INTEGER NOT NULL, `sort` INTEGER NOT NULL, `createTime` TEXT NOT NULL, `updateTime` TEXT NOT NULL, `delFlag` INTEGER NOT NULL)'); + 'CREATE TABLE IF NOT EXISTS `canteen_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `serviceUniqueCode` TEXT NOT NULL, `classifyServiceUniqueCode` TEXT NOT NULL, `hourType` INTEGER, `saleDate` TEXT, `name` TEXT NOT NULL, `price` INTEGER NOT NULL, `image` TEXT, `isDefault` INTEGER NOT NULL, `status` 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_sku` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)'); + await database.execute( + 'CREATE TABLE IF NOT EXISTS `supermarket_spu` (`id` INTEGER PRIMARY KEY AUTOINCREMENT)'); await database.execute( 'CREATE TABLE IF NOT EXISTS `shop_card` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `orderId` INTEGER NOT NULL, `productServiceUniqueCode` TEXT NOT NULL, `productName` TEXT NOT NULL, `productPic` TEXT NOT NULL, `productPrice` INTEGER NOT NULL, `productNumber` INTEGER NOT NULL, `productWidget` REAL NOT NULL, `totalPrice` INTEGER NOT NULL)'); await database.execute( @@ -443,13 +447,12 @@ class _$ProductDao extends ProductDao { this.database, this.changeListener, ) : _queryAdapter = QueryAdapter(database), - _productEntityInsertionAdapter = InsertionAdapter( + _canteenSpuEntityInsertionAdapter = InsertionAdapter( database, - 'product', - (ProductEntity item) => { + 'canteen_spu', + (CanteenSpuEntity item) => { 'id': item.id, 'serviceUniqueCode': item.serviceUniqueCode, - 'sysType': _sysTypeConverter.encode(item.sysType), 'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'hourType': item.hourType?.index, 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), @@ -463,14 +466,13 @@ class _$ProductDao extends ProductDao { 'updateTime': _dateTimeConverter.encode(item.updateTime), 'delFlag': _boolConverter.encode(item.delFlag) }), - _productEntityUpdateAdapter = UpdateAdapter( + _canteenSpuEntityUpdateAdapter = UpdateAdapter( database, - 'product', + 'canteen_spu', ['id'], - (ProductEntity item) => { + (CanteenSpuEntity item) => { 'id': item.id, 'serviceUniqueCode': item.serviceUniqueCode, - 'sysType': _sysTypeConverter.encode(item.sysType), 'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'hourType': item.hourType?.index, 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), @@ -484,14 +486,13 @@ class _$ProductDao extends ProductDao { 'updateTime': _dateTimeConverter.encode(item.updateTime), 'delFlag': _boolConverter.encode(item.delFlag) }), - _productEntityDeletionAdapter = DeletionAdapter( + _canteenSpuEntityDeletionAdapter = DeletionAdapter( database, - 'product', + 'canteen_spu', ['id'], - (ProductEntity item) => { + (CanteenSpuEntity item) => { 'id': item.id, 'serviceUniqueCode': item.serviceUniqueCode, - 'sysType': _sysTypeConverter.encode(item.sysType), 'classifyServiceUniqueCode': item.classifyServiceUniqueCode, 'hourType': item.hourType?.index, 'saleDate': _dateTimeEmptyConverter.encode(item.saleDate), @@ -512,17 +513,15 @@ class _$ProductDao extends ProductDao { final QueryAdapter _queryAdapter; - final InsertionAdapter _productEntityInsertionAdapter; + final InsertionAdapter _canteenSpuEntityInsertionAdapter; - final UpdateAdapter _productEntityUpdateAdapter; + final UpdateAdapter _canteenSpuEntityUpdateAdapter; - final DeletionAdapter _productEntityDeletionAdapter; + final DeletionAdapter _canteenSpuEntityDeletionAdapter; @override - Future delAllByType(String sysType) async { - await _queryAdapter.queryNoReturn( - 'DELETE FROM product WHERE (?1 = \'-1\' OR sysType = ?1)', - arguments: [sysType]); + Future delAllByType() async { + await _queryAdapter.queryNoReturn('DELETE FROM canteen_spu'); } @override @@ -532,7 +531,7 @@ class _$ProductDao extends ProductDao { String hourType, ) async { await _queryAdapter.queryNoReturn( - 'UPDATE product SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', + 'UPDATE canteen_spu SET isDefault = ?1 WHERE delFlag = 0 AND serviceUniqueCode = ?2 AND hourType = ?3 AND (sysType = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', arguments: [_boolConverter.encode(isDefault), uniqueCode, hourType]); } @@ -542,51 +541,33 @@ class _$ProductDao extends ProductDao { String hourType, ) async { return _queryAdapter.query( - 'SELECT DISTINCT COUNT(0) FROM product WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', + 'SELECT DISTINCT COUNT(0) FROM canteen_spu WHERE delFlag = 0 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', mapper: (Map row) => row.values.first as int, arguments: [sysType, hourType]); } @override - Future getByCode(String code) async { + Future getByCode(String code) async { return _queryAdapter.query( - 'SELECT * FROM product WHERE delFlag = 0 AND serviceUniqueCode = ?1', - mapper: (Map row) => ProductEntity( - id: row['id'] as int?, - serviceUniqueCode: row['serviceUniqueCode'] as String, - sysType: _sysTypeConverter.decode(row['sysType'] as String), - classifyServiceUniqueCode: - row['classifyServiceUniqueCode'] as String, - hourType: row['hourType'] == null - ? null - : ProductHourType.values[row['hourType'] as int], - saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), - name: row['name'] as String, - price: row['price'] as int, - image: row['image'] as String?, - isDefault: _boolConverter.decode(row['isDefault'] as int), - status: row['status'] 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)), + 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND serviceUniqueCode = ?1', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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]); } @override - Future> getAll( + Future> getAll( String classifyServiceUniqueCode, String hourType, String sysType, ) async { return _queryAdapter.queryList( - 'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) ORDER BY classify.sort, product.price', - mapper: (Map row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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)), + 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR canteen_spu.sysType = ?3) ORDER BY classify.sort, canteen_spu.price', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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, hourType, sysType]); } @override - Future> getAllPage( + Future> getAllPage( String classifyServiceUniqueCode, String hourType, String sysType, @@ -594,8 +575,8 @@ class _$ProductDao extends ProductDao { int offset, ) async { return _queryAdapter.queryList( - 'SELECT product.* FROM product LEFT JOIN classify ON product.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE product.delFlag = 0 AND (?1 = \'-1\' OR product.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || product.hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR product.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', product.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, product.price LIMIT ?4 OFFSET ?5', - mapper: (Map row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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)), + 'SELECT canteen_spu.* FROM canteen_spu LEFT JOIN classify ON canteen_spu.classifyServiceUniqueCode = classify.serviceUniqueCode WHERE canteen_spu.delFlag = 0 AND (?1 = \'-1\' OR canteen_spu.classifyServiceUniqueCode = ?1) AND (?2 = \'-1\' OR INSTR(\',\' || canteen_spu.hourType || \',\', \',\' || ?2 || \',\') > 0) AND (?3 = \'-1\' OR canteen_spu.sysType = ?3) AND (?3 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', canteen_spu.saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\')) ORDER BY classify.sort, classify.id, canteen_spu.price LIMIT ?4 OFFSET ?5', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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, hourType, @@ -606,37 +587,37 @@ class _$ProductDao extends ProductDao { } @override - Future> getDefault( + Future> getDefault( String sysType, String hourType, ) async { return _queryAdapter.queryList( - 'SELECT * FROM product WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', - mapper: (Map row) => ProductEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, sysType: _sysTypeConverter.decode(row['sysType'] as String), classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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)), + 'SELECT * FROM canteen_spu WHERE delFlag = 0 AND isDefault = 1 AND (?1 = \'-1\' OR sysType = ?1) AND (?2 = \'-1\' OR hourType = ?2) AND (?1 = \'CANTEEN\' OR strftime(\'%Y-%m-%d\', saleDate) = strftime(\'%Y-%m-%d\', \'now\', \'localtime\'))', + mapper: (Map row) => CanteenSpuEntity(id: row['id'] as int?, serviceUniqueCode: row['serviceUniqueCode'] as String, classifyServiceUniqueCode: row['classifyServiceUniqueCode'] as String, hourType: row['hourType'] == null ? null : ProductHourType.values[row['hourType'] as int], saleDate: _dateTimeEmptyConverter.decode(row['saleDate'] as String), name: row['name'] as String, price: row['price'] as int, image: row['image'] as String?, isDefault: _boolConverter.decode(row['isDefault'] as int), status: row['status'] 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: [sysType, hourType]); } @override - Future save(ProductEntity entity) async { - await _productEntityInsertionAdapter.insert( + Future save(CanteenSpuEntity entity) async { + await _canteenSpuEntityInsertionAdapter.insert( entity, OnConflictStrategy.abort); } @override - Future batchSave(List entitys) async { - await _productEntityInsertionAdapter.insertList( + Future batchSave(List entitys) async { + await _canteenSpuEntityInsertionAdapter.insertList( entitys, OnConflictStrategy.abort); } @override - Future batchEdit(List entitys) async { - await _productEntityUpdateAdapter.updateList( + Future batchEdit(List entitys) async { + await _canteenSpuEntityUpdateAdapter.updateList( entitys, OnConflictStrategy.abort); } @override - Future batchDel(List entitys) async { - await _productEntityDeletionAdapter.deleteList(entitys); + Future batchDel(List entitys) async { + await _canteenSpuEntityDeletionAdapter.deleteList(entitys); } } diff --git a/lib/common/services/database/entity/product_entity.dart b/lib/common/services/database/entity/canteen_spu_entity.dart similarity index 79% rename from lib/common/services/database/entity/product_entity.dart rename to lib/common/services/database/entity/canteen_spu_entity.dart index 00fd0ef..4071d03 100644 --- a/lib/common/services/database/entity/product_entity.dart +++ b/lib/common/services/database/entity/canteen_spu_entity.dart @@ -4,11 +4,11 @@ import 'package:json_annotation/json_annotation.dart'; import 'package:pj_supermarket_cloud/common/models/index.dart'; -part 'product_entity.g.dart'; +part 'canteen_spu_entity.g.dart'; @JsonSerializable() -@Entity(tableName: "product") -class ProductEntity extends Equatable { +@Entity(tableName: "canteen_spu") +class CanteenSpuEntity extends Equatable { /// 自增ID @PrimaryKey(autoGenerate: true) int? id; @@ -16,9 +16,6 @@ class ProductEntity extends Equatable { /// 服务端唯一标识 String serviceUniqueCode; - /// 平台类型 - SysType sysType; - /// 分类 serviceID String classifyServiceUniqueCode; @@ -55,10 +52,9 @@ class ProductEntity extends Equatable { /// 是否删除 bool delFlag; - ProductEntity({ + CanteenSpuEntity({ this.id, required this.serviceUniqueCode, - required this.sysType, required this.classifyServiceUniqueCode, this.hourType, this.saleDate, @@ -73,15 +69,14 @@ class ProductEntity extends Equatable { required this.delFlag, }); - factory ProductEntity.fromJson(Map json) => - _$ProductEntityFromJson(json); + factory CanteenSpuEntity.fromJson(Map json) => + _$CanteenSpuEntityFromJson(json); - Map toJson() => _$ProductEntityToJson(this); + Map toJson() => _$CanteenSpuEntityToJson(this); @override List get props => [ serviceUniqueCode, - sysType, classifyServiceUniqueCode, hourType, name, diff --git a/lib/common/services/database/entity/product_entity.g.dart b/lib/common/services/database/entity/canteen_spu_entity.g.dart similarity index 82% rename from lib/common/services/database/entity/product_entity.g.dart rename to lib/common/services/database/entity/canteen_spu_entity.g.dart index ec5bdf0..1e4029b 100644 --- a/lib/common/services/database/entity/product_entity.g.dart +++ b/lib/common/services/database/entity/canteen_spu_entity.g.dart @@ -1,16 +1,15 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'product_entity.dart'; +part of 'canteen_spu_entity.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -ProductEntity _$ProductEntityFromJson(Map json) => - ProductEntity( +CanteenSpuEntity _$CanteenSpuEntityFromJson(Map json) => + CanteenSpuEntity( id: (json['id'] as num?)?.toInt(), serviceUniqueCode: json['serviceUniqueCode'] as String, - sysType: $enumDecode(_$SysTypeEnumMap, json['sysType']), classifyServiceUniqueCode: json['classifyServiceUniqueCode'] as String, hourType: $enumDecodeNullable(_$ProductHourTypeEnumMap, json['hourType']), saleDate: json['saleDate'] == null @@ -27,11 +26,10 @@ ProductEntity _$ProductEntityFromJson(Map json) => delFlag: json['delFlag'] as bool, ); -Map _$ProductEntityToJson(ProductEntity instance) => +Map _$CanteenSpuEntityToJson(CanteenSpuEntity instance) => { 'id': instance.id, 'serviceUniqueCode': instance.serviceUniqueCode, - 'sysType': _$SysTypeEnumMap[instance.sysType]!, 'classifyServiceUniqueCode': instance.classifyServiceUniqueCode, 'hourType': _$ProductHourTypeEnumMap[instance.hourType], 'saleDate': instance.saleDate?.toIso8601String(), @@ -46,11 +44,6 @@ Map _$ProductEntityToJson(ProductEntity instance) => 'delFlag': instance.delFlag, }; -const _$SysTypeEnumMap = { - SysType.SUPERMARKET: 'SUPERMARKET', - SysType.CANTEEN: 'CANTEEN', -}; - const _$ProductHourTypeEnumMap = { ProductHourType.TOTAL: 'TOTAL', ProductHourType.MORNING: 'MORNING', diff --git a/lib/common/services/database/entity/supermarket_sku_entity.dart b/lib/common/services/database/entity/supermarket_sku_entity.dart new file mode 100644 index 0000000..7be9560 --- /dev/null +++ b/lib/common/services/database/entity/supermarket_sku_entity.dart @@ -0,0 +1,21 @@ +import 'package:floor/floor.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'supermarket_sku_entity.g.dart'; + +@JsonSerializable() +@Entity(tableName: "supermarket_sku") +class SupermarketSkuEntity { + /// 自增ID + @PrimaryKey(autoGenerate: true) + int? id; + + SupermarketSkuEntity({ + this.id, + }); + + factory SupermarketSkuEntity.fromJson(Map json) => + _$SupermarketSkuEntityFromJson(json); + + Map toJson() => _$SupermarketSkuEntityToJson(this); +} diff --git a/lib/common/services/database/entity/supermarket_sku_entity.g.dart b/lib/common/services/database/entity/supermarket_sku_entity.g.dart new file mode 100644 index 0000000..232051a --- /dev/null +++ b/lib/common/services/database/entity/supermarket_sku_entity.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'supermarket_sku_entity.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SupermarketSkuEntity _$SupermarketSkuEntityFromJson( + Map json) => + SupermarketSkuEntity( + id: (json['id'] as num?)?.toInt(), + ); + +Map _$SupermarketSkuEntityToJson( + SupermarketSkuEntity instance) => + { + 'id': instance.id, + }; diff --git a/lib/common/services/database/entity/supermarket_spu_entity.dart b/lib/common/services/database/entity/supermarket_spu_entity.dart new file mode 100644 index 0000000..662cb9e --- /dev/null +++ b/lib/common/services/database/entity/supermarket_spu_entity.dart @@ -0,0 +1,21 @@ +import 'package:floor/floor.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'supermarket_spu_entity.g.dart'; + +@JsonSerializable() +@Entity(tableName: "supermarket_spu") +class SupermarketSpuEntity { + /// 自增ID + @PrimaryKey(autoGenerate: true) + int? id; + + SupermarketSpuEntity({ + this.id, + }); + + factory SupermarketSpuEntity.fromJson(Map json) => + _$SupermarketSpuEntityFromJson(json); + + Map toJson() => _$SupermarketSpuEntityToJson(this); +} diff --git a/lib/common/services/database/entity/supermarket_spu_entity.g.dart b/lib/common/services/database/entity/supermarket_spu_entity.g.dart new file mode 100644 index 0000000..ad3329e --- /dev/null +++ b/lib/common/services/database/entity/supermarket_spu_entity.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'supermarket_spu_entity.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +SupermarketSpuEntity _$SupermarketSpuEntityFromJson( + Map json) => + SupermarketSpuEntity( + id: (json['id'] as num?)?.toInt(), + ); + +Map _$SupermarketSpuEntityToJson( + SupermarketSpuEntity instance) => + { + 'id': instance.id, + }; diff --git a/lib/common/services/index.dart b/lib/common/services/index.dart index 184e382..4e53e56 100644 --- a/lib/common/services/index.dart +++ b/lib/common/services/index.dart @@ -8,16 +8,20 @@ export './database/dao/classify_dao.dart'; export './database/dao/face_dao.dart'; export './database/dao/order_dao.dart'; export './database/dao/print_history_dao.dart'; -export './database/dao/product_dao.dart'; +export './database/dao/canteen_spu_dao.dart'; export './database/dao/setting_dao.dart'; export './database/dao/shop_card_dao.dart'; +export './database/dao/supermarket_sku_dao.dart'; +export './database/dao/supermarket_spu_dao.dart'; export './database/dao/user_dao.dart'; export './database/entity/classify_entity.dart'; export './database/entity/face_entity.dart'; export './database/entity/order_entity.dart'; export './database/entity/print_history_entity.dart'; -export './database/entity/product_entity.dart'; +export './database/entity/canteen_spu_entity.dart'; export './database/entity/setting_entity.dart'; export './database/entity/shop_card_entity.dart'; +export './database/entity/supermarket_sku_entity.dart'; +export './database/entity/supermarket_spu_entity.dart'; export './database/entity/user_entity.dart'; diff --git a/lib/common/utils/sync/sync_product_tool.dart b/lib/common/utils/sync/sync_product_tool.dart index 40a1573..a847df6 100644 --- a/lib/common/utils/sync/sync_product_tool.dart +++ b/lib/common/utils/sync/sync_product_tool.dart @@ -227,13 +227,12 @@ abstract class SyncProductTool { final app = Get.find(); final dataBase = app.dataBase; final productDao = dataBase.getProductDao; - List changeList = []; + List changeList = []; for (final v in list) { - ProductEntity item = ProductEntity( + CanteenSpuEntity item = CanteenSpuEntity( serviceUniqueCode: sysType == SysType.CANTEEN ? v.spuId.toString() : v.spuId.toString(), - sysType: sysType, classifyServiceUniqueCode: v.categoryId != null ? v.categoryId.toString() : "-1", name: v.name!, diff --git a/lib/common/widgets/app/app_back.dart b/lib/common/widgets/app/app_back.dart index 5f3d8bc..5c9ab50 100644 --- a/lib/common/widgets/app/app_back.dart +++ b/lib/common/widgets/app/app_back.dart @@ -12,5 +12,5 @@ Widget appBack( return FIcon( FAssets.icons.chevronLeft, size: theme.typography.xl4.fontSize, - ).alignLeft().width(height).onTap(() => onTap()); + ).center().width(height).height(height).onTap(() => onTap()); } diff --git a/lib/common/widgets/card/card_common.dart b/lib/common/widgets/card/card_common.dart index 9d5549d..98be402 100644 --- a/lib/common/widgets/card/card_common.dart +++ b/lib/common/widgets/card/card_common.dart @@ -1,4 +1,3 @@ -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'; diff --git a/lib/common/widgets/order/mixin/order_mixin.dart b/lib/common/widgets/order/mixin/order_mixin.dart index 77a2188..5b7a795 100644 --- a/lib/common/widgets/order/mixin/order_mixin.dart +++ b/lib/common/widgets/order/mixin/order_mixin.dart @@ -28,10 +28,7 @@ mixin OrderMixin { RxList classifyList = RxList([]); // 商品 - RxList productList = RxList([]); - - // 商品分类ids - RxList productClassifyList = RxList([]); + RxList productList = RxList([]); // 总价 RxInt totalPrice = RxInt(0); @@ -96,7 +93,6 @@ mixin OrderMixin { _sysType.name, hourType.value.code, ); - productClassifyList.value = list.map((v) => v.serviceUniqueCode).toList(); list.insert( 0, ClassifyEntity( @@ -123,7 +119,7 @@ mixin OrderMixin { ); productList.value = list; productList.refresh(); - productClassifyList.refresh(); + classifyList.refresh(); } // 创建本地订单 diff --git a/lib/common/widgets/order/order_common.dart b/lib/common/widgets/order/order_common.dart index 8a0482d..90500ee 100644 --- a/lib/common/widgets/order/order_common.dart +++ b/lib/common/widgets/order/order_common.dart @@ -160,20 +160,33 @@ Widget orderRowClassify( .map((v) { final target = classifyList[currentTabIndex]; final active = target.id == v.id; - return FButton( - style: active ? FButtonStyle.primary : FButtonStyle.secondary, - label: Text( - v.name, - textAlign: TextAlign.center, - maxLines: 1, - overflow: TextOverflow.ellipsis, - style: theme.typography.xl.copyWith( + return Text( + v.name, + textAlign: TextAlign.center, + maxLines: 1, + overflow: TextOverflow.ellipsis, + style: theme.typography.xl2.copyWith( + height: 1, + color: active + ? theme.colorScheme.background + : theme.colorScheme.primary, + ), + ) + .center() + .width(180.w) + .height(60.h) + .decorated( color: active - ? theme.colorScheme.secondary - : theme.colorScheme.primary, - ), - ).center().width(120.w), - onPress: () { + ? theme.colorScheme.primary + : theme.colorScheme.background, + border: Border.all( + color: theme.colorScheme.primary, + width: 1, + ), + borderRadius: theme.style.borderRadius / 2, + ) + .onTap( + () { final index = classifyList.indexWhere((i) => i.id == v.id); onChange(index); }, diff --git a/lib/common/widgets/order/steelyard_container.dart b/lib/common/widgets/order/steelyard_container.dart index 0501c98..1351aa4 100644 --- a/lib/common/widgets/order/steelyard_container.dart +++ b/lib/common/widgets/order/steelyard_container.dart @@ -22,7 +22,7 @@ class SteelyardController extends GetxController { final app = Get.find(); // 称重商品 - Rxn _widgetProduct = Rxn(null); + Rxn _widgetProduct = Rxn(null); // 重量 RxDouble widget = RxDouble(0); @@ -65,7 +65,7 @@ class SteelyardController extends GetxController { } // 打开称重 - bool open(ProductEntity current) { + bool open(CanteenSpuEntity current) { final isOpen = _openSerial(); if (!isOpen) { _closeStatus(); diff --git a/lib/pages/canteen_product/controller.dart b/lib/pages/canteen_product/controller.dart index 43ef875..8008046 100644 --- a/lib/pages/canteen_product/controller.dart +++ b/lib/pages/canteen_product/controller.dart @@ -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 _getDefaultProduct() async { final sysType = appSetting.sysType.name; final productDao = appC.dataBase.getProductDao; - List list = await productDao.getDefault( + List 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; }); diff --git a/lib/pages/canteen_product/view.dart b/lib/pages/canteen_product/view.dart index 6751fef..6603c8d 100644 --- a/lib/pages/canteen_product/view.dart +++ b/lib/pages/canteen_product/view.dart @@ -17,21 +17,39 @@ class CanteenProductPage extends GetView { final context = Get.context!; final theme = FTheme.of(context); return [ - appBack( - context, - height: headerHeight, - onTap: () => Get.offAndToNamed(RouteNames.panel), - ), - Obx( - () => orderRowClassify( + [ + 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 { 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 { /// 商品项 Widget _buildProductItem( BuildContext context, { - required List productList, + required List productList, required double productSpacing, required Size productSize, String? title = "", @@ -212,6 +230,7 @@ class CanteenProductPage extends GetView { final width = context.width; final theme = FTheme.of(context); return [ + SizedBox(width: 15.w), _buildProduct().expanded(), SizedBox(width: 15.w), _buildUser().width(width * 0.25).decorated( @@ -232,9 +251,7 @@ class CanteenProductPage extends GetView { 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, diff --git a/lib/pages/setting/widgets/setting_face.dart b/lib/pages/setting/widgets/setting_face.dart index bee631d..8fb7302 100644 --- a/lib/pages/setting/widgets/setting_face.dart +++ b/lib/pages/setting/widgets/setting_face.dart @@ -22,7 +22,7 @@ class FaceManageController extends GetxController { RxInt pageSize = RxInt(15); - final TextEditingController usernameC = TextEditingController(); + final usernameC = TextEditingController(); late StreamSubscription mqUpdateListen; diff --git a/lib/pages/setting/widgets/setting_product.dart b/lib/pages/setting/widgets/setting_product.dart index e8179ec..c70e8c5 100644 --- a/lib/pages/setting/widgets/setting_product.dart +++ b/lib/pages/setting/widgets/setting_product.dart @@ -10,7 +10,7 @@ import 'package:pj_supermarket_cloud/common/index.dart'; class ProductManageController extends GetxController { static const _tag = "商品管理 Controller"; - RxList productList = [].obs; + RxList productList = [].obs; ProductHourType hourType = ProductHourType.MORNING; @@ -110,7 +110,7 @@ class ProductManageController extends GetxController { } // 切换是否默认 - Future trigger(ProductEntity v) async { + Future trigger(CanteenSpuEntity v) async { try { final isSure = await appMessageDialog( Get.context!, @@ -123,7 +123,7 @@ class ProductManageController extends GetxController { ); final app = Get.find(); 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, diff --git a/lib/pages/supermarket_order/controller.dart b/lib/pages/supermarket_order/controller.dart index 4d08d8e..1d2edeb 100644 --- a/lib/pages/supermarket_order/controller.dart +++ b/lib/pages/supermarket_order/controller.dart @@ -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(); + 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 _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(); // 获取分类和商品 diff --git a/lib/pages/supermarket_order/view.dart b/lib/pages/supermarket_order/view.dart index 94d0928..7042781 100644 --- a/lib/pages/supermarket_order/view.dart +++ b/lib/pages/supermarket_order/view.dart @@ -33,7 +33,38 @@ class SupermarketOrderPage extends GetView { onChange: (tabIndex) => controller.doTab(tabIndex), ), ).scrollable(scrollDirection: Axis.horizontal).expanded(), - ].toRow(); + [ + 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 { Widget _buildProductItem( BuildContext context, { - required List productList, + required List productList, required double productSpacing, required Size productSize, String? title = "", @@ -65,13 +96,13 @@ class SupermarketOrderPage extends GetView { 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 { final width = context.width; final theme = FTheme.of(context); return [ + SizedBox(width: 15.w), _buildProductArea().expanded(), SizedBox(width: 15.w), _buildUser().width(width * 0.25).decorated( @@ -208,9 +240,7 @@ class SupermarketOrderPage extends GetView { 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,