借还管理物品详情页面细节接口

hmxc
小赖 4 years ago
parent c54b390609
commit d32bba3521

@ -65,4 +65,7 @@ class _Manage {
///id
String get borrowDetailList => '/user/borrow/articleDetailList';
///id
String get borrowItemDetail => '/user/borrow/findById';
}

@ -7,7 +7,7 @@ class BorrowDetailItemModel {
int borrowStatus;
List<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
bool get borrowed => borrowStatus == 2;
BorrowDetailItemModel(
{this.id, this.name, this.code, this.borrowStatus, this.imgUrls});

@ -0,0 +1,60 @@
import 'package:aku_community_manager/models/common/img_model.dart';
class BorrowItemDetailModel {
int id;
String name;
String code;
int borrowStatus;
int status;
List<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
bool get borrowed => borrowStatus == 2;
String get statusValue {
switch (status) {
case 1:
return '正常';
case 2:
return '破损';
case 3:
return '丢失';
default:
return '未知';
}
}
BorrowItemDetailModel(
{this.id,
this.name,
this.code,
this.borrowStatus,
this.status,
this.imgUrls});
BorrowItemDetailModel.fromJson(Map<String, dynamic> json) {
id = json['id'];
name = json['name'];
code = json['code'];
borrowStatus = json['borrowStatus'];
status = json['status'];
if (json['imgUrls'] != null) {
imgUrls = new List<ImgModel>();
json['imgUrls'].forEach((v) {
imgUrls.add(new ImgModel.fromJson(v));
});
} else
imgUrls = [];
}
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['borrowStatus'] = this.borrowStatus;
data['status'] = this.status;
if (this.imgUrls != null) {
data['imgUrls'] = this.imgUrls.map((v) => v.toJson()).toList();
}
return data;
}
}

@ -1,8 +1,13 @@
// Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/borrow/borrow_item_detail_model.dart';
import 'package:aku_community_manager/utils/network/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:flutter/material.dart';
// Package imports:
import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:provider/provider.dart';
// Project imports:
@ -14,8 +19,8 @@ import 'package:aku_community_manager/tools/widget_tool.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class BorrowItemDetailPage extends StatefulWidget {
final SingleBorrowGoods item;
BorrowItemDetailPage({Key key, this.item}) : super(key: key);
final int id;
BorrowItemDetailPage({Key key, this.id}) : super(key: key);
@override
_BorrowItemDetailPageState createState() => _BorrowItemDetailPageState();
@ -24,10 +29,11 @@ class BorrowItemDetailPage extends StatefulWidget {
class _BorrowItemDetailPageState extends State<BorrowItemDetailPage> {
bool _isEditing = false;
TextEditingController _textEditingController;
BorrowItemDetailModel _detailModel;
@override
void initState() {
super.initState();
_textEditingController = TextEditingController(text: widget.item.name);
_textEditingController = TextEditingController(text: '');
}
@override
@ -60,77 +66,86 @@ class _BorrowItemDetailPageState extends State<BorrowItemDetailPage> {
)
: SizedBox(),
],
body: ListView(
padding: EdgeInsets.symmetric(vertical: 16.w),
children: [
Container(
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Column(
children: [
_buildRow(
'物品名称',
TextField(
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
controller: _textEditingController,
enabled: _isEditing,
onChanged: (text) {
widget.item.name = text;
},
decoration: InputDecoration(
border: InputBorder.none,
),
)),
Divider(height: 1.w),
_buildRow(
'物品单号',
Text(
widget.item.code,
style: TextStyle(
color: _isEditing
? AppStyle.minorTextColor
: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
)),
_buildRow(
'出借状态',
Text(
'未出借',
style: TextStyle(
color: _isEditing
? AppStyle.minorTextColor
: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
)),
_buildRow(
'物品图片',
(widget.item.assetpath is String)
? Image.asset(
widget.item.assetpath,
height: 184.w,
width: 184.w,
fit: BoxFit.cover,
)
: Image.file(
widget.item.assetpath,
height: 184.w,
width: 184.w,
fit: BoxFit.cover,
body: EasyRefresh(
firstRefresh: true,
header: MaterialHeader(),
onRefresh: () async {
BaseModel model = await NetUtil().get(
API.manage.borrowItemDetail,
params: {'articleDetailId': widget.id},
);
_detailModel = BorrowItemDetailModel.fromJson(model.data);
_textEditingController.text = _detailModel.name;
setState(() {});
},
child: _detailModel == null
? SizedBox()
: ListView(
padding: EdgeInsets.symmetric(vertical: 16.w),
children: [
Container(
color: Colors.white,
padding: EdgeInsets.symmetric(horizontal: 32.w),
child: Column(
children: [
_buildRow(
'物品名称',
TextField(
style: TextStyle(
color: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
controller: _textEditingController,
enabled: _isEditing,
onChanged: (text) {
//TODO edit
// widget.item.name = text;
},
decoration: InputDecoration(
border: InputBorder.none,
),
)),
Divider(height: 1.w),
_buildRow(
'物品单号',
Text(
_detailModel.code,
style: TextStyle(
color: _isEditing
? AppStyle.minorTextColor
: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
)),
_buildRow(
'出借状态',
Text(
'未出借',
style: TextStyle(
color: _isEditing
? AppStyle.minorTextColor
: AppStyle.primaryTextColor,
fontSize: 28.sp,
fontWeight: FontWeight.bold,
),
)),
_buildRow(
'物品图片',
FadeInImage.assetNetwork(
placeholder: R.ASSETS_PLACEHOLDER_WEBP,
image: API.image(_detailModel.firstImg?.url ?? ''),
height: 184.w,
width: 184.w,
),
),
),
AkuBox.h(28),
],
),
),
],
AkuBox.h(28),
],
),
),
],
),
),
);
}

@ -1,6 +1,7 @@
// Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/models/manager/borrow/borrow_detail_item_model.dart';
import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart';
import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
@ -12,13 +13,10 @@ import 'package:get/get.dart';
import 'package:provider/provider.dart';
// Project imports:
import 'package:aku_community_manager/mock_models/borrow/borrow_model.dart';
import 'package:aku_community_manager/mock_models/users/user_info_model.dart';
import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/widget_tool.dart';
import 'package:aku_community_manager/ui/sub_pages/borrow_manager/add_borrow_item_page.dart';
import 'package:aku_community_manager/ui/sub_pages/borrow_manager/borrow_item_detail_page.dart';
import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class BorrowItemPage extends StatefulWidget {
@ -77,7 +75,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
final userProvider = Provider.of<UserProvider>(context);
return GestureDetector(
onTap: () {
// Get.to(BorrowItemDetailPage(item: item));
Get.to(BorrowItemDetailPage(id: item.id));
},
child: Container(
margin: EdgeInsets.only(top: 16.w),
@ -172,7 +170,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
_buildRow(
R.ASSETS_MANAGE_BORROW_PNG,
'出借状态',
'未借出',
item.borrowed ? '已出借' : '未借出',
color: AppStyle.secondaryColor,
),
],

Loading…
Cancel
Save