|
@@ -8,6 +8,8 @@ import 'package:dio/dio.dart'; |
|
@@ -8,6 +8,8 @@ import 'package:dio/dio.dart'; |
|
8
|
import 'package:flutter/material.dart';
|
8
|
import 'package:flutter/material.dart';
|
|
9
|
import 'package:flutter_picker/Picker.dart';
|
9
|
import 'package:flutter_picker/Picker.dart';
|
|
10
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
10
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
|
|
11
|
+import 'package:one_key/models/get_export_info_model.dart';
|
|
|
|
12
|
+import 'package:one_key/models/get_report_field_model.dart';
|
|
11
|
import 'package:one_key/provider/user_model.dart';
|
13
|
import 'package:one_key/provider/user_model.dart';
|
|
12
|
import 'package:one_key/res/colors.dart';
|
14
|
import 'package:one_key/res/colors.dart';
|
|
13
|
import 'package:one_key/widgets/round_button.dart';
|
15
|
import 'package:one_key/widgets/round_button.dart';
|
|
@@ -19,6 +21,7 @@ import 'package:provider/provider.dart'; |
|
@@ -19,6 +21,7 @@ import 'package:provider/provider.dart'; |
|
19
|
|
21
|
|
|
20
|
import '../../../../app.dart';
|
22
|
import '../../../../app.dart';
|
|
21
|
import '../../../../net/dio_util.dart';
|
23
|
import '../../../../net/dio_util.dart';
|
|
|
|
24
|
+import '../../../../provider/customer_provider.dart';
|
|
22
|
import '../../../../utils/dialog_util.dart';
|
25
|
import '../../../../utils/dialog_util.dart';
|
|
23
|
import '../../../../utils/screen_util.dart';
|
26
|
import '../../../../utils/screen_util.dart';
|
|
24
|
import '../../../../utils/utils.dart';
|
27
|
import '../../../../utils/utils.dart';
|
|
@@ -56,238 +59,28 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -56,238 +59,28 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
56
|
// DownloadTaskStatus status;
|
59
|
// DownloadTaskStatus status;
|
|
57
|
int progress;
|
60
|
int progress;
|
|
58
|
|
61
|
|
|
|
|
62
|
+ CustomerProvider customerProvider;
|
|
|
|
63
|
+
|
|
|
|
64
|
+ // List<Map<String, String>> fieldData = {};
|
|
|
|
65
|
+
|
|
59
|
@override
|
66
|
@override
|
|
60
|
void initState() {
|
67
|
void initState() {
|
|
61
|
super.initState();
|
68
|
super.initState();
|
|
62
|
|
69
|
|
|
63
|
- // IsolateNameServer.registerPortWithName(
|
|
|
|
64
|
- // _port.sendPort, 'downloader_send_port');
|
|
|
|
65
|
- // _port.listen((dynamic data) {
|
|
|
|
66
|
- // taskId = data[0];
|
|
|
|
67
|
- // status = DownloadTaskStatus(data[1]);
|
|
|
|
68
|
- // progress = data[2];
|
|
|
|
69
|
- // setState(() {});
|
|
|
|
70
|
- // if (status == DownloadTaskStatus.undefined) {
|
|
|
|
71
|
- // // _requestDownload(task);
|
|
|
|
72
|
- // } else if (status == DownloadTaskStatus.running) {
|
|
|
|
73
|
- // // _pauseDownload(task);
|
|
|
|
74
|
- // // setState(() {});
|
|
|
|
75
|
- // } else if (status == DownloadTaskStatus.paused) {
|
|
|
|
76
|
- // // _resumeDownload(task);
|
|
|
|
77
|
- // // setState(() {});
|
|
|
|
78
|
- // } else if (status == DownloadTaskStatus.complete ||
|
|
|
|
79
|
- // status == DownloadTaskStatus.canceled) {
|
|
|
|
80
|
- // // _delete(task);
|
|
|
|
81
|
-
|
|
|
|
82
|
- // // 显示是否打开的对话框
|
|
|
|
83
|
-
|
|
|
|
84
|
- // DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
85
|
- // title: '提示',
|
|
|
|
86
|
- // content: '文件下载完成,是否打开?',
|
|
|
|
87
|
- // lTitle: '取消',
|
|
|
|
88
|
- // rTitle: '打开', lCallback: () {
|
|
|
|
89
|
- // Navigator.pop(context);
|
|
|
|
90
|
- // }, rCallback: () async {
|
|
|
|
91
|
- // // Navigator.pop(context);
|
|
|
|
92
|
-
|
|
|
|
93
|
- // print(_localPath);
|
|
|
|
94
|
-
|
|
|
|
95
|
- // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
96
|
- // String str = '';
|
|
|
|
97
|
- // tasks.forEach((element) {
|
|
|
|
98
|
- // str = element.savedDir + '/' + element.filename;
|
|
|
|
99
|
- // });
|
|
|
|
100
|
- // print(str);
|
|
|
|
101
|
-
|
|
|
|
102
|
- // if (str != '') {
|
|
|
|
103
|
- // OpenFile.open(str);
|
|
|
|
104
|
- // _delete();
|
|
|
|
105
|
- // }
|
|
|
|
106
|
- // });
|
|
|
|
107
|
- // // showDialog(
|
|
|
|
108
|
- // // // 设置点击 dialog 外部不取消 dialog,默认能够取消
|
|
|
|
109
|
- // // barrierDismissible: false,
|
|
|
|
110
|
- // // context: context,
|
|
|
|
111
|
- // // builder: (context) => AlertDialog(
|
|
|
|
112
|
- // // title: Text('提示'),
|
|
|
|
113
|
- // // // 标题文字样式
|
|
|
|
114
|
- // // content: Text('文件下载完成,是否打开?'),
|
|
|
|
115
|
- // // // 内容文字样式
|
|
|
|
116
|
- // // backgroundColor: MyColours.color_ffffff,
|
|
|
|
117
|
- // // elevation: 8.0,
|
|
|
|
118
|
- // // // 投影的阴影高度
|
|
|
|
119
|
- // // semanticLabel: 'Label',
|
|
|
|
120
|
- // // // 这个用于无障碍下弹出 dialog 的提示
|
|
|
|
121
|
- // // shape: Border.all(),
|
|
|
|
122
|
- // // // dialog 的操作按钮,actions 的个数尽量控制不要过多,否则会溢出 `Overflow`
|
|
|
|
123
|
- // // actions: <Widget>[
|
|
|
|
124
|
- // // // 点击取消按钮
|
|
|
|
125
|
- // // InkWell(
|
|
|
|
126
|
- // // onTap: () => Navigator.pop(context), child: Text('取消')),
|
|
|
|
127
|
- // // // 点击打开按钮
|
|
|
|
128
|
- // // InkWell(
|
|
|
|
129
|
- // // onTap: () async {
|
|
|
|
130
|
- // // Navigator.pop(context);
|
|
|
|
131
|
-
|
|
|
|
132
|
- // // print(_localPath);
|
|
|
|
133
|
-
|
|
|
|
134
|
- // // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
135
|
- // // String str = '';
|
|
|
|
136
|
- // // tasks.forEach((element) {
|
|
|
|
137
|
- // // str = element.savedDir + '/' + element.filename;
|
|
|
|
138
|
- // // });
|
|
|
|
139
|
- // // print(str);
|
|
|
|
140
|
- // // if (str != '') {
|
|
|
|
141
|
- // // OpenFile.open(str);
|
|
|
|
142
|
- // // }
|
|
|
|
143
|
-
|
|
|
|
144
|
- // // // 打开文件
|
|
|
|
145
|
- // // // _openDownloadedFile(taskId).then((success) {
|
|
|
|
146
|
- // // // if (!success) {
|
|
|
|
147
|
- // // // Utils.showToast('Cannot open this file');
|
|
|
|
148
|
- // // // // Scaffold.of(context).showSnackBar(SnackBar(
|
|
|
|
149
|
- // // // // content: Text('Cannot open this file')));
|
|
|
|
150
|
- // // // }
|
|
|
|
151
|
- // // // });
|
|
|
|
152
|
- // // },
|
|
|
|
153
|
- // // child: Text('打开')),
|
|
|
|
154
|
- // // ],
|
|
|
|
155
|
- // // ));
|
|
|
|
156
|
- // } else if (status == DownloadTaskStatus.failed) {
|
|
|
|
157
|
- // // _retryDownload(task);
|
|
|
|
158
|
- // Utils.showToast('下载异常,请稍后重试');
|
|
|
|
159
|
- // }
|
|
|
|
160
|
- // });
|
|
|
|
161
|
-
|
|
|
|
162
|
- // FlutterDownloader.registerCallback(downloadCallback);
|
|
|
|
163
|
-
|
|
|
|
164
|
- // // _bindBackgroundIsolate();
|
|
|
|
165
|
-
|
|
|
|
166
|
- // // FlutterDownloader.registerCallback(downloadCallback, step: 1);
|
|
|
|
167
|
- // _delete();
|
70
|
+ WidgetsBinding.instance.addPostFrameCallback((_) async {
|
|
|
|
71
|
+ _getReportField();
|
|
|
|
72
|
+ });
|
|
168
|
}
|
73
|
}
|
|
169
|
|
74
|
|
|
170
|
- // _preae() async {
|
|
|
|
171
|
- // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
172
|
-
|
|
|
|
173
|
- // if (tasks == null) {
|
|
|
|
174
|
- // print('No tasks were retrieved from the database.');
|
|
|
|
175
|
- // return;
|
|
|
|
176
|
- // } else {
|
|
|
|
177
|
- // tasks.forEach((element) {
|
|
|
|
178
|
- // FlutterDownloader.remove(
|
|
|
|
179
|
- // taskId: element.taskId, shouldDeleteContent: false);
|
|
|
|
180
|
- // });
|
|
|
|
181
|
- // }
|
|
|
|
182
|
- // }
|
|
|
|
183
|
-
|
|
|
|
184
|
- @override
|
|
|
|
185
|
- void dispose() {
|
|
|
|
186
|
- // _unbindBackgroundIsolate();
|
|
|
|
187
|
- super.dispose();
|
75
|
+ _getReportField() async {
|
|
|
|
76
|
+ bool success = await customerProvider.getReportField(context);
|
|
|
|
77
|
+ // if (success) {
|
|
|
|
78
|
+ // customerProvider.reportFieldModelData.forEach((element) {
|
|
|
|
79
|
+ // fieldData[element.code] = element.name;
|
|
|
|
80
|
+ // });
|
|
|
|
81
|
+ // }
|
|
188
|
}
|
82
|
}
|
|
189
|
|
83
|
|
|
190
|
- // @pragma('vm:entry-point')
|
|
|
|
191
|
- // static void downloadCallback(
|
|
|
|
192
|
- // String id,
|
|
|
|
193
|
- // int status,
|
|
|
|
194
|
- // int progress,
|
|
|
|
195
|
- // ) {
|
|
|
|
196
|
- // final SendPort send =
|
|
|
|
197
|
- // IsolateNameServer.lookupPortByName('downloader_send_port');
|
|
|
|
198
|
- // send.send([id, status, progress]);
|
|
|
|
199
|
- // }
|
|
|
|
200
|
-
|
|
|
|
201
|
- // // 根据taskId打开下载文件
|
|
|
|
202
|
- // Future<bool> _openDownloadedFile(taskId) {
|
|
|
|
203
|
- // return FlutterDownloader.open(taskId: taskId);
|
|
|
|
204
|
- // }
|
|
|
|
205
|
-
|
|
|
|
206
|
- // void _bindBackgroundIsolate() {
|
|
|
|
207
|
- // final isSuccess = IsolateNameServer.registerPortWithName(
|
|
|
|
208
|
- // _port.sendPort,
|
|
|
|
209
|
- // 'downloader_send_port',
|
|
|
|
210
|
- // );
|
|
|
|
211
|
- // if (!isSuccess) {
|
|
|
|
212
|
- // _unbindBackgroundIsolate();
|
|
|
|
213
|
- // _bindBackgroundIsolate();
|
|
|
|
214
|
- // return;
|
|
|
|
215
|
- // }
|
|
|
|
216
|
- // _port.listen((dynamic data) {
|
|
|
|
217
|
- // taskId = (data as List<dynamic>)[0] as String;
|
|
|
|
218
|
- // status = DownloadTaskStatus(data[1] as int);
|
|
|
|
219
|
- // progressT = data[2] as int;
|
|
|
|
220
|
-
|
|
|
|
221
|
- // print(
|
|
|
|
222
|
- // 'Callback on UI isolate: '
|
|
|
|
223
|
- // 'task ($taskId) is in status ($status) and process ($progressT)',
|
|
|
|
224
|
- // );
|
|
|
|
225
|
- // if (status == DownloadTaskStatus.undefined) {
|
|
|
|
226
|
- // // _requestDownload(task);
|
|
|
|
227
|
- // } else if (status == DownloadTaskStatus.running) {
|
|
|
|
228
|
- // // _pauseDownload(task);
|
|
|
|
229
|
- // setState(() {});
|
|
|
|
230
|
- // } else if (status == DownloadTaskStatus.paused) {
|
|
|
|
231
|
- // // _resumeDownload(task);
|
|
|
|
232
|
- // setState(() {});
|
|
|
|
233
|
- // } else if (status == DownloadTaskStatus.complete ||
|
|
|
|
234
|
- // status == DownloadTaskStatus.canceled) {
|
|
|
|
235
|
- // // _delete(task);
|
|
|
|
236
|
- // // 显示是否打开的对话框
|
|
|
|
237
|
- // showDialog(
|
|
|
|
238
|
- // // 设置点击 dialog 外部不取消 dialog,默认能够取消
|
|
|
|
239
|
- // barrierDismissible: false,
|
|
|
|
240
|
- // context: context,
|
|
|
|
241
|
- // builder: (context) => AlertDialog(
|
|
|
|
242
|
- // title: Text('提示'),
|
|
|
|
243
|
- // // 标题文字样式
|
|
|
|
244
|
- // content: Text('文件下载完成,是否打开?'),
|
|
|
|
245
|
- // // 内容文字样式
|
|
|
|
246
|
- // backgroundColor: MyColours.color_ffffff,
|
|
|
|
247
|
- // elevation: 8.0,
|
|
|
|
248
|
- // // 投影的阴影高度
|
|
|
|
249
|
- // semanticLabel: 'Label',
|
|
|
|
250
|
- // // 这个用于无障碍下弹出 dialog 的提示
|
|
|
|
251
|
- // shape: Border.all(),
|
|
|
|
252
|
- // // dialog 的操作按钮,actions 的个数尽量控制不要过多,否则会溢出 `Overflow`
|
|
|
|
253
|
- // actions: <Widget>[
|
|
|
|
254
|
- // // 点击取消按钮
|
|
|
|
255
|
- // InkWell(
|
|
|
|
256
|
- // onTap: () => Navigator.pop(context), child: Text('取消')),
|
|
|
|
257
|
- // // 点击打开按钮
|
|
|
|
258
|
- // InkWell(
|
|
|
|
259
|
- // onTap: () {
|
|
|
|
260
|
- // Navigator.pop(context);
|
|
|
|
261
|
- // // 打开文件
|
|
|
|
262
|
- // _openDownloadedFile(taskId).then((success) {
|
|
|
|
263
|
- // if (!success) {
|
|
|
|
264
|
- // Utils.showToast('Cannot open this file');
|
|
|
|
265
|
- // // Scaffold.of(context).showSnackBar(SnackBar(
|
|
|
|
266
|
- // // content: Text('Cannot open this file')));
|
|
|
|
267
|
- // }
|
|
|
|
268
|
- // });
|
|
|
|
269
|
- // },
|
|
|
|
270
|
- // child: Text('打开')),
|
|
|
|
271
|
- // ],
|
|
|
|
272
|
- // ));
|
|
|
|
273
|
- // } else if (status == DownloadTaskStatus.failed) {
|
|
|
|
274
|
- // // _retryDownload(task);
|
|
|
|
275
|
- // Utils.showToast('下载异常,请稍后重试');
|
|
|
|
276
|
- // }
|
|
|
|
277
|
- // });
|
|
|
|
278
|
- // }
|
|
|
|
279
|
- // Future<void> _delete() async {
|
|
|
|
280
|
- // final task = await FlutterDownloader.loadTasks();
|
|
|
|
281
|
- // if (task != null) {
|
|
|
|
282
|
- // task.forEach((element) {
|
|
|
|
283
|
- // FlutterDownloader.remove(
|
|
|
|
284
|
- // taskId: element.taskId,
|
|
|
|
285
|
- // shouldDeleteContent: true,
|
|
|
|
286
|
- // );
|
|
|
|
287
|
- // });
|
|
|
|
288
|
- // }
|
|
|
|
289
|
- // }
|
|
|
|
290
|
-
|
|
|
|
291
|
Future<void> _prepareSaveDir() async {
|
84
|
Future<void> _prepareSaveDir() async {
|
|
292
|
_localPath = (await _getSavedDir());
|
85
|
_localPath = (await _getSavedDir());
|
|
293
|
final savedDir = Directory(_localPath);
|
86
|
final savedDir = Directory(_localPath);
|
|
@@ -356,10 +149,6 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -356,10 +149,6 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
356
|
throw StateError('unknown platform');
|
149
|
throw StateError('unknown platform');
|
|
357
|
}
|
150
|
}
|
|
358
|
|
151
|
|
|
359
|
- // void _unbindBackgroundIsolate() {
|
|
|
|
360
|
- // IsolateNameServer.removePortNameMapping('downloader_send_port');
|
|
|
|
361
|
- // }
|
|
|
|
362
|
-
|
|
|
|
363
|
///时间选择
|
152
|
///时间选择
|
|
364
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
153
|
Widget _select(String title, String hintText, GestureTapCallback onTap) {
|
|
365
|
return InkWell(
|
154
|
return InkWell(
|
|
@@ -404,17 +193,26 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -404,17 +193,26 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
404
|
|
193
|
|
|
405
|
List<Widget> itemWidget() {
|
194
|
List<Widget> itemWidget() {
|
|
406
|
List<Widget> data = [];
|
195
|
List<Widget> data = [];
|
|
407
|
- for (var i = 0; i < 10; i++) {
|
196
|
+ for (var i = 0; i < customerProvider.reportFieldModelData.length; i++) {
|
|
|
|
197
|
+ GetReportFieldSunModel getReportFieldSunModel =
|
|
|
|
198
|
+ customerProvider.reportFieldModelData[i];
|
|
408
|
data.add(
|
199
|
data.add(
|
|
409
|
GestureDetector(
|
200
|
GestureDetector(
|
|
410
|
- onTap: () {},
|
201
|
+ onTap: () {
|
|
|
|
202
|
+ setState(() {
|
|
|
|
203
|
+ getReportFieldSunModel.select = !getReportFieldSunModel.select;
|
|
|
|
204
|
+ });
|
|
|
|
205
|
+ },
|
|
411
|
child: Container(
|
206
|
child: Container(
|
|
412
|
height: w(34),
|
207
|
height: w(34),
|
|
413
|
padding:
|
208
|
padding:
|
|
414
|
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
|
209
|
EdgeInsets.symmetric(horizontal: ScreenUtil().setWidth(20)),
|
|
415
|
- decoration: false
|
210
|
+ decoration: getReportFieldSunModel.select
|
|
416
|
? BoxDecoration(
|
211
|
? BoxDecoration(
|
|
417
|
color: MyColours.color_438E93,
|
212
|
color: MyColours.color_438E93,
|
|
|
|
213
|
+ border: Border.all(
|
|
|
|
214
|
+ color: MyColours.color_438E93,
|
|
|
|
215
|
+ width: ScreenUtil().setWidth(2)),
|
|
418
|
borderRadius:
|
216
|
borderRadius:
|
|
419
|
BorderRadius.circular(ScreenUtil().setWidth(10)))
|
217
|
BorderRadius.circular(ScreenUtil().setWidth(10)))
|
|
420
|
: BoxDecoration(
|
218
|
: BoxDecoration(
|
|
@@ -427,11 +225,12 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -427,11 +225,12 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
427
|
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
225
|
child: Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
|
|
428
|
Flexible(
|
226
|
Flexible(
|
|
429
|
child: Text(
|
227
|
child: Text(
|
|
430
|
- '下单时间',
|
228
|
+ getReportFieldSunModel.name,
|
|
431
|
style: TextStyle(
|
229
|
style: TextStyle(
|
|
432
|
fontSize: ScreenUtil().setSp(28),
|
230
|
fontSize: ScreenUtil().setSp(28),
|
|
433
|
- color:
|
|
|
|
434
|
- false ? MyColours.color_ffffff : MyColours.color_515151,
|
231
|
+ color: getReportFieldSunModel.select
|
|
|
|
232
|
+ ? MyColours.color_ffffff
|
|
|
|
233
|
+ : MyColours.color_515151,
|
|
435
|
),
|
234
|
),
|
|
436
|
overflow: TextOverflow.ellipsis,
|
235
|
overflow: TextOverflow.ellipsis,
|
|
437
|
)),
|
236
|
)),
|
|
@@ -449,23 +248,70 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -449,23 +248,70 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
449
|
Stopwatch stopwatch = new Stopwatch()..start();
|
248
|
Stopwatch stopwatch = new Stopwatch()..start();
|
|
450
|
|
249
|
|
|
451
|
excelUtil.Excel excel = excelUtil.Excel.createExcel();
|
250
|
excelUtil.Excel excel = excelUtil.Excel.createExcel();
|
|
|
|
251
|
+
|
|
|
|
252
|
+ excelUtil.Sheet sh2 = excel['Sheet2'];
|
|
|
|
253
|
+
|
|
|
|
254
|
+ //表头
|
|
|
|
255
|
+
|
|
|
|
256
|
+ sh2
|
|
|
|
257
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: 0))
|
|
|
|
258
|
+ .value = '订单数';
|
|
|
|
259
|
+ sh2
|
|
|
|
260
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: 1))
|
|
|
|
261
|
+ .value = '客户经理';
|
|
|
|
262
|
+
|
|
|
|
263
|
+ for (int row = 0;
|
|
|
|
264
|
+ row < customerProvider.exportInfoSunModel.count.length;
|
|
|
|
265
|
+ row++) {
|
|
|
|
266
|
+ for (int column = 0; column < 2; column++) {
|
|
|
|
267
|
+ Count count = customerProvider.exportInfoSunModel.count[row];
|
|
|
|
268
|
+ if (column == 0) {
|
|
|
|
269
|
+ sh2
|
|
|
|
270
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(
|
|
|
|
271
|
+ rowIndex: row + 1, columnIndex: column))
|
|
|
|
272
|
+ .value = count.total;
|
|
|
|
273
|
+ } else {
|
|
|
|
274
|
+ sh2
|
|
|
|
275
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(
|
|
|
|
276
|
+ rowIndex: row + 1, columnIndex: column))
|
|
|
|
277
|
+ .value = count.nickName ?? '';
|
|
|
|
278
|
+ }
|
|
|
|
279
|
+ }
|
|
|
|
280
|
+ }
|
|
|
|
281
|
+
|
|
|
|
282
|
+ // excel.delete('Sheet1');
|
|
452
|
excelUtil.Sheet sh = excel['Sheet1'];
|
283
|
excelUtil.Sheet sh = excel['Sheet1'];
|
|
|
|
284
|
+
|
|
453
|
//表头
|
285
|
//表头
|
|
454
|
- for (int i = 0; i < 8; i++) {
|
286
|
+ for (int i = 0; i < customerProvider.reportFieldModelData.length; i++) {
|
|
|
|
287
|
+ GetReportFieldSunModel getReportFieldSunModel =
|
|
|
|
288
|
+ customerProvider.reportFieldModelData[i];
|
|
455
|
sh
|
289
|
sh
|
|
456
|
.cell(
|
290
|
.cell(
|
|
457
|
excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i))
|
291
|
excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i))
|
|
458
|
- .value = 'Column $i';
|
292
|
+ .value = getReportFieldSunModel.name;
|
|
459
|
//sh.cell(CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i)).cellStyle =CellStyle(bold: true);
|
293
|
//sh.cell(CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i)).cellStyle =CellStyle(bold: true);
|
|
460
|
}
|
294
|
}
|
|
461
|
- for (int row = 1; row < 9; row++) {
|
|
|
|
462
|
- for (int column = 0; column < 8; column++) {
|
295
|
+ for (int row = 0;
|
|
|
|
296
|
+ row < customerProvider.exportInfoSunModel.list.length;
|
|
|
|
297
|
+ row++) {
|
|
|
|
298
|
+ for (int column = 0;
|
|
|
|
299
|
+ column < customerProvider.reportFieldModelData.length;
|
|
|
|
300
|
+ column++) {
|
|
|
|
301
|
+ dynamic excelData = customerProvider.exportInfoSunModel.excelData[row];
|
|
|
|
302
|
+
|
|
463
|
sh
|
303
|
sh
|
|
464
|
- .cell(excelUtil.CellIndex.indexByColumnRow(
|
|
|
|
465
|
- rowIndex: row, columnIndex: column))
|
|
|
|
466
|
- .value = '$row$column value';
|
304
|
+ .cell(excelUtil.CellIndex.indexByColumnRow(
|
|
|
|
305
|
+ rowIndex: row + 1, columnIndex: column))
|
|
|
|
306
|
+ .value =
|
|
|
|
307
|
+ excelData[customerProvider.reportFieldModelData[column].code];
|
|
467
|
}
|
308
|
}
|
|
468
|
}
|
309
|
}
|
|
|
|
310
|
+ // var sheet1rtl = excel['Sheet1'].isRTL;
|
|
|
|
311
|
+ // excel['Sheet1'].isRTL = true;
|
|
|
|
312
|
+ excel.rename('Sheet1', '订单统计列表');
|
|
|
|
313
|
+ excel.rename('Sheet2', '排行榜列表');
|
|
|
|
314
|
+
|
|
469
|
print('Generating executed in ${stopwatch.elapsed}');
|
315
|
print('Generating executed in ${stopwatch.elapsed}');
|
|
470
|
stopwatch.reset();
|
316
|
stopwatch.reset();
|
|
471
|
var fileBytes = excel.encode();
|
317
|
var fileBytes = excel.encode();
|
|
@@ -476,12 +322,13 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -476,12 +322,13 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
476
|
Provider.of<UserModel>(context, listen: false).user.sellername;
|
322
|
Provider.of<UserModel>(context, listen: false).user.sellername;
|
|
477
|
String starttime = fromDate.replaceAll('-', '');
|
323
|
String starttime = fromDate.replaceAll('-', '');
|
|
478
|
String endtime = endDate.replaceAll('-', '');
|
324
|
String endtime = endDate.replaceAll('-', '');
|
|
|
|
325
|
+ String fileName = "/${sellername}${starttime}至${endtime}.xlsx";
|
|
|
|
326
|
+ String filePath = _localPath + fileName;
|
|
479
|
if (fileBytes != null) {
|
327
|
if (fileBytes != null) {
|
|
480
|
- File file =
|
|
|
|
481
|
- File(_localPath + "/${sellername}${starttime}至${endtime}预订.xlsx")
|
|
|
|
482
|
- ..createSync(recursive: true)
|
|
|
|
483
|
- ..writeAsBytesSync(fileBytes);
|
|
|
|
484
|
- file.copy('/storage/emulated/0/Download/dongle.xlsx');
|
328
|
+ File file = File(filePath)
|
|
|
|
329
|
+ ..createSync(recursive: true)
|
|
|
|
330
|
+ ..writeAsBytesSync(fileBytes);
|
|
|
|
331
|
+ file.copy('/storage/emulated/0/Download${fileName}');
|
|
485
|
Loading.hideLoading(context);
|
332
|
Loading.hideLoading(context);
|
|
486
|
DialogUtil.cupertinoAlertDialog(context,
|
333
|
DialogUtil.cupertinoAlertDialog(context,
|
|
487
|
title: '提示',
|
334
|
title: '提示',
|
|
@@ -506,8 +353,7 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -506,8 +353,7 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
506
|
// print(savePath);
|
353
|
// print(savePath);
|
|
507
|
// progress = null;
|
354
|
// progress = null;
|
|
508
|
// setState(() {});
|
355
|
// setState(() {});
|
|
509
|
- OpenFile.open(
|
|
|
|
510
|
- _localPath + "/${sellername}${starttime}至${endtime}预订.xlsx");
|
356
|
+ OpenFile.open(filePath);
|
|
511
|
// _delete();
|
357
|
// _delete();
|
|
512
|
// }
|
358
|
// }
|
|
513
|
});
|
359
|
});
|
|
@@ -524,6 +370,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -524,6 +370,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
524
|
|
370
|
|
|
525
|
@override
|
371
|
@override
|
|
526
|
Widget build(BuildContext context) {
|
372
|
Widget build(BuildContext context) {
|
|
|
|
373
|
+//
|
|
|
|
374
|
+ // reportFieldModel
|
|
|
|
375
|
+ customerProvider = Provider.of<CustomerProvider>(context, listen: true);
|
|
527
|
return Scaffold(
|
376
|
return Scaffold(
|
|
528
|
key: scaffoldKey,
|
377
|
key: scaffoldKey,
|
|
529
|
backgroundColor: MyColours.color_f3f3f3,
|
378
|
backgroundColor: MyColours.color_f3f3f3,
|
|
@@ -674,82 +523,71 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
@@ -674,82 +523,71 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { |
|
674
|
Utils.showToast('请选择结束日期');
|
523
|
Utils.showToast('请选择结束日期');
|
|
675
|
return;
|
524
|
return;
|
|
676
|
}
|
525
|
}
|
|
|
|
526
|
+ if (DateUtil.getDateTime(endDate)
|
|
|
|
527
|
+ .compareTo(DateUtil.getDateTime(fromDate)) <
|
|
|
|
528
|
+ 0) {
|
|
|
|
529
|
+ Utils.showToast('结束日期不能早于开始日期!');
|
|
|
|
530
|
+ return;
|
|
|
|
531
|
+ }
|
|
|
|
532
|
+ // }
|
|
677
|
|
533
|
|
|
678
|
- bool _permissionReady = await _checkPermission();
|
|
|
|
679
|
- if (_permissionReady) {
|
|
|
|
680
|
- await _prepareSaveDir();
|
|
|
|
681
|
- _download();
|
|
|
|
682
|
- } else {
|
|
|
|
683
|
- String title = Platform.isAndroid ? '存储' : '相册';
|
|
|
|
684
|
-
|
|
|
|
685
|
- //用户选择不在弹出权限提示框
|
|
|
|
686
|
- print('never');
|
|
|
|
687
|
- // Navigator.pop(context);
|
|
|
|
688
|
- DialogUtil.openAlertDialog(context, '未获得${title}权限',
|
|
|
|
689
|
- "请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, onTap: () {
|
|
|
|
690
|
- openSetting();
|
|
|
|
691
|
- Navigator.pop(context, '');
|
|
|
|
692
|
- });
|
534
|
+ bool temp = customerProvider.reportFieldModelData
|
|
|
|
535
|
+ .any((element) => element.select);
|
|
|
|
536
|
+ if (!temp) {
|
|
|
|
537
|
+ Utils.showToast('请选择导出字段');
|
|
|
|
538
|
+ return;
|
|
693
|
}
|
539
|
}
|
|
694
|
|
540
|
|
|
695
|
- // _delete();
|
|
|
|
696
|
- // String savePath = _localPath + "/fff.pdf";
|
|
|
|
697
|
- // Directory directory = new Directory(savePath);
|
|
|
|
698
|
- // if (directory.existsSync()) {
|
|
|
|
699
|
- // //删除历史
|
|
|
|
700
|
- // final List<FileSystemEntity> files = directory.listSync();
|
|
|
|
701
|
- // for (FileSystemEntity file in files) {
|
|
|
|
702
|
- // file.deleteSync();
|
|
|
|
703
|
- // }
|
|
|
|
704
|
- // }
|
541
|
+ String from = fromDate + ' 00:00:00';
|
|
|
|
542
|
+ String end = endDate + ' 23:59:59';
|
|
|
|
543
|
+ String stime = fromDate == '点击设置开始日期'
|
|
|
|
544
|
+ ? ""
|
|
|
|
545
|
+ : '${(DateUtil.getDateMsByTimeStr(from) / 1000).floor()}';
|
|
|
|
546
|
+ String etime = endDate == '点击设置结束日期'
|
|
|
|
547
|
+ ? ''
|
|
|
|
548
|
+ : '${(DateUtil.getDateMsByTimeStr(end) / 1000).floor()}';
|
|
|
|
549
|
+
|
|
|
|
550
|
+ String fields = '';
|
|
|
|
551
|
+ customerProvider.reportFieldModelData.forEach((element) {
|
|
|
|
552
|
+ if (element.select) {
|
|
|
|
553
|
+ fields += element.code + ',';
|
|
|
|
554
|
+ }
|
|
|
|
555
|
+ });
|
|
|
|
556
|
+ if (fields.endsWith(',')) {
|
|
|
|
557
|
+ fields = fields.substring(0, fields.length - 1);
|
|
|
|
558
|
+ }
|
|
705
|
|
559
|
|
|
706
|
- // try {
|
|
|
|
707
|
- // Response response = await DioUtil().download(
|
|
|
|
708
|
- // 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
|
|
|
|
709
|
- // savePath, onProgress: (received, total) {
|
|
|
|
710
|
- // if (progress != 100) {
|
|
|
|
711
|
- // progress = ((received / total) * 100).round();
|
|
|
|
712
|
-
|
|
|
|
713
|
- // setState(() {});
|
|
|
|
714
|
- // }
|
|
|
|
715
|
- // if (received == total) {
|
|
|
|
716
|
- // //下载完成
|
|
|
|
717
|
- // print('xaizaiwancheng');
|
|
|
|
718
|
-
|
|
|
|
719
|
- // DialogUtil.cupertinoAlertDialog(context,
|
|
|
|
720
|
- // title: '提示',
|
|
|
|
721
|
- // content: '文件下载完成,是否打开?',
|
|
|
|
722
|
- // lTitle: '取消',
|
|
|
|
723
|
- // rTitle: '打开', lCallback: () {
|
|
|
|
724
|
- // progress = null;
|
|
|
|
725
|
- // setState(() {});
|
|
|
|
726
|
- // }, rCallback: () async {
|
|
|
|
727
|
- // // Navigator.pop(context);
|
|
|
|
728
|
-
|
|
|
|
729
|
- // // print(_localPath);
|
|
|
|
730
|
-
|
|
|
|
731
|
- // // final tasks = await FlutterDownloader.loadTasks();
|
|
|
|
732
|
- // // String str = '';
|
|
|
|
733
|
- // // tasks.forEach((element) {
|
|
|
|
734
|
- // // str = element.savedDir + '/' + element.filename;
|
|
|
|
735
|
- // // });
|
|
|
|
736
|
- // // print(str);
|
|
|
|
737
|
-
|
|
|
|
738
|
- // // if (str != '') {
|
|
|
|
739
|
- // print(savePath);
|
|
|
|
740
|
- // progress = null;
|
|
|
|
741
|
- // setState(() {});
|
|
|
|
742
|
- // OpenFile.open(savePath);
|
|
|
|
743
|
- // // _delete();
|
|
|
|
744
|
- // // }
|
|
|
|
745
|
- // });
|
|
|
|
746
|
- // }
|
|
|
|
747
|
- // });
|
|
|
|
748
|
- // print(response);
|
|
|
|
749
|
- // } catch (e) {
|
|
|
|
750
|
- // print(e);
|
|
|
|
751
|
- // Utils.showToast('下载异常,请稍后重试');
|
|
|
|
752
|
- // }
|
560
|
+ Map<String, String> pramas = {
|
|
|
|
561
|
+ 'sid': Provider.of<UserModel>(context, listen: false)
|
|
|
|
562
|
+ .user
|
|
|
|
563
|
+ .sellerid,
|
|
|
|
564
|
+ 'time': timeType == '到店时间' ? 'ddate' : 'cdate',
|
|
|
|
565
|
+ 'rdate': stime,
|
|
|
|
566
|
+ 'edate': etime,
|
|
|
|
567
|
+ 'fields': fields
|
|
|
|
568
|
+ };
|
|
|
|
569
|
+ bool success =
|
|
|
|
570
|
+ await customerProvider.getExportInfo(context, pramas);
|
|
|
|
571
|
+ if (success) {
|
|
|
|
572
|
+ //成功
|
|
|
|
573
|
+
|
|
|
|
574
|
+ bool _permissionReady = await _checkPermission();
|
|
|
|
575
|
+ if (_permissionReady) {
|
|
|
|
576
|
+ await _prepareSaveDir();
|
|
|
|
577
|
+ _download();
|
|
|
|
578
|
+ } else {
|
|
|
|
579
|
+ String title = Platform.isAndroid ? '存储' : '相册';
|
|
|
|
580
|
+
|
|
|
|
581
|
+ //用户选择不在弹出权限提示框
|
|
|
|
582
|
+ print('never');
|
|
|
|
583
|
+ // Navigator.pop(context);
|
|
|
|
584
|
+ DialogUtil.openAlertDialog(context, '未获得${title}权限',
|
|
|
|
585
|
+ "请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, onTap: () {
|
|
|
|
586
|
+ openSetting();
|
|
|
|
587
|
+ Navigator.pop(context, '');
|
|
|
|
588
|
+ });
|
|
|
|
589
|
+ }
|
|
|
|
590
|
+ }
|
|
753
|
},
|
591
|
},
|
|
754
|
)
|
592
|
)
|
|
755
|
],
|
593
|
],
|