|
|
|
@ -1,10 +1,15 @@
|
|
|
|
|
import 'package:dio/dio.dart'; |
|
|
|
|
import 'package:flutter/material.dart'; |
|
|
|
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; |
|
|
|
|
import 'package:huixiang/utils/font_weight.dart'; |
|
|
|
|
import 'package:huixiang/view_widget/my_appbar.dart'; |
|
|
|
|
import 'package:pull_to_refresh/pull_to_refresh.dart'; |
|
|
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart'; |
|
|
|
|
|
|
|
|
|
import '../../retrofit/business_api.dart'; |
|
|
|
|
import '../../retrofit/data/base_data.dart'; |
|
|
|
|
import '../../retrofit/data/business_order_list.dart'; |
|
|
|
|
import '../../utils/business_instance.dart'; |
|
|
|
|
import '../../view_widget/classic_header.dart'; |
|
|
|
|
import '../../view_widget/my_footer.dart'; |
|
|
|
|
|
|
|
|
@ -25,6 +30,9 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
List<Tickets> tickets; |
|
|
|
|
String productName; |
|
|
|
|
int nameIndex = 0; |
|
|
|
|
BusinessApiService businessService; |
|
|
|
|
List<dynamic> itemMap = []; |
|
|
|
|
List<dynamic> skuTickets = []; |
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
void initState() { |
|
|
|
@ -33,6 +41,66 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
productName = widget.arguments["productName"]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///单个核销 |
|
|
|
|
singleWiped() async { |
|
|
|
|
if (businessService == null) { |
|
|
|
|
businessService = BusinessApiService(Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: BusinessInstance.instance.businessToken, |
|
|
|
|
tenant: BusinessInstance.instance.businessTenant, |
|
|
|
|
storeId: widget.arguments["storeId"]); |
|
|
|
|
} |
|
|
|
|
BaseData baseData = await businessService.wiped({ |
|
|
|
|
"pageNum":1, |
|
|
|
|
"pageSize":10, |
|
|
|
|
"productId":"", |
|
|
|
|
"productSkuId":"", |
|
|
|
|
"searchKey":"", |
|
|
|
|
"state":"", |
|
|
|
|
"storeId":"", |
|
|
|
|
"ticketCode":"", |
|
|
|
|
"ticketId":"", |
|
|
|
|
"ticketItemIds":[], |
|
|
|
|
"type":"" |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
SmartDialog.showToast("核销成功", alignment: Alignment.center); |
|
|
|
|
Navigator.pop(context); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
///多个核销 |
|
|
|
|
severalWiped() async { |
|
|
|
|
if (businessService == null) { |
|
|
|
|
businessService = BusinessApiService(Dio(), |
|
|
|
|
context: context, |
|
|
|
|
token: BusinessInstance.instance.businessToken, |
|
|
|
|
tenant: BusinessInstance.instance.businessTenant, |
|
|
|
|
storeId: widget.arguments["storeId"]); |
|
|
|
|
} |
|
|
|
|
BaseData baseData = await businessService.posTicketRecharge({ |
|
|
|
|
"itemMap":[{ |
|
|
|
|
"productSkuld":tickets[nameIndex].productSkuId ?? "", |
|
|
|
|
"skuTickets":[{ |
|
|
|
|
"number":1, |
|
|
|
|
"skuTicket":tickets[nameIndex].name ?? "", |
|
|
|
|
"state":tickets[nameIndex].state ?? "", |
|
|
|
|
}] |
|
|
|
|
}], |
|
|
|
|
"ticketCode":tickets[nameIndex].code ?? "", |
|
|
|
|
}).catchError((error) {}); |
|
|
|
|
if (baseData != null && baseData.isSuccess) { |
|
|
|
|
SmartDialog.showToast("核销成功", alignment: Alignment.center); |
|
|
|
|
Navigator.pop(context); |
|
|
|
|
} else { |
|
|
|
|
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
|
Widget build(BuildContext context) { |
|
|
|
|
return Scaffold( |
|
|
|
@ -49,14 +117,16 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
enablePullDown: true, |
|
|
|
|
enablePullUp: false, |
|
|
|
|
header: MyHeader( |
|
|
|
|
color: Colors.white, |
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
), |
|
|
|
|
footer: CustomFooter( |
|
|
|
|
builder: (context, mode) { |
|
|
|
|
return MyFooter(mode); |
|
|
|
|
}, |
|
|
|
|
), |
|
|
|
|
onRefresh: () {}, |
|
|
|
|
onRefresh: () { |
|
|
|
|
refreshController.refreshCompleted(); |
|
|
|
|
}, |
|
|
|
|
physics: BouncingScrollPhysics(), |
|
|
|
|
scrollController: ScrollController(), |
|
|
|
|
child: SingleChildScrollView( |
|
|
|
@ -67,10 +137,33 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
children: [ |
|
|
|
|
basicInfo(), |
|
|
|
|
writeOffInfo(), |
|
|
|
|
Container( |
|
|
|
|
GestureDetector( |
|
|
|
|
onTap:(){ |
|
|
|
|
if (itemMap.length != 0) itemMap.clear(); |
|
|
|
|
tickets.forEach((element) { |
|
|
|
|
if (element.isSelect) { |
|
|
|
|
skuTickets.add({ |
|
|
|
|
"number":1, |
|
|
|
|
"skuTicket":element.name, |
|
|
|
|
"state":element.state,}); |
|
|
|
|
itemMap.add({ |
|
|
|
|
"productSkuld":element.productSkuId, |
|
|
|
|
"skuTickets":skuTickets |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
if (itemMap.length == 0) { |
|
|
|
|
SmartDialog.showToast("请选择要核销的商品", |
|
|
|
|
alignment: Alignment.center); |
|
|
|
|
return; |
|
|
|
|
} else { |
|
|
|
|
severalWiped(); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
child: Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
alignment: Alignment.center, |
|
|
|
|
margin: EdgeInsets.only(bottom:55.h,top: 125.h), |
|
|
|
|
margin: EdgeInsets.only(bottom:55.h,), |
|
|
|
|
padding: EdgeInsets.symmetric(vertical:16.h), |
|
|
|
|
decoration: BoxDecoration( |
|
|
|
|
borderRadius: BorderRadius.circular(27), |
|
|
|
@ -84,6 +177,7 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
color: Colors.white, |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
@ -229,6 +323,20 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
) |
|
|
|
|
// ListView.builder( |
|
|
|
|
// padding: EdgeInsets.zero, |
|
|
|
|
// itemCount:3, |
|
|
|
|
// scrollDirection: Axis.vertical, |
|
|
|
|
// shrinkWrap: true, |
|
|
|
|
// physics: BouncingScrollPhysics(), |
|
|
|
|
// itemBuilder: (context, position) { |
|
|
|
|
// return GestureDetector( |
|
|
|
|
// onTap: () { |
|
|
|
|
// }, |
|
|
|
|
// child: writeOffInfoItems(), |
|
|
|
|
// ); |
|
|
|
|
// }, |
|
|
|
|
// ) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
@ -266,10 +374,10 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
SizedBox(height:25.h,), |
|
|
|
|
if(tickets.state == 1) |
|
|
|
|
Checkbox( |
|
|
|
|
value: writeOffCheck, |
|
|
|
|
value: tickets.isSelect, |
|
|
|
|
onChanged: (a) { |
|
|
|
|
setState(() { |
|
|
|
|
writeOffCheck = !writeOffCheck; |
|
|
|
|
tickets.isSelect = !tickets.isSelect; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
@ -313,4 +421,62 @@ class _OrderWriteOff extends State<OrderWriteOff> {
|
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Widget writeOffInfoItems(){ |
|
|
|
|
return Container( |
|
|
|
|
width: double.infinity, |
|
|
|
|
child: Column( |
|
|
|
|
children: [ |
|
|
|
|
Row( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start, |
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center, |
|
|
|
|
children: [ |
|
|
|
|
Expanded(child: Text( |
|
|
|
|
"哈哈哈哈哈", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: MyFontWeight.regular, |
|
|
|
|
fontSize: 14.sp, |
|
|
|
|
color: Color(0xFF0D0D0D), |
|
|
|
|
), |
|
|
|
|
)), |
|
|
|
|
Expanded(child: Column( |
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.end, |
|
|
|
|
children: [ |
|
|
|
|
Padding(padding: EdgeInsets.only(right:10.w), |
|
|
|
|
child: Text( |
|
|
|
|
"已核销", |
|
|
|
|
style: TextStyle( |
|
|
|
|
fontWeight: MyFontWeight.semi_bold, |
|
|
|
|
fontSize: 12.sp, |
|
|
|
|
color: Color(0xFF30415B), |
|
|
|
|
), |
|
|
|
|
),), |
|
|
|
|
SizedBox(height:25.h,), |
|
|
|
|
Checkbox( |
|
|
|
|
value: writeOffCheck, |
|
|
|
|
onChanged: (a) { |
|
|
|
|
setState(() { |
|
|
|
|
writeOffCheck = !writeOffCheck; |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
shape: RoundedRectangleBorder( |
|
|
|
|
borderRadius: BorderRadius.circular(2.0), |
|
|
|
|
), |
|
|
|
|
checkColor: Color(0xFFFFFFFF), |
|
|
|
|
fillColor:MaterialStateProperty.all(Color(0xFF30415B)), |
|
|
|
|
), |
|
|
|
|
], |
|
|
|
|
)) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
Container( |
|
|
|
|
margin: EdgeInsets.only(bottom:11.h,top: 13.h), |
|
|
|
|
width: double.infinity, |
|
|
|
|
height: 1.h, |
|
|
|
|
color: Color(0xFFEBECEF), |
|
|
|
|
) |
|
|
|
|
], |
|
|
|
|
), |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|