import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:m80app/viewmodels/mainpage_viewmodel.dart';
import 'package:m80app/viewmodels/retrievalpage_viewmodel.dart';
import 'package:provider/provider.dart';
import '../../components/app_button.dart';
import '../../components/app_dropdownbutton.dart';
import 'package:m80app/constants/route_paths_constants.dart' as routes;
import 'package:m80app/constants/constants.dart' as constants;
const List<String> retrievalType = ['台番号', 'カード番号', '管理番号'];
const List<String> cardType1 = <String>['Cカード', 'Mカード'];
const List<String> cardType2 = <String>['パチンコ', 'スロット'];
List<String> cardType = cardType2;
var serachcondition = TextEditingController();
String retrievalTypeValue = retrievalType.first;
String cardTypeValue = cardType.first;
List<String> columnNames = [];
List<DataColumn> columns = [];
Map<String, String> resultData = {};
class RetrievalPage extends StatefulWidget {
const RetrievalPage({super.key});
@override
State<RetrievalPage> createState() => _RetrievalPageState();
}
class _RetrievalPageState extends State<RetrievalPage> {
int cardTypeIntValue = 0;
String type = '台番号';
String cardTypeStr = '種別';
List<TextInputFormatter> inputType = <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
NumericalRangeFormatter(min: 0, max: 2147483647),
];
final timeController = TextEditingController();
final timeController2 = TextEditingController();
final dataController = TextEditingController();
@override
Widget build(BuildContext context) {
RetrievalPageViewModel retrievalPageViewModel =
context.watch<RetrievalPageViewModel>();
MainPageViewModel mainpageViewModel = context.watch<MainPageViewModel>();
return Column(children: [
const SizedBox(
height: 30,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
const SizedBox(
width: 150,
child: Text('検索種別',
style: TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
fontWeight: FontWeight.bold))),
const SizedBox(
width: 30,
),
CustomDropdownButton(
width: 220,
items: retrievalType,
onChanged: (value) {
List<String> tmpCardType = [];
setState(() {
retrievalTypeValue = value;
switch (retrievalTypeValue) {
case '台番号':
type = '台番号';
cardTypeStr = '種別';
cardType = cardType2;
cardTypeValue = cardType.first;
cardTypeIntValue = 1;
dataController.clear();
inputType = <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
NumericalRangeFormatter(min: 0, max: 2147483647),
];
break;
case 'カード番号':
type = 'カード番号';
cardTypeStr = 'カード種別';
cardType = cardType1;
cardTypeValue = cardType.first;
cardTypeIntValue = 0;
dataController.clear();
inputType = <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
NumericalRangeFormatter(min: 0, max: 2147483647),
];
break;
case '管理番号':
type = '管理番号';
cardTypeStr = 'カード種別';
cardType = cardType1;
cardTypeValue = cardType.first;
cardTypeIntValue = 2;
dataController.clear();
inputType = <TextInputFormatter>[
FilteringTextInputFormatter.allow(RegExp("[0-9a-zA-Z]"))
];
break;
}
tmpCardType = cardType;
});
cardType = tmpCardType;
},
),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(
width: 150,
child: Text(cardTypeStr,
style: const TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
fontWeight: FontWeight.bold))),
const SizedBox(
width: 30,
),
CustomDropdownButton(
width: 220,
items: cardType,
onChanged: (value) {
setState(() {
cardTypeValue = value;
switch (value) {
case 'Cカード':
case 'P':
cardTypeIntValue = 0;
break;
case 'Mカード':
case 'M':
cardTypeIntValue = 1;
break;
}
});
},
),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
children: [
const SizedBox(
width: 150,
child: Text('時間範囲',
style: TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
fontWeight: FontWeight.bold))),
const SizedBox(
width: 30,
),
SizedBox(
width: 350,
child: TextField(
style: const TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
height: 2.0,
color: Colors.black),
decoration: const InputDecoration(
border: InputBorder.none,
filled: true,
fillColor: constants.COLOR_GREY,
),
controller: timeController,
onTap: () async {
var time = await showTimePicker(
context: context, initialTime: TimeOfDay.now());
if (time != null) {
// ignore: use_build_context_synchronously
timeController.text = time.format(context);
}
},
),
),
const SizedBox(
width: 30,
),
const Text('~',
style: TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
fontWeight: FontWeight.bold)),
const SizedBox(
width: 30,
),
SizedBox(
width: 350,
child: TextField(
style: const TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
height: 2.0,
color: Colors.black),
decoration: const InputDecoration(
border: InputBorder.none,
filled: true,
fillColor: constants.COLOR_GREY,
),
controller: timeController2,
onTap: () async {
var time = await showTimePicker(
context: context, initialTime: TimeOfDay.now());
if (time != null) {
// ignore: use_build_context_synchronously
timeController2.text = time.format(context);
}
},
),
),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
children: [
SizedBox(
width: 150,
child: Text(type,
style: const TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
fontWeight: FontWeight.bold))),
const SizedBox(
width: 30,
),
SizedBox(
width: 400,
child: TextField(
style: const TextStyle(
fontSize: constants.NORMAL_FONT_SIZE,
height: 2.0,
color: Colors.black),
decoration: const InputDecoration(
border: InputBorder.none,
filled: true,
fillColor: constants.COLOR_GREY,
),
inputFormatters: inputType,
controller: dataController,
),
),
],
),
),
const SizedBox(
height: 80,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CustomButton(
text: '検索',
width: 200,
onPressed: () {
RetrievalPageViewModel();
columnNames = [
"日時",
"場所",
"種別",
"カード番号",
"処理1",
"処理2",
"結果",
"取引前度数",
"加算度数",
"減算度数",
"取引後度数",
'お助け日付',
'前カード番号',
'前管理番号',
];
switch (retrievalTypeValue) {
case '台番号':
retrievalPageViewModel.sendB6A1(
timeController.text,
timeController2.text,
cardTypeIntValue,
int.parse(dataController.value.text),
12344,
);
resultData = {
'機器種別': cardTypeValue,
'調査種別': retrievalTypeValue,
'期間': '${timeController.text}~${timeController2.text}',
'台番号': dataController.text,
};
break;
case 'カード番号':
retrievalPageViewModel.sendB6B1(
timeController.text,
timeController2.text,
cardTypeIntValue,
int.parse(dataController.value.text),
);
resultData = {
'機器種別': '',
'調査種別': retrievalTypeValue,
'期間': '${timeController.text}~${timeController2.text}',
'カード種別': cardTypeValue,
'カード番号': dataController.text,
'管理番号': '',
};
break;
case '管理番号':
retrievalPageViewModel.sendB1C1(
cardTypeIntValue,
dataController.value.text,
);
resultData = {
'機器種別': '',
'調査種別': retrievalTypeValue,
'期間': '${timeController.text}~${timeController2.text}',
'カード種別': cardTypeValue,
'カード番号': '',
'管理番号': dataController.text,
};
break;
}
columns = columnNames.map((columnName) {
return DataColumn(label: Text(columnName));
}).toList();
mainpageViewModel.setretrievalResultData(resultData);
mainpageViewModel.setcurrentRoute(routes.RetrievalResultRoute);
mainpageViewModel.settitleList(['営業モード', '検索', '検索結果']);
},
),
const SizedBox(
width: 20,
),
CustomButton(
text: '戻る',
width: 120,
onPressed: () {
mainpageViewModel.setcurrentRoute(routes.BusinessMenuRoute);
mainpageViewModel.settitleList(['営業モード']);
},
),
],
),
),
]);
}
}
import 'package:flutter/material.dart';
import 'package:m80app/components/app_button.dart';
import 'package:m80app/viewmodels/mainpage_viewmodel.dart';
import 'package:m80app/views/retrievalpage/retrieval_page.dart';
import 'package:provider/provider.dart';
import 'package:m80app/constants/constants.dart' as constants;
import 'package:m80app/constants/route_paths_constants.dart' as routes;
const labelWidth = 132.0;
const valueWidth = 200.0;
const selectedheight = 60.0;
List<String> rowNamesControl = [
'機器種別',
'調査種別',
'期間',
'台番号',
];
const controlData = {
'機器種別': '',
'調査種別': '',
'期間': '',
'台番号': '',
};
List<String> rowNamesCardMachine = [
'機器種別',
'調査種別',
'期間',
'カード種別',
'カード番号',
'管理番号',
];
const cardmachineData = {
'機器種別': '',
'調査種別': '',
'期間': '',
'カード種別': '',
'カード番号': '',
'管理番号': '',
};
class RetrievalResultPage extends StatefulWidget {
final Map<String, String> dataFilter;
const RetrievalResultPage({super.key, required this.dataFilter});
@override
State<RetrievalResultPage> createState() => _RetrievalResultPageState();
}
class _RetrievalResultPageState extends State<RetrievalResultPage> {
Map<String, String>? dataFilter;
bool isDataFilterEmpty = false;
@override
void initState() {
super.initState();
dataFilter = widget.dataFilter;
if (dataFilter!.isEmpty) {
dataFilter = controlData;
isDataFilterEmpty = true;
}
}
getUIRetrieval() {
List<DataRow> listRow = [];
listRow.add(DataRow(cells: [
DataCell(Text('111111111111111111',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('222222222222222222',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('333333333333333333',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('5444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('6444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('7444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('8444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('9444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('10444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('11444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('12444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('13444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
DataCell(Text('14444444444444444444',
maxLines: 100, overflow: TextOverflow.ellipsis)),
]));
return listRow;
}
Row rowControl(String label, String? value) {
return Row(children: [
SizedBox(
width: labelWidth,
height: selectedheight,
child: Text(style: constants.TEXT_STYLE, label)),
SizedBox(
width: valueWidth,
height: selectedheight,
child: Text(style: constants.TEXT_STYLE, ': ${value ?? ""}')),
]);
}
Container allRowControl(Map<String, String> dataMap) {
return Container(
padding: const EdgeInsets.fromLTRB(12, 13, 10, 0),
decoration: const BoxDecoration(color: Colors.white),
child: Column(children: [
Row(
children: [
rowControl(rowNamesControl[0], dataMap[rowNamesControl[0]]),
rowControl(rowNamesControl[1], dataMap[rowNamesControl[1]]),
Row(
children: [
SizedBox(
width: labelWidth,
height: selectedheight,
child: Text(
style: constants.TEXT_STYLE, rowNamesControl[2])),
SizedBox(
width: 400,
height: selectedheight,
child: Text(
style: constants.TEXT_STYLE,
': ${dataMap[rowNamesControl[2]] ?? ""}')),
],
),
],
),
Row(
children: [
rowControl(rowNamesControl[3], dataMap[rowNamesControl[3]]),
],
),
]));
}
Row rowCardMachine(String label, String? value) {
return Row(children: [
SizedBox(
width: labelWidth,
height: selectedheight,
child: Text(style: constants.TEXT_STYLE, label)),
SizedBox(
width: valueWidth,
height: selectedheight,
child: Text(style: constants.TEXT_STYLE, ': ${value ?? ""}')),
]);
}
Container allRowCardMachine(Map<String, String> dataMap) {
return Container(
padding: const EdgeInsets.fromLTRB(12, 13, 10, 0),
decoration: const BoxDecoration(color: Colors.white),
child: Column(children: [
Row(
children: [
rowCardMachine(
rowNamesCardMachine[0], dataMap[rowNamesCardMachine[0]]),
rowCardMachine(
rowNamesCardMachine[1], dataMap[rowNamesCardMachine[1]]),
Row(
children: [
SizedBox(
width: labelWidth,
height: selectedheight,
child: Text(
style: constants.TEXT_STYLE, rowNamesCardMachine[2])),
SizedBox(
width: 400,
height: selectedheight,
child: Text(
style: constants.TEXT_STYLE,
': ${dataMap[rowNamesCardMachine[2]] ?? ""}')),
],
),
],
),
Row(
children: [
rowCardMachine(
rowNamesCardMachine[3], dataMap[rowNamesCardMachine[3]]),
rowCardMachine(
rowNamesCardMachine[4], dataMap[rowNamesCardMachine[4]]),
rowCardMachine(
rowNamesCardMachine[5], dataMap[rowNamesCardMachine[5]]),
],
),
]));
}
@override
Widget build(BuildContext context) {
MainPageViewModel mainpageViewModel = context.watch<MainPageViewModel>();
return Column(children: [
// const AppHeaderBar(title: '検索結果',),
// AppTitleBar(title: '営業日: ${DateFormat('yyyy/MM/dd').format(DateTime.now())} HC通信: 正常-(閉店中)'),
const SizedBox(
height: 20,
),
Container(
width: constants.CONTENT_WIDTH,
color: Colors.white,
child: Table(
border: TableBorder.all(color: Colors.black),
children: [
TableRow(
children: <Widget>[
TableCell(
verticalAlignment: TableCellVerticalAlignment.top,
child: Container(
height: 153,
color: Colors.white,
child: Column(
children: [
retrievalTypeValue == '台番号'
? allRowControl(dataFilter!)
: allRowCardMachine(dataFilter!)
],
),
),
),
],
),
],
),
),
const SizedBox(
height: 20,
),
SizedBox(
height: 320,
width: constants.CONTENT_WIDTH,
child: Column(
children: <Widget>[
DataTable(
headingRowColor: MaterialStateColor.resolveWith(
(states) => const Color.fromARGB(255, 115, 188, 248)),
columnSpacing: 0,
columns: columns,
dataRowHeight: 0,
rows: const [
DataRow(cells: [
DataCell(SizedBox(
child: Text(''),
width: 85,
)),
DataCell(SizedBox(
child: Text(''),
width: 113,
)),
DataCell(SizedBox(
child: Text(''),
width: 57,
)),
DataCell(SizedBox(
child: Text(''),
width: 105,
)),
DataCell(SizedBox(
child: Text(''),
width: 65,
)),
DataCell(SizedBox(
child: Text(''),
width: 67,
)),
DataCell(SizedBox(
child: Text(''),
width: 62,
)),
DataCell(SizedBox(
child: Text(''),
width: 101,
)),
DataCell(SizedBox(
child: Text(''),
width: 88,
)),
DataCell(SizedBox(
child: Text(''),
width: 88,
)),
DataCell(SizedBox(
child: Text(''),
width: 90,
)),
DataCell(SizedBox(
child: Text(''),
width: 95,
)),
DataCell(SizedBox(
child: Text(''),
width: 111,
)),
DataCell(SizedBox(
child: Text(''),
width: 98,
)),
])
],
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Container(
color: constants.COLOR_GREY,
child: Table(
border: TableBorder.all(color: Colors.black),
children: [
TableRow(
children: <Widget>[
TableCell(
// verticalAlignment: TableCellVerticalAlignment.top,
child: Container(
height: 260,
color: Colors.white,
child: ListView(
children: [
DataTable(
headingRowHeight: 0,
dataRowMaxHeight: 100,
columnSpacing: 0,
columns: const [
DataColumn(
label: SizedBox(
height: 85,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 113,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 57,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 105,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 65,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 67,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 62,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 101,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 88,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 88,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 90,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 95,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 111,
child: Text(''),
)),
DataColumn(
label: SizedBox(
height: 98,
child: Text(''),
)),
],
rows: getUIRetrieval())
],
),
),
),
],
),
],
),
),
),
],
)),
const SizedBox(
height: 8,
),
SizedBox(
width: constants.CONTENT_WIDTH,
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
CustomButton(
text: 'PDF',
width: 120,
onPressed: () {},
),
const SizedBox(
width: 20,
),
CustomButton(
text: '戻る',
width: 120,
onPressed: () {
mainpageViewModel.setcurrentRoute(routes.RetrievalRoute);
mainpageViewModel.settitleList(['営業モード', '検索']);
},
),
],
),
),
]);
}
}