You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1149 lines
45 KiB
1149 lines
45 KiB
import 'package:dio/dio.dart'; |
|
import 'package:flutter/cupertino.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/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 'package:shimmer/shimmer.dart'; |
|
|
|
import '../../../generated/l10n.dart'; |
|
import '../../../retrofit/business_api.dart'; |
|
import '../../../retrofit/data/base_data.dart'; |
|
import '../../../retrofit/data/goods_type_sales_list.dart'; |
|
import '../../../retrofit/data/single_sales_list.dart'; |
|
import '../../../utils/business_instance.dart'; |
|
import '../../../utils/flutter_utils.dart'; |
|
import '../../../utils/font_weight.dart'; |
|
import '../../../view_widget/no_data_view.dart'; |
|
|
|
class TradeGoods extends StatefulWidget { |
|
final storeId; |
|
|
|
TradeGoods(this.storeId); |
|
|
|
@override |
|
State<StatefulWidget> createState() { |
|
return _TradeGoods(); |
|
} |
|
} |
|
|
|
class _TradeGoods extends State<TradeGoods> { |
|
final RefreshController _refreshController = RefreshController(); |
|
final ScrollController scrollController = ScrollController(); |
|
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月dd").format(DateTime.now())}"; |
|
String customDate = ""; |
|
String customDateNum = "${DateFormat("yyyy年MM月dd日").format(DateTime.now())}"; |
|
int _loadCount = 0; |
|
BusinessApiService businessService; |
|
List<SingleSalesList> singleSalesList = []; |
|
List<GoodsTypeSalesList> goodsTypeSalesList = []; |
|
String networkError = ""; |
|
int networkStatus = 0; |
|
|
|
@override |
|
void dispose() { |
|
super.dispose(); |
|
_refreshController.dispose(); |
|
} |
|
|
|
@override |
|
void initState() { |
|
super.initState(); |
|
_onRefresh(); |
|
} |
|
|
|
_onRefresh({isLoading = true}) async { |
|
if(isLoading) |
|
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); |
|
if (dateIndex == 0) { |
|
querySingleSales( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
isSing: false); |
|
queryGoodsSalesList( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
isSing: false); |
|
} else if (dateIndex == 1) { |
|
querySingleSales( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(12, 23), |
|
isSing: false); |
|
queryGoodsSalesList( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(12, 23), |
|
isSing: false); |
|
} else if (dateIndex == 2) { |
|
querySingleSales( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
"", |
|
isSing: false); |
|
queryGoodsSalesList( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
"", |
|
isSing: false); |
|
} else if (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), |
|
isSing: false); |
|
queryGoodsSalesList( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(timeDate().length <= 15 ? 0 : 12, |
|
timeDate().length <= 15 ? 10 : 23), |
|
isSing: false); |
|
} |
|
}); |
|
} |
|
|
|
addLoadCount() { |
|
_loadCount += 1; |
|
if (_loadCount == 2) { |
|
_loadCount = 0; |
|
EasyLoading.dismiss(); |
|
if (_refreshController.isRefresh) _refreshController.refreshCompleted(); |
|
if (mounted) setState(() {}); |
|
} |
|
} |
|
|
|
///商品种类销售数据 |
|
queryGoodsSalesList(date, endDat, {isSing = true}) async { |
|
if (isSing) |
|
EasyLoading.show( |
|
status: S.current.zhengzaijiazai, |
|
maskType: EasyLoadingMaskType.black); |
|
try { |
|
BaseData<List<GoodsTypeSalesList>> baseData = |
|
await businessService.goodsSalesList({ |
|
"date": date, |
|
"endDate": endDat, |
|
"groupId": 0, |
|
"orderBy": 1, |
|
"searchType": 2, |
|
"type": 1 |
|
}).catchError((error) { |
|
networkError = AppUtils.dioErrorTypeToString(error.type); |
|
networkStatus = -1; |
|
}); |
|
if (baseData != null && baseData.isSuccess) { |
|
goodsTypeSalesList = baseData.data; |
|
networkStatus = 1; |
|
} |
|
} finally { |
|
if (isSing) { |
|
setState(() {}); |
|
EasyLoading.dismiss(); |
|
} else { |
|
addLoadCount(); |
|
} |
|
} |
|
} |
|
|
|
///单品销量报表 |
|
querySingleSales(date, endDate, {isSing = true}) async { |
|
if (isSing) |
|
EasyLoading.show( |
|
status: S.current.zhengzaijiazai, |
|
maskType: EasyLoadingMaskType.black); |
|
try { |
|
BaseData<List<SingleSalesList>> baseData = |
|
await businessService.singleSales({ |
|
"date": date, |
|
"endDate": endDate, |
|
"groupId": 0, |
|
"orderBy": 1, |
|
"searchType": 2, |
|
"type": 1 |
|
}).catchError((error) {}); |
|
if (baseData != null && baseData.isSuccess) { |
|
singleSalesList = baseData.data; |
|
} |
|
} finally { |
|
if (isSing) { |
|
setState(() {}); |
|
EasyLoading.dismiss(); |
|
} else { |
|
addLoadCount(); |
|
} |
|
} |
|
} |
|
|
|
@override |
|
Widget build(BuildContext context) { |
|
return Scaffold( |
|
backgroundColor: Colors.white, |
|
body: Column( |
|
children: [ |
|
Container( |
|
color: Color(0xFFD8D8D8), |
|
width: double.infinity, |
|
height: 1.h, |
|
), |
|
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(isLoading: false); |
|
}, |
|
child: networkStatus == -1 ? noNetwork() : 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; |
|
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, |
|
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: () { |
|
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, |
|
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: () { |
|
dateIndex = 2; |
|
querySingleSales( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
""); |
|
queryGoodsSalesList( |
|
timeDate() |
|
.replaceAll("年", "-") |
|
.replaceAll("月", "-") |
|
.replaceAll("日", "") |
|
.substring(0, 10), |
|
""); |
|
}, |
|
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: () { |
|
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, |
|
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; |
|
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) { |
|
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) { |
|
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) { |
|
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)); |
|
}); |
|
} |
|
}, |
|
child: Container( |
|
width: 200.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( |
|
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, |
|
), |
|
], |
|
), |
|
), |
|
), |
|
), |
|
Padding( |
|
padding: EdgeInsets.only(left: 16.w, bottom: 15.h), |
|
child: Text( |
|
"商品分析", |
|
style: TextStyle( |
|
fontSize: 18.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Colors.black, |
|
), |
|
)), |
|
goodsTypeRecord(), |
|
Container( |
|
margin: |
|
EdgeInsets.only(top: 14.h, left: 16.w, right: 16.w), |
|
color: Color(0xFFECECEC), |
|
height: 1.h, |
|
width: double.infinity, |
|
), |
|
singleSalesStatement(), |
|
], |
|
)), |
|
), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
|
|
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.substring(0,11)} ""${customDate.substring(21,34)}"); |
|
} |
|
} |
|
|
|
///商品种类销售数据 |
|
Widget goodsTypeRecord() { |
|
return Column( |
|
children: [ |
|
Padding( |
|
padding: EdgeInsets.only(left: 16.w, bottom: 19.h), |
|
child: Row( |
|
children: [ |
|
Container( |
|
width: 4.w, |
|
height: 16.h, |
|
color: Color(0xFF30415B), |
|
margin: EdgeInsets.only(right: 12.w), |
|
), |
|
Text( |
|
"商品种类销售数据", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
SizedBox( |
|
width: 8.w, |
|
), |
|
Text( |
|
"比上周一同时段", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF666666), |
|
), |
|
) |
|
], |
|
)), |
|
Container( |
|
margin: EdgeInsets.symmetric(horizontal: 16.w), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(2), |
|
border: Border.all( |
|
color: Color(0xFFD6D6D6), |
|
width: 1, |
|
), |
|
), |
|
child: Column( |
|
children: [ |
|
Container( |
|
color: Color(0xFFF3F7FF), |
|
padding: EdgeInsets.only( |
|
top: 7.h, left: 11.w, right: 24.w, bottom: 8.h), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
"分类", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
), |
|
Text( |
|
"销售额", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
if(networkStatus == 1) |
|
(goodsTypeSalesList == null || goodsTypeSalesList.length == 0) |
|
? NoDataView( |
|
src: "assets/image/bs_no data_logo.webp", |
|
isShowBtn: false, |
|
text: "暂无数据", |
|
fontSize: 16.sp, |
|
margin: EdgeInsets.all(20.h), |
|
) |
|
: Container( |
|
height: 220.h, |
|
child: ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount: goodsTypeSalesList?.length ?? 0, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () {}, |
|
child: goodsTypeItem( |
|
goodsTypeSalesList[position], position), |
|
); |
|
}, |
|
), |
|
), |
|
if(networkStatus == 0) |
|
ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount: 9, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return goodsTypeItemSm(position); |
|
}, |
|
) |
|
], |
|
), |
|
), |
|
], |
|
); |
|
} |
|
|
|
Widget goodsTypeItem(GoodsTypeSalesList goodsTypeSalesList, int index) { |
|
return Container( |
|
color: index % 2 == 0 ? Color(0xFFF9FAF8) : Colors.white, |
|
padding: EdgeInsets.only(top: 8.h, left: 11.w, right: 24.w, bottom: 7.h), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
goodsTypeSalesList?.name ?? "", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
), |
|
Text( |
|
goodsTypeSalesList?.value ?? "", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget goodsTypeItemSm(index) { |
|
return Container( |
|
margin: EdgeInsets.only(bottom: 12.h), |
|
padding: EdgeInsets.only(top: 8.h, left: 11.w, right: 24.w, bottom: 7.h), |
|
width: double.infinity, |
|
decoration: BoxDecoration( |
|
color: index % 2 == 0 ? Color(0xFFF9FAF8) : Colors.white, |
|
borderRadius: BorderRadius.circular(6), |
|
), |
|
child: |
|
Row( |
|
children: [ |
|
Shimmer.fromColors( |
|
baseColor: Color(0XFFD8D8D8), |
|
highlightColor: Color(0XFFD8D8D8), |
|
child: Container( |
|
decoration: BoxDecoration( |
|
color: Color(0XFFD8D8D8), |
|
borderRadius: BorderRadius.circular(2), |
|
), |
|
width: 50.w, |
|
height: 20.h, |
|
), |
|
), |
|
Spacer(), |
|
Shimmer.fromColors( |
|
baseColor: Color(0XFFD8D8D8), |
|
highlightColor: Color(0XFFD8D8D8), |
|
child: Container( |
|
decoration: BoxDecoration( |
|
color: Color(0XFFD8D8D8), |
|
borderRadius: BorderRadius.circular(2), |
|
), |
|
width: 50.w, |
|
height: 20.h, |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
///单品销量报表 |
|
Widget singleSalesStatement() { |
|
return Container( |
|
padding: EdgeInsets.only(top: 23.h, bottom: 45.h), |
|
child: Column( |
|
children: [ |
|
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), |
|
), |
|
Text( |
|
"单品销量报表", |
|
style: TextStyle( |
|
fontSize: 15.sp, |
|
fontWeight: MyFontWeight.semi_bold, |
|
color: Color(0xFF0D0D0D), |
|
), |
|
), |
|
SizedBox( |
|
width: 8.w, |
|
), |
|
Text( |
|
"比上周一同时段", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.regular, |
|
color: Color(0xFF666666), |
|
), |
|
) |
|
], |
|
)), |
|
Container( |
|
margin: EdgeInsets.symmetric(horizontal: 16.w), |
|
decoration: BoxDecoration( |
|
color: Colors.white, |
|
borderRadius: BorderRadius.circular(2), |
|
border: Border.all( |
|
color: Color(0xFFD6D6D6), |
|
width: 1, |
|
), |
|
), |
|
child: Column( |
|
children: [ |
|
Container( |
|
color: Color(0xFFF3F7FF), |
|
padding: EdgeInsets.only(top: 7.h, left: 17.w, bottom: 8.h), |
|
child: Row( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
"分类", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
flex: 2, |
|
), |
|
Expanded( |
|
child: Text( |
|
"名称", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
flex: 2, |
|
), |
|
Expanded( |
|
child: Text( |
|
"销售额", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
), |
|
Expanded( |
|
child: Text( |
|
"单价", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
), |
|
Expanded( |
|
child: Text( |
|
"销量", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF969799), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
), |
|
(singleSalesList == null || singleSalesList.length == 0) |
|
? NoDataView( |
|
src: "assets/image/bs_no data_logo.webp", |
|
isShowBtn: false, |
|
text: "暂无数据", |
|
fontSize: 16.sp, |
|
margin: EdgeInsets.all(20), |
|
) |
|
: Container( |
|
height: 243.h, |
|
child: ListView.builder( |
|
padding: EdgeInsets.zero, |
|
itemCount: singleSalesList?.length ?? 0, |
|
scrollDirection: Axis.vertical, |
|
shrinkWrap: true, |
|
physics: BouncingScrollPhysics(), |
|
itemBuilder: (context, position) { |
|
return GestureDetector( |
|
onTap: () {}, |
|
child: singleSalesItem( |
|
singleSalesList[position], position), |
|
); |
|
}, |
|
), |
|
) |
|
], |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget singleSalesItem(SingleSalesList singleSalesList, int index) { |
|
return Container( |
|
color: index % 2 == 0 ? Color(0xFFF9FAF8) : Colors.white, |
|
padding: EdgeInsets.only(top: 8.h, left: 16.w, bottom: 7.h), |
|
child: Row( |
|
children: [ |
|
Expanded( |
|
child: Text( |
|
singleSalesList?.productGroupName ?? "", |
|
maxLines: 1, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
flex: 2, |
|
), |
|
Expanded( |
|
child: Text( |
|
singleSalesList?.productName ?? "", |
|
maxLines: 1, |
|
overflow: TextOverflow.ellipsis, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
flex: 2, |
|
), |
|
Expanded( |
|
child: Text( |
|
singleSalesList?.sumPrice ?? "", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
), |
|
Expanded( |
|
child: Text( |
|
singleSalesList?.sellPrict ?? "", |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
), |
|
Expanded( |
|
child: Text( |
|
(singleSalesList?.saleNum ?? 0).toString(), |
|
textAlign: TextAlign.center, |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
fontWeight: MyFontWeight.medium, |
|
color: Color(0xFF000000), |
|
), |
|
), |
|
), |
|
], |
|
), |
|
); |
|
} |
|
|
|
Widget noNetwork() { |
|
return Container( |
|
color: Colors.white, |
|
child: Column( |
|
mainAxisAlignment: MainAxisAlignment.center, |
|
children: [ |
|
Text( |
|
networkError.substring(0,4), |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: Color(0xFF0D0D0D), |
|
fontWeight: MyFontWeight.bold), |
|
), |
|
Padding( |
|
padding: EdgeInsets.symmetric(vertical: 10.h), |
|
child: Text( |
|
"请检查网络设置或稍后重试", |
|
style: TextStyle( |
|
fontSize: 12.sp, |
|
color: Color(0xFF7A797F), |
|
fontWeight: MyFontWeight.regular), |
|
), |
|
), |
|
GestureDetector( |
|
behavior: HitTestBehavior.opaque, |
|
onTap: () { |
|
_onRefresh(); |
|
}, |
|
child: Container( |
|
decoration: BoxDecoration( |
|
color: Color(0xFF30415B), |
|
borderRadius: BorderRadius.circular(15), |
|
), |
|
padding: EdgeInsets.symmetric(horizontal: 12.w, vertical: 3.h), |
|
child: Text( |
|
"重试", |
|
style: TextStyle( |
|
fontSize: 14.sp, |
|
color: Colors.white, |
|
fontWeight: MyFontWeight.regular), |
|
)), |
|
) |
|
], |
|
), |
|
); |
|
} |
|
}
|
|
|