对接: 新增物品明细

hmxc
张萌 4 years ago
parent e8df4c569a
commit a38f8d788e

@ -179,6 +179,9 @@ class _Manage {
/// ///
String get borrowDelete => '/user/borrow/delete'; String get borrowDelete => '/user/borrow/delete';
///
String get borrowinsertArticleDetail => '/user/borrow/insertArticleDetail';
} }
class _Upload { class _Upload {

@ -1,38 +1,52 @@
// Dart imports: // Dart imports:
import 'dart:io'; import 'dart:io';
import 'dart:math';
// 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/net_util.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get/get.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:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:common_utils/common_utils.dart';
// Project imports: // Project imports:
import 'package:aku_community_manager/mock_models/borrow/borrow_model.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/widgets/common/aku_scaffold.dart'; import 'package:aku_community_manager/ui/widgets/common/aku_scaffold.dart';
import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart'; import 'package:aku_community_manager/ui/widgets/inner/pick_image.dart';
import 'package:get/instance_manager.dart';
class AddBorrowItemPage extends StatefulWidget { class AddBorrowItemPage extends StatefulWidget {
final BorrowObject object; final int articleId;
AddBorrowItemPage({Key key, @required this.object}) : super(key: key); AddBorrowItemPage({
Key key,
this.articleId,
}) : super(key: key);
@override @override
_AddBorrowItemPageState createState() => _AddBorrowItemPageState(); _AddBorrowItemPageState createState() => _AddBorrowItemPageState();
} }
class _AddBorrowItemPageState extends State<AddBorrowItemPage> { class _AddBorrowItemPageState extends State<AddBorrowItemPage> {
TextEditingController _textEditingController = TextEditingController(); TextEditingController _textEditingController;
String code = ''; TextEditingController _codeEditingCOntroller;
File file; File file;
@override @override
void initState() { void initState() {
super.initState(); super.initState();
code = (10000000 + Random().nextInt(999999)).toString(); _textEditingController = TextEditingController();
_codeEditingCOntroller = TextEditingController();
}
@override
void dispose() {
_textEditingController?.dispose();
_codeEditingCOntroller?.dispose();
super.dispose();
} }
@override @override
@ -42,20 +56,24 @@ class _AddBorrowItemPageState extends State<AddBorrowItemPage> {
actions: [ actions: [
AkuMaterialButton( AkuMaterialButton(
minWidth: 120.w, minWidth: 120.w,
onPressed: () { onPressed: () async {
if (TextUtil.isEmpty(_textEditingController.text)) { BaseFileModel baseFileModel =
BotToast.showText(text: '名称不能为空'); await NetUtil().upload(API.upload.uploadArticleDetail, file);
} else if (file == null) { if (baseFileModel.status) {
BotToast.showText(text: '图片不能为空'); await NetUtil().post(
API.manage.borrowinsertArticleDetail,
params: {
"articleId": widget.articleId,
"name": _textEditingController.text,
"code": _codeEditingCOntroller.text,
"fileUrls": [baseFileModel.url]
},
showMessage: true,
);
Get.back();
} else { } else {
widget.object.items.insert( BotToast.showText(text: baseFileModel.message);
0,
SingleBorrowGoods(
name: _textEditingController.text,
code: code,
assetpath: file,
status: BORROW_STATUS.NOT_BORROW,
));
} }
}, },
child: Text( child: Text(
@ -92,14 +110,22 @@ class _AddBorrowItemPageState extends State<AddBorrowItemPage> {
Divider(height: 1.w), Divider(height: 1.w),
_buildRow( _buildRow(
'物品单号', '物品单号',
Text( TextField(
code, inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r"[0-9]*"))
],
style: TextStyle( style: TextStyle(
color: AppStyle.minorTextColor, color: AppStyle.primaryTextColor,
fontSize: 28.sp, fontSize: 28.sp,
fontWeight: FontWeight.bold, fontWeight: FontWeight.bold,
), ),
controller: _codeEditingCOntroller,
decoration: InputDecoration(
border: InputBorder.none,
hintText: '请输入物品单号',
),
)), )),
Divider(height: 1.w),
_buildRow( _buildRow(
'物品图片', '物品图片',
file == null file == null

@ -40,7 +40,11 @@ class _BorrowItemPageState extends State<BorrowItemPage> {
? AkuMaterialButton( ? AkuMaterialButton(
minWidth: 120.w, minWidth: 120.w,
onPressed: () { onPressed: () {
// Get.to(AddBorrowItemPage(object: widget.object)); Get.to(
AddBorrowItemPage(
articleId: widget.id,
),
);
}, },
child: Text( child: Text(
'新增', '新增',

Loading…
Cancel
Save