From 62434ed083d504d04d671d418555504ecf6770cc Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Fri, 16 Apr 2021 10:11:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=95=B0=E9=87=8F=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../borrow/borrow_goods_page.dart | 27 ++++++++++++------- .../borrow_goods_detail_page.dart | 9 ++++--- 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/lib/pages/goods_manage_page/borrow/borrow_goods_page.dart b/lib/pages/goods_manage_page/borrow/borrow_goods_page.dart index 2af0228f..2b461eea 100644 --- a/lib/pages/goods_manage_page/borrow/borrow_goods_page.dart +++ b/lib/pages/goods_manage_page/borrow/borrow_goods_page.dart @@ -21,6 +21,7 @@ class BorrowGoodsPage extends StatefulWidget { class _BorrowGoodsPageState extends State { EasyRefreshController _easyRefreshController; + List _receiveIds = []; List _submitIds = []; List _counts = []; @override @@ -52,16 +53,18 @@ class _BorrowGoodsPageState extends State { path: API.manager.articleBorrow, controller: _easyRefreshController, convert: (models) { - _counts.addAll(List.filled(models.tableList.length, 0)); return models.tableList .map((e) => ArticleBorrowModel.fromJson(e)) .toList(); }, builder: (items) { + if (_counts.isEmpty) { + _counts = List.filled(items.length, 0); + } return ListView.separated( padding: EdgeInsets.symmetric(vertical: 16.w, horizontal: 32.w), itemBuilder: (context, index) { - return _goodsCard(items[index], _counts[index]); + return _goodsCard(items[index], index); }, separatorBuilder: (_, __) { return 16.w.heightBox; @@ -71,7 +74,11 @@ class _BorrowGoodsPageState extends State { bottomNavi: Row( children: [ '已选择 '.richText.color(ktextPrimary).size(24.sp).withTextSpanChildren([ - '0'.textSpan.size(32.sp).color(ktextPrimary).make(), + '${_submitIds.length}' + .textSpan + .size(32.sp) + .color(ktextPrimary) + .make(), ' 项'.textSpan.size(24.sp).color(ktextPrimary).make(), ]).make(), Spacer(), @@ -144,7 +151,7 @@ class _BorrowGoodsPageState extends State { _counts[index] == 0 ? SizedBox() : Column( - crossAxisAlignment: CrossAxisAlignment.end, + crossAxisAlignment: CrossAxisAlignment.end, children: [ Container( alignment: Alignment.center, @@ -173,15 +180,17 @@ class _BorrowGoodsPageState extends State { .withRounded(value: 6.w) .make() .onInkTap(() async { - List ids; + _receiveIds.forEach((element) { + _submitIds.remove(element); + }); await Get.to(() => BorrowGoodsDetailPage( articleId: model.id, )).then((value) { - ids = value; - _counts[index] = ids.length; - _submitIds.addAll(ids); - setState(() {}); + _receiveIds = value; }); + _counts[index] = _receiveIds.length; + _submitIds.addAll(_receiveIds); + setState(() {}); }); } } diff --git a/lib/pages/goods_manage_page/borrow_goods_detail_page.dart b/lib/pages/goods_manage_page/borrow_goods_detail_page.dart index f175d487..fe5ed43c 100644 --- a/lib/pages/goods_manage_page/borrow_goods_detail_page.dart +++ b/lib/pages/goods_manage_page/borrow_goods_detail_page.dart @@ -2,8 +2,6 @@ import 'package:akuCommunity/base/base_style.dart'; import 'package:akuCommunity/constants/api.dart'; import 'package:akuCommunity/model/common/img_model.dart'; import 'package:akuCommunity/model/manager/article_borrow_detail_model.dart'; -import 'package:akuCommunity/pages/goods_deto_page/deto_create_page/widget/common_radio.dart'; -import 'package:akuCommunity/pages/things_page/widget/bee_list_view.dart'; import 'package:akuCommunity/utils/network/base_model.dart'; import 'package:akuCommunity/utils/network/net_util.dart'; import 'package:akuCommunity/widget/animated/animated_scale.dart'; @@ -18,7 +16,9 @@ import 'package:akuCommunity/const/resource.dart'; class BorrowGoodsDetailPage extends StatefulWidget { final int articleId; - BorrowGoodsDetailPage({Key key, this.articleId}) : super(key: key); + final List receiveIds; + BorrowGoodsDetailPage({Key key, this.articleId, this.receiveIds}) + : super(key: key); @override _BorrowGoodsDetailPageState createState() => _BorrowGoodsDetailPageState(); @@ -34,6 +34,9 @@ class _BorrowGoodsDetailPageState extends State { void initState() { super.initState(); _easyRefreshController = EasyRefreshController(); + if (widget.receiveIds != null && widget.receiveIds.isNotEmpty) { + _selectItems = widget.receiveIds; + } } @override