对接:借还管理:新增总类

hmxc
张萌 4 years ago
parent b077ef6449
commit 34fa3693e8

@ -173,6 +173,10 @@ class _Manage {
/// ///
String get backlogList => '/user/backlog/list'; String get backlogList => '/user/backlog/list';
///
String get insertArticle => '/user/borrow/insertArticle';
} }
class _Upload { class _Upload {

@ -2,6 +2,10 @@
import 'dart:io'; import 'dart:io';
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart';
import 'package:aku_community_manager/utils/network/base_file_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:
@ -31,48 +35,48 @@ class AddBorrowObjectPage extends StatefulWidget {
class _AddBorrowObjectPageState extends State<AddBorrowObjectPage> { class _AddBorrowObjectPageState extends State<AddBorrowObjectPage> {
TextEditingController _textEditingController = TextEditingController(); TextEditingController _textEditingController = TextEditingController();
TextEditingController _numberController = TextEditingController(); // TextEditingController _numberController = TextEditingController();
File file; File file;
List<BorrowObject> get objects => BorrowData.borrowObjects; // List<BorrowObject> get objects => BorrowData.borrowObjects;
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final userProvider = Provider.of<UserProvider>(context); // final userProvider = Provider.of<UserProvider>(context);
return AkuScaffold( return AkuScaffold(
title: '物品详情', title: '新增总类',
actions: [ // actions: [
userProvider.userInfoModel.role != USER_ROLE.MANAGER // userProvider.userInfoModel.role != USER_ROLE.MANAGER
? AkuMaterialButton( // ? AkuMaterialButton(
minWidth: 120.w, // minWidth: 120.w,
onPressed: () { // onPressed: () {
if (TextUtil.isEmpty(_textEditingController.text)) { // if (TextUtil.isEmpty(_textEditingController.text)) {
BotToast.showText(text: '名称不能为空'); // BotToast.showText(text: '名称不能为空');
} else if (file == null) { // } else if (file == null) {
BotToast.showText(text: '图片不能为空'); // BotToast.showText(text: '图片不能为空');
} else if (int.tryParse(_numberController.text) == null) { // } else if (int.tryParse(_numberController.text) == null) {
BotToast.showText(text: '数量错误'); // BotToast.showText(text: '数量错误');
} else { // } else {
objects.insert( // objects.insert(
0, // 0,
BorrowObject.init( // BorrowObject.init(
name: _textEditingController.text, // name: _textEditingController.text,
allNumber: int.parse(_numberController.text), // allNumber: int.parse(_numberController.text),
assetPath: file, // assetPath: file,
), // ),
); // );
Get.back(); // Get.back();
} // }
}, // },
child: Text( // child: Text(
'完成', // '完成',
style: TextStyle( // style: TextStyle(
fontSize: 28.w, // fontSize: 28.w,
color: AppStyle.primaryTextColor, // color: AppStyle.primaryTextColor,
), // ),
), // ),
) // )
: SizedBox(), // : SizedBox(),
], // ],
body: ListView( body: ListView(
padding: EdgeInsets.symmetric(vertical: 16.w), padding: EdgeInsets.symmetric(vertical: 16.w),
children: [ children: [
@ -99,24 +103,24 @@ class _AddBorrowObjectPageState extends State<AddBorrowObjectPage> {
), ),
)), )),
Divider(height: 1.w), Divider(height: 1.w),
_buildRow( // _buildRow(
'物品数量', // '物品数量',
TextField( // TextField(
onChanged: (_) { // onChanged: (_) {
setState(() {}); // setState(() {});
}, // },
style: TextStyle( // style: TextStyle(
color: AppStyle.primaryTextColor, // color: AppStyle.primaryTextColor,
fontSize: 28.sp, // fontSize: 28.sp,
fontWeight: FontWeight.bold, // fontWeight: FontWeight.bold,
), // ),
controller: _numberController, // controller: _numberController,
decoration: InputDecoration( // decoration: InputDecoration(
border: InputBorder.none, // border: InputBorder.none,
hintText: '请输入物品数量', // hintText: '请输入物品数量',
), // ),
)), // )),
Divider(height: 1.w), // Divider(height: 1.w),
AkuBox.h(24), AkuBox.h(24),
_buildRow( _buildRow(
'物品图片', '物品图片',
@ -174,21 +178,29 @@ class _AddBorrowObjectPageState extends State<AddBorrowObjectPage> {
padding: EdgeInsets.symmetric(horizontal: 64.w), padding: EdgeInsets.symmetric(horizontal: 64.w),
child: AkuBottomButton( child: AkuBottomButton(
title: '确定', title: '确定',
onTap: TextUtil.isEmpty(_textEditingController.text) || onTap:
TextUtil.isEmpty(_numberController.text) || TextUtil.isEmpty(_textEditingController.text) || file == null
file == null || // TextUtil.isEmpty(_numberController.text) ||
int.tryParse(_numberController.text) == null // file == null ||
? null // int.tryParse(_numberController.text) == null
: () { ? null
BorrowData.borrowObjects.add( : () async {
BorrowObject.init( BaseFileModel baseFileModel = await NetUtil()
name: _textEditingController.text, .upload(API.upload.uploadArtical, file);
allNumber: int.parse(_numberController.text), if (baseFileModel.status) {
assetPath: file, await NetUtil().post(
), API.manage.insertArticle,
); params: {
Get.back(); "name": _textEditingController.text,
}, "fileUrls": [baseFileModel.url]
},
showMessage: true,
);
} else {
BotToast.showText(text: baseFileModel.message);
}
Get.back();
},
), ),
), ),
], ],

Loading…
Cancel
Save