11
This commit is contained in:
1 parent
cc98644cb5
commit
d5bfd91bc1
3 files changed
+94
-9
No files matched your search
@@ -1,10 +1,23 @@
|
||||
import 'package:floor/floor.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import 'package:pj_supermarket_cloud/common/index.dart';
|
||||
|
||||
// broadcast
|
||||
@dao
|
||||
abstract class BroadcastDao {
|
||||
Future<int> toggleEnable(bool enable) async {
|
||||
final app = Get.find<AppControl>();
|
||||
final database = app.dataBase.database;
|
||||
final sql = '''
|
||||
UPDATE broadcast SET enable = ${enable ? 1 : 0}
|
||||
WHERE
|
||||
isDone = 0
|
||||
AND strftime('%Y-%m-%d', createTime) = strftime('%Y-%m-%d', 'now', 'localtime')
|
||||
''';
|
||||
return await database.rawUpdate(sql, []);
|
||||
}
|
||||
|
||||
@insert
|
||||
Future<void> save(BroadcastEntity entity);
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||||
import 'package:forui/forui.dart';
|
||||
import 'package:get/get.dart';
|
||||
@@ -109,9 +110,43 @@ class CanteenReserveController extends GetxController {
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final broadcastDao = appC.dataBase.getBroadcastDao;
|
||||
v.broadcastCount = 10;
|
||||
v.broadcastCount = 0;
|
||||
await broadcastDao.edit(v);
|
||||
await _getReservePage();
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
/// 立即广播
|
||||
Future<void> startBroadcast() async {
|
||||
EasyLoading.show(
|
||||
status: '广播中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
await _getReservePage();
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
/// 关闭全部广播
|
||||
Future<void> closeBroadcast() async {
|
||||
EasyLoading.show(
|
||||
status: '关闭中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final broadcastDao = appC.dataBase.getBroadcastDao;
|
||||
await broadcastDao.toggleEnable(false);
|
||||
await _getReservePage();
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
|
||||
/// 打开全部广播
|
||||
Future<void> openBroadcast() async {
|
||||
EasyLoading.show(
|
||||
status: '打开中...',
|
||||
maskType: EasyLoadingMaskType.black,
|
||||
);
|
||||
final broadcastDao = appC.dataBase.getBroadcastDao;
|
||||
await broadcastDao.toggleEnable(true);
|
||||
await _getReservePage();
|
||||
EasyLoading.dismiss();
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ class CanteenReservePage extends GetView<CanteenReserveController> {
|
||||
final height = context.height;
|
||||
final headerHeight = height * 0.08;
|
||||
return <Widget>[
|
||||
_buildCondition(context, headerHeight),
|
||||
_buildCondition(context, headerHeight).marginSymmetric(horizontal: 30.w),
|
||||
SizedBox(height: 20.h),
|
||||
_buildTable(context).center().expanded(),
|
||||
Obx(
|
||||
@@ -37,9 +37,47 @@ class CanteenReservePage extends GetView<CanteenReserveController> {
|
||||
final theme = FTheme.of(context);
|
||||
return <Widget>[
|
||||
const Spacer(),
|
||||
appRadioHourTypeDialog(context, controller.hourTypeC)
|
||||
.width(300.w)
|
||||
.marginOnly(right: 15.w),
|
||||
appRadioHourTypeDialog(context, controller.hourTypeC).width(300.w),
|
||||
FButton(
|
||||
prefix: FIcon(
|
||||
FAssets.icons.rocket,
|
||||
size: theme.typography.base.fontSize,
|
||||
),
|
||||
label: Text(
|
||||
'立即广播',
|
||||
style: theme.typography.base.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
onPress: () => controller.startBroadcast(),
|
||||
),
|
||||
FButton(
|
||||
prefix: FIcon(
|
||||
FAssets.icons.rocket,
|
||||
size: theme.typography.base.fontSize,
|
||||
),
|
||||
label: Text(
|
||||
'开启全部广播',
|
||||
style: theme.typography.base.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
onPress: () => controller.openBroadcast(),
|
||||
),
|
||||
FButton(
|
||||
style: FButtonStyle.destructive,
|
||||
prefix: FIcon(
|
||||
FAssets.icons.ban,
|
||||
size: theme.typography.base.fontSize,
|
||||
),
|
||||
label: Text(
|
||||
'关闭全部广播',
|
||||
style: theme.typography.base.copyWith(
|
||||
color: theme.colorScheme.secondary,
|
||||
),
|
||||
),
|
||||
onPress: () => controller.closeBroadcast(),
|
||||
),
|
||||
].toRowSpace(space: 15.w, mainAxisAlignment: MainAxisAlignment.center);
|
||||
}
|
||||
|
||||
@@ -117,8 +155,8 @@ class CanteenReservePage extends GetView<CanteenReserveController> {
|
||||
),
|
||||
DataCell(
|
||||
Text(
|
||||
"${v.broadcastCount}",
|
||||
textAlign: TextAlign.center,
|
||||
"已播报${v.broadcastCount}次,最多播报${v.broadcastMaxCount}次",
|
||||
textAlign: TextAlign.start,
|
||||
).center(),
|
||||
),
|
||||
DataCell(
|
||||
@@ -137,8 +175,7 @@ class CanteenReservePage extends GetView<CanteenReserveController> {
|
||||
<Widget>[
|
||||
FButton(
|
||||
label: Text(
|
||||
// v.enable ? "关闭播报" : '开启播报',
|
||||
"${v.enable}",
|
||||
v.enable ? "关闭播报" : '开启播报',
|
||||
style: theme.typography.sm.copyWith(
|
||||
color: theme.colorScheme.primary,
|
||||
),
|
||||
|
||||
Reference in new issue
Block a user