fix: bug
This commit is contained in:
parent
1a3f57ce0e
commit
49ddf62751
|
@ -3,7 +3,7 @@ import 'package:get/get_rx/src/rx_types/rx_types.dart';
|
||||||
class SaleQuotationModel {
|
class SaleQuotationModel {
|
||||||
final String name;
|
final String name;
|
||||||
RxBool isExpanded = true.obs;
|
RxBool isExpanded = true.obs;
|
||||||
List<SaleQuotationItemModel> items;
|
RxList<SaleQuotationItemModel> items;
|
||||||
SaleQuotationModel({required this.name, required this.items});
|
SaleQuotationModel({required this.name, required this.items});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -199,9 +199,7 @@ class InventorySearch extends StatelessWidget {
|
||||||
controller: controller.refreshController,
|
controller: controller.refreshController,
|
||||||
onLoading: controller.onLoading,
|
onLoading: controller.onLoading,
|
||||||
onRefresh: controller.onRefresh,
|
onRefresh: controller.onRefresh,
|
||||||
child: controller.refreshController.isLoading
|
child: controller.inventories.isEmpty
|
||||||
? const SizedBox()
|
|
||||||
: controller.inventories.isEmpty
|
|
||||||
? const Center(
|
? const Center(
|
||||||
child: Empty(text: '暂无库存'),
|
child: Empty(text: '暂无库存'),
|
||||||
)
|
)
|
||||||
|
@ -332,8 +330,7 @@ class InventorySearch extends StatelessWidget {
|
||||||
Text(
|
Text(
|
||||||
'${itemData.product?.company?.name}',
|
'${itemData.product?.company?.name}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize:
|
fontSize: ScreenAdaper.height(15),
|
||||||
ScreenAdaper.height(15),
|
|
||||||
color: AppTheme.grey),
|
color: AppTheme.grey),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
|
|
|
@ -175,14 +175,14 @@ class GroupSearchController extends GetxController {
|
||||||
// isRefresh == true ? list.assignAll(newList) : list.addAll(newList);
|
// isRefresh == true ? list.assignAll(newList) : list.addAll(newList);
|
||||||
|
|
||||||
List<SaleQuotationModel> newList = [
|
List<SaleQuotationModel> newList = [
|
||||||
SaleQuotationModel(name: '中间过渡架电控部分', items: []),
|
SaleQuotationModel(name: '中间过渡架电控部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '端头架电控部分', items: []),
|
SaleQuotationModel(name: '端头架电控部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '主阀部分', items: []),
|
SaleQuotationModel(name: '主阀部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '自动反冲洗过滤器部分', items: []),
|
SaleQuotationModel(name: '自动反冲洗过滤器部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '位移测量部分', items: []),
|
SaleQuotationModel(name: '位移测量部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '压力检测部分', items: []),
|
SaleQuotationModel(name: '压力检测部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '煤机定位部分', items: []),
|
SaleQuotationModel(name: '煤机定位部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '姿态检测部分', items: []),
|
SaleQuotationModel(name: '姿态检测部分', items: RxList([])),
|
||||||
];
|
];
|
||||||
list.assignAll(newList);
|
list.assignAll(newList);
|
||||||
return newList;
|
return newList;
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:pull_to_refresh/pull_to_refresh.dart';
|
|
||||||
import 'package:sk_base_mobile/models/base_search_more.dart';
|
import 'package:sk_base_mobile/models/base_search_more.dart';
|
||||||
import 'package:sk_base_mobile/models/sale_quotation.model.dart';
|
import 'package:sk_base_mobile/models/sale_quotation.model.dart';
|
||||||
import 'package:sk_base_mobile/screens/sale_quotation/components/sale_quotation_group_search.dart';
|
import 'package:sk_base_mobile/screens/sale_quotation/components/sale_quotation_group_search.dart';
|
||||||
import 'package:sk_base_mobile/widgets/core/sk_single_search_more.dart';
|
import 'package:sk_base_mobile/widgets/core/sk_single_search_more.dart';
|
||||||
import 'package:sk_base_mobile/util/modal.util.dart';
|
import 'package:sk_base_mobile/util/modal.util.dart';
|
||||||
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
import 'package:sk_base_mobile/util/screen_adaper_util.dart';
|
||||||
|
import 'package:pinyin/pinyin.dart';
|
||||||
|
|
||||||
class SaleQuotationController extends GetxController {
|
class SaleQuotationController extends GetxController {
|
||||||
static SaleQuotationController get to => Get.find();
|
static SaleQuotationController get to => Get.find();
|
||||||
|
@ -37,15 +37,6 @@ class SaleQuotationController extends GetxController {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void onReady() {
|
void onReady() {
|
||||||
// groups.assignAll();
|
|
||||||
// SaleQuotationModel(name: '中间过渡架电控部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '端头架电控部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '主阀部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '自动反冲洗过滤器部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '位移测量部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '压力检测部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '煤机定位部分', items: products),
|
|
||||||
// SaleQuotationModel(name: '姿态检测部分', items: products),
|
|
||||||
super.onReady();
|
super.onReady();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +77,7 @@ class SaleQuotationController extends GetxController {
|
||||||
groups.removeAt(index);
|
groups.removeAt(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> addItems() async {
|
Future<void> addItems(int groupIndex) async {
|
||||||
final controller = Get.put(ItemSearchMoreController());
|
final controller = Get.put(ItemSearchMoreController());
|
||||||
// 选择产品
|
// 选择产品
|
||||||
ModalUtil.showGeneralDialog(
|
ModalUtil.showGeneralDialog(
|
||||||
|
@ -99,13 +90,7 @@ class SaleQuotationController extends GetxController {
|
||||||
return InkWell(
|
return InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
Get.back();
|
Get.back();
|
||||||
// if (beforeSelectedCheck != null)
|
groups[groupIndex].items.add(controller.list[index]);
|
||||||
// {
|
|
||||||
// if (beforeSelectedCheck!(controller.list[index]))
|
|
||||||
// {onSelected!(controller.list[index])}
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {onSelected!(controller.list[index])}
|
|
||||||
},
|
},
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: EdgeInsets.symmetric(
|
padding: EdgeInsets.symmetric(
|
||||||
|
@ -136,16 +121,19 @@ class GroupSearchMoreController extends GetxController
|
||||||
@override
|
@override
|
||||||
Future<List<SaleQuotationModel>> getData({bool isRefresh = false}) async {
|
Future<List<SaleQuotationModel>> getData({bool isRefresh = false}) async {
|
||||||
List<SaleQuotationModel> newList = [
|
List<SaleQuotationModel> newList = [
|
||||||
SaleQuotationModel(name: '中间过渡架电控部分', items: []),
|
SaleQuotationModel(name: '中间过渡架电控部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '端头架电控部分', items: []),
|
SaleQuotationModel(name: '端头架电控部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '主阀部分', items: []),
|
SaleQuotationModel(name: '主阀部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '自动反冲洗过滤器部分', items: []),
|
SaleQuotationModel(name: '自动反冲洗过滤器部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '位移测量部分', items: []),
|
SaleQuotationModel(name: '位移测量部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '压力检测部分', items: []),
|
SaleQuotationModel(name: '压力检测部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '煤机定位部分', items: []),
|
SaleQuotationModel(name: '煤机定位部分', items: RxList([])),
|
||||||
SaleQuotationModel(name: '姿态检测部分', items: []),
|
SaleQuotationModel(name: '姿态检测部分', items: RxList([])),
|
||||||
];
|
];
|
||||||
list.assignAll(newList);
|
list.assignAll(newList
|
||||||
|
.where((element) => PinyinHelper.getPinyin(element.name, separator: '')
|
||||||
|
.contains(searchKey.value))
|
||||||
|
.toList());
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +164,10 @@ class ItemSearchMoreController extends GetxController
|
||||||
SaleQuotationItemModel(name: '倾角传感器'),
|
SaleQuotationItemModel(name: '倾角传感器'),
|
||||||
SaleQuotationItemModel(name: '各类安装附件'),
|
SaleQuotationItemModel(name: '各类安装附件'),
|
||||||
];
|
];
|
||||||
list.assignAll(newList);
|
list.assignAll(newList
|
||||||
|
.where((element) => PinyinHelper.getPinyin(element.name, separator: '')
|
||||||
|
.contains(searchKey.value))
|
||||||
|
.toList());
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,7 +128,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget buildBody(SaleQuotationModel group, int index) {
|
Widget buildBody(SaleQuotationModel group, int groupIndex) {
|
||||||
final titleStyle = TextStyle(
|
final titleStyle = TextStyle(
|
||||||
fontSize: ScreenAdaper.height(30),
|
fontSize: ScreenAdaper.height(30),
|
||||||
color: AppTheme.nearlyBlack,
|
color: AppTheme.nearlyBlack,
|
||||||
|
@ -143,16 +143,17 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
alignment: Alignment.centerLeft,
|
alignment: Alignment.centerLeft,
|
||||||
child: InkWell(
|
child: InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
controller.groups[index].isExpanded.value =
|
controller.groups[groupIndex].isExpanded.value =
|
||||||
!controller.groups[index].isExpanded.value;
|
!controller.groups[groupIndex].isExpanded.value;
|
||||||
},
|
},
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
Obx(() => controller.groups[index].isExpanded.value
|
Obx(() => controller.groups[groupIndex].isExpanded.value
|
||||||
? IconButton(
|
? IconButton(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.groups[index].isExpanded.value = false;
|
controller.groups[groupIndex].isExpanded.value =
|
||||||
|
false;
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.expand_more,
|
Icons.expand_more,
|
||||||
|
@ -162,7 +163,8 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
: IconButton(
|
: IconButton(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.groups[index].isExpanded.value = true;
|
controller.groups[groupIndex].isExpanded.value =
|
||||||
|
true;
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.chevron_right,
|
Icons.chevron_right,
|
||||||
|
@ -179,7 +181,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
ModalUtil.confirm(
|
ModalUtil.confirm(
|
||||||
title: '确定要删除此组吗?',
|
title: '确定要删除此组吗?',
|
||||||
onConfirm: () {
|
onConfirm: () {
|
||||||
controller.removeGroup(index);
|
controller.removeGroup(groupIndex);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
|
@ -188,7 +190,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
)),
|
)),
|
||||||
IconButton(
|
IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
controller.addItems();
|
controller.addItems(groupIndex);
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.add_circle_outline,
|
Icons.add_circle_outline,
|
||||||
|
@ -196,7 +198,7 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
)),
|
)),
|
||||||
],
|
],
|
||||||
))),
|
))),
|
||||||
sliver: Obx(() => !controller.groups[index].isExpanded.value
|
sliver: Obx(() => !controller.groups[groupIndex].isExpanded.value
|
||||||
? SliverList(
|
? SliverList(
|
||||||
delegate: SliverChildBuilderDelegate(
|
delegate: SliverChildBuilderDelegate(
|
||||||
(context, i) => SizedBox(),
|
(context, i) => SizedBox(),
|
||||||
|
@ -212,11 +214,13 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
children: [
|
children: [
|
||||||
SlidableAction(
|
SlidableAction(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
onPressed: (_) {},
|
onPressed: (_) {
|
||||||
|
controller.groups[groupIndex].items.removeAt(i);
|
||||||
|
},
|
||||||
backgroundColor: AppTheme.dangerColor,
|
backgroundColor: AppTheme.dangerColor,
|
||||||
foregroundColor: Colors.white,
|
foregroundColor: Colors.white,
|
||||||
icon: Icons.delete,
|
icon: Icons.delete,
|
||||||
label: 'Delete',
|
label: '删除',
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -304,51 +308,53 @@ class SaleQuotationPage extends StatelessWidget {
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
width: quantityWidth,
|
width: quantityWidth,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.groups[index].items[i].quantity}',
|
'${controller.groups[groupIndex].items[i].quantity}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenAdaper.height(25)),
|
fontSize: ScreenAdaper.height(25)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
groupIndex: index,
|
groupIndex: groupIndex,
|
||||||
rowIndex: i,
|
rowIndex: i,
|
||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
inputWidth: quantityWidth,
|
inputWidth: quantityWidth,
|
||||||
value: controller.groups[index].items[i].quantity),
|
value: controller
|
||||||
|
.groups[groupIndex].items[i].quantity),
|
||||||
buildEditCell(
|
buildEditCell(
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
width: unitPriceWidth,
|
width: unitPriceWidth,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.groups[index].items[i].cost}',
|
'${controller.groups[groupIndex].items[i].cost}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenAdaper.height(25)),
|
fontSize: ScreenAdaper.height(25)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
groupIndex: index,
|
groupIndex: groupIndex,
|
||||||
rowIndex: i,
|
rowIndex: i,
|
||||||
field: 'cost',
|
field: 'cost',
|
||||||
inputWidth: unitPriceWidth,
|
inputWidth: unitPriceWidth,
|
||||||
value: controller.groups[index].items[i].cost),
|
value: controller.groups[groupIndex].items[i].cost),
|
||||||
buildEditCell(
|
buildEditCell(
|
||||||
Container(
|
Container(
|
||||||
alignment: Alignment.center,
|
alignment: Alignment.center,
|
||||||
width: amountWidth,
|
width: amountWidth,
|
||||||
child: Text(
|
child: Text(
|
||||||
'${controller.groups[index].items[i].amount}',
|
'${controller.groups[groupIndex].items[i].amount}',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: ScreenAdaper.height(25)),
|
fontSize: ScreenAdaper.height(25)),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
groupIndex: index,
|
groupIndex: groupIndex,
|
||||||
rowIndex: i,
|
rowIndex: i,
|
||||||
field: 'amount',
|
field: 'amount',
|
||||||
inputWidth: amountWidth,
|
inputWidth: amountWidth,
|
||||||
value: controller.groups[index].items[i].amount),
|
value:
|
||||||
|
controller.groups[groupIndex].items[i].amount),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
childCount: !controller.groups[index].isExpanded.value
|
childCount: !controller.groups[groupIndex].isExpanded.value
|
||||||
? 0
|
? 0
|
||||||
: group.items.length,
|
: group.items.length,
|
||||||
),
|
),
|
||||||
|
|
|
@ -48,7 +48,7 @@ class _SkNumberInputState extends State<SkNumberInput> {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
focusNode: focusNode,
|
focusNode: focusNode,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (widget.onTap == null) {
|
if (widget.onTap != null) {
|
||||||
widget.onTap!(focusNode);
|
widget.onTap!(focusNode);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -37,9 +37,23 @@ class SkSingleSearchMore<T> extends StatelessWidget {
|
||||||
vertical: ScreenAdaper.height(20)),
|
vertical: ScreenAdaper.height(20)),
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
buildDialogHeader(),
|
||||||
|
SizedBox(
|
||||||
|
height: ScreenAdaper.height(defaultPadding) / 2,
|
||||||
|
),
|
||||||
|
buildSearchBar(),
|
||||||
|
SizedBox(
|
||||||
|
height: ScreenAdaper.height(defaultPadding) / 2,
|
||||||
|
),
|
||||||
|
Expanded(child: buildList())
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget buildDialogHeader() {
|
||||||
|
return Container(
|
||||||
height: ScreenAdaper.height(60),
|
height: ScreenAdaper.height(60),
|
||||||
padding: EdgeInsets.only(bottom: ScreenAdaper.height(15)),
|
|
||||||
child: Stack(
|
child: Stack(
|
||||||
children: [
|
children: [
|
||||||
Center(
|
Center(
|
||||||
|
@ -52,16 +66,14 @@ class SkSingleSearchMore<T> extends StatelessWidget {
|
||||||
),
|
),
|
||||||
Positioned(
|
Positioned(
|
||||||
right: 0,
|
right: 0,
|
||||||
child:
|
child: GestureDetector(
|
||||||
GestureDetector(onTap: () {}, child: Icon(Icons.close)))
|
onTap: () {
|
||||||
],
|
Get.back();
|
||||||
),
|
},
|
||||||
),
|
child: Icon(
|
||||||
buildSearchBar(),
|
Icons.close,
|
||||||
SizedBox(
|
size: ScreenAdaper.height(40),
|
||||||
height: ScreenAdaper.height(defaultPadding) / 2,
|
)))
|
||||||
),
|
|
||||||
Expanded(child: buildList())
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
|
@ -736,6 +736,14 @@ packages:
|
||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "0.14.0"
|
version: "0.14.0"
|
||||||
|
pinyin:
|
||||||
|
dependency: "direct main"
|
||||||
|
description:
|
||||||
|
name: pinyin
|
||||||
|
sha256: "509a51abec754d8b69cc94074b2bdb9f4a407bc4daf5723ec6d995b7682a048a"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "3.2.0"
|
||||||
platform:
|
platform:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
|
|
@ -64,6 +64,7 @@ dependencies:
|
||||||
flutter_svg: ^2.0.10+1
|
flutter_svg: ^2.0.10+1
|
||||||
flutter_sticky_header: ^0.6.5
|
flutter_sticky_header: ^0.6.5
|
||||||
flutter_slidable: ^3.1.0
|
flutter_slidable: ^3.1.0
|
||||||
|
pinyin: ^3.2.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
sdk: flutter
|
sdk: flutter
|
||||||
|
|
Loading…
Reference in New Issue