parent
5f5813724b
commit
cef324e737
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,50 @@
|
||||
import 'package:akuCommunity/model/common/img_model.dart';
|
||||
|
||||
class ArticleBorrowDetailModel {
|
||||
int id;
|
||||
String name;
|
||||
String code;
|
||||
int status;
|
||||
List<ImgModel> imgList;
|
||||
String get borrowStatus {
|
||||
switch (this.status) {
|
||||
case 1:
|
||||
return '正常';
|
||||
break;
|
||||
case 2:
|
||||
return '破损';
|
||||
case 3:
|
||||
return '丢失';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
ArticleBorrowDetailModel(
|
||||
{this.id, this.name, this.code, this.status, this.imgList});
|
||||
|
||||
ArticleBorrowDetailModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
code = json['code'];
|
||||
status = json['status'];
|
||||
if (json['imgList'] != null) {
|
||||
imgList = new List<ImgModel>();
|
||||
json['imgList'].forEach((v) {
|
||||
imgList.add(new ImgModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
data['code'] = this.code;
|
||||
data['status'] = this.status;
|
||||
if (this.imgList != null) {
|
||||
data['imgList'] = this.imgList.map((v) => v.toJson()).toList();
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
import 'package:akuCommunity/model/common/img_model.dart';
|
||||
|
||||
class ArticleReturnModel {
|
||||
int id;
|
||||
String name;
|
||||
String code;
|
||||
String beginDate;
|
||||
int borrowTime;
|
||||
List<ImgModel> imgList;
|
||||
|
||||
ArticleReturnModel(
|
||||
{this.id,
|
||||
this.name,
|
||||
this.code,
|
||||
this.beginDate,
|
||||
this.borrowTime,
|
||||
this.imgList});
|
||||
|
||||
ArticleReturnModel.fromJson(Map<String, dynamic> json) {
|
||||
id = json['id'];
|
||||
name = json['name'];
|
||||
code = json['code'];
|
||||
beginDate = json['beginDate'];
|
||||
borrowTime = json['borrowTime'];
|
||||
if (json['imgList'] != null) {
|
||||
imgList = new List<ImgModel>();
|
||||
json['imgList'].forEach((v) {
|
||||
imgList.add(new ImgModel.fromJson(v));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = new Map<String, dynamic>();
|
||||
data['id'] = this.id;
|
||||
data['name'] = this.name;
|
||||
data['code'] = this.code;
|
||||
data['beginDate'] = this.beginDate;
|
||||
data['borrowTime'] = this.borrowTime;
|
||||
if (this.imgList != null) {
|
||||
data['imgList'] = this.imgList.map((v) => v.toJson()).toList();
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
@ -0,0 +1,139 @@
|
||||
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/bee_scaffold.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_easyrefresh/easy_refresh.dart';
|
||||
import 'package:velocity_x/velocity_x.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:akuCommunity/const/resource.dart';
|
||||
|
||||
class BorrowGoodsDetailPage extends StatefulWidget {
|
||||
final int articleId;
|
||||
BorrowGoodsDetailPage({Key key, this.articleId}) : super(key: key);
|
||||
|
||||
@override
|
||||
_BorrowGoodsDetailPageState createState() => _BorrowGoodsDetailPageState();
|
||||
}
|
||||
|
||||
class _BorrowGoodsDetailPageState extends State<BorrowGoodsDetailPage> {
|
||||
EasyRefreshController _easyRefreshController;
|
||||
List<ArticleBorrowDetailModel> _models;
|
||||
bool _onload = true;
|
||||
List<int> _selectItems = [];
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_easyRefreshController = EasyRefreshController();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_easyRefreshController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return BeeScaffold(
|
||||
title: '选择物品',
|
||||
body: EasyRefresh(
|
||||
firstRefresh: true,
|
||||
header: MaterialHeader(),
|
||||
onRefresh: () async {
|
||||
List models = await getModels();
|
||||
_models =
|
||||
models.map((e) => ArticleBorrowDetailModel.fromJson(e)).toList();
|
||||
_onload = false;
|
||||
setState(() {});
|
||||
},
|
||||
child: _onload
|
||||
? _empty()
|
||||
: ListView(
|
||||
children: [..._models.map((e) => _goodsCard(e)).toList()],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _empty() {
|
||||
return Container();
|
||||
}
|
||||
|
||||
Future getModels() async {
|
||||
BaseModel baseModel =
|
||||
await NetUtil().get(API.manager.articleBorrowFindDetail, params: {
|
||||
"articleId": widget.articleId,
|
||||
});
|
||||
return baseModel.data as List;
|
||||
}
|
||||
|
||||
Widget _goodsCard(ArticleBorrowDetailModel model) {
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
CommonRadio(
|
||||
size: 32.w,
|
||||
value: model.id,
|
||||
groupValue: _selectItems,
|
||||
),
|
||||
24.w.widthBox,
|
||||
SizedBox(
|
||||
width: 184.w,
|
||||
height: 184.w,
|
||||
child: ClipRRect(
|
||||
child: FadeInImage.assetNetwork(
|
||||
placeholder: R.ASSETS_IMAGES_PLACEHOLDER_WEBP,
|
||||
image: API.image(ImgModel.first(model.imgList)),
|
||||
),
|
||||
),
|
||||
),
|
||||
24.w.widthBox,
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
R.ASSETS_ICONS_ARTICLE_NAME_PNG,
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
4.w.widthBox,
|
||||
'物品名称:'.text.color(ktextSubColor).size(28.sp).make(),
|
||||
'${model.name}'.text.color(ktextPrimary).size(28.sp).make(),
|
||||
],
|
||||
),
|
||||
12.w.heightBox,
|
||||
Row(
|
||||
children: [
|
||||
Image.asset(
|
||||
R.ASSETS_ICONS_ARTICLE_COUNT_PNG,
|
||||
width: 40.w,
|
||||
height: 40.w,
|
||||
),
|
||||
4.w.widthBox,
|
||||
'剩余数量:'.text.color(ktextSubColor).size(28.sp).make(),
|
||||
'${model.borrowStatus}'
|
||||
.text
|
||||
.color(ktextPrimary)
|
||||
.size(28.sp)
|
||||
.make(),
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
],
|
||||
)
|
||||
.box
|
||||
.color(Colors.white)
|
||||
.padding(EdgeInsets.symmetric(vertical: 24.w, horizontal: 24.w))
|
||||
.withRounded(value: 6.w)
|
||||
.make();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue