From 76f61e25255045327dc17122b4c9780e0af6a997 Mon Sep 17 00:00:00 2001 From: wurong <953969641@qq.com> Date: Wed, 15 Nov 2023 14:55:34 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A2=E5=8D=95=E5=88=97=E8=A1=A8=E8=BF=94?= =?UTF-8?q?=E5=9B=9E=E7=8A=B6=E6=80=81=E6=9B=B4=E6=94=B9;=20=E6=A0=B8?= =?UTF-8?q?=E9=94=80=E9=A1=B5=E9=9D=A2=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/business_system/order/order_list.dart | 48 ++--- .../order/order_write_off.dart | 178 ++++++++++-------- 2 files changed, 119 insertions(+), 107 deletions(-) diff --git a/lib/business_system/order/order_list.dart b/lib/business_system/order/order_list.dart index 9825165b..2e6f3b88 100644 --- a/lib/business_system/order/order_list.dart +++ b/lib/business_system/order/order_list.dart @@ -43,7 +43,6 @@ class _OrderList extends State { List adminOrderDTOList = []; int _pageIndex = 1; bool _shimmer = true; - int index = 0; @override void dispose() { @@ -84,7 +83,7 @@ class _OrderList extends State { await businessService.findAdminOrderList({ "orderCode": "", "keywordType": 1, - "keyword": widget?.keyword ?? queryId ?? "", + "keyword": widget.keyword == "" ? (queryId ?? "") : widget.keyword, "orderStatus": "", "startTime": widget.time .replaceAll("年", "-") @@ -97,7 +96,7 @@ class _OrderList extends State { .replaceAll("日", "") .substring(widget.time.length >= 21 ? 22 : 0, widget.time.length >= 21 ? 41 : 0), - "pageIndex": _pageIndex, + "pageIndex": (widget.keyword != "" || queryId != null) ? 1 : _pageIndex, "pageSize": 10, "refundStatus": widget.status == 3 ? "1" : "", "payStatus": widget.status == 1 ? "0" : (widget.status == 2 ? "1" : ""), @@ -111,21 +110,20 @@ class _OrderList extends State { }); if (!mounted) return; if (baseData != null && baseData.isSuccess) { - if (queryId == null){ + if (queryId == null) { adminOrderDTOList.addAll(baseData?.data?.adminOrderDTOList ?? []); if ((baseData?.data?.adminOrderDTOList ?? []).isEmpty || adminOrderDTOList.length == baseData.data.total) _refreshController.loadNoData(); else _refreshController.loadComplete(); - } - else - adminOrderDTOList.forEach((element) { - if (element.id == queryId) { - adminOrderDTOList[index] = element; - return; + } else if (adminOrderDTOList != null) + for (int i = 0; i < adminOrderDTOList.length; i++) { + if (adminOrderDTOList[i].orderCode == queryId) { + adminOrderDTOList[i] = baseData?.data?.adminOrderDTOList?.first; + break; } - }); + } } else { SmartDialog.showToast(baseData.msg, alignment: Alignment.center); } @@ -272,13 +270,8 @@ class _OrderList extends State { shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - index = position; - }, - child: orderGoodsList( - adminOrderDtoList.orderProductList[position]), - ); + return orderGoodsList( + adminOrderDtoList.orderProductList[position]); }, ), ), @@ -342,8 +335,10 @@ class _OrderList extends State { Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - if (adminOrderDtoList.ticketStatus != null && adminOrderDtoList.refundStatus == 0) - GestureDetector(behavior: HitTestBehavior.opaque, + if (adminOrderDtoList.ticketStatus != null && + adminOrderDtoList.refundStatus == 0) + GestureDetector( + behavior: HitTestBehavior.opaque, onTap: () { Navigator.of(context) .pushNamed('/router/order_write_off', arguments: { @@ -352,12 +347,7 @@ class _OrderList extends State { "userName": adminOrderDtoList?.name ?? "", "ticketStatus": adminOrderDtoList?.ticketStatus, }).then((value) async { - // if (value == 1) { - // _pageIndex = 1; - // adminOrderDTOList.clear(); - // _onRefresh(isShowLoad: false); - queryOrderList(queryId: adminOrderDtoList.id); - // } + queryOrderList(queryId: adminOrderDtoList.orderCode); }); }, child: Container( @@ -394,10 +384,8 @@ class _OrderList extends State { "storeId": widget.storeId ?? "", }).then((value) { if (value == 1) { - // _pageIndex = 1; - // adminOrderDTOList.clear(); - // _onRefresh(isShowLoad: false); - queryOrderList(queryId: adminOrderDtoList.id); + queryOrderList( + queryId: adminOrderDtoList.orderCode); } }); }, diff --git a/lib/business_system/order/order_write_off.dart b/lib/business_system/order/order_write_off.dart index 5ffcb605..91a73aee 100644 --- a/lib/business_system/order/order_write_off.dart +++ b/lib/business_system/order/order_write_off.dart @@ -33,7 +33,6 @@ class _OrderWriteOff extends State { List tickets; TicketDetails ticketDetails; business.AdminOrderDtoList adminOrderDTOList; - int nameIndex = 0; BusinessApiService businessService; @override @@ -49,24 +48,25 @@ class _OrderWriteOff extends State { ///多个核销 severalWiped(ticketWipedBatch) async { try { - EasyLoading.show( - status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); - if (businessService == null) { - businessService = BusinessApiService(Dio(), - context: context, - token: BusinessInstance.instance.businessToken, - tenant: BusinessInstance.instance.businessTenant, - storeId: widget.arguments["storeId"]); - } - BaseData baseData = await businessService - .wipedBatchs(jsonEncode(ticketWipedBatch).replaceAll("\\\"", "\"")) - .catchError((error) {}); - if (baseData != null && baseData.isSuccess) { - Navigator.of(context).pop(1); - SmartDialog.showToast("核销成功", alignment: Alignment.center); - } else { - SmartDialog.showToast(baseData.msg, alignment: Alignment.center); - } + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + if (businessService == null) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.arguments["storeId"]); + } + BaseData baseData = await businessService + .wipedBatchs(jsonEncode(ticketWipedBatch).replaceAll("\\\"", "\"")) + .catchError((error) {}); + if (baseData != null && baseData.isSuccess) { + Navigator.of(context).pop(); + SmartDialog.showToast("核销成功", alignment: Alignment.center); + } else { + SmartDialog.showToast(baseData.msg, alignment: Alignment.center); + } } finally { EasyLoading.dismiss(); } @@ -110,11 +110,13 @@ class _OrderWriteOff extends State { writeOffInfo(), GestureDetector( onTap: () { - if (tickets != null ? (widget.arguments["ticketStatus"] == false) : (ticketDetails.state == 9)) { + if (tickets != null + ? (widget.arguments["ticketStatus"] == false) + : (ticketDetails.state == 9)) { return; } else { List ticketWipedBatch = []; - if(widget.arguments["tickets"] != null){ + if (widget.arguments["tickets"] != null) { tickets.forEach((element) { List skuTickets = []; element.ticketItemList.forEach((ele) { @@ -140,30 +142,30 @@ class _OrderWriteOff extends State { }); } }); - }else{ - List skuTickets = []; - ticketDetails.ticketItemList.forEach((element) { - if (element.isSelect) { - skuTickets.add({ - "number": 1, - "skuTicket": element.name, - "state": element.state, - }); - } - }); - if (skuTickets.isNotEmpty) { - ticketWipedBatch.add({ - "itemMap": [ - { - "productSkuld": ticketDetails.productSkuId, - "ticketExchangeName": ticketDetails.name, - "ticketId": ticketDetails.id, - "skuTickets": skuTickets - } - ], - "ticketCode": ticketDetails.code, + } else { + List skuTickets = []; + ticketDetails.ticketItemList.forEach((element) { + if (element.isSelect) { + skuTickets.add({ + "number": 1, + "skuTicket": element.name, + "state": element.state, }); } + }); + if (skuTickets.isNotEmpty) { + ticketWipedBatch.add({ + "itemMap": [ + { + "productSkuld": ticketDetails.productSkuId, + "ticketExchangeName": ticketDetails.name, + "ticketId": ticketDetails.id, + "skuTickets": skuTickets + } + ], + "ticketCode": ticketDetails.code, + }); + } } if (ticketWipedBatch.length == 0) { SmartDialog.showToast("请选择要核销的商品", @@ -177,14 +179,22 @@ class _OrderWriteOff extends State { child: Container( width: double.infinity, 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), decoration: BoxDecoration( 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(0xFFABACAB)), + : Color(0xFFABACAB)), child: Text( "确认核销", style: TextStyle( @@ -243,8 +253,13 @@ class _OrderWriteOff extends State { SizedBox( height: 12.h, ), - basicInfoItem("用户名称::", widget?.arguments["userName"] ?? ticketDetails?.userName ?? "" ), - basicInfoItem("订单编号::", widget?.arguments["orderCode"] ?? (ticketDetails.code.replaceAll("T","")) ?? ""), + basicInfoItem("用户名称::", + widget?.arguments["userName"] ?? ticketDetails?.userName ?? ""), + basicInfoItem( + "订单编号::", + widget?.arguments["orderCode"] ?? + (ticketDetails.code.replaceAll("T", "")) ?? + ""), ], ), ); @@ -322,19 +337,16 @@ class _OrderWriteOff extends State { ), ListView.builder( 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, shrinkWrap: true, physics: BouncingScrollPhysics(), itemBuilder: (context, position) { - return GestureDetector( - onTap: () { - setState(() { - nameIndex = position; - }); - }, - child: tickets != null ? writeOffInfoItem(tickets[position]):scanCodeInfoItem(ticketDetails.ticketItemList[position]), - ); + return tickets != null + ? writeOffInfoItem(tickets[position]) + : scanCodeInfoItem(ticketDetails.ticketItemList[position]); }, ) // ListView.builder( @@ -435,7 +447,7 @@ class _OrderWriteOff extends State { } ///扫码进入的核销数据 - Widget scanCodeInfoItem(TicketItemList ticketItemList){ + Widget scanCodeInfoItem(TicketItemList ticketItemList) { return Container( width: double.infinity, child: Column( @@ -444,28 +456,38 @@ class _OrderWriteOff extends State { crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - Expanded(child: Text( + Expanded( + child: Text( ticketItemList?.name ?? "", style: TextStyle( fontWeight: MyFontWeight.regular, 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, children: [ - Padding(padding: EdgeInsets.only(right:10.w), + Padding( + padding: EdgeInsets.only(right: 10.w), child: Text( - (ticketItemList.state == 1)?"待核销":"已核销", + (ticketItemList.state == 1) ? "待核销" : "已核销", style: TextStyle( fontWeight: MyFontWeight.semi_bold, 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( value: ticketItemList.isSelect, onChanged: (a) { @@ -477,17 +499,17 @@ class _OrderWriteOff extends State { borderRadius: BorderRadius.circular(2.0), ), checkColor: Color(0xFFFFFFFF), - fillColor:MaterialStateProperty.all(Color(0xFF30415B)), + fillColor: MaterialStateProperty.all(Color(0xFF30415B)), ), ], )) ], ), - if(ticketItemList.state != 1) + if (ticketItemList.state != 1) Align( alignment: Alignment.centerRight, - child:Container( - margin: EdgeInsets.only(right:10.w), + child: Container( + margin: EdgeInsets.only(right: 10.w), decoration: BoxDecoration( color: Colors.white, borderRadius: BorderRadius.circular( @@ -502,10 +524,10 @@ class _OrderWriteOff extends State { Icons.check, color: Color(0xFFCFCFCF), size: 14.w, - ) - ),), + )), + ), Container( - margin: EdgeInsets.only(bottom:11.h,top: 13.h), + margin: EdgeInsets.only(bottom: 11.h, top: 13.h), width: double.infinity, height: 1.h, color: Color(0xFFEBECEF), @@ -528,10 +550,12 @@ class _OrderWriteOff extends State { style: TextStyle( fontWeight: MyFontWeight.regular, 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 ? Container( margin: EdgeInsets.symmetric(vertical: 20.h),