You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
595 lines
23 KiB
595 lines
23 KiB
6 months ago
|
import 'dart:convert';
|
||
|
|
||
|
import 'package:dio/dio.dart';
|
||
|
import 'package:flutter/material.dart';
|
||
|
import 'package:flutter/services.dart';
|
||
|
import 'package:flutter_easyloading/flutter_easyloading.dart';
|
||
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||
|
import 'package:shared_preferences/shared_preferences.dart';
|
||
|
import 'package:shimmer/shimmer.dart';
|
||
|
|
||
|
import '../../generated/l10n.dart';
|
||
|
import '../../retrofit/data/base_data.dart';
|
||
|
import '../../retrofit/data/user_info.dart';
|
||
|
import '../../retrofit/retrofit_api.dart';
|
||
|
import '../../utils/flutter_utils.dart';
|
||
|
import '../../utils/font_weight.dart';
|
||
|
import '../../view_widget/my_appbar.dart';
|
||
|
|
||
|
class EditInvoicesInfo extends StatefulWidget {
|
||
|
final Map<String, dynamic> arguments;
|
||
|
|
||
|
EditInvoicesInfo({this.arguments});
|
||
|
|
||
|
@override
|
||
|
State<StatefulWidget> createState() {
|
||
|
return _EditInvoicesInfo();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
class _EditInvoicesInfo extends State<EditInvoicesInfo> {
|
||
|
bool isKeyBoardShow = false;
|
||
|
FocusNode _focusNode = FocusNode();
|
||
|
String selectPrice;
|
||
|
String headerId = "";
|
||
|
String phone = "";
|
||
|
String name = "";
|
||
|
ApiService apiService;
|
||
|
Map invoicesInfo;
|
||
|
String mobile;
|
||
|
final TextEditingController editPhoneController = TextEditingController();
|
||
|
List<dynamic> ids;
|
||
|
|
||
|
@override
|
||
|
void initState() {
|
||
|
super.initState();
|
||
|
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||
|
setState(() {
|
||
|
print("object: ${MediaQuery.of(context).viewInsets.bottom}");
|
||
|
if (MediaQuery.of(context).viewInsets.bottom == 0) {
|
||
|
if (isKeyBoardShow) {
|
||
|
isKeyBoardShow = false;
|
||
|
//关闭键盘 软键盘关闭了, 清除输入控件的焦点, 否则重新进入页面会导致软键盘再弹出问题
|
||
|
FocusScope.of(context).requestFocus(FocusNode());
|
||
|
}
|
||
|
} else {
|
||
|
isKeyBoardShow = true;
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
SharedPreferences.getInstance().then((value) => {
|
||
|
apiService = ApiService(Dio(),
|
||
|
context: context, token: value.getString('token'),),
|
||
|
setState(() {
|
||
|
mobile = value.getString('mobile');
|
||
|
})
|
||
|
});
|
||
|
selectPrice = widget?.arguments["selectPrice"] ?? "";
|
||
|
ids = widget?.arguments["ids"] ?? [];
|
||
|
}
|
||
|
|
||
|
///离开页面记着销毁和清除
|
||
|
@override
|
||
|
void dispose() {
|
||
|
super.dispose();
|
||
|
_focusNode.unfocus();
|
||
|
}
|
||
|
|
||
|
///提交发票审核
|
||
|
submitInvoiceReview() async {
|
||
|
try {
|
||
|
EasyLoading.show(
|
||
|
status: S.current.zhengzaijiazai,
|
||
|
maskType: EasyLoadingMaskType.black);
|
||
|
BaseData baseData = await apiService.invoiceSubmit({
|
||
|
"headerId": headerId, //选择的抬头id
|
||
|
"isDelete": 0,
|
||
|
"money": selectPrice, //开票金额
|
||
|
"orderIds": ids, //开票的订单id数组
|
||
|
"ossId": 0,
|
||
|
"phone": phone, //抬头保存的号码
|
||
|
"reason": "",
|
||
|
"reviewerBy": 0,
|
||
|
"reviewerTime": "",
|
||
|
"state": 0,
|
||
|
"type": 1,
|
||
|
"receivingPhone": editPhoneController.text == "" ? mobile :editPhoneController.text, //申请人手机号码
|
||
|
}).catchError((error) {
|
||
|
SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type),
|
||
|
alignment: Alignment.center);
|
||
|
});
|
||
|
if (baseData != null && baseData.isSuccess) {
|
||
|
Navigator.of(context).pop(1);
|
||
|
} else {
|
||
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
|
||
|
}
|
||
|
} finally {
|
||
|
EasyLoading.dismiss();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
@override
|
||
|
Widget build(BuildContext context) {
|
||
|
return GestureDetector(
|
||
|
behavior: HitTestBehavior.translucent,
|
||
|
onTap: () {
|
||
|
FocusScope.of(context).unfocus();
|
||
|
},
|
||
|
child: Scaffold(
|
||
|
resizeToAvoidBottomInset: false,
|
||
|
appBar: MyAppBar(
|
||
|
title: "填写发票信息",
|
||
|
titleColor: Colors.black,
|
||
|
background: Colors.white,
|
||
|
leadingColor: Colors.black,
|
||
|
),
|
||
|
body: // networkStatus == -1 ? noNetwork() :
|
||
|
Container(
|
||
|
margin: EdgeInsets.only(top: 12.h),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: SingleChildScrollView(
|
||
|
physics: BouncingScrollPhysics(),
|
||
|
child: Container(
|
||
|
padding: EdgeInsets.symmetric(horizontal: 17.w),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
///业务流程需求暂时用不到
|
||
|
// Container(
|
||
|
// padding: EdgeInsets.only(
|
||
|
// top: 12.h, bottom: 12.h, left: 12.w, right: 10.w),
|
||
|
// margin: EdgeInsets.only(bottom: 12.h),
|
||
|
// decoration: BoxDecoration(
|
||
|
// color: Colors.white,
|
||
|
// borderRadius: BorderRadius.circular(6),
|
||
|
// boxShadow: [
|
||
|
// BoxShadow(
|
||
|
// color: Color(0x0F06152E),
|
||
|
// offset: Offset(0, 2),
|
||
|
// blurRadius: 4,
|
||
|
// spreadRadius: 0,
|
||
|
// )
|
||
|
// ],
|
||
|
// ),
|
||
|
// child: Row(
|
||
|
// crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
// children: [
|
||
|
// Padding(
|
||
|
// padding: EdgeInsets.only(top: 5.h),
|
||
|
// child: Image.asset(
|
||
|
// "assets/image/tip_info.webp",
|
||
|
// width: 17.h,
|
||
|
// height: 17.h,
|
||
|
// fit: BoxFit.fill,
|
||
|
// ),
|
||
|
// ),
|
||
|
// Padding(
|
||
|
// padding: EdgeInsets.only(left: 5.w),
|
||
|
// child: Text(
|
||
|
// "失败原因:已经开具过纸质发票,不能重复开具\n电子发票",
|
||
|
// style: TextStyle(
|
||
|
// letterSpacing: 0.5,
|
||
|
// height: 1.5,
|
||
|
// color: Color(0xFF32A060),
|
||
|
// fontSize: 14.sp,
|
||
|
// fontWeight: MyFontWeight.regular,
|
||
|
// ),
|
||
|
// ),
|
||
|
// )
|
||
|
// ],
|
||
|
// ),
|
||
|
// ),
|
||
|
Container(
|
||
|
padding:
|
||
|
EdgeInsets.only(top: 16.h, bottom: 16.h, left: 18.w),
|
||
|
margin: EdgeInsets.symmetric(vertical: 12.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(6),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Text(
|
||
|
"发票抬头",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 15.sp,
|
||
|
fontWeight: MyFontWeight.bold,
|
||
|
),
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(top: 16.h, bottom: 18.h),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(right: 31.w),
|
||
|
child: Text(
|
||
|
"发票类型",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
)),
|
||
|
Text(
|
||
|
"电子发票",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF32A060),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.translucent,
|
||
|
onTap: () {
|
||
|
Navigator.of(context)
|
||
|
.pushNamed('/router/invoices_title_info',arguments:{
|
||
|
"enterType":0,
|
||
|
})
|
||
|
.then((value) {
|
||
|
if(value != null){
|
||
|
invoicesInfo = value;
|
||
|
headerId = (value as Map)['id'];
|
||
|
phone = (value as Map)['phone'];
|
||
|
name = (value as Map)['name'];
|
||
|
setState(() {});
|
||
|
}
|
||
|
});
|
||
|
},
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(right: 31.w),
|
||
|
child: Text(
|
||
|
"发票抬头",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
)),
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
name == "" ? "请选择" : name,
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
)),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(right: 21.w),
|
||
|
child: Icon(Icons.arrow_forward_ios,
|
||
|
color: Color(0xFF181818),
|
||
|
size: 14.sp))
|
||
|
],
|
||
|
))
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
padding: EdgeInsets.symmetric(
|
||
|
vertical: 16.h, horizontal: 17.w),
|
||
|
margin: EdgeInsets.symmetric(vertical: 12.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(6),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
child: Row(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Expanded(
|
||
|
child: Text(
|
||
|
"开票金额",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
)),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(right: 6.w),
|
||
|
child: Text(
|
||
|
"可开票金额",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
Text(
|
||
|
"${selectPrice ?? "0"}元",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF32A060),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
padding: EdgeInsets.symmetric(horizontal: 17.w),
|
||
|
margin: EdgeInsets.symmetric(vertical: 12.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(6),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
child: Row(
|
||
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||
|
children: [
|
||
|
Text(
|
||
|
"发票接收",
|
||
|
style: TextStyle(
|
||
|
color: Color(0xFF1A1A1A),
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular,
|
||
|
),
|
||
|
),
|
||
|
Expanded(
|
||
|
child: TextField(
|
||
|
controller: editPhoneController,
|
||
|
decoration: InputDecoration(
|
||
|
hintText: mobile,
|
||
|
hintStyle: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
hintTextDirection: TextDirection.rtl,
|
||
|
border: InputBorder.none,
|
||
|
contentPadding:
|
||
|
EdgeInsets.only(left: 16.w),
|
||
|
),
|
||
|
textAlign: TextAlign.right,
|
||
|
style: TextStyle(
|
||
|
color: Colors.black,
|
||
|
fontSize: 14.sp,
|
||
|
fontWeight: MyFontWeight.regular),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
)),
|
||
|
GestureDetector(
|
||
|
behavior: HitTestBehavior.opaque,
|
||
|
onTap:(){
|
||
|
if(name == ""){
|
||
|
SmartDialog.showToast("请选择发票抬头",
|
||
|
alignment: Alignment.center);
|
||
|
}else{
|
||
|
submitInvoiceReview();
|
||
|
}
|
||
|
},
|
||
|
child: Container(
|
||
|
padding: EdgeInsets.symmetric(vertical: 20.h),
|
||
|
color: Color(0xff32A060),
|
||
|
width: double.infinity,
|
||
|
alignment: Alignment.center,
|
||
|
child: Text(
|
||
|
"确认提交",
|
||
|
style: TextStyle(
|
||
|
color: Colors.white,
|
||
|
fontSize: 16.sp,
|
||
|
fontWeight: MyFontWeight.medium,
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
));
|
||
|
}
|
||
|
|
||
|
Widget editInvoicesInfoSm() {
|
||
|
return Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Container(
|
||
|
padding: EdgeInsets.only(top: 16.h, bottom: 16.h, left: 18.w),
|
||
|
margin: EdgeInsets.symmetric(vertical: 12.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(6),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
child: Column(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 62,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Padding(
|
||
|
padding: EdgeInsets.only(top: 16.h, bottom: 18.h),
|
||
|
child: Row(
|
||
|
children: [
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(right: 31.w),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 58,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 58,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Row(
|
||
|
children: [
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(right: 31.w),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 58,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 140,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Spacer(),
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(right: 21.w),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 14,
|
||
|
height: 14),
|
||
|
),
|
||
|
],
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
Container(
|
||
|
padding: EdgeInsets.symmetric(vertical: 16.h, horizontal: 17.w),
|
||
|
margin: EdgeInsets.symmetric(vertical: 12.h),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Colors.white,
|
||
|
borderRadius: BorderRadius.circular(6),
|
||
|
boxShadow: [
|
||
|
BoxShadow(
|
||
|
color: Color(0x0F06152E),
|
||
|
offset: Offset(0, 2),
|
||
|
blurRadius: 4,
|
||
|
spreadRadius: 0,
|
||
|
)
|
||
|
],
|
||
|
),
|
||
|
child: Row(
|
||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||
|
children: [
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 58,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Spacer(),
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
margin: EdgeInsets.only(right: 6.w),
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 70,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
Shimmer.fromColors(
|
||
|
baseColor: Color(0XFFD8D8D8),
|
||
|
highlightColor: Color(0XFFD8D8D8),
|
||
|
child: Container(
|
||
|
decoration: BoxDecoration(
|
||
|
color: Color(0XFFD8D8D8),
|
||
|
borderRadius: BorderRadius.circular(2),
|
||
|
),
|
||
|
width: 31,
|
||
|
height: 20,
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
),
|
||
|
),
|
||
|
],
|
||
|
);
|
||
|
}
|
||
|
}
|