feat:交易记录、日期组建
This commit is contained in:
1 parent
08ad1c2d81
commit
88e73ad950
32 files changed
+672
-279
No files matched your search
@@ -1,3 +1,4 @@
|
||||
import 'package:common_utils/common_utils.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -19,14 +20,12 @@ class SettingController extends GetxController {
|
||||
);
|
||||
|
||||
// 付款方式
|
||||
var globalPayTableC = FMultiSelectGroupController(
|
||||
values: OrderPayDisplayType.values.map((v) => v.code).toSet(),
|
||||
var globalPayTableC = FMultiSelectGroupController<String>(
|
||||
values: {},
|
||||
);
|
||||
|
||||
// 默认付款方式
|
||||
var defaultGlobalPayTableC = FRadioSelectGroupController<String>(
|
||||
value: OrderPayDisplayType.face.code,
|
||||
);
|
||||
var defaultGlobalPayTableC = FRadioSelectGroupController<String>();
|
||||
|
||||
_initData() {
|
||||
update(["setting"]);
|
||||
@@ -39,6 +38,11 @@ class SettingController extends GetxController {
|
||||
title: "基本信息",
|
||||
type: SettingMenuType.baseInfo,
|
||||
),
|
||||
SettingMenu(
|
||||
prefixIcon: FAssets.icons.databaseBackup,
|
||||
title: "资源备份",
|
||||
type: SettingMenuType.backup,
|
||||
),
|
||||
SettingMenu(
|
||||
prefixIcon: FAssets.icons.refreshCw,
|
||||
title: "同步设置",
|
||||
@@ -49,11 +53,6 @@ class SettingController extends GetxController {
|
||||
title: "支付设置",
|
||||
type: SettingMenuType.paySetting,
|
||||
),
|
||||
SettingMenu(
|
||||
prefixIcon: FAssets.icons.databaseBackup,
|
||||
title: "资源备份",
|
||||
type: SettingMenuType.backup,
|
||||
),
|
||||
SettingMenu(
|
||||
prefixIcon: FAssets.icons.scanFace,
|
||||
title: "人脸管理",
|
||||
@@ -79,6 +78,26 @@ class SettingController extends GetxController {
|
||||
final appTheme = Get.find<AppThemeControl>();
|
||||
appTheme.setSizeScalar(fontSizeType);
|
||||
});
|
||||
globalPayTableC.addValueListener((v) async {
|
||||
List<OrderPayDisplayType> usePayList = [];
|
||||
for (final i in v) {
|
||||
final payType = OrderPayDisplayType.values.fromCode(
|
||||
i,
|
||||
);
|
||||
if (payType == null) continue;
|
||||
usePayList.add(payType);
|
||||
}
|
||||
sysSetting.value?.usePayDisplayType = usePayList;
|
||||
await AppSettingTool.setSysSetting(sysSetting.value!);
|
||||
});
|
||||
defaultGlobalPayTableC.addValueListener((v) async {
|
||||
final payType = OrderPayDisplayType.values.fromCode(
|
||||
v.first,
|
||||
);
|
||||
if (payType == null) return;
|
||||
sysSetting.value?.defaultPayDisplayType = payType;
|
||||
await AppSettingTool.setSysSetting(sysSetting.value!);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -213,6 +232,7 @@ class SettingController extends GetxController {
|
||||
EasyLoading.dismiss();
|
||||
} catch (e) {
|
||||
Toast.error(msg: "备份中sql失败");
|
||||
logger.e("|$_tag|备份中sqlerror:|$e|");
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -222,13 +242,46 @@ class SettingController extends GetxController {
|
||||
Toast.success(msg: "当前日志为实时备份");
|
||||
}
|
||||
|
||||
Future<void> getSetting() async {
|
||||
sysSetting.value = await AppSettingTool.getSysSetting();
|
||||
userSetting.value = await AppSettingTool.getUserSetting();
|
||||
if (userSetting.value!.globalFontSize != null) {
|
||||
globalFontSizeC = FRadioSelectGroupController(
|
||||
value: SettingGlobalFontSize.xl3.code,
|
||||
);
|
||||
// sql恢复
|
||||
Future<void> recoverSql() async {
|
||||
EasyLoading.show(
|
||||
status: '恢复中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
try {
|
||||
await AppFileTool.useLastBackDatabase();
|
||||
EasyLoading.dismiss();
|
||||
Toast.success(msg: "sql恢复成功");
|
||||
EasyLoading.dismiss();
|
||||
} catch (e) {
|
||||
Toast.error(msg: "sql恢复失败");
|
||||
logger.e("|$_tag|sql恢复失败error:|$e|");
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> getSetting() async {
|
||||
sysSetting.value = await AppSettingTool.getSysSetting();
|
||||
if (sysSetting.value!.globalFontSize != null) {
|
||||
globalFontSizeC.value = {sysSetting.value!.globalFontSize!.code};
|
||||
}
|
||||
if (!ObjectUtil.isEmptyList(sysSetting.value!.usePayDisplayType)) {
|
||||
globalPayTableC.value =
|
||||
sysSetting.value!.usePayDisplayType!.map((v) => v.code).toSet();
|
||||
}
|
||||
if (sysSetting.value!.defaultPayDisplayType != null) {
|
||||
defaultGlobalPayTableC.value = {
|
||||
sysSetting.value!.defaultPayDisplayType!.code
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> checkIsBind() async {
|
||||
final sysSetting = await AppSettingTool.getSysSetting();
|
||||
final id = sysSetting.serviceMerchantId;
|
||||
if (ObjectUtil.isEmpty(id)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
+39
-17
@@ -3,7 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/models/index.dart';
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/pages/setting/widgets/index.dart';
|
||||
|
||||
import 'index.dart';
|
||||
@@ -85,22 +86,43 @@ class SettingPage extends GetView<SettingController> {
|
||||
}
|
||||
|
||||
Widget _buildDetail(BuildContext context, SettingMenuType type) {
|
||||
switch (type) {
|
||||
case SettingMenuType.baseInfo:
|
||||
return settingBaseInfo(context);
|
||||
case SettingMenuType.syncSetting:
|
||||
return settingSync(context);
|
||||
case SettingMenuType.paySetting:
|
||||
return settingPay(context);
|
||||
case SettingMenuType.backup:
|
||||
return settingBackup(context);
|
||||
case SettingMenuType.faceSetting:
|
||||
return settingFace(context);
|
||||
case SettingMenuType.productSetting:
|
||||
return settingProduct(context);
|
||||
default:
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
return FutureBuilder(
|
||||
future: controller.checkIsBind(),
|
||||
builder: (context, snapshot) {
|
||||
if (!snapshot.hasData) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
final isBand = snapshot.data!;
|
||||
switch (type) {
|
||||
case SettingMenuType.baseInfo:
|
||||
return settingBaseInfo(context);
|
||||
case SettingMenuType.backup:
|
||||
return settingBackup(context);
|
||||
case SettingMenuType.syncSetting:
|
||||
if (!isBand) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return settingSync(context);
|
||||
case SettingMenuType.paySetting:
|
||||
if (!isBand) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return settingPay(context);
|
||||
case SettingMenuType.faceSetting:
|
||||
if (!isBand) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return settingFace(context);
|
||||
case SettingMenuType.productSetting:
|
||||
if (!isBand) {
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
return settingProduct(context);
|
||||
default:
|
||||
return SizedBox.shrink();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -13,6 +13,7 @@ Widget settingBackup(BuildContext context) {
|
||||
final sys = controller.sysSetting.value;
|
||||
if (sys == null) return const SizedBox.shrink();
|
||||
return <Widget>[
|
||||
appDividerTitle(context, "备份"),
|
||||
FTile(
|
||||
prefixIcon: appPrefixIcon(context, FAssets.icons.user),
|
||||
suffixIcon: appSuffixIcon(context, FAssets.icons.files),
|
||||
@@ -32,6 +33,13 @@ Widget settingBackup(BuildContext context) {
|
||||
title: appPrefixTitle(context, "log备份"),
|
||||
onPress: () => controller.backupsLog(),
|
||||
),
|
||||
appDividerTitle(context, "恢复"),
|
||||
FTile(
|
||||
prefixIcon: appPrefixIcon(context, FAssets.icons.user),
|
||||
suffixIcon: appSuffixIcon(context, FAssets.icons.folderSync),
|
||||
title: appPrefixTitle(context, "sql恢复"),
|
||||
onPress: () => controller.recoverSql(),
|
||||
),
|
||||
].toColumnSpace(space: 20.h);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -14,26 +14,21 @@ Widget settingPay(BuildContext context) {
|
||||
final sys = controller.sysSetting.value;
|
||||
if (sys == null) return const SizedBox.shrink();
|
||||
return <Widget>[
|
||||
FSelectMenuTile.builder(
|
||||
FSelectMenuTile(
|
||||
groupController: controller.globalPayTableC,
|
||||
validator: (value) => value == null ? '请选择' : null,
|
||||
autoHide: true,
|
||||
prefixIcon: appPrefixIcon(context, FAssets.icons.settings),
|
||||
suffixIcon: appSuffixIcon(context, FAssets.icons.audioLines),
|
||||
title: appPrefixTitle(context, "使用支付方式"),
|
||||
menuTileBuilder: (context, index) {
|
||||
if (index >= OrderPayDisplayType.values.length) {
|
||||
return null;
|
||||
}
|
||||
final type = OrderPayDisplayType.values[index];
|
||||
menu: OrderPayDisplayType.values.map((v) {
|
||||
return FSelectTile(
|
||||
title: Text(
|
||||
type.title,
|
||||
v.title,
|
||||
style: theme.typography.xl,
|
||||
),
|
||||
value: type.code,
|
||||
value: v.code,
|
||||
);
|
||||
},
|
||||
}).toList(),
|
||||
details: ListenableBuilder(
|
||||
listenable: controller.globalPayTableC,
|
||||
builder: (context, _) {
|
||||
|
||||
@@ -70,10 +70,8 @@ class ProductManageController extends GetxController {
|
||||
sysType,
|
||||
currnetHourType,
|
||||
);
|
||||
if (findCount != null) {
|
||||
totalPage.value = (findCount / pageSize.value).ceil();
|
||||
}
|
||||
final list = await productDao.getCurrentDayAllPage(
|
||||
if (findCount != null) totalPage.value = findCount;
|
||||
final list = await productDao.getAllPage(
|
||||
"-1",
|
||||
currnetHourType,
|
||||
sysType,
|
||||
@@ -101,7 +99,7 @@ class ProductManageController extends GetxController {
|
||||
try {
|
||||
final isSure = await appMessageDialog(
|
||||
Get.context!,
|
||||
"是否${v.isDefault ? '设置为' : '取消'}默认菜品",
|
||||
"是否${v.isDefault ? '取消' : '设置为'}默认菜品",
|
||||
);
|
||||
if (!isSure) return;
|
||||
EasyLoading.show(
|
||||
@@ -151,58 +149,57 @@ Widget buildSearch(BuildContext context) {
|
||||
Widget buildList(BuildContext context) {
|
||||
final theme = FTheme.of(context);
|
||||
final productC = Get.find<ProductManageController>();
|
||||
return GridView.builder(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 8,
|
||||
mainAxisSpacing: 10.w,
|
||||
crossAxisSpacing: 10.w,
|
||||
childAspectRatio: 0.7,
|
||||
),
|
||||
itemCount: productC.productList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final v = productC.productList[index];
|
||||
return FCard(
|
||||
style: theme.cardStyle.copyWith(
|
||||
contentStyle: theme.cardStyle.contentStyle.copyWith(
|
||||
padding: EdgeInsets.all(0),
|
||||
return Obx(
|
||||
() => GridView.builder(
|
||||
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
|
||||
crossAxisCount: 8,
|
||||
mainAxisSpacing: 10.w,
|
||||
crossAxisSpacing: 10.w,
|
||||
childAspectRatio: 0.7,
|
||||
),
|
||||
itemCount: productC.productList.length,
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
final v = productC.productList[index];
|
||||
return FCard(
|
||||
style: theme.cardStyle.copyWith(
|
||||
contentStyle: theme.cardStyle.contentStyle.copyWith(
|
||||
padding: EdgeInsets.all(0),
|
||||
),
|
||||
),
|
||||
),
|
||||
image: appImg(v.image, width: double.infinity, height: 120.h),
|
||||
title: Text(v.name, maxLines: 2, style: theme.typography.base).center(),
|
||||
subtitle: appPrice(context, v.price.toString())
|
||||
.center()
|
||||
.paddingOnly(top: 10.h),
|
||||
child: <Widget>[
|
||||
Text("是否默认", style: theme.typography.sm),
|
||||
FSwitch(
|
||||
value: v.isDefault,
|
||||
onChange: (value) => productC.trigger(v),
|
||||
)
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.center),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
/// 分页
|
||||
Widget buildPage(BuildContext context) {
|
||||
final productC = Get.find<ProductManageController>();
|
||||
return appPage(
|
||||
context,
|
||||
pageNo: productC.currentPage.value,
|
||||
pageSize: productC.pageSize.value,
|
||||
total: productC.totalPage.value * productC.pageSize.value,
|
||||
onPageChanged: (pageNo) => productC.doPage(page: pageNo),
|
||||
image: appImg(v.image, width: double.infinity, height: 120.h),
|
||||
title:
|
||||
Text(v.name, maxLines: 2, style: theme.typography.base).center(),
|
||||
subtitle: appPrice(context, v.price.toString())
|
||||
.center()
|
||||
.paddingOnly(top: 10.h),
|
||||
child: <Widget>[
|
||||
Text("是否默认", style: theme.typography.sm),
|
||||
FSwitch(
|
||||
value: v.isDefault,
|
||||
onChange: (value) => productC.trigger(v),
|
||||
)
|
||||
].toRow(mainAxisAlignment: MainAxisAlignment.center),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget settingProduct(BuildContext context) {
|
||||
Get.put<ProductManageController>(
|
||||
final productC = Get.put<ProductManageController>(
|
||||
ProductManageController(),
|
||||
);
|
||||
return <Widget>[
|
||||
buildSearch(context),
|
||||
buildList(context).expanded(),
|
||||
buildPage(context),
|
||||
Obx(
|
||||
() => appPage(
|
||||
context,
|
||||
pageNo: productC.currentPage.value,
|
||||
pageSize: productC.pageSize.value,
|
||||
total: productC.totalPage.value,
|
||||
onPageChanged: (pageNo) => productC.doPage(page: pageNo),
|
||||
),
|
||||
),
|
||||
].toColumnSpace(space: 10.h);
|
||||
}
|
||||
Reference in new issue
Block a user