feat:超市实体
This commit is contained in:
1 parent
321ae3378a
commit
c0fbf652fb
16 files changed
+640
-80
No files matched your search
@@ -101,12 +101,12 @@ class FaceManageController extends GetxController {
|
||||
getFaceList();
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
currentPage.value = 1;
|
||||
getFaceList();
|
||||
// 重新生成人脸模型
|
||||
await AppFaceTool.removeFace(sampleId: "-1");
|
||||
await AppFaceTool.faceRegister(forceRegister: true);
|
||||
} finally {
|
||||
currentPage.value = 1;
|
||||
Toast.success(msg: "同步成功");
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
@@ -10,14 +9,22 @@ import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
class ProductManageController extends GetxController {
|
||||
static const _tag = "商品管理 Controller";
|
||||
|
||||
RxList<CanteenSpuEntity> productList = <CanteenSpuEntity>[].obs;
|
||||
AppControl appC = Get.find<AppControl>();
|
||||
|
||||
late SysSetting sysSetting;
|
||||
|
||||
Rx<SysType> sysType = SysType.CANTEEN.obs;
|
||||
|
||||
// 食堂商品
|
||||
RxList<CanteenSpuEntity> canteenSpuList = <CanteenSpuEntity>[].obs;
|
||||
|
||||
// 超市商品
|
||||
final supermarketSpuList = <SupermarketSpuEntity>[].obs;
|
||||
|
||||
ProductHourType hourType = ProductHourType.MORNING;
|
||||
|
||||
RxInt currentPage = RxInt(1);
|
||||
|
||||
RxInt totalPage = RxInt(0);
|
||||
|
||||
RxInt pageSize = RxInt(24);
|
||||
|
||||
final hourTypeC = FRadioSelectGroupController<String>(
|
||||
@@ -26,8 +33,10 @@ class ProductManageController extends GetxController {
|
||||
|
||||
@override
|
||||
void onInit() async {
|
||||
await initData();
|
||||
super.onInit();
|
||||
sysSetting = await AppSettingTool.getSysSetting();
|
||||
sysType.value = sysSetting.sysType;
|
||||
await getProductList();
|
||||
hourTypeC.addValueListener((v) async {
|
||||
final currentHourType = ProductHourType.values.fromCode(
|
||||
v.first,
|
||||
@@ -44,13 +53,6 @@ class ProductManageController extends GetxController {
|
||||
hourTypeC.dispose();
|
||||
}
|
||||
|
||||
Future<void> initData() async {
|
||||
await getProductList();
|
||||
if (ObjectUtil.isEmptyList(productList)) {
|
||||
getProductList();
|
||||
}
|
||||
}
|
||||
|
||||
// 更新商品和分类
|
||||
Future<void> updateProductAndClassify() async {
|
||||
EasyLoading.show(
|
||||
@@ -76,22 +78,35 @@ class ProductManageController extends GetxController {
|
||||
);
|
||||
}
|
||||
try {
|
||||
final app = Get.find<AppControl>();
|
||||
final sysSetting = await AppSettingTool.getSysSetting();
|
||||
final productDao = app.dataBase.getCanteenSpuDao;
|
||||
final currnetHourType = hourType.code;
|
||||
String sysType = sysSetting.sysType.name;
|
||||
final findCount = await productDao.getCount(
|
||||
currnetHourType,
|
||||
);
|
||||
if (findCount != null) totalPage.value = findCount;
|
||||
final list = await productDao.getAllPage(
|
||||
"-1",
|
||||
currnetHourType,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
productList.value = list;
|
||||
SysType sysType = sysSetting.sysType;
|
||||
|
||||
if (sysType == SysType.SUPERMARKET) {
|
||||
// 超市
|
||||
final supermarketSpuDao = appC.dataBase.getSupermarketSpuDao;
|
||||
final findCount = await supermarketSpuDao.getCount();
|
||||
totalPage.value = findCount ?? 0;
|
||||
final list = await supermarketSpuDao.getAllPage(
|
||||
"-1",
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
supermarketSpuList.value = list;
|
||||
} else if (sysType == SysType.CANTEEN) {
|
||||
// 食堂
|
||||
final productDao = appC.dataBase.getCanteenSpuDao;
|
||||
final findCount = await productDao.getCount(
|
||||
currnetHourType,
|
||||
);
|
||||
totalPage.value = findCount ?? 0;
|
||||
final list = await productDao.getAllPage(
|
||||
"-1",
|
||||
currnetHourType,
|
||||
pageSize.value,
|
||||
(currentPage.value - 1) * pageSize.value,
|
||||
);
|
||||
canteenSpuList.value = list;
|
||||
}
|
||||
} finally {
|
||||
if (isLoading) {
|
||||
Future.delayed(const Duration(seconds: 1), () {
|
||||
@@ -119,8 +134,7 @@ class ProductManageController extends GetxController {
|
||||
status: '设置中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final app = Get.find<AppControl>();
|
||||
final productDao = app.dataBase.getCanteenSpuDao;
|
||||
final productDao = appC.dataBase.getCanteenSpuDao;
|
||||
final editObj = CanteenSpuEntity.fromJson(v.toJson());
|
||||
editObj.isDefault = !editObj.isDefault;
|
||||
await productDao.edit(
|
||||
@@ -135,16 +149,20 @@ class ProductManageController extends GetxController {
|
||||
}
|
||||
}
|
||||
|
||||
/// 搜索条件
|
||||
Widget buildSearch(BuildContext context) {
|
||||
// 搜索条件
|
||||
Widget _buildSearch(BuildContext context) {
|
||||
final theme = FTheme.of(context);
|
||||
final productC = Get.find<ProductManageController>();
|
||||
return <Widget>[
|
||||
<Widget>[
|
||||
appRadioHourTypeDialog(
|
||||
context,
|
||||
productC.hourTypeC,
|
||||
).width(300.w),
|
||||
Obx(
|
||||
() => appRadioHourTypeDialog(
|
||||
context,
|
||||
productC.hourTypeC,
|
||||
).offstage(
|
||||
offstage: productC.sysType.value != SysType.CANTEEN,
|
||||
),
|
||||
).width(300.w)
|
||||
].toRow().expanded(),
|
||||
FButton(
|
||||
prefix: FIcon(
|
||||
@@ -172,8 +190,8 @@ Widget buildSearch(BuildContext context) {
|
||||
].toRow();
|
||||
}
|
||||
|
||||
/// 列表
|
||||
Widget buildList(BuildContext context) {
|
||||
// 食堂列表
|
||||
Widget _buildCanteenList(BuildContext context) {
|
||||
final theme = FTheme.of(context);
|
||||
final productC = Get.find<ProductManageController>();
|
||||
return Obx(
|
||||
@@ -184,9 +202,9 @@ Widget buildList(BuildContext context) {
|
||||
crossAxisSpacing: 10.w,
|
||||
childAspectRatio: 0.7,
|
||||
),
|
||||
itemCount: productC.productList.length,
|
||||
itemCount: productC.canteenSpuList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final v = productC.productList[index];
|
||||
final v = productC.canteenSpuList[index];
|
||||
return FCard(
|
||||
style: theme.cardStyle.copyWith(
|
||||
contentStyle: theme.cardStyle.contentStyle.copyWith(
|
||||
@@ -212,13 +230,24 @@ Widget buildList(BuildContext context) {
|
||||
);
|
||||
}
|
||||
|
||||
// 超市列表
|
||||
Widget _buildSupermarketList(BuildContext context) {
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
|
||||
Widget settingProduct(BuildContext context) {
|
||||
final productC = Get.put<ProductManageController>(
|
||||
ProductManageController(),
|
||||
);
|
||||
return <Widget>[
|
||||
buildSearch(context),
|
||||
buildList(context).expanded(),
|
||||
_buildSearch(context),
|
||||
Obx(
|
||||
() => Visibility(
|
||||
visible: productC.sysType.value == SysType.CANTEEN,
|
||||
replacement: _buildSupermarketList(context),
|
||||
child: _buildCanteenList(context),
|
||||
),
|
||||
).expanded(),
|
||||
Obx(
|
||||
() => appPage(
|
||||
context,
|
||||
|
||||
Reference in new issue
Block a user