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