From bf84640e9116ced4a773ccd3841e915169cda2f0 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Tue, 25 May 2021 14:12:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=80=9F=E8=BF=98=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3=E8=B0=83=E7=94=A8=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../manager/article_return_list_model.dart | 31 ++----------------- .../retrun/return_goods_detail_page.dart | 16 ++++++---- 2 files changed, 13 insertions(+), 34 deletions(-) diff --git a/lib/model/manager/article_return_list_model.dart b/lib/model/manager/article_return_list_model.dart index 6d1186ff..978b2edd 100644 --- a/lib/model/manager/article_return_list_model.dart +++ b/lib/model/manager/article_return_list_model.dart @@ -37,6 +37,9 @@ class ArticleReturnListModel { } } + factory ArticleReturnListModel.fail() => ArticleReturnListModel( + id: -1, name: '', code: '', beginDate: '', borrowTime: 0, imgList: []); + Map toJson() { final Map data = new Map(); data['id'] = this.id; @@ -50,31 +53,3 @@ class ArticleReturnListModel { return data; } } - -class ImgList { - String? url; - String? size; - int? longs; - int? paragraph; - int? sort; - - ImgList({this.url, this.size, this.longs, this.paragraph, this.sort}); - - ImgList.fromJson(Map json) { - url = json['url']; - size = json['size']; - longs = json['longs']; - paragraph = json['paragraph']; - sort = json['sort']; - } - - Map toJson() { - final Map data = new Map(); - data['url'] = this.url; - data['size'] = this.size; - data['longs'] = this.longs; - data['paragraph'] = this.paragraph; - data['sort'] = this.sort; - return data; - } -} diff --git a/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart b/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart index 0946aaa3..ef444e1e 100644 --- a/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart +++ b/lib/pages/goods_manage_page/retrun/return_goods_detail_page.dart @@ -24,7 +24,7 @@ class ReturnGoodsDetailPage extends StatefulWidget { } class _ReturnGoodsDetailPageState extends State { - EasyRefreshController? _easyRefreshController; + late EasyRefreshController _easyRefreshController; late List _models; bool _onload = true; List _selectItems = []; @@ -37,7 +37,7 @@ class _ReturnGoodsDetailPageState extends State { @override void dispose() { - _easyRefreshController?.dispose(); + _easyRefreshController.dispose(); super.dispose(); } @@ -48,10 +48,9 @@ class _ReturnGoodsDetailPageState extends State { body: EasyRefresh( firstRefresh: true, header: MaterialHeader(), + controller: _easyRefreshController, onRefresh: () async { - List models = await (getModels()); - _models = - models.map((e) => ArticleReturnListModel.fromJson(e)).toList(); + _models = await (getModels()); _onload = false; setState(() {}); }, @@ -162,7 +161,12 @@ class _ReturnGoodsDetailPageState extends State { Future getModels() async { BaseModel baseModel = await NetUtil().get(API.manager.articleReturnList); - return baseModel.data as List?; + if (baseModel.status! && baseModel.data != null) { + return (baseModel.data as List) + .map((e) => ArticleReturnListModel.fromJson(e)) + .toList(); + } + return [ArticleReturnListModel.fail()]; } Widget _goodsCard(ArticleReturnListModel model) {