|
|
|
|
@ -2,7 +2,8 @@ import 'dart:convert';
|
|
|
|
|
import 'dart:io';
|
|
|
|
|
import 'dart:typed_data';
|
|
|
|
|
|
|
|
|
|
import 'package:easy_localization/src/public_ext.dart';
|
|
|
|
|
import 'package:easy_localization/easy_localization.dart';
|
|
|
|
|
import 'package:fl_chart/fl_chart.dart';
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
import 'package:flutter_svg/flutter_svg.dart';
|
|
|
|
|
import 'package:mohem_flutter_app/api/worklist/worklist_api_client.dart';
|
|
|
|
|
@ -60,13 +61,21 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
|
|
|
|
|
int tabIndex = 0;
|
|
|
|
|
PageController controller = PageController();
|
|
|
|
|
|
|
|
|
|
final ScrollController _horizontalScrollController = ScrollController();
|
|
|
|
|
final ScrollController _horizontalHeaderScrollController = ScrollController();
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void initState() {
|
|
|
|
|
super.initState();
|
|
|
|
|
_horizontalScrollController.addListener(() {
|
|
|
|
|
_horizontalHeaderScrollController.jumpTo(_horizontalScrollController.offset);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
void dispose() {
|
|
|
|
|
_horizontalScrollController.dispose();
|
|
|
|
|
_horizontalHeaderScrollController.dispose();
|
|
|
|
|
super.dispose();
|
|
|
|
|
actionHistoryList.clear();
|
|
|
|
|
}
|
|
|
|
|
@ -129,23 +138,231 @@ class _ItemHistoryScreenState extends State<ItemHistoryScreen> {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TableRow rowChildren(GetPoItemHistoryList poData, int index) {
|
|
|
|
|
return TableRow(
|
|
|
|
|
decoration: BoxDecoration(color: index % 2 == 0 ? Colors.white : Colors.grey[100]),
|
|
|
|
|
children: [
|
|
|
|
|
rowCell(poData.cREATIONDATE!, index),
|
|
|
|
|
rowCell(poData.pURCHASEPRICE!.toString(), index),
|
|
|
|
|
rowCell(poData.sUPPLIER!, index),
|
|
|
|
|
rowCell(poData.pONUMBER!.toString(), index),
|
|
|
|
|
rowCell(poData.oUNAME!, index),
|
|
|
|
|
rowCell(poData.rEVISIONNUM!.toString(), index),
|
|
|
|
|
rowCell(poData.bUYER!, index),
|
|
|
|
|
rowCell(poData.uOM!, index),
|
|
|
|
|
rowCell(poData.qUANTITYORDERED!.toString(), index),
|
|
|
|
|
rowCell(poData.qUANTITYRECEIVED!.toString(), index),
|
|
|
|
|
rowCell(poData.bONUSQUANTITY!.toString(), index),
|
|
|
|
|
rowCell(poData.dISCOUNTPERCENTAGE!.toString(), index),
|
|
|
|
|
rowCell(poData.bALANCEQUANTITY!.toString(), index),
|
|
|
|
|
rowCell(poData.nETPRICE!.toString(), index),
|
|
|
|
|
rowCell(poData.cLOSEDCODE!, index),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget rowCell(String data, int index) {
|
|
|
|
|
return TableCell(
|
|
|
|
|
verticalAlignment: TableCellVerticalAlignment.middle,
|
|
|
|
|
child: Center(
|
|
|
|
|
child: Text(
|
|
|
|
|
data,
|
|
|
|
|
style: TextStyle(fontSize: 12, color: MyColors.normalTextColor, fontWeight: FontWeight.w500),
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
// data.toText12(color: MyColors.normalTextColor),
|
|
|
|
|
).paddingAll(8));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Widget headerCell(String data) {
|
|
|
|
|
return Container(
|
|
|
|
|
padding: const EdgeInsets.only(top: 16, bottom: 16, left: 8, right: 8),
|
|
|
|
|
width: 120,
|
|
|
|
|
alignment: Alignment.center,
|
|
|
|
|
decoration: BoxDecoration(color: Colors.grey[300]),
|
|
|
|
|
child: data.toText14(color: MyColors.darkIconColor),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Color> gradientColors = [MyColors.gradiantEndColor, MyColors.gradiantEndColor];
|
|
|
|
|
|
|
|
|
|
LineChartData drawLineChart(List<FlSpot> spots, List<GetPoItemHistoryList> reversedList) {
|
|
|
|
|
return LineChartData(
|
|
|
|
|
lineTouchData: LineTouchData(enabled: true, touchTooltipData: LineTouchTooltipData(tooltipBgColor: Colors.grey[300])),
|
|
|
|
|
gridData: FlGridData(
|
|
|
|
|
show: true,
|
|
|
|
|
drawHorizontalLine: true,
|
|
|
|
|
drawVerticalLine: true,
|
|
|
|
|
verticalInterval: 1,
|
|
|
|
|
horizontalInterval: 1,
|
|
|
|
|
getDrawingVerticalLine: (value) {
|
|
|
|
|
return FlLine(color: Color(0xff37434d), strokeWidth: .3);
|
|
|
|
|
},
|
|
|
|
|
getDrawingHorizontalLine: (value) {
|
|
|
|
|
return FlLine(color: Color(0xff37434d), strokeWidth: .3);
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
titlesData: FlTitlesData(
|
|
|
|
|
show: true,
|
|
|
|
|
bottomTitles: AxisTitles(
|
|
|
|
|
sideTitles: SideTitles(
|
|
|
|
|
showTitles: true,
|
|
|
|
|
reservedSize: 30,
|
|
|
|
|
interval: 1,
|
|
|
|
|
getTitlesWidget: (double value, TitleMeta meta) {
|
|
|
|
|
return SideTitleWidget(
|
|
|
|
|
axisSide: meta.axisSide,
|
|
|
|
|
child: Text(reversedList[int.parse(meta.formattedValue)].cREATIONDATE!, style: TextStyle(fontSize: 10)),
|
|
|
|
|
);
|
|
|
|
|
})),
|
|
|
|
|
leftTitles: AxisTitles(
|
|
|
|
|
sideTitles: SideTitles(
|
|
|
|
|
showTitles: true,
|
|
|
|
|
reservedSize: 30,
|
|
|
|
|
interval: 1,
|
|
|
|
|
getTitlesWidget: (double value, TitleMeta meta) {
|
|
|
|
|
return SideTitleWidget(
|
|
|
|
|
axisSide: meta.axisSide,
|
|
|
|
|
child: Text(meta.formattedValue, style: TextStyle(fontSize: 10)),
|
|
|
|
|
);
|
|
|
|
|
})),
|
|
|
|
|
topTitles: AxisTitles(sideTitles: SideTitles(showTitles: false)),
|
|
|
|
|
rightTitles: AxisTitles(
|
|
|
|
|
sideTitles: SideTitles(
|
|
|
|
|
showTitles: true,
|
|
|
|
|
reservedSize: 15,
|
|
|
|
|
getTitlesWidget: (double value, TitleMeta meta) {
|
|
|
|
|
return SideTitleWidget(
|
|
|
|
|
axisSide: meta.axisSide,
|
|
|
|
|
child: Text("", style: TextStyle(fontSize: 10)),
|
|
|
|
|
);
|
|
|
|
|
})),
|
|
|
|
|
),
|
|
|
|
|
borderData: FlBorderData(show: true, border: Border.all(color: const Color(0xff37434d))),
|
|
|
|
|
minX: 0,
|
|
|
|
|
maxX: poItemHistoryList.length.toDouble() - 1,
|
|
|
|
|
minY: poItemHistoryList.map((e) => e.pURCHASEPRICE!.toDouble()).reduce((curr, next) => curr < next ? curr : next) - 1,
|
|
|
|
|
maxY: poItemHistoryList.map((e) => e.pURCHASEPRICE!.toDouble()).reduce((curr, next) => curr > next ? curr : next) + 1,
|
|
|
|
|
lineBarsData: [
|
|
|
|
|
LineChartBarData(
|
|
|
|
|
spots: spots,
|
|
|
|
|
isCurved: true,
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
ColorTween(begin: gradientColors[0], end: gradientColors[1]).lerp(0.2)!,
|
|
|
|
|
ColorTween(begin: gradientColors[0], end: gradientColors[1]).lerp(0.2)!,
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
barWidth: 2,
|
|
|
|
|
isStrokeCapRound: true,
|
|
|
|
|
dotData: FlDotData(show: true),
|
|
|
|
|
belowBarData: BarAreaData(
|
|
|
|
|
show: true,
|
|
|
|
|
gradient: LinearGradient(
|
|
|
|
|
colors: [
|
|
|
|
|
ColorTween(begin: gradientColors[0], end: gradientColors[1]).lerp(0.2)!.withOpacity(0.1),
|
|
|
|
|
ColorTween(begin: gradientColors[0], end: gradientColors[1]).lerp(0.2)!.withOpacity(0.1),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@override
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
loadData();
|
|
|
|
|
Widget? chartWidget;
|
|
|
|
|
|
|
|
|
|
if (_screenParams!.isItemHistory && poItemHistoryList.isNotEmpty) {
|
|
|
|
|
try {
|
|
|
|
|
List<GetPoItemHistoryList> reversedList = poItemHistoryList.reversed.toList();
|
|
|
|
|
List<FlSpot> dataPoints = List.generate(
|
|
|
|
|
reversedList.length,
|
|
|
|
|
(index) => FlSpot(index.toDouble(), reversedList[index].pURCHASEPRICE!.toDouble()),
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
double chartWidth = dataPoints.length * 70.0;
|
|
|
|
|
chartWidget = Column(
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
children: [
|
|
|
|
|
LocaleKeys.graphicalAnalysis.tr().toText14(color: MyColors.darkIconColor),
|
|
|
|
|
SizedBox(
|
|
|
|
|
height: 400,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
child: Container(
|
|
|
|
|
width: chartWidth,
|
|
|
|
|
padding: const EdgeInsets.all(16.0),
|
|
|
|
|
child: LineChart(drawLineChart(dataPoints, reversedList)),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
],
|
|
|
|
|
);
|
|
|
|
|
} catch (ex) {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Scaffold(
|
|
|
|
|
appBar: AppBarWidget(context, title: _screenParams?.title ?? ""),
|
|
|
|
|
backgroundColor: Colors.white,
|
|
|
|
|
body: ListView(
|
|
|
|
|
padding: _screenParams!.isPRInfo ? const EdgeInsets.all(0) : const EdgeInsets.all(21),
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
children: [
|
|
|
|
|
if (_screenParams!.isPRInfo) prLinesDataView(),
|
|
|
|
|
if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData(),
|
|
|
|
|
if (poItemHistoryList.isNotEmpty) loadPoItemHistoryData(),
|
|
|
|
|
if (quotationAnalysisList.isNotEmpty) loadQuotationAnalysisData(),
|
|
|
|
|
if (moItemHistoryList.isEmpty && poItemHistoryList.isEmpty && quotationAnalysisList.isEmpty && !_screenParams!.isPRInfo) Utils.getNoDataWidget(context),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
body: (_screenParams!.isItemHistory && poItemHistoryList.isNotEmpty)
|
|
|
|
|
? Column(
|
|
|
|
|
children: [
|
|
|
|
|
if (chartWidget != null) chartWidget,
|
|
|
|
|
if (poItemHistoryList.isNotEmpty) ...[
|
|
|
|
|
LocaleKeys.itemHistoryAnalysis.tr().toText14(color: MyColors.darkIconColor),
|
|
|
|
|
16.height,
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
controller: _horizontalHeaderScrollController,
|
|
|
|
|
child: Row(
|
|
|
|
|
children: [
|
|
|
|
|
headerCell(LocaleKeys.creationDate.tr()),
|
|
|
|
|
headerCell(LocaleKeys.purchasePrice.tr()),
|
|
|
|
|
headerCell(LocaleKeys.supplier.tr()),
|
|
|
|
|
headerCell(LocaleKeys.pOno.tr()),
|
|
|
|
|
headerCell(LocaleKeys.oprUnit.tr()),
|
|
|
|
|
headerCell(LocaleKeys.revision.tr()),
|
|
|
|
|
headerCell(LocaleKeys.buyer.tr()),
|
|
|
|
|
headerCell(LocaleKeys.uom.tr()),
|
|
|
|
|
headerCell(LocaleKeys.qtyOrdered.tr()),
|
|
|
|
|
headerCell(LocaleKeys.qtyReceived.tr()),
|
|
|
|
|
headerCell(LocaleKeys.bonusQty.tr()),
|
|
|
|
|
headerCell(LocaleKeys.discountPer.tr()),
|
|
|
|
|
headerCell(LocaleKeys.balQty.tr()),
|
|
|
|
|
headerCell(LocaleKeys.netPrice.tr()),
|
|
|
|
|
headerCell(LocaleKeys.closureStatus.tr()),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.vertical,
|
|
|
|
|
child: SingleChildScrollView(
|
|
|
|
|
scrollDirection: Axis.horizontal,
|
|
|
|
|
controller: _horizontalScrollController,
|
|
|
|
|
child: Table(
|
|
|
|
|
defaultColumnWidth: const FixedColumnWidth(120.0),
|
|
|
|
|
children: [for (int index = 0; index < poItemHistoryList.length; index++) rowChildren(poItemHistoryList[index], index)],
|
|
|
|
|
),
|
|
|
|
|
),
|
|
|
|
|
).expanded,
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
: ListView(
|
|
|
|
|
padding: _screenParams!.isPRInfo ? const EdgeInsets.all(0) : const EdgeInsets.all(21),
|
|
|
|
|
// physics: const NeverScrollableScrollPhysics(),
|
|
|
|
|
children: [
|
|
|
|
|
if (_screenParams!.isPRInfo) prLinesDataView(),
|
|
|
|
|
if (moItemHistoryList.isNotEmpty) loadMoItemHistoryData(),
|
|
|
|
|
if (poItemHistoryList.isNotEmpty) loadPoItemHistoryData(),
|
|
|
|
|
if (quotationAnalysisList.isNotEmpty) loadQuotationAnalysisData(),
|
|
|
|
|
if (moItemHistoryList.isEmpty && poItemHistoryList.isEmpty && quotationAnalysisList.isEmpty && !_screenParams!.isPRInfo) Utils.getNoDataWidget(context),
|
|
|
|
|
],
|
|
|
|
|
),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|