修复借还管理接口调用错误

hmxc
张萌 4 years ago
parent ca6e4745c7
commit bf84640e91

@ -37,6 +37,9 @@ class ArticleReturnListModel {
}
}
factory ArticleReturnListModel.fail() => ArticleReturnListModel(
id: -1, name: '', code: '', beginDate: '', borrowTime: 0, imgList: []);
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> json) {
url = json['url'];
size = json['size'];
longs = json['longs'];
paragraph = json['paragraph'];
sort = json['sort'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['url'] = this.url;
data['size'] = this.size;
data['longs'] = this.longs;
data['paragraph'] = this.paragraph;
data['sort'] = this.sort;
return data;
}
}

@ -24,7 +24,7 @@ class ReturnGoodsDetailPage extends StatefulWidget {
}
class _ReturnGoodsDetailPageState extends State<ReturnGoodsDetailPage> {
EasyRefreshController? _easyRefreshController;
late EasyRefreshController _easyRefreshController;
late List<ArticleReturnListModel> _models;
bool _onload = true;
List<int?> _selectItems = [];
@ -37,7 +37,7 @@ class _ReturnGoodsDetailPageState extends State<ReturnGoodsDetailPage> {
@override
void dispose() {
_easyRefreshController?.dispose();
_easyRefreshController.dispose();
super.dispose();
}
@ -48,10 +48,9 @@ class _ReturnGoodsDetailPageState extends State<ReturnGoodsDetailPage> {
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<ReturnGoodsDetailPage> {
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) {

Loading…
Cancel
Save