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

hmxc
小赖 4 years ago
parent c54b390609
commit d32bba3521

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

@ -7,7 +7,7 @@ class BorrowDetailItemModel {
int borrowStatus; int borrowStatus;
List<ImgModel> imgUrls; List<ImgModel> imgUrls;
ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first; ImgModel get firstImg => imgUrls.isEmpty ? null : imgUrls.first;
bool get borrowed => borrowStatus == 2;
BorrowDetailItemModel( BorrowDetailItemModel(
{this.id, this.name, this.code, this.borrowStatus, this.imgUrls}); {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: // 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'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:aku_ui/common_widgets/aku_material_button.dart'; import 'package:aku_ui/common_widgets/aku_material_button.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// Project imports: // 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'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class BorrowItemDetailPage extends StatefulWidget { class BorrowItemDetailPage extends StatefulWidget {
final SingleBorrowGoods item; final int id;
BorrowItemDetailPage({Key key, this.item}) : super(key: key); BorrowItemDetailPage({Key key, this.id}) : super(key: key);
@override @override
_BorrowItemDetailPageState createState() => _BorrowItemDetailPageState(); _BorrowItemDetailPageState createState() => _BorrowItemDetailPageState();
@ -24,10 +29,11 @@ class BorrowItemDetailPage extends StatefulWidget {
class _BorrowItemDetailPageState extends State<BorrowItemDetailPage> { class _BorrowItemDetailPageState extends State<BorrowItemDetailPage> {
bool _isEditing = false; bool _isEditing = false;
TextEditingController _textEditingController; TextEditingController _textEditingController;
BorrowItemDetailModel _detailModel;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
_textEditingController = TextEditingController(text: widget.item.name); _textEditingController = TextEditingController(text: '');
} }
@override @override
@ -60,77 +66,86 @@ class _BorrowItemDetailPageState extends State<BorrowItemDetailPage> {
) )
: SizedBox(), : SizedBox(),
], ],
body: ListView( body: EasyRefresh(
padding: EdgeInsets.symmetric(vertical: 16.w), firstRefresh: true,
children: [ header: MaterialHeader(),
Container( onRefresh: () async {
color: Colors.white, BaseModel model = await NetUtil().get(
padding: EdgeInsets.symmetric(horizontal: 32.w), API.manage.borrowItemDetail,
child: Column( params: {'articleDetailId': widget.id},
children: [ );
_buildRow( _detailModel = BorrowItemDetailModel.fromJson(model.data);
'物品名称', _textEditingController.text = _detailModel.name;
TextField( setState(() {});
style: TextStyle( },
color: AppStyle.primaryTextColor, child: _detailModel == null
fontSize: 28.sp, ? SizedBox()
fontWeight: FontWeight.bold, : ListView(
), padding: EdgeInsets.symmetric(vertical: 16.w),
controller: _textEditingController, children: [
enabled: _isEditing, Container(
onChanged: (text) { color: Colors.white,
widget.item.name = text; padding: EdgeInsets.symmetric(horizontal: 32.w),
}, child: Column(
decoration: InputDecoration( children: [
border: InputBorder.none, _buildRow(
), '物品名称',
)), TextField(
Divider(height: 1.w), style: TextStyle(
_buildRow( color: AppStyle.primaryTextColor,
'物品单号', fontSize: 28.sp,
Text( fontWeight: FontWeight.bold,
widget.item.code, ),
style: TextStyle( controller: _textEditingController,
color: _isEditing enabled: _isEditing,
? AppStyle.minorTextColor onChanged: (text) {
: AppStyle.primaryTextColor, //TODO edit
fontSize: 28.sp, // widget.item.name = text;
fontWeight: FontWeight.bold, },
), decoration: InputDecoration(
)), border: InputBorder.none,
_buildRow( ),
'出借状态', )),
Text( Divider(height: 1.w),
'未出借', _buildRow(
style: TextStyle( '物品单号',
color: _isEditing Text(
? AppStyle.minorTextColor _detailModel.code,
: AppStyle.primaryTextColor, style: TextStyle(
fontSize: 28.sp, color: _isEditing
fontWeight: FontWeight.bold, ? AppStyle.minorTextColor
), : AppStyle.primaryTextColor,
)), fontSize: 28.sp,
_buildRow( fontWeight: FontWeight.bold,
'物品图片', ),
(widget.item.assetpath is String) )),
? Image.asset( _buildRow(
widget.item.assetpath, '出借状态',
height: 184.w, Text(
width: 184.w, '未出借',
fit: BoxFit.cover, style: TextStyle(
) color: _isEditing
: Image.file( ? AppStyle.minorTextColor
widget.item.assetpath, : AppStyle.primaryTextColor,
height: 184.w, fontSize: 28.sp,
width: 184.w, fontWeight: FontWeight.bold,
fit: BoxFit.cover, ),
)),
_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: // Flutter imports:
import 'package:aku_community_manager/const/api.dart'; 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/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:aku_community_manager/ui/widgets/common/bee_list_view.dart';
import 'package:flutter/cupertino.dart'; import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@ -12,13 +13,10 @@ import 'package:get/get.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
// Project imports: // 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/mock_models/users/user_info_model.dart';
import 'package:aku_community_manager/provider/user_provider.dart'; import 'package:aku_community_manager/provider/user_provider.dart';
import 'package:aku_community_manager/style/app_style.dart'; import 'package:aku_community_manager/style/app_style.dart';
import 'package:aku_community_manager/tools/widget_tool.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'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
class BorrowItemPage extends StatefulWidget { class BorrowItemPage extends StatefulWidget {
@ -77,7 +75,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
final userProvider = Provider.of<UserProvider>(context); final userProvider = Provider.of<UserProvider>(context);
return GestureDetector( return GestureDetector(
onTap: () { onTap: () {
// Get.to(BorrowItemDetailPage(item: item)); Get.to(BorrowItemDetailPage(id: item.id));
}, },
child: Container( child: Container(
margin: EdgeInsets.only(top: 16.w), margin: EdgeInsets.only(top: 16.w),
@ -172,7 +170,7 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
_buildRow( _buildRow(
R.ASSETS_MANAGE_BORROW_PNG, R.ASSETS_MANAGE_BORROW_PNG,
'出借状态', '出借状态',
'未借出', item.borrowed ? '已出借' : '未借出',
color: AppStyle.secondaryColor, color: AppStyle.secondaryColor,
), ),
], ],

Loading…
Cancel
Save