Browse Source

订单列表返回状态更改;

核销页面优化
wr_2023_business
wurong 1 year ago
parent
commit
76f61e2525
  1. 48
      lib/business_system/order/order_list.dart
  2. 178
      lib/business_system/order/order_write_off.dart

48
lib/business_system/order/order_list.dart

@ -43,7 +43,6 @@ class _OrderList extends State<OrderList> {
List<AdminOrderDtoList> adminOrderDTOList = []; List<AdminOrderDtoList> adminOrderDTOList = [];
int _pageIndex = 1; int _pageIndex = 1;
bool _shimmer = true; bool _shimmer = true;
int index = 0;
@override @override
void dispose() { void dispose() {
@ -84,7 +83,7 @@ class _OrderList extends State<OrderList> {
await businessService.findAdminOrderList({ await businessService.findAdminOrderList({
"orderCode": "", "orderCode": "",
"keywordType": 1, "keywordType": 1,
"keyword": widget?.keyword ?? queryId ?? "", "keyword": widget.keyword == "" ? (queryId ?? "") : widget.keyword,
"orderStatus": "", "orderStatus": "",
"startTime": widget.time "startTime": widget.time
.replaceAll("", "-") .replaceAll("", "-")
@ -97,7 +96,7 @@ class _OrderList extends State<OrderList> {
.replaceAll("", "") .replaceAll("", "")
.substring(widget.time.length >= 21 ? 22 : 0, .substring(widget.time.length >= 21 ? 22 : 0,
widget.time.length >= 21 ? 41 : 0), widget.time.length >= 21 ? 41 : 0),
"pageIndex": _pageIndex, "pageIndex": (widget.keyword != "" || queryId != null) ? 1 : _pageIndex,
"pageSize": 10, "pageSize": 10,
"refundStatus": widget.status == 3 ? "1" : "", "refundStatus": widget.status == 3 ? "1" : "",
"payStatus": widget.status == 1 ? "0" : (widget.status == 2 ? "1" : ""), "payStatus": widget.status == 1 ? "0" : (widget.status == 2 ? "1" : ""),
@ -111,21 +110,20 @@ class _OrderList extends State<OrderList> {
}); });
if (!mounted) return; if (!mounted) return;
if (baseData != null && baseData.isSuccess) { if (baseData != null && baseData.isSuccess) {
if (queryId == null){ if (queryId == null) {
adminOrderDTOList.addAll(baseData?.data?.adminOrderDTOList ?? []); adminOrderDTOList.addAll(baseData?.data?.adminOrderDTOList ?? []);
if ((baseData?.data?.adminOrderDTOList ?? []).isEmpty || if ((baseData?.data?.adminOrderDTOList ?? []).isEmpty ||
adminOrderDTOList.length == baseData.data.total) adminOrderDTOList.length == baseData.data.total)
_refreshController.loadNoData(); _refreshController.loadNoData();
else else
_refreshController.loadComplete(); _refreshController.loadComplete();
} } else if (adminOrderDTOList != null)
else for (int i = 0; i < adminOrderDTOList.length; i++) {
adminOrderDTOList.forEach((element) { if (adminOrderDTOList[i].orderCode == queryId) {
if (element.id == queryId) { adminOrderDTOList[i] = baseData?.data?.adminOrderDTOList?.first;
adminOrderDTOList[index] = element; break;
return;
} }
}); }
} else { } else {
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
} }
@ -272,13 +270,8 @@ class _OrderList extends State<OrderList> {
shrinkWrap: true, shrinkWrap: true,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return orderGoodsList(
onTap: () { adminOrderDtoList.orderProductList[position]);
index = position;
},
child: orderGoodsList(
adminOrderDtoList.orderProductList[position]),
);
}, },
), ),
), ),
@ -342,8 +335,10 @@ class _OrderList extends State<OrderList> {
Row( Row(
mainAxisAlignment: MainAxisAlignment.end, mainAxisAlignment: MainAxisAlignment.end,
children: [ children: [
if (adminOrderDtoList.ticketStatus != null && adminOrderDtoList.refundStatus == 0) if (adminOrderDtoList.ticketStatus != null &&
GestureDetector(behavior: HitTestBehavior.opaque, adminOrderDtoList.refundStatus == 0)
GestureDetector(
behavior: HitTestBehavior.opaque,
onTap: () { onTap: () {
Navigator.of(context) Navigator.of(context)
.pushNamed('/router/order_write_off', arguments: { .pushNamed('/router/order_write_off', arguments: {
@ -352,12 +347,7 @@ class _OrderList extends State<OrderList> {
"userName": adminOrderDtoList?.name ?? "", "userName": adminOrderDtoList?.name ?? "",
"ticketStatus": adminOrderDtoList?.ticketStatus, "ticketStatus": adminOrderDtoList?.ticketStatus,
}).then((value) async { }).then((value) async {
// if (value == 1) { queryOrderList(queryId: adminOrderDtoList.orderCode);
// _pageIndex = 1;
// adminOrderDTOList.clear();
// _onRefresh(isShowLoad: false);
queryOrderList(queryId: adminOrderDtoList.id);
// }
}); });
}, },
child: Container( child: Container(
@ -394,10 +384,8 @@ class _OrderList extends State<OrderList> {
"storeId": widget.storeId ?? "", "storeId": widget.storeId ?? "",
}).then((value) { }).then((value) {
if (value == 1) { if (value == 1) {
// _pageIndex = 1; queryOrderList(
// adminOrderDTOList.clear(); queryId: adminOrderDtoList.orderCode);
// _onRefresh(isShowLoad: false);
queryOrderList(queryId: adminOrderDtoList.id);
} }
}); });
}, },

178
lib/business_system/order/order_write_off.dart

@ -33,7 +33,6 @@ class _OrderWriteOff extends State<OrderWriteOff> {
List<business.Tickets> tickets; List<business.Tickets> tickets;
TicketDetails ticketDetails; TicketDetails ticketDetails;
business.AdminOrderDtoList adminOrderDTOList; business.AdminOrderDtoList adminOrderDTOList;
int nameIndex = 0;
BusinessApiService businessService; BusinessApiService businessService;
@override @override
@ -49,24 +48,25 @@ class _OrderWriteOff extends State<OrderWriteOff> {
/// ///
severalWiped(ticketWipedBatch) async { severalWiped(ticketWipedBatch) async {
try { try {
EasyLoading.show( EasyLoading.show(
status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); status: S.current.zhengzaijiazai,
if (businessService == null) { maskType: EasyLoadingMaskType.black);
businessService = BusinessApiService(Dio(), if (businessService == null) {
context: context, businessService = BusinessApiService(Dio(),
token: BusinessInstance.instance.businessToken, context: context,
tenant: BusinessInstance.instance.businessTenant, token: BusinessInstance.instance.businessToken,
storeId: widget.arguments["storeId"]); tenant: BusinessInstance.instance.businessTenant,
} storeId: widget.arguments["storeId"]);
BaseData baseData = await businessService }
.wipedBatchs(jsonEncode(ticketWipedBatch).replaceAll("\\\"", "\"")) BaseData baseData = await businessService
.catchError((error) {}); .wipedBatchs(jsonEncode(ticketWipedBatch).replaceAll("\\\"", "\""))
if (baseData != null && baseData.isSuccess) { .catchError((error) {});
Navigator.of(context).pop(1); if (baseData != null && baseData.isSuccess) {
SmartDialog.showToast("核销成功", alignment: Alignment.center); Navigator.of(context).pop();
} else { SmartDialog.showToast("核销成功", alignment: Alignment.center);
SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } else {
} SmartDialog.showToast(baseData.msg, alignment: Alignment.center);
}
} finally { } finally {
EasyLoading.dismiss(); EasyLoading.dismiss();
} }
@ -110,11 +110,13 @@ class _OrderWriteOff extends State<OrderWriteOff> {
writeOffInfo(), writeOffInfo(),
GestureDetector( GestureDetector(
onTap: () { onTap: () {
if (tickets != null ? (widget.arguments["ticketStatus"] == false) : (ticketDetails.state == 9)) { if (tickets != null
? (widget.arguments["ticketStatus"] == false)
: (ticketDetails.state == 9)) {
return; return;
} else { } else {
List<dynamic> ticketWipedBatch = []; List<dynamic> ticketWipedBatch = [];
if(widget.arguments["tickets"] != null){ if (widget.arguments["tickets"] != null) {
tickets.forEach((element) { tickets.forEach((element) {
List<dynamic> skuTickets = []; List<dynamic> skuTickets = [];
element.ticketItemList.forEach((ele) { element.ticketItemList.forEach((ele) {
@ -140,30 +142,30 @@ class _OrderWriteOff extends State<OrderWriteOff> {
}); });
} }
}); });
}else{ } else {
List<dynamic> skuTickets = []; List<dynamic> skuTickets = [];
ticketDetails.ticketItemList.forEach((element) { ticketDetails.ticketItemList.forEach((element) {
if (element.isSelect) { if (element.isSelect) {
skuTickets.add({ skuTickets.add({
"number": 1, "number": 1,
"skuTicket": element.name, "skuTicket": element.name,
"state": element.state, "state": element.state,
});
}
});
if (skuTickets.isNotEmpty) {
ticketWipedBatch.add({
"itemMap": [
{
"productSkuld": ticketDetails.productSkuId,
"ticketExchangeName": ticketDetails.name,
"ticketId": ticketDetails.id,
"skuTickets": skuTickets
}
],
"ticketCode": ticketDetails.code,
}); });
} }
});
if (skuTickets.isNotEmpty) {
ticketWipedBatch.add({
"itemMap": [
{
"productSkuld": ticketDetails.productSkuId,
"ticketExchangeName": ticketDetails.name,
"ticketId": ticketDetails.id,
"skuTickets": skuTickets
}
],
"ticketCode": ticketDetails.code,
});
}
} }
if (ticketWipedBatch.length == 0) { if (ticketWipedBatch.length == 0) {
SmartDialog.showToast("请选择要核销的商品", SmartDialog.showToast("请选择要核销的商品",
@ -177,14 +179,22 @@ class _OrderWriteOff extends State<OrderWriteOff> {
child: Container( child: Container(
width: double.infinity, width: double.infinity,
alignment: Alignment.center, alignment: Alignment.center,
margin: EdgeInsets.only(bottom: 55.h, top: (tickets != null ? tickets.length : ticketDetails.ticketItemList.length) <= 2 ? 125.h : 0), margin: EdgeInsets.only(
bottom: 55.h,
top: (tickets != null
? tickets.length
: ticketDetails.ticketItemList.length) <=
1
? 125.h
: 10.h),
padding: EdgeInsets.symmetric(vertical: 16.h), padding: EdgeInsets.symmetric(vertical: 16.h),
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: BorderRadius.circular(27), borderRadius: BorderRadius.circular(27),
color: (tickets != null ? (widget.arguments["ticketStatus"] == true) : (ticketDetails.state != 9)) color: (tickets != null
? (widget.arguments["ticketStatus"] == true)
: (ticketDetails.state != 9))
? Color(0xFF30415B) ? Color(0xFF30415B)
: : Color(0xFFABACAB)),
Color(0xFFABACAB)),
child: Text( child: Text(
"确认核销", "确认核销",
style: TextStyle( style: TextStyle(
@ -243,8 +253,13 @@ class _OrderWriteOff extends State<OrderWriteOff> {
SizedBox( SizedBox(
height: 12.h, height: 12.h,
), ),
basicInfoItem("用户名称::", widget?.arguments["userName"] ?? ticketDetails?.userName ?? "" ), basicInfoItem("用户名称::",
basicInfoItem("订单编号::", widget?.arguments["orderCode"] ?? (ticketDetails.code.replaceAll("T","")) ?? ""), widget?.arguments["userName"] ?? ticketDetails?.userName ?? ""),
basicInfoItem(
"订单编号::",
widget?.arguments["orderCode"] ??
(ticketDetails.code.replaceAll("T", "")) ??
""),
], ],
), ),
); );
@ -322,19 +337,16 @@ class _OrderWriteOff extends State<OrderWriteOff> {
), ),
ListView.builder( ListView.builder(
padding: EdgeInsets.zero, padding: EdgeInsets.zero,
itemCount: tickets != null ?(tickets?.length ?? 0):(ticketDetails?.ticketItemList?.length ?? 0), itemCount: tickets != null
? (tickets?.length ?? 0)
: (ticketDetails?.ticketItemList?.length ?? 0),
scrollDirection: Axis.vertical, scrollDirection: Axis.vertical,
shrinkWrap: true, shrinkWrap: true,
physics: BouncingScrollPhysics(), physics: BouncingScrollPhysics(),
itemBuilder: (context, position) { itemBuilder: (context, position) {
return GestureDetector( return tickets != null
onTap: () { ? writeOffInfoItem(tickets[position])
setState(() { : scanCodeInfoItem(ticketDetails.ticketItemList[position]);
nameIndex = position;
});
},
child: tickets != null ? writeOffInfoItem(tickets[position]):scanCodeInfoItem(ticketDetails.ticketItemList[position]),
);
}, },
) )
// ListView.builder( // ListView.builder(
@ -435,7 +447,7 @@ class _OrderWriteOff extends State<OrderWriteOff> {
} }
/// ///
Widget scanCodeInfoItem(TicketItemList ticketItemList){ Widget scanCodeInfoItem(TicketItemList ticketItemList) {
return Container( return Container(
width: double.infinity, width: double.infinity,
child: Column( child: Column(
@ -444,28 +456,38 @@ class _OrderWriteOff extends State<OrderWriteOff> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.center,
children: [ children: [
Expanded(child: Text( Expanded(
child: Text(
ticketItemList?.name ?? "", ticketItemList?.name ?? "",
style: TextStyle( style: TextStyle(
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
fontSize: 14.sp, fontSize: 14.sp,
color: ticketItemList.state == 1?Color(0xFF0D0D0D):Color(0xFFABACAB), color: ticketItemList.state == 1
? Color(0xFF0D0D0D)
: Color(0xFFABACAB),
), ),
)), )),
Expanded(child: Column( Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.end,
children: [ children: [
Padding(padding: EdgeInsets.only(right:10.w), Padding(
padding: EdgeInsets.only(right: 10.w),
child: Text( child: Text(
(ticketItemList.state == 1)?"待核销":"已核销", (ticketItemList.state == 1) ? "待核销" : "已核销",
style: TextStyle( style: TextStyle(
fontWeight: MyFontWeight.semi_bold, fontWeight: MyFontWeight.semi_bold,
fontSize: 12.sp, fontSize: 12.sp,
color: (ticketItemList.state == 1)?Color(0xFF30415B):Color(0xFFACACAC), color: (ticketItemList.state == 1)
? Color(0xFF30415B)
: Color(0xFFACACAC),
), ),
),), ),
SizedBox(height:25.h,), ),
if(ticketItemList.state == 1) SizedBox(
height: 25.h,
),
if (ticketItemList.state == 1)
Checkbox( Checkbox(
value: ticketItemList.isSelect, value: ticketItemList.isSelect,
onChanged: (a) { onChanged: (a) {
@ -477,17 +499,17 @@ class _OrderWriteOff extends State<OrderWriteOff> {
borderRadius: BorderRadius.circular(2.0), borderRadius: BorderRadius.circular(2.0),
), ),
checkColor: Color(0xFFFFFFFF), checkColor: Color(0xFFFFFFFF),
fillColor:MaterialStateProperty.all(Color(0xFF30415B)), fillColor: MaterialStateProperty.all(Color(0xFF30415B)),
), ),
], ],
)) ))
], ],
), ),
if(ticketItemList.state != 1) if (ticketItemList.state != 1)
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child:Container( child: Container(
margin: EdgeInsets.only(right:10.w), margin: EdgeInsets.only(right: 10.w),
decoration: BoxDecoration( decoration: BoxDecoration(
color: Colors.white, color: Colors.white,
borderRadius: BorderRadius.circular( borderRadius: BorderRadius.circular(
@ -502,10 +524,10 @@ class _OrderWriteOff extends State<OrderWriteOff> {
Icons.check, Icons.check,
color: Color(0xFFCFCFCF), color: Color(0xFFCFCFCF),
size: 14.w, size: 14.w,
) )),
),), ),
Container( Container(
margin: EdgeInsets.only(bottom:11.h,top: 13.h), margin: EdgeInsets.only(bottom: 11.h, top: 13.h),
width: double.infinity, width: double.infinity,
height: 1.h, height: 1.h,
color: Color(0xFFEBECEF), color: Color(0xFFEBECEF),
@ -528,10 +550,12 @@ class _OrderWriteOff extends State<OrderWriteOff> {
style: TextStyle( style: TextStyle(
fontWeight: MyFontWeight.regular, fontWeight: MyFontWeight.regular,
fontSize: 12.sp, fontSize: 12.sp,
color: Color(0xFF0D0D0D), color: ticketItemList.state == 1
? Color(0xFF0D0D0D)
: Color(0xFFABACAB),
), ),
)), )),
(tickets[nameIndex].state == 7 || tickets[nameIndex].state == 8) (ticketItemList.state == 7 || ticketItemList.state == 8)
? (ticketItemList.state != 9 ? (ticketItemList.state != 9
? Container( ? Container(
margin: EdgeInsets.symmetric(vertical: 20.h), margin: EdgeInsets.symmetric(vertical: 20.h),

Loading…
Cancel
Save