feat:按回车进行搜索

This commit is contained in:
dzc committed 2025-03-25 21:58:01 +08:00
1 parent 4a61bf35e0
commit 34e8f3ddd6
5 files changed
+55 -8

No files matched your search

+7 -2
View File
@@ -2,8 +2,13 @@ import 'package:ducafe_ui_core/ducafe_ui_core.dart';
import 'package:flutter/material.dart';
import 'package:forui/forui.dart';
Widget appPrice(BuildContext context, dynamic price) {
Widget appPrice(
BuildContext context,
dynamic price, {
TextStyle? textStyle,
}) {
final theme = FTheme.of(context);
textStyle ??= theme.typography.xl;
double? priceNum = price is double
? price
: double.tryParse(
@@ -21,7 +26,7 @@ Widget appPrice(BuildContext context, dynamic price) {
),
Text(
priceNum.toStringAsFixed(2),
style: theme.typography.xl.copyWith(
style: textStyle.copyWith(
color: theme.colorScheme.error,
height: 1,
),
+16 -5
View File
@@ -68,6 +68,7 @@ Widget orderSelectPanel(
int total = 1,
double widget = 0,
num price = 0,
num totalPrice = 0,
int index = 0,
double height = 50,
showPlus = false,
@@ -153,11 +154,21 @@ Widget orderSelectPanel(
}
},
),
Text(
"${widget.toString()}/kg",
style: theme.typography.base.copyWith(height: 1),
textAlign: TextAlign.center,
).center().width(textWidth.w).height(double.infinity).decorated(
<Widget>[
Text(
"${widget.toString()}/kg",
style: theme.typography.sm.copyWith(height: 1),
textAlign: TextAlign.center,
),
appPrice(context, totalPrice, textStyle: theme.typography.sm),
]
.toColumn(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
)
.width(textWidth.w)
.height(double.infinity)
.decorated(
color: theme.colorScheme.secondary,
borderRadius: theme.style.borderRadius / 2,
),
@@ -150,6 +150,7 @@ class FaceManageController extends GetxController {
});
}
/// 搜索
Future<void> doPage({int? page}) async {
if (page != null) currentPage.value = page;
// 收起键盘
@@ -157,6 +158,15 @@ class FaceManageController extends GetxController {
await getFaceList(isLoading: true);
}
/// 重置
Future<void> doReset() async {
currentPage.value = 1;
usernameC.clear();
// 收起键盘
FocusManager.instance.primaryFocus?.unfocus();
await getFaceList(isLoading: true);
}
// 删除人脸
Future<void> deleteFace(FaceEntity v) async {
final isSure = await appMessageDialog(Get.context!, "是否删除人脸");
@@ -199,9 +209,27 @@ Widget buildFaceSearch(BuildContext context) {
controller: faceC.usernameC,
hint: '请输入姓名',
maxLines: 1,
onSubmit: (_) => faceC.doPage(),
),
).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: () => faceC.doReset(),
),
FButton(
prefix: FIcon(
FAssets.icons.search,
size: theme.typography.base.fontSize,
),
label: Text(
'搜索',
style: theme.typography.base.copyWith(
@@ -103,7 +103,7 @@ class ProductManageController extends GetxController {
final findCount = await supermarketSpuDao.getCount("-1", "-1");
totalPage.value = findCount ?? 0;
final list = await supermarketSpuDao.getAllPage(
"-1",
selfCodeC.text,
"-1",
pageSize.value,
(currentPage.value - 1) * pageSize.value,
@@ -199,6 +199,7 @@ Widget _buildSearch(BuildContext context) {
controller: productC.selfCodeC,
hint: '请输入自编码/商品名',
maxLines: 1,
onSubmit: (_) => productC.doPage(),
).offstage(
offstage: productC.sysType.value != SysType.SUPERMARKET,
),
+2
View File
@@ -42,6 +42,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
focusNode: controller.focusNode,
hint: '请输入自编码/商品名',
maxLines: 1,
onSubmit: (_) => controller.doPage(),
).width(300.w),
FButton(
prefix: FIcon(
@@ -242,6 +243,7 @@ class SupermarketOrderPage extends GetView<SupermarketOrderController> {
Get.context!,
label: current.productName,
price: current.productPrice,
totalPrice: current.totalPrice,
widget: current.productWidget,
total: current.productNumber,
index: index,