diff --git a/lib/business_system/home/business_home_page.dart b/lib/business_system/home/business_home_page.dart index 518abe51..1dd2da17 100644 --- a/lib/business_system/home/business_home_page.dart +++ b/lib/business_system/home/business_home_page.dart @@ -205,7 +205,9 @@ class _BusinessHomePage extends State controller: refreshController, enablePullDown: true, enablePullUp: false, - header: MyHeader(), + header: MyHeader( + color: Color(0xFF30415B), + ), physics: BouncingScrollPhysics(), scrollController: scrollController, footer: CustomFooter( @@ -906,10 +908,8 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - daySelectIndex = 1; - queryPopularList(); - }); + daySelectIndex = 1; + queryPopularList(); }, child: Container( padding: @@ -940,10 +940,8 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - daySelectIndex = 2; - queryPopularList(); - }); + daySelectIndex = 7; + queryPopularList(); }, child: Container( padding: @@ -952,7 +950,7 @@ class _BusinessHomePage extends State margin: EdgeInsets.only(right: 16.w, bottom: 16.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(2.w), - color: daySelectIndex == 2 + color: daySelectIndex == 7 ? Color(0xFF30415B) : Colors.transparent, border: Border.all( @@ -965,7 +963,7 @@ class _BusinessHomePage extends State style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: daySelectIndex == 2 + color: daySelectIndex == 7 ? Colors.white : Color(0XFF30415B), ), @@ -974,10 +972,8 @@ class _BusinessHomePage extends State GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - daySelectIndex = 3; - queryPopularList(); - }); + daySelectIndex = 30; + queryPopularList(); }, child: Container( padding: @@ -986,7 +982,7 @@ class _BusinessHomePage extends State margin: EdgeInsets.only(right: 16.w, bottom: 16.h), decoration: BoxDecoration( borderRadius: BorderRadius.circular(2.w), - color: daySelectIndex == 3 + color: daySelectIndex == 30 ? Color(0xFF30415B) : Colors.transparent, border: Border.all( @@ -999,7 +995,7 @@ class _BusinessHomePage extends State style: TextStyle( fontSize: 12.sp, fontWeight: MyFontWeight.regular, - color: daySelectIndex == 3 + color: daySelectIndex == 30 ? Colors.white : Color(0XFF30415B), ), @@ -1012,11 +1008,11 @@ class _BusinessHomePage extends State child: (popularSalesList == null || popularSalesList.saleProductList.length == 0) ? NoDataView( - src: "assets/image/xiao_fei.webp", + src: "assets/image/bs_no data_logo.webp", isShowBtn: false, text: "暂无数据", fontSize: 16.sp, - margin: EdgeInsets.all(20.h), + margin: EdgeInsets.all(20.h), ) : ListView.builder( padding: EdgeInsets.zero, @@ -1176,11 +1172,11 @@ class _BusinessHomePage extends State height: 360.h, child: (dayFlowList.length == null || dayFlowList?.length == 0) ? NoDataView( - src: "assets/image/xiao_fei.webp", + src: "assets/image/bs_no data_logo.webp", isShowBtn: false, text: "暂无数据", fontSize: 16.sp, - margin: EdgeInsets.all(20.h), + margin: EdgeInsets.all(20.h), ) : ListView.builder( padding: EdgeInsets.zero, diff --git a/lib/business_system/home/flow_page.dart b/lib/business_system/home/flow_page.dart index 7839c674..d397c637 100644 --- a/lib/business_system/home/flow_page.dart +++ b/lib/business_system/home/flow_page.dart @@ -2,6 +2,7 @@ import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:flutter_datetime_picker/flutter_datetime_picker.dart'; import 'package:flutter_easyloading/flutter_easyloading.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:intl/intl.dart'; @@ -14,8 +15,10 @@ import '../../retrofit/business_api.dart'; import '../../retrofit/data/base_data.dart'; import '../../retrofit/data/day_flow_list.dart'; import '../../utils/business_instance.dart'; +import '../../utils/flutter_utils.dart'; import '../../view_widget/classic_header.dart'; import '../../view_widget/my_footer.dart'; +import '../../view_widget/no_data_view.dart'; class FlowPage extends StatefulWidget { final arguments; @@ -33,44 +36,67 @@ class _FlowPage extends State { String storeId; BusinessApiService businessService; List dayFlowList = []; + int _loadCount = 0; @override void initState() { super.initState(); storeId = widget.arguments["storeId"]; + _onRefresh(); + } + + _onRefresh() async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); SharedPreferences.getInstance().then((value) { businessService = BusinessApiService(Dio(), context: context, token: BusinessInstance.instance.businessToken, tenant: BusinessInstance.instance.businessTenant, storeId: storeId); - queryDayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "0"); + queryDayFlow(DateFormat("yyyy-MM-dd").format(DateTime.now()), "0", + isSing: false); }); } + addLoadCount() { + _loadCount += 1; + if (_loadCount == 1) { + _loadCount = 0; + EasyLoading.dismiss(); + if (refreshController.isRefresh) refreshController.refreshCompleted(); + if (mounted) setState(() {}); + } + } + ///今日流水/isMonth=0(当月数据),isMonth=1(当日数据) - queryDayFlow(yearMonth, isMonth) async { - EasyLoading.show( - status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + queryDayFlow(yearMonth, isMonth, {isSing = true}) async { + if (isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); try { - BaseData> baseData = await businessService - .dayFlow( - // "${DateFormat("yyyy-MM-dd").format(DateTime.now())}", - yearMonth, - isMonth) - .catchError((error) {}); + BaseData> baseData = + await businessService.dayFlow(yearMonth, isMonth).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); if (baseData != null && baseData.isSuccess) { if (isMonth == "0") { dayFlowList = baseData.data; } else { - dayFlowList.firstWhere((element) => element.localDate == yearMonth) + dayFlowList + .firstWhere((element) => element.localDate == yearMonth) .detailList = baseData.data; - } - setState(() {}); } } finally { - EasyLoading.dismiss(); + if (isSing) { + setState(() {}); + EasyLoading.dismiss(); + } else { + addLoadCount(); + } } } @@ -90,14 +116,14 @@ class _FlowPage extends State { enablePullDown: true, enablePullUp: false, header: MyHeader( - color: Colors.white, + color: Color(0xFF30415B), ), footer: CustomFooter( builder: (context, mode) { return MyFooter(mode); }, ), - onRefresh: () {}, + onRefresh: _onRefresh, physics: BouncingScrollPhysics(), scrollController: ScrollController(), child: SingleChildScrollView( @@ -114,7 +140,7 @@ class _FlowPage extends State { child: Row( children: [ Text( - "2023年6月", + DateFormat("yyyy年MM月").format(DateTime.now()), style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, @@ -132,19 +158,27 @@ class _FlowPage extends State { SizedBox( height: 16.h, ), - ListView.builder( - padding: EdgeInsets.zero, - itemCount: dayFlowList?.length ?? 0, - scrollDirection: Axis.vertical, - shrinkWrap: true, - physics: BouncingScrollPhysics(), - itemBuilder: (context, position) { - return GestureDetector( - onTap: () {}, - child: billItem(dayFlowList[position]), - ); - }, - ) + (dayFlowList == null || dayFlowList.length == 0) + ? NoDataView( + src: "assets/image/bs_no data_logo.webp", + isShowBtn: false, + text: "暂无数据", + fontSize: 16.sp, + margin: EdgeInsets.all(20.h), + ) + : ListView.builder( + padding: EdgeInsets.zero, + itemCount: dayFlowList?.length ?? 0, + scrollDirection: Axis.vertical, + shrinkWrap: true, + physics: BouncingScrollPhysics(), + itemBuilder: (context, position) { + return GestureDetector( + onTap: () {}, + child: billItem(dayFlowList[position]), + ); + }, + ) ], ), ), @@ -166,11 +200,11 @@ class _FlowPage extends State { children: [ GestureDetector( onTap: () { - if(dayFlowList.detailList != null){ - setState((){ + if (dayFlowList.detailList != null) { + setState(() { dayFlowList.detailList = null; }); - }else{ + } else { queryDayFlow(dayFlowList?.localDate ?? "", "1"); } }, @@ -222,9 +256,9 @@ class _FlowPage extends State { SizedBox( height: 20.h, ), - if(dayFlowList.detailList != null) + if (dayFlowList.detailList != null) Column( - children:dayFlowList.detailList.map((e) { + children: dayFlowList.detailList.map((e) { return billIDetailsItem(e); }).toList(), ) @@ -246,7 +280,7 @@ class _FlowPage extends State { Padding( padding: EdgeInsets.only(bottom: 15.h), child: Text( - detailList?.localDateTime ??"", + detailList?.localDateTime ?? "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, @@ -255,7 +289,10 @@ class _FlowPage extends State { ), ), Text( - detailList?.phone ?? detailList?.nickname ?? detailList?.storeName ??"", + detailList?.nickname ?? + AppUtils.phoneEncode(detailList?.phone) ?? + detailList?.storeName ?? + "", style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.regular, @@ -269,7 +306,7 @@ class _FlowPage extends State { TextSpan( children: [ TextSpan( - text: "+", + text: (detailList?.amount != "0.00") ? "+" : "-", style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.medium, @@ -277,7 +314,9 @@ class _FlowPage extends State { ), ), TextSpan( - text: detailList?.amount ?? "", + text: (detailList?.amount != "0.00") + ? (detailList?.amount ?? "") + : (detailList?.refundAmount ?? ""), style: TextStyle( fontSize: 18.sp, fontWeight: MyFontWeight.medium, @@ -294,7 +333,7 @@ class _FlowPage extends State { showDateSelector() { DatePicker.showDatePicker(context, showTitleActions: true, - minTime: DateTime.now(), + minTime: DateTime.now().subtract(const Duration(days: 360)), maxTime: DateTime.now(), theme: DatePickerTheme( headerColor: Colors.white, @@ -303,13 +342,13 @@ class _FlowPage extends State { color: Colors.black, fontWeight: MyFontWeight.bold, fontSize: 18), - doneStyle: TextStyle(color: Color(0xFF32A060), fontSize: 16.sp)), + doneStyle: TextStyle(color: Color(0xFF30415B), fontSize: 16.sp)), onChanged: (date) { print('change $date in time zone ' + date.timeZoneOffset.inHours.toString()); }, onConfirm: (date) { // "2023-09-04"; - setState(() {}); + // setState(() {}); }, currentTime: DateTime.now(), locale: LocaleType.zh); } } diff --git a/lib/business_system/home/home_view/home_sideslip_dialog.dart b/lib/business_system/home/home_view/home_sideslip_dialog.dart index 2a83a155..c98ce54e 100644 --- a/lib/business_system/home/home_view/home_sideslip_dialog.dart +++ b/lib/business_system/home/home_view/home_sideslip_dialog.dart @@ -4,6 +4,7 @@ import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:huixiang/utils/font_weight.dart'; import 'package:shared_preferences/shared_preferences.dart'; +import '../../../generated/l10n.dart'; import '../../../retrofit/data/business_login_info.dart'; import '../../../utils/flutter_utils.dart'; import '../../../view_widget/custom_image.dart'; @@ -202,7 +203,7 @@ class _HomeSideslipDialog extends State borderRadius: BorderRadius.circular(4.w), ), child: Text( - "退出登录", + S.of(context).tuichudenglu, style: TextStyle( fontSize: 14.sp, fontWeight: MyFontWeight.medium, diff --git a/lib/business_system/home/overview/trade_goods.dart b/lib/business_system/home/overview/trade_goods.dart index 194a77a2..da896561 100644 --- a/lib/business_system/home/overview/trade_goods.dart +++ b/lib/business_system/home/overview/trade_goods.dart @@ -73,16 +73,12 @@ class _TradeGoods extends State { storeId: widget.storeId); querySingleSales( dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), - dayDate - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "")); + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + isSing: false); queryGoodsSalesList( dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), - dayDate - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "")); + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + isSing: false); }); } @@ -97,7 +93,11 @@ class _TradeGoods extends State { } ///商品种类销售数据 - queryGoodsSalesList(date, endDat) async { + queryGoodsSalesList(date, endDat, {isSing = true}) async { + if (isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); try { BaseData> baseData = await businessService.goodsSalesList({ @@ -115,12 +115,21 @@ class _TradeGoods extends State { goodsTypeSalesList = baseData.data; } } finally { - addLoadCount(); + if (isSing) { + setState(() {}); + EasyLoading.dismiss(); + } else { + addLoadCount(); + } } } ///单品销量报表 - querySingleSales(date, endDate) async { + querySingleSales(date, endDate, {isSing = true}) async { + if (isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); try { BaseData> baseData = await businessService.singleSales({ @@ -130,15 +139,17 @@ class _TradeGoods extends State { "orderBy": 1, "searchType": 2, "type": 1 - }).catchError((error) { - SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), - alignment: Alignment.center); - }); + }).catchError((error) {}); if (baseData != null && baseData.isSuccess) { singleSalesList = baseData.data; } } finally { - addLoadCount(); + if (isSing) { + setState(() {}); + EasyLoading.dismiss(); + } else { + addLoadCount(); + } } } @@ -158,7 +169,9 @@ class _TradeGoods extends State { controller: _refreshController, enablePullDown: true, enablePullUp: false, - header: MyHeader(), + header: MyHeader( + color: Color(0xFF30415B), + ), physics: BouncingScrollPhysics(), scrollController: scrollController, footer: CustomFooter( @@ -187,31 +200,29 @@ class _TradeGoods extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - dateIndex = 0; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - }); + dateIndex = 0; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); }, child: Container( alignment: Alignment.center, @@ -238,31 +249,29 @@ class _TradeGoods extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - dateIndex = 1; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - }); + dateIndex = 1; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); }, child: Container( alignment: Alignment.center, @@ -289,23 +298,21 @@ class _TradeGoods extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - dateIndex = 2; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - ""); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - ""); - }); + dateIndex = 2; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + ""); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + ""); }, child: Container( alignment: Alignment.center, @@ -332,31 +339,33 @@ class _TradeGoods extends State { child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - setState(() { - dateIndex = 3; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - }); + dateIndex = 3; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring( + timeDate().length <= 15 ? 0 : 12, + timeDate().length <= 15 ? 10 : 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring( + timeDate().length <= 15 ? 0 : 12, + timeDate().length <= 15 ? 10 : 23)); }, child: Container( alignment: Alignment.center, @@ -391,121 +400,113 @@ class _TradeGoods extends State { Navigator.of(context) .pushNamed('/router/day_report_page') .then((value) { - setState(() { - selectedDate = value; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - }); + selectedDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); }); } else if (dateIndex == 1) { Navigator.of(context) .pushNamed('/router/week_report_page') .then((value) { - setState(() { - weekDate = value; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - }); + weekDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); }); } else if (dateIndex == 2) { Navigator.of(context) .pushNamed('/router/monthly_report_page') .then((value) { - setState(() { - monthlyDate = value; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10)); - }); + monthlyDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10)); }); } else if (dateIndex == 3) { Navigator.of(context) .pushNamed('/router/custom_page') .then((value) { - setState(() { - customDate = value; - querySingleSales( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - queryGoodsSalesList( - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(0, 10), - timeDate() - .replaceAll("年", "-") - .replaceAll("月", "-") - .replaceAll("日", "") - .substring(12, 23)); - }); + customDate = value; + querySingleSales( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); + queryGoodsSalesList( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23)); }); } }, @@ -676,7 +677,7 @@ class _TradeGoods extends State { ), (goodsTypeSalesList == null || goodsTypeSalesList.length == 0) ? NoDataView( - src: "assets/image/xiao_fei.webp", + src: "assets/image/bs_no data_logo.webp", isShowBtn: false, text: "暂无数据", fontSize: 16.sp, @@ -850,11 +851,11 @@ class _TradeGoods extends State { ), (singleSalesList == null || singleSalesList.length == 0) ? NoDataView( - src: "assets/image/xiao_fei.webp", + src: "assets/image/bs_no data_logo.webp", isShowBtn: false, text: "暂无数据", fontSize: 16.sp, - margin: EdgeInsets.all(20.h), + margin: EdgeInsets.all(20), ) : Container( height: 243.h, diff --git a/lib/business_system/home/overview/trade_overview_page.dart b/lib/business_system/home/overview/trade_overview_page.dart index 8f84d573..e47bda0e 100644 --- a/lib/business_system/home/overview/trade_overview_page.dart +++ b/lib/business_system/home/overview/trade_overview_page.dart @@ -69,7 +69,7 @@ class _TradeOverviewPage extends State with SingleTickerProvi ), body: TabBarView( children: [ - TradeSummary(), + TradeSummary(storeId), TradeOrder(), TradeGoods(storeId),], ), diff --git a/lib/business_system/home/overview/trade_summary.dart b/lib/business_system/home/overview/trade_summary.dart index 96b4e67c..b253ac6c 100644 --- a/lib/business_system/home/overview/trade_summary.dart +++ b/lib/business_system/home/overview/trade_summary.dart @@ -1,19 +1,32 @@ +import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:flutter_localizations/flutter_localizations.dart'; +import 'package:flutter_easyloading/flutter_easyloading.dart'; +import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; import 'package:huixiang/view_widget/classic_header.dart'; import 'package:huixiang/view_widget/my_footer.dart'; import 'package:intl/intl.dart'; import 'package:pull_to_refresh/pull_to_refresh.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; +import 'package:shared_preferences/shared_preferences.dart'; +import '../../../generated/l10n.dart'; +import '../../../retrofit/business_api.dart'; +import '../../../retrofit/data/base_data.dart'; +import '../../../retrofit/data/trade_summary_list.dart'; +import '../../../utils/business_instance.dart'; +import '../../../utils/flutter_utils.dart'; import '../../../utils/font_weight.dart'; -import '../../date_select/monthly_report_page.dart'; +import '../../../view_widget/no_data_view.dart'; import '../home_view/donut_auto_label_chart.dart'; import '../home_view/my_line_chart.dart'; import 'package:charts_flutter/flutter.dart' as charts; class TradeSummary extends StatefulWidget { + final storeId; + + TradeSummary(this.storeId); + @override State createState() { return _TradeSummary(); @@ -28,29 +41,35 @@ class _TradeSummary extends State { int dateIndex = 0; String selectedDate = ""; String dayDate = "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; - String weekDate =""; - String weekDateNum = "${DateFormat("yyyy年MM月dd日").format(DateTime.now().subtract(Duration(days:6)))} 至 " - "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; - String monthlyDate =""; - String monthlyDateNum = "${DateFormat("yyyy年MM月").format(DateTime.now())}"; - String customDate =""; + String weekDate = ""; + String weekDateNum = + "${DateFormat("yyyy年MM月dd日").format(DateTime.now().subtract(Duration(days: 6)))} 至 " + "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; + String monthlyDate = ""; + String monthlyDateNum = "${DateFormat("yyyy年MM月dd").format(DateTime.now())}"; + String customDate = ""; String customDateNum = "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; - List lineChartSample2DataAmount = - [LineChartSample2Data(0,40,"2023-03-09"), - LineChartSample2Data(1,10,"2023-03-10"), - LineChartSample2Data(2,50,"2023-03-11"), - LineChartSample2Data(3,35,"2023-03-12"), - LineChartSample2Data(4,20,"2023-03-13"), - LineChartSample2Data(5,55,"2023-03-14"), - LineChartSample2Data(6,100,"2023-03-15")]; - List lineChartSample2DataNum = - [LineChartSample2Data(0,20,"2023-03-09"), - LineChartSample2Data(1,30,"2023-03-10"), - LineChartSample2Data(2,50,"2023-03-11"), - LineChartSample2Data(3,60,"2023-03-12"), - LineChartSample2Data(4,5,"2023-03-13"), - LineChartSample2Data(5,55,"2023-03-14"), - LineChartSample2Data(6,95,"2023-03-15")]; + int _loadCount = 0; + BusinessApiService businessService; + TradeSummaryList tradeSummaryList; + List lineChartSample2DataAmount = [ + LineChartSample2Data(0, 0, "2023-03-09"), + LineChartSample2Data(1, 0, "2023-03-10"), + LineChartSample2Data(2, 0, "2023-03-11"), + LineChartSample2Data(3, 0, "2023-03-12"), + LineChartSample2Data(4, 0, "2023-03-13"), + LineChartSample2Data(5, 0, "2023-03-14"), + LineChartSample2Data(6, 0, "2023-03-15") + ]; + List lineChartSample2DataNum = [ + LineChartSample2Data(0, 0, "2023-03-09"), + LineChartSample2Data(1, 0, "2023-03-10"), + LineChartSample2Data(2, 0, "2023-03-11"), + LineChartSample2Data(3, 0, "2023-03-12"), + LineChartSample2Data(4, 0, "2023-03-13"), + LineChartSample2Data(5, 0, "2023-03-14"), + LineChartSample2Data(6, 0, "2023-03-15") + ]; @override void dispose() { @@ -61,9 +80,84 @@ class _TradeSummary extends State { @override void initState() { super.initState(); + _onRefresh(); } _onRefresh() async { + EasyLoading.show( + status: S.current.zhengzaijiazai, maskType: EasyLoadingMaskType.black); + SharedPreferences.getInstance().then((value) { + businessService = BusinessApiService(Dio(), + context: context, + token: BusinessInstance.instance.businessToken, + tenant: BusinessInstance.instance.businessTenant, + storeId: widget.storeId); + queryBusinessAnalysis( + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + dayDate.replaceAll("年", "-").replaceAll("月", "-").replaceAll("日", ""), + "day", + isSing: false); + }); + } + + addLoadCount() { + _loadCount += 1; + if (_loadCount == 1) { + _loadCount = 0; + EasyLoading.dismiss(); + if (_refreshController.isRefresh) _refreshController.refreshCompleted(); + if (mounted) setState(() {}); + } + } + + ///经营分析 + queryBusinessAnalysis(selectDay, selectEndDay, queryRange, + {isSing = true}) async { + if (isSing) + EasyLoading.show( + status: S.current.zhengzaijiazai, + maskType: EasyLoadingMaskType.black); + try { + BaseData baseData = await businessService + .saleBusinessAnalysis({ + "selectDay": selectDay, + "selectEndDay": selectEndDay, + "queryRange": queryRange + }).catchError((error) { + SmartDialog.showToast(AppUtils.dioErrorTypeToString(error.type), + alignment: Alignment.center); + }); + if (baseData != null && baseData.isSuccess) { + int amountIndex = 0; + int numIndex = 0; + if (baseData.data.saleBusinessAnalysisVOS.isNotEmpty) { + lineChartSample2DataAmount.clear(); + lineChartSample2DataNum.clear(); + } + tradeSummaryList = baseData.data; + tradeSummaryList.saleBusinessAnalysisVOS.forEach((element) { + lineChartSample2DataAmount.add(LineChartSample2Data( + amountIndex.toDouble(), + double.tryParse(element.localDateBigDecimal.toString()), + element.localDateTime.substring(0, 10))); + amountIndex += 1; + }); + tradeSummaryList.saleBusinessAnalysisVOS.forEach((element) { + lineChartSample2DataNum.add(LineChartSample2Data( + numIndex.toDouble(), + double.tryParse(element.localDateCount.toString()), + element.localDateTime.substring(0, 10))); + numIndex += 1; + }); + } + } finally { + if (isSing) { + setState(() {}); + EasyLoading.dismiss(); + } else { + addLoadCount(); + } + } } @override @@ -77,375 +171,534 @@ class _TradeSummary extends State { width: double.infinity, height: 1.h, ), - Expanded(child: SmartRefresher( - controller: _refreshController, - enablePullDown: true, - enablePullUp: false, - header: MyHeader(), - physics: BouncingScrollPhysics(), - scrollController: scrollController, - footer: CustomFooter( - builder: (context, mode) { - return MyFooter(mode); - }, - ), - onRefresh: () { - setState(() { - _onRefresh(); - }); - }, - child: SingleChildScrollView( - physics: NeverScrollableScrollPhysics(), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - Container( - decoration: BoxDecoration( - color: Color(0xFFF6F6F6), - borderRadius: BorderRadius.circular(2), - border: Border.all(color: Color(0xFFCFD0D1), - width: 1.w), - ), - margin: EdgeInsets.only( - top: 16.h, right: 20.w, left: 20.w, bottom: 12.h), - child: Row( - children: [ - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + Expanded( + child: SmartRefresher( + controller: _refreshController, + enablePullDown: true, + enablePullUp: false, + header: MyHeader( + color: Color(0xFF30415B), + ), + physics: BouncingScrollPhysics(), + scrollController: scrollController, + footer: CustomFooter( + builder: (context, mode) { + return MyFooter(mode); + }, + ), + onRefresh: _onRefresh, + child: SingleChildScrollView( + physics: NeverScrollableScrollPhysics(), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Container( + decoration: BoxDecoration( + color: Color(0xFFF6F6F6), + borderRadius: BorderRadius.circular(2), + border: + Border.all(color: Color(0xFFCFD0D1), width: 1.w), + ), + margin: EdgeInsets.only( + top: 16.h, right: 20.w, left: 20.w, bottom: 12.h), + child: Row( + children: [ + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { dateIndex = 0; - }); - }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 0 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "日报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 0 ? Colors.white:Color(0xFF30415B), + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + "day"); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 0 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "日报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 0 + ? Colors.white + : Color(0xFF30415B), + ), ), ), - ), - )), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { dateIndex = 1; - });}, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 1 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "周报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 1 ? Colors.white:Color(0xFF30415B), + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23), + "week"); + }, + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 1 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "周报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 1 + ? Colors.white + : Color(0xFF30415B), + ), + ), ), - ), - ),)), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { dateIndex = 2; - }); + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + "month"); }, - child: Container( - alignment: Alignment.center, - decoration: BoxDecoration( - borderRadius: BorderRadius.circular(2), - color: dateIndex == 2 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "月报", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 2 ? Colors.white:Color(0xFF30415B), + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 2 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "月报", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 2 + ? Colors.white + : Color(0xFF30415B), + ), + ), ), - ), - ),)), - Expanded(child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + )), + Expanded( + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { dateIndex = 3; - }); + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring( + timeDate().length <= 15 ? 0 : 12, + timeDate().length <= 15 ? 10 : 23), + "custom"); }, - child: Container( + child: Container( + alignment: Alignment.center, + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(2), + color: dateIndex == 3 + ? Color(0xFF30415B) + : Colors.transparent, + ), + padding: EdgeInsets.symmetric(vertical: 9.h), + child: Text( + "自定义", + style: TextStyle( + fontSize: 12.sp, + fontWeight: MyFontWeight.medium, + color: dateIndex == 3 + ? Colors.white + : Color(0xFF30415B), + ), + ), + ), + )), + ], + ), + ), + Align( + alignment: Alignment.center, + child: GestureDetector( + behavior: HitTestBehavior.opaque, + onTap: () { + if (dateIndex == 0) { + Navigator.of(context) + .pushNamed('/router/day_report_page') + .then((value) { + selectedDate = value; + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + "day"); + }); + } else if (dateIndex == 1) { + Navigator.of(context) + .pushNamed('/router/week_report_page') + .then((value) { + weekDate = value; + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23), + "week"); + }); + } else if (dateIndex == 2) { + Navigator.of(context) + .pushNamed('/router/monthly_report_page') + .then((value) { + monthlyDate = value; + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + "month"); + }); + } else if (dateIndex == 3) { + Navigator.of(context) + .pushNamed('/router/custom_page') + .then((value) { + customDate = value; + queryBusinessAnalysis( + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(0, 10), + timeDate() + .replaceAll("年", "-") + .replaceAll("月", "-") + .replaceAll("日", "") + .substring(12, 23), + "custom"); + }); + } + }, + child: Container( + width: 194.w, alignment: Alignment.center, + padding: EdgeInsets.all(8), decoration: BoxDecoration( + color: Color(0xFFF6F6F6), borderRadius: BorderRadius.circular(2), - color: dateIndex == 3 ? Color(0xFF30415B):Colors.transparent, - ), - padding: EdgeInsets.symmetric(vertical: 9.h), - child: Text( - "自定义", - style: TextStyle( - fontSize: 12.sp, - fontWeight: MyFontWeight.medium, - color: dateIndex == 3 ? Colors.white:Color(0xFF30415B), - ), ), - ),)), - ], - ), - ), - Align(alignment: Alignment.center, - child: GestureDetector( - behavior: HitTestBehavior.opaque, - onTap: (){ - if(dateIndex == 0){ - Navigator.of(context).pushNamed('/router/day_report_page').then((value) { - setState((){ - selectedDate = value; - }); - }); - } - else if(dateIndex == 1){ - Navigator.of(context).pushNamed('/router/week_report_page').then((value) { - setState((){ - weekDate = value; - }); - }); - } - else if(dateIndex == 2){ - Navigator.of(context).pushNamed('/router/monthly_report_page').then((value) { - setState((){ - monthlyDate = value; - }); - }); - } - else if(dateIndex == 3){ - Navigator.of(context).pushNamed('/router/custom_page').then((value){ - setState((){ - customDate = value; - }); - }); - } - }, - child: Container( - width: 194.w, - alignment: Alignment.center, - padding: EdgeInsets.all(8), - decoration: BoxDecoration( - color: Color(0xFFF6F6F6), - borderRadius: BorderRadius.circular(2), - ), - margin: EdgeInsets.only(bottom:16.h), - child: Row( - children: [ - Expanded(child:Container( - alignment: Alignment.center, - child: Text( - timeDate(), - style: TextStyle( - fontSize: 10.sp, - fontWeight: MyFontWeight.regular, - color: Colors.black, + margin: EdgeInsets.only(bottom: 16.h), + child: Row( + children: [ + Expanded( + child: Container( + alignment: Alignment.center, + child: Text( + dateIndex == 2 + ? ((monthlyDateNum.substring(0, 8) == + timeDate().substring(0, 8)) + ? "${timeDate().substring(0, 8)}(当月)" + : timeDate().substring(0, 8)) + : timeDate(), + style: TextStyle( + fontSize: 10.sp, + fontWeight: MyFontWeight.regular, + color: Colors.black, + ), + ), + )), + Image.asset( + "assets/image/bs_calendar_logo.webp", + width: 15, + height: 15, ), - ), - )), - Image.asset( - "assets/image/bs_calendar_logo.webp", - width:15, - height:15, + ], ), - ], + ), ), ), - ),), - Padding(padding:EdgeInsets.only(left:16.w,bottom:15.h), - child:Text( - "经营分析", - style: TextStyle( - fontSize: 18.sp, - fontWeight: MyFontWeight.semi_bold, - color: Colors.black, + Padding( + padding: EdgeInsets.only(left: 16.w, bottom: 15.h), + child: Text( + "经营分析", + style: TextStyle( + fontSize: 18.sp, + fontWeight: MyFontWeight.semi_bold, + color: Colors.black, + ), + )), + operateAnalysis(), + Container( + color: Color(0xFFF9FAF8), + height: 16.h, + width: double.infinity, ), - )), - operateAnalysis(), - Container( - color: Color(0xFFF9FAF8), - height: 16.h, - width: double.infinity, - ), - expensesAnalysis(), - ], - )), - ),) + expensesAnalysis(), + ], + )), + ), + ) ], ), ); } - String timeDate(){ - if(dateIndex == 0){ - return (selectedDate == "" || selectedDate == null) ? "${dayDate ?? ""}(今日)":(dayDate == DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate)) - ?"${DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))}(今日)":DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))); + String timeDate() { + if (dateIndex == 0) { + return (selectedDate == "" || selectedDate == null) + ? "${dayDate ?? ""}(今日)" + : (dayDate == + DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate)) + ? "${DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))}(今日)" + : DateFormat("yyyy年MM月dd日").format(DateTime.parse(selectedDate))); + } else if (dateIndex == 1) { + return (weekDate == "" || weekDate == null) ? weekDateNum : weekDate; + } else if (dateIndex == 2) { + return (monthlyDate == "" || monthlyDate == null) + ? "${monthlyDateNum ?? ""}" + : (monthlyDateNum == + (DateFormat("yyyy年MM月dd日") + .format(DateTime.parse(monthlyDate))) + ? "${(DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)))}" + : DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate))); + } else if (dateIndex == 3) { + return (customDate == "" || customDate == null) + ? "${customDateNum ?? ""}(今日)" + : customDate; } - else if(dateIndex == 1){ - return (weekDate == "" || weekDate == null) ? weekDateNum : weekDate;} - else if(dateIndex == 2){ - return (monthlyDate == "" || monthlyDate == null) ? "${monthlyDateNum ?? ""}(当月)": - (monthlyDateNum == (DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8))? - "${(DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8))}(当月)" - :DateFormat("yyyy年MM月dd日").format(DateTime.parse(monthlyDate)).substring(0,8)); - } - else if(dateIndex == 3){ - return (customDate == "" || customDate == null) ? "${customDateNum??""}(今日)" : customDate;} } ///经营分析 - Widget operateAnalysis(){ + Widget operateAnalysis() { return Column( children: [ - Padding(padding: EdgeInsets.only(left:21.w,bottom: 1.h), + Padding( + padding: EdgeInsets.only(left: 21.w, bottom: 1.h), child: Row( children: [ GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + onTap: () { + setState(() { operateSelect = 0; }); }, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding(padding:EdgeInsets.only(bottom: 10.h), - child:Text( + Padding( + padding: EdgeInsets.only(bottom: 10.h), + child: Text( "营业额", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.medium, - color: operateSelect == 0 ? Colors.black:Color(0xFF969696), + color: operateSelect == 0 + ? Colors.black + : Color(0xFF969696), ), )), - if(operateSelect == 0) - Container( - height: 2.h, - width: 44.w, - decoration: BoxDecoration( - color: Color(0xFF30415B), - borderRadius: BorderRadius.circular(2), + if (operateSelect == 0) + Container( + height: 2.h, + width: 44.w, + decoration: BoxDecoration( + color: Color(0xFF30415B), + borderRadius: BorderRadius.circular(2), + ), ), - ), ], ), ), - SizedBox(width:47.w,), + SizedBox( + width: 47.w, + ), GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + onTap: () { + setState(() { operateSelect = 1; - });}, - child:Column( + }); + }, + child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding(padding:EdgeInsets.only(bottom: 10.h), - child:Text( + Padding( + padding: EdgeInsets.only(bottom: 10.h), + child: Text( "交易笔数", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.medium, - color: operateSelect == 1 ? Colors.black:Color(0xFF969696), + color: operateSelect == 1 + ? Colors.black + : Color(0xFF969696), ), )), - if(operateSelect == 1) - Container( - height: 2.h, - width: 44.w, - decoration: BoxDecoration( - color: Color(0xFF30415B), - borderRadius: BorderRadius.circular(2), + if (operateSelect == 1) + Container( + height: 2.h, + width: 44.w, + decoration: BoxDecoration( + color: Color(0xFF30415B), + borderRadius: BorderRadius.circular(2), + ), ), - ), ], ), ), ], - ),), + ), + ), Container( width: double.infinity, height: 1.h, color: Color(0xFFD8D8D8), - margin: EdgeInsets.only(bottom:30.h), + margin: EdgeInsets.only(bottom: 30.h), + ), + if (operateSelect == 0) + // lineChartSample2DataAmount.isNotEmpty + // ? NoDataView( + // src: "assets/image/bs_no data_logo.webp", + // isShowBtn: false, + // text: "暂无数据", + // fontSize: 16.sp, + // margin: EdgeInsets.all(20.h), + // ) + // : + Container( + padding: EdgeInsets.symmetric(horizontal: 20.w), + child: LineChartSample2(lineChartSample2DataAmount, "金额"), + ), + if (operateSelect == 1) + Padding( + padding: EdgeInsets.symmetric(horizontal: 20.w), + child: LineChartSample2(lineChartSample2DataNum, "交易笔数"), + ), + SizedBox( + height: 16.h, ), - if(operateSelect== 0) - Container(padding: EdgeInsets.symmetric(horizontal: 20.w), - child:LineChartSample2(lineChartSample2DataAmount,"金额"),), - if(operateSelect == 1) - Padding(padding: EdgeInsets.symmetric(horizontal: 20.w), - child:LineChartSample2(lineChartSample2DataNum,"交易笔数"),), - SizedBox(height:16.h,), ], ); } ///收退款分析 - Widget expensesAnalysis(){ + Widget expensesAnalysis() { return Container( - padding: EdgeInsets.only(top:12.h,bottom: 33.h), + padding: EdgeInsets.only(top: 12.h, bottom: 33.h), child: Column( children: [ - Padding(padding:EdgeInsets.only(left:16.w,bottom: 15.h), - child:Row( + Padding( + padding: EdgeInsets.only(left: 16.w, bottom: 15.h), + child: Row( children: [ Container( width: 4.w, height: 16.h, color: Color(0xFF30415B), - margin: EdgeInsets.only(right:12.w), + margin: EdgeInsets.only(right: 12.w), ), Text( "收退款分析", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.semi_bold, - color:Color(0xFF0D0D0D), + color: Color(0xFF0D0D0D), ), ) ], )), - Padding(padding: EdgeInsets.only(left:21.w,bottom: 1.h), + Padding( + padding: EdgeInsets.only(left: 21.w, bottom: 1.h), child: Row( children: [ GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + onTap: () { + setState(() { expensesSelect = 0; }); }, child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding(padding:EdgeInsets.only(bottom: 10.h), - child:Text( + Padding( + padding: EdgeInsets.only(bottom: 10.h), + child: Text( "交易金额", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.medium, - color: expensesSelect == 0 ? Colors.black:Color(0xFF969696), + color: expensesSelect == 0 + ? Colors.black + : Color(0xFF969696), ), )), - if(expensesSelect == 0) + if (expensesSelect == 0) Container( height: 2.h, width: 44.w, @@ -457,26 +710,32 @@ class _TradeSummary extends State { ], ), ), - SizedBox(width:37.w,), + SizedBox( + width: 37.w, + ), GestureDetector( behavior: HitTestBehavior.opaque, - onTap: (){ - setState((){ + onTap: () { + setState(() { expensesSelect = 1; - });}, - child:Column( + }); + }, + child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - Padding(padding:EdgeInsets.only(bottom: 10.h), - child:Text( + Padding( + padding: EdgeInsets.only(bottom: 10.h), + child: Text( "交易笔数", style: TextStyle( fontSize: 15.sp, fontWeight: MyFontWeight.medium, - color: expensesSelect == 1 ? Colors.black:Color(0xFF969696), + color: expensesSelect == 1 + ? Colors.black + : Color(0xFF969696), ), )), - if(expensesSelect == 1) + if (expensesSelect == 1) Container( height: 2.h, width: 44.w, @@ -489,49 +748,53 @@ class _TradeSummary extends State { ), ), ], - ),), - if(expensesSelect == 0) - Container( - height:150.h, - child: DonutAutoLabelChart([ - new charts.Series( - id: 'Sales', - colorFn: (LinearSales sales, __) => - sales.color, - domainFn: (LinearSales sales, _) => - sales.year, - measureFn: (LinearSales sales, _) => - sales.sales, - data: [ - new LinearSales(0, 78100, charts.Color.fromHex(code: "#313CA9")), - new LinearSales(1, 135458, charts.Color.fromHex(code: "#30415B")) - ], - // Set a label accessor to control the text of the arc label. - labelAccessorFn: (LinearSales row, _) => - '${(row.sales / 100)}', - ) - ]), + ), ), - if(expensesSelect == 1) + if (expensesSelect == 0) Container( - height:150.h, + height: 150.h, child: DonutAutoLabelChart([ new charts.Series( id: 'Sales', - colorFn: (LinearSales sales, __) => - sales.color, - domainFn: (LinearSales sales, _) => - sales.year, - measureFn: (LinearSales sales, _) => - sales.sales, + colorFn: (LinearSales sales, __) => sales.color, + domainFn: (LinearSales sales, _) => sales.year, + measureFn: (LinearSales sales, _) => sales.sales, data: [ - new LinearSales(0, 66, charts.Color.fromHex(code: "#313CA9")), - new LinearSales(1, 998, charts.Color.fromHex(code: "#30415B")), - new LinearSales(2, 155, charts.Color.fromHex(code: "#30415B")), + new LinearSales( + 0, + int.parse((tradeSummaryList?.collectionAmount ?? "0") + .replaceAll(".", "")), + charts.Color.fromHex(code: "#313CA9")), + new LinearSales( + 1, + int.parse((tradeSummaryList?.refundAmount ?? "0") + .replaceAll(".", "")), + charts.Color.fromHex(code: "#30415B")) ], // Set a label accessor to control the text of the arc label. labelAccessorFn: (LinearSales row, _) => - '${(row.sales)} 笔', + '${(row.sales / 100)}', + ) + ]), + ), + if (expensesSelect == 1) + Container( + height: 150.h, + child: DonutAutoLabelChart([ + new charts.Series( + id: 'Sales', + colorFn: (LinearSales sales, __) => sales.color, + domainFn: (LinearSales sales, _) => sales.year, + measureFn: (LinearSales sales, _) => sales.sales, + + data: [ + new LinearSales(0, tradeSummaryList?.collectionCount ?? 0, + charts.Color.fromHex(code: "#313CA9")), + new LinearSales(2, tradeSummaryList?.refundCount ?? 0, + charts.Color.fromHex(code: "#30415B")), + ], + // Set a label accessor to control the text of the arc label. + labelAccessorFn: (LinearSales row, _) => '${(row.sales)} 笔', ), ]), ), @@ -539,5 +802,4 @@ class _TradeSummary extends State { ), ); } - } diff --git a/lib/retrofit/business_api.dart b/lib/retrofit/business_api.dart index ea803232..fa2dbf6c 100644 --- a/lib/retrofit/business_api.dart +++ b/lib/retrofit/business_api.dart @@ -6,18 +6,17 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyloading/flutter_easyloading.dart'; import 'package:flutter_smart_dialog/flutter_smart_dialog.dart'; -import 'package:huixiang/retrofit/data/business_login_info.dart'; import 'package:huixiang/retrofit/data/day_count.dart'; import 'package:huixiang/retrofit/data/order_trend.dart'; import 'package:huixiang/retrofit/data/vip_counts_info.dart'; import 'package:retrofit/retrofit.dart'; -import '../utils/flutter_utils.dart'; import 'data/base_data.dart'; import 'data/day_flow_list.dart'; import 'data/goods_type_sales_list.dart'; import 'data/popular_sales_list.dart'; import 'data/single_sales_list.dart'; +import 'data/trade_summary_list.dart'; part 'business_api.g.dart'; @@ -137,7 +136,7 @@ abstract class BusinessApiService { @POST("comprehensiveReport/getDayCounts") Future> getDayCounts(@Body() Map param); - ///商家概览/热销榜单 + ///商家概览/热销榜单,当天传0,昨天传1,最近7天传7,最近30天传30 @GET("dashBoard/store/?offsetDay={offsetDay}") Future> popularList( @Path("offsetDay") String offsetDay); @@ -164,4 +163,8 @@ abstract class BusinessApiService { @POST("audit/allKindsSalesStatistics") Future>> goodsSalesList(@Body() Map param); + ///经营分析/查询范围 day week month custom + @POST("largeScreenReport/saleBusinessAnalysis") + Future> saleBusinessAnalysis(@Body() Map param); + } diff --git a/lib/retrofit/business_api.g.dart b/lib/retrofit/business_api.g.dart index 56114271..c5845d4d 100644 --- a/lib/retrofit/business_api.g.dart +++ b/lib/retrofit/business_api.g.dart @@ -209,4 +209,27 @@ class _BusinessApiService implements BusinessApiService { return value; } + @override + Future> saleBusinessAnalysis(param) async { + ArgumentError.checkNotNull(param, 'param'); + const _extra = {}; + final queryParameters = {}; + final _data = {}; + _data.addAll(param ?? {}); + final _result = await _dio.request>( + 'largeScreenReport/saleBusinessAnalysis', + queryParameters: queryParameters, + options: RequestOptions( + method: 'POST', + headers: {}, + extra: _extra, + baseUrl: baseUrl), + data: _data); + final value = BaseData.fromJson( + _result.data, + (json) => json == "" ? null :TradeSummaryList.fromJson(json), + ); + return value; + } + } diff --git a/lib/retrofit/data/trade_summary_list.dart b/lib/retrofit/data/trade_summary_list.dart new file mode 100644 index 00000000..92c9a851 --- /dev/null +++ b/lib/retrofit/data/trade_summary_list.dart @@ -0,0 +1,110 @@ +/// saleBusinessAnalysisVOS : [{"localDateTime":"2023-08-29 00:00:00","localDateBigDecimal":"22.00","localDateCount":"1"},{"localDateTime":"2023-08-13 00:00:00","localDateBigDecimal":"12.00","localDateCount":"1"},{"localDateTime":"2023-08-12 00:00:00","localDateBigDecimal":"485.00","localDateCount":"23"},{"localDateTime":"2023-08-11 00:00:00","localDateBigDecimal":"1105.00","localDateCount":"40"},{"localDateTime":"2023-08-10 00:00:00","localDateBigDecimal":"720.00","localDateCount":"28"},{"localDateTime":"2023-08-09 00:00:00","localDateBigDecimal":"311.50","localDateCount":"26"},{"localDateTime":"2023-08-08 00:00:00","localDateBigDecimal":"273.50","localDateCount":"18"},{"localDateTime":"2023-08-07 00:00:00","localDateBigDecimal":"411.00","localDateCount":"19"},{"localDateTime":"2023-08-06 00:00:00","localDateBigDecimal":"26.00","localDateCount":"4"},{"localDateTime":"2023-08-05 00:00:00","localDateBigDecimal":"131.00","localDateCount":"6"},{"localDateTime":"2023-08-04 00:00:00","localDateBigDecimal":"53.00","localDateCount":"4"},{"localDateTime":"2023-08-01 00:00:00","localDateBigDecimal":"442.00","localDateCount":"3"}] +/// collectionAmount : "2816.00" +/// collectionCount : 173 +/// refundAmount : "0" +/// refundCount : 0 + +class TradeSummaryList { + TradeSummaryList({ + List saleBusinessAnalysisVOS, + String collectionAmount, + num collectionCount, + String refundAmount, + num refundCount,}){ + _saleBusinessAnalysisVOS = saleBusinessAnalysisVOS; + _collectionAmount = collectionAmount; + _collectionCount = collectionCount; + _refundAmount = refundAmount; + _refundCount = refundCount; +} + + TradeSummaryList.fromJson(dynamic json) { + if (json['saleBusinessAnalysisVOS'] != null) { + _saleBusinessAnalysisVOS = []; + json['saleBusinessAnalysisVOS'].forEach((v) { + _saleBusinessAnalysisVOS.add(SaleBusinessAnalysisVos.fromJson(v)); + }); + } + _collectionAmount = json['collectionAmount']; + _collectionCount = json['collectionCount']; + _refundAmount = json['refundAmount']; + _refundCount = json['refundCount']; + } + List _saleBusinessAnalysisVOS; + String _collectionAmount; + num _collectionCount; + String _refundAmount; + num _refundCount; +TradeSummaryList copyWith({ List saleBusinessAnalysisVOS, + String collectionAmount, + num collectionCount, + String refundAmount, + num refundCount, +}) => TradeSummaryList( saleBusinessAnalysisVOS: saleBusinessAnalysisVOS ?? _saleBusinessAnalysisVOS, + collectionAmount: collectionAmount ?? _collectionAmount, + collectionCount: collectionCount ?? _collectionCount, + refundAmount: refundAmount ?? _refundAmount, + refundCount: refundCount ?? _refundCount, +); + List get saleBusinessAnalysisVOS => _saleBusinessAnalysisVOS; + String get collectionAmount => _collectionAmount; + num get collectionCount => _collectionCount; + String get refundAmount => _refundAmount; + num get refundCount => _refundCount; + + Map toJson() { + final map = {}; + if (_saleBusinessAnalysisVOS != null) { + map['saleBusinessAnalysisVOS'] = _saleBusinessAnalysisVOS.map((v) => v.toJson()).toList(); + } + map['collectionAmount'] = _collectionAmount; + map['collectionCount'] = _collectionCount; + map['refundAmount'] = _refundAmount; + map['refundCount'] = _refundCount; + return map; + } + +} + +/// localDateTime : "2023-08-29 00:00:00" +/// localDateBigDecimal : "22.00" +/// localDateCount : "1" + +class SaleBusinessAnalysisVos { + SaleBusinessAnalysisVos({ + String localDateTime, + String localDateBigDecimal, + String localDateCount,}){ + _localDateTime = localDateTime; + _localDateBigDecimal = localDateBigDecimal; + _localDateCount = localDateCount; +} + + SaleBusinessAnalysisVos.fromJson(dynamic json) { + _localDateTime = json['localDateTime']; + _localDateBigDecimal = json['localDateBigDecimal']; + _localDateCount = json['localDateCount']; + } + String _localDateTime; + String _localDateBigDecimal; + String _localDateCount; +SaleBusinessAnalysisVos copyWith({ String localDateTime, + String localDateBigDecimal, + String localDateCount, +}) => SaleBusinessAnalysisVos( localDateTime: localDateTime ?? _localDateTime, + localDateBigDecimal: localDateBigDecimal ?? _localDateBigDecimal, + localDateCount: localDateCount ?? _localDateCount, +); + String get localDateTime => _localDateTime; + String get localDateBigDecimal => _localDateBigDecimal; + String get localDateCount => _localDateCount; + + Map toJson() { + final map = {}; + map['localDateTime'] = _localDateTime; + map['localDateBigDecimal'] = _localDateBigDecimal; + map['localDateCount'] = _localDateCount; + return map; + } + +} \ No newline at end of file diff --git a/lib/setting/setting_page.dart b/lib/setting/setting_page.dart index c70a0929..9a729e7e 100644 --- a/lib/setting/setting_page.dart +++ b/lib/setting/setting_page.dart @@ -292,6 +292,9 @@ class _SettingPage extends State { sharedPreferences.setString("userId", ""); sharedPreferences.setString("mobile", ""); sharedPreferences.setString("nick", ""); + sharedPreferences.setString("account", ""); + sharedPreferences.setString("password", ""); + Navigator.of(context) .pushNamedAndRemoveUntil('/router/new_login_page', (route) => false);