Commit f376c56163ca6141c23acf8c32931107da1f9ff0

Authored by wdn127929
1 parent a924ed54

预订定金指输入小数保留两位&&其他角色展示备、连、回

@@ -111,6 +111,8 @@ PODS: @@ -111,6 +111,8 @@ PODS:
111 - Mantle/extobjc (= 2.2.0) 111 - Mantle/extobjc (= 2.2.0)
112 - Mantle/extobjc (2.2.0) 112 - Mantle/extobjc (2.2.0)
113 - MTBBarcodeScanner (5.0.11) 113 - MTBBarcodeScanner (5.0.11)
  114 + - open_file (0.0.1):
  115 + - Flutter
114 - OrderedSet (5.0.0) 116 - OrderedSet (5.0.0)
115 - package_info (0.0.1): 117 - package_info (0.0.1):
116 - Flutter 118 - Flutter
@@ -191,6 +193,7 @@ DEPENDENCIES: @@ -191,6 +193,7 @@ DEPENDENCIES:
191 - image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`) 193 - image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
192 - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`) 194 - image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
193 - install_plugin (from `.symlinks/plugins/install_plugin/ios`) 195 - install_plugin (from `.symlinks/plugins/install_plugin/ios`)
  196 + - open_file (from `.symlinks/plugins/open_file/ios`)
194 - package_info (from `.symlinks/plugins/package_info/ios`) 197 - package_info (from `.symlinks/plugins/package_info/ios`)
195 - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`) 198 - path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
196 - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) 199 - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
@@ -290,6 +293,8 @@ EXTERNAL SOURCES: @@ -290,6 +293,8 @@ EXTERNAL SOURCES:
290 :path: ".symlinks/plugins/image_picker_ios/ios" 293 :path: ".symlinks/plugins/image_picker_ios/ios"
291 install_plugin: 294 install_plugin:
292 :path: ".symlinks/plugins/install_plugin/ios" 295 :path: ".symlinks/plugins/install_plugin/ios"
  296 + open_file:
  297 + :path: ".symlinks/plugins/open_file/ios"
293 package_info: 298 package_info:
294 :path: ".symlinks/plugins/package_info/ios" 299 :path: ".symlinks/plugins/package_info/ios"
295 path_provider_foundation: 300 path_provider_foundation:
@@ -362,6 +367,7 @@ SPEC CHECKSUMS: @@ -362,6 +367,7 @@ SPEC CHECKSUMS:
362 libwebp: 33dc822fbbf4503668d09f7885bbfedc76c45e96 367 libwebp: 33dc822fbbf4503668d09f7885bbfedc76c45e96
363 Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d 368 Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
364 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb 369 MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
  370 + open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
365 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c 371 OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
366 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62 372 package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
367 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943 373 path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
@@ -355,6 +355,7 @@ @@ -355,6 +355,7 @@
355 "${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework", 355 "${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework",
356 "${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework", 356 "${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework",
357 "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework", 357 "${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework",
  358 + "${BUILT_PRODUCTS_DIR}/open_file/open_file.framework",
358 "${BUILT_PRODUCTS_DIR}/package_info/package_info.framework", 359 "${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
359 "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework", 360 "${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework",
360 "${BUILT_PRODUCTS_DIR}/photo_manager/photo_manager.framework", 361 "${BUILT_PRODUCTS_DIR}/photo_manager/photo_manager.framework",
@@ -402,6 +403,7 @@ @@ -402,6 +403,7 @@
402 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework", 403 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework",
403 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework", 404 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework",
404 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework", 405 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
  406 + "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/open_file.framework",
405 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework", 407 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
406 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework", 408 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework",
407 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/photo_manager.framework", 409 "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/photo_manager.framework",
@@ -548,7 +550,10 @@ @@ -548,7 +550,10 @@
548 ); 550 );
549 INFOPLIST_FILE = Runner/Info.plist; 551 INFOPLIST_FILE = Runner/Info.plist;
550 IPHONEOS_DEPLOYMENT_TARGET = 12.0; 552 IPHONEOS_DEPLOYMENT_TARGET = 12.0;
551 - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 553 + LD_RUNPATH_SEARCH_PATHS = (
  554 + "$(inherited)",
  555 + "@executable_path/Frameworks",
  556 + );
552 LIBRARY_SEARCH_PATHS = ( 557 LIBRARY_SEARCH_PATHS = (
553 "$(inherited)", 558 "$(inherited)",
554 "$(PROJECT_DIR)/Flutter", 559 "$(PROJECT_DIR)/Flutter",
@@ -694,7 +699,10 @@ @@ -694,7 +699,10 @@
694 ); 699 );
695 INFOPLIST_FILE = Runner/Info.plist; 700 INFOPLIST_FILE = Runner/Info.plist;
696 IPHONEOS_DEPLOYMENT_TARGET = 12.0; 701 IPHONEOS_DEPLOYMENT_TARGET = 12.0;
697 - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 702 + LD_RUNPATH_SEARCH_PATHS = (
  703 + "$(inherited)",
  704 + "@executable_path/Frameworks",
  705 + );
698 LIBRARY_SEARCH_PATHS = ( 706 LIBRARY_SEARCH_PATHS = (
699 "$(inherited)", 707 "$(inherited)",
700 "$(PROJECT_DIR)/Flutter", 708 "$(PROJECT_DIR)/Flutter",
@@ -730,7 +738,10 @@ @@ -730,7 +738,10 @@
730 ); 738 );
731 INFOPLIST_FILE = Runner/Info.plist; 739 INFOPLIST_FILE = Runner/Info.plist;
732 IPHONEOS_DEPLOYMENT_TARGET = 12.0; 740 IPHONEOS_DEPLOYMENT_TARGET = 12.0;
733 - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 741 + LD_RUNPATH_SEARCH_PATHS = (
  742 + "$(inherited)",
  743 + "@executable_path/Frameworks",
  744 + );
734 LIBRARY_SEARCH_PATHS = ( 745 LIBRARY_SEARCH_PATHS = (
735 "$(inherited)", 746 "$(inherited)",
736 "$(PROJECT_DIR)/Flutter", 747 "$(PROJECT_DIR)/Flutter",
1 import 'package:common_utils/common_utils.dart'; 1 import 'package:common_utils/common_utils.dart';
2 import 'package:flutter/gestures.dart'; 2 import 'package:flutter/gestures.dart';
3 import 'package:flutter/material.dart'; 3 import 'package:flutter/material.dart';
  4 +import 'package:flutter/services.dart';
4 import 'package:flutter_picker/Picker.dart'; 5 import 'package:flutter_picker/Picker.dart';
5 import 'package:flutter_screenutil/flutter_screenutil.dart'; 6 import 'package:flutter_screenutil/flutter_screenutil.dart';
6 import 'package:one_key/models/filter_btn_model.dart'; 7 import 'package:one_key/models/filter_btn_model.dart';
@@ -16,6 +17,8 @@ import '../../provider/feast_model.dart'; @@ -16,6 +17,8 @@ import '../../provider/feast_model.dart';
16 import '../../provider/notebook_detail_model.dart'; 17 import '../../provider/notebook_detail_model.dart';
17 import '../../provider/user_model.dart'; 18 import '../../provider/user_model.dart';
18 import '../../res/colors.dart'; 19 import '../../res/colors.dart';
  20 +import '../../utils/MyNumberTextInputFormatter.dart';
  21 +import '../../utils/NumLengthInputFormatter.dart';
19 import '../../utils/dialog_util.dart'; 22 import '../../utils/dialog_util.dart';
20 import '../../utils/event_bus.dart'; 23 import '../../utils/event_bus.dart';
21 import '../../utils/screen_util.dart'; 24 import '../../utils/screen_util.dart';
@@ -231,7 +234,14 @@ class _BookDepositPageState extends State<BookDepositPage> { @@ -231,7 +234,14 @@ class _BookDepositPageState extends State<BookDepositPage> {
231 // textAlign: TextAlign.right, 234 // textAlign: TextAlign.right,
232 // textAlignVertical: TextAlignVertical.bottom, 235 // textAlignVertical: TextAlignVertical.bottom,
233 maxLines: 1, 236 maxLines: 1,
234 - inputFormatters: [], 237 +
  238 + inputFormatters: title == '金额'
  239 + ? [
  240 + FilteringTextInputFormatter(RegExp("[0-9.]"),
  241 + allow: true),
  242 + MyNumberTextInputFormatter(digit: 2),
  243 + ]
  244 + : [],
235 245
236 // //光标颜色 246 // //光标颜色
237 // cursorColor: 247 // cursorColor:
@@ -8,21 +8,27 @@ import 'package:dio/dio.dart'; @@ -8,21 +8,27 @@ 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/provider/user_model.dart';
11 import 'package:one_key/res/colors.dart'; 12 import 'package:one_key/res/colors.dart';
12 import 'package:one_key/widgets/round_button.dart'; 13 import 'package:one_key/widgets/round_button.dart';
13 import 'package:one_key/widgets/system_app_bar.dart'; 14 import 'package:one_key/widgets/system_app_bar.dart';
14 import 'package:one_key/widgets/v_empty_view.dart'; 15 import 'package:one_key/widgets/v_empty_view.dart';
15 import 'package:path_provider/path_provider.dart'; 16 import 'package:path_provider/path_provider.dart';
16 import 'package:permission_handler/permission_handler.dart'; 17 import 'package:permission_handler/permission_handler.dart';
  18 +import 'package:provider/provider.dart';
17 19
  20 +import '../../../../app.dart';
18 import '../../../../net/dio_util.dart'; 21 import '../../../../net/dio_util.dart';
19 import '../../../../utils/dialog_util.dart'; 22 import '../../../../utils/dialog_util.dart';
20 import '../../../../utils/screen_util.dart'; 23 import '../../../../utils/screen_util.dart';
21 import '../../../../utils/utils.dart'; 24 import '../../../../utils/utils.dart';
22 import '../../../../widgets/h_empty_view.dart'; 25 import '../../../../widgets/h_empty_view.dart';
23 -import 'package:flutter_downloader/flutter_downloader.dart';  
24 -import 'package:android_path_provider/android_path_provider.dart'; 26 +// import 'package:flutter_downloader/flutter_downloader.dart';
  27 +// import 'package:android_path_provider/android_path_provider.dart';
25 import 'package:open_file/open_file.dart'; 28 import 'package:open_file/open_file.dart';
  29 +import 'package:excel/excel.dart' as excelUtil;
  30 +
  31 +import '../../../../widgets/loading.dart';
26 32
27 /** 33 /**
28 * 导出预订数据 34 * 导出预订数据
@@ -43,11 +49,11 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -43,11 +49,11 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
43 49
44 List<String> data = ['到店时间', '下单时间']; 50 List<String> data = ['到店时间', '下单时间'];
45 int timeIndex; 51 int timeIndex;
46 - ReceivePort _port = ReceivePort(); 52 + // ReceivePort _port = ReceivePort();
47 String _localPath; 53 String _localPath;
48 54
49 String taskId; 55 String taskId;
50 - DownloadTaskStatus status; 56 + // DownloadTaskStatus status;
51 int progress; 57 int progress;
52 58
53 @override 59 @override
@@ -181,21 +187,21 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -181,21 +187,21 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
181 super.dispose(); 187 super.dispose();
182 } 188 }
183 189
184 - @pragma('vm:entry-point')  
185 - static void downloadCallback(  
186 - String id,  
187 - int status,  
188 - int progress,  
189 - ) {  
190 - final SendPort send =  
191 - IsolateNameServer.lookupPortByName('downloader_send_port');  
192 - send.send([id, status, progress]);  
193 - } 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 + // }
194 200
195 - // 根据taskId打开下载文件  
196 - Future<bool> _openDownloadedFile(taskId) {  
197 - return FlutterDownloader.open(taskId: taskId);  
198 - } 201 + // // 根据taskId打开下载文件
  202 + // Future<bool> _openDownloadedFile(taskId) {
  203 + // return FlutterDownloader.open(taskId: taskId);
  204 + // }
199 205
200 // void _bindBackgroundIsolate() { 206 // void _bindBackgroundIsolate() {
201 // final isSuccess = IsolateNameServer.registerPortWithName( 207 // final isSuccess = IsolateNameServer.registerPortWithName(
@@ -270,17 +276,17 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -270,17 +276,17 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
270 // } 276 // }
271 // }); 277 // });
272 // } 278 // }
273 - Future<void> _delete() async {  
274 - final task = await FlutterDownloader.loadTasks();  
275 - if (task != null) {  
276 - task.forEach((element) {  
277 - FlutterDownloader.remove(  
278 - taskId: element.taskId,  
279 - shouldDeleteContent: true,  
280 - );  
281 - });  
282 - }  
283 - } 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 + // }
284 290
285 Future<void> _prepareSaveDir() async { 291 Future<void> _prepareSaveDir() async {
286 _localPath = (await _getSavedDir()); 292 _localPath = (await _getSavedDir());
@@ -299,9 +305,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -299,9 +305,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
299 // } catch (err, st) { 305 // } catch (err, st) {
300 // print('failed to get downloads path: $err, $st'); 306 // print('failed to get downloads path: $err, $st');
301 307
  308 + // if()/
  309 +
302 final directory = await getExternalStorageDirectory(); 310 final directory = await getExternalStorageDirectory();
303 externalStorageDirPath = directory?.path; 311 externalStorageDirPath = directory?.path;
304 - // }  
305 } else if (Platform.isIOS) { 312 } else if (Platform.isIOS) {
306 externalStorageDirPath = 313 externalStorageDirPath =
307 (await getApplicationDocumentsDirectory()).absolute.path; 314 (await getApplicationDocumentsDirectory()).absolute.path;
@@ -325,6 +332,23 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -325,6 +332,23 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
325 return true; 332 return true;
326 } 333 }
327 334
  335 + if (Platform.isAndroid) {
  336 + // try {
  337 + // externalStorageDirPath = await AndroidPathProvider.downloadsPath;
  338 + // } catch (err, st) {
  339 + // print('failed to get downloads path: $err, $st');
  340 +
  341 + // if()/
  342 + PermissionStatus permissionStatus = await Permission.storage.status;
  343 +
  344 + if (permissionStatus != PermissionStatus.permanentlyDenied) {
  345 +//全局提示权限使用目的
  346 + BuildContext context = App.navigatorKey.currentState.overlay.context;
  347 + DialogUtil.showAuthorityDestination(
  348 + context, 'h_storage', '存储权限使用说明', '用于存储下载的预订表。');
  349 + }
  350 + }
  351 +
328 final result = await Permission.storage.request(); 352 final result = await Permission.storage.request();
329 return result == PermissionStatus.granted; 353 return result == PermissionStatus.granted;
330 } 354 }
@@ -332,9 +356,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -332,9 +356,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
332 throw StateError('unknown platform'); 356 throw StateError('unknown platform');
333 } 357 }
334 358
335 - void _unbindBackgroundIsolate() {  
336 - IsolateNameServer.removePortNameMapping('downloader_send_port');  
337 - } 359 + // void _unbindBackgroundIsolate() {
  360 + // IsolateNameServer.removePortNameMapping('downloader_send_port');
  361 + // }
338 362
339 ///时间选择 363 ///时间选择
340 Widget _select(String title, String hintText, GestureTapCallback onTap) { 364 Widget _select(String title, String hintText, GestureTapCallback onTap) {
@@ -418,6 +442,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -418,6 +442,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
418 return data; 442 return data;
419 } 443 }
420 444
  445 + void _download() async {
  446 + Loading.showLoading(
  447 + context,
  448 + );
  449 + Stopwatch stopwatch = new Stopwatch()..start();
  450 +
  451 + excelUtil.Excel excel = excelUtil.Excel.createExcel();
  452 + excelUtil.Sheet sh = excel['Sheet1'];
  453 + //表头
  454 + for (int i = 0; i < 8; i++) {
  455 + sh
  456 + .cell(
  457 + excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i))
  458 + .value = 'Column $i';
  459 + //sh.cell(CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i)).cellStyle =CellStyle(bold: true);
  460 + }
  461 + for (int row = 1; row < 9; row++) {
  462 + for (int column = 0; column < 8; column++) {
  463 + sh
  464 + .cell(excelUtil.CellIndex.indexByColumnRow(
  465 + rowIndex: row, columnIndex: column))
  466 + .value = '$row$column value';
  467 + }
  468 + }
  469 + print('Generating executed in ${stopwatch.elapsed}');
  470 + stopwatch.reset();
  471 + var fileBytes = excel.encode();
  472 +
  473 + print('Encoding executed in ${stopwatch.elapsed}');
  474 + stopwatch.reset();
  475 + String sellername =
  476 + Provider.of<UserModel>(context, listen: false).user.sellername;
  477 + String starttime = fromDate.replaceAll('-', '');
  478 + String endtime = endDate.replaceAll('-', '');
  479 + 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');
  485 + Loading.hideLoading(context);
  486 + DialogUtil.cupertinoAlertDialog(context,
  487 + title: '提示',
  488 + content: '文件下载完成,是否打开?',
  489 + lTitle: '取消',
  490 + rTitle: '打开', lCallback: () {
  491 + progress = null;
  492 + setState(() {});
  493 + }, rCallback: () async {
  494 + // Navigator.pop(context);
  495 +
  496 + // print(_localPath);
  497 +
  498 + // final tasks = await FlutterDownloader.loadTasks();
  499 + // String str = '';
  500 + // tasks.forEach((element) {
  501 + // str = element.savedDir + '/' + element.filename;
  502 + // });
  503 + // print(str);
  504 +
  505 + // if (str != '') {
  506 + // print(savePath);
  507 + // progress = null;
  508 + // setState(() {});
  509 + OpenFile.open(
  510 + _localPath + "/${sellername}${starttime}至${endtime}预订.xlsx");
  511 + // _delete();
  512 + // }
  513 + });
  514 + } else {
  515 + Loading.hideLoading(context);
  516 + }
  517 +
  518 + print('Downloaded executed in ${stopwatch.elapsed}');
  519 + }
  520 +
  521 + Future<bool> openSetting() {
  522 + return openAppSettings();
  523 + }
  524 +
421 @override 525 @override
422 Widget build(BuildContext context) { 526 Widget build(BuildContext context) {
423 return Scaffold( 527 return Scaffold(
@@ -554,87 +658,98 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> { @@ -554,87 +658,98 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
554 fontSize: 32, 658 fontSize: 32,
555 isBold: true, 659 isBold: true,
556 onPressed: () async { 660 onPressed: () async {
557 - if (progress != null) { 661 + // if (progress != null) {
  662 + // return;
  663 + // }
  664 +
  665 + if (timeType == '点击选择') {
  666 + Utils.showToast('请选择时间类型');
  667 + return;
  668 + }
  669 + if (fromDate == '点击选择') {
  670 + Utils.showToast('请选择开始日期');
  671 + return;
  672 + }
  673 + if (endDate == '点击选择') {
  674 + Utils.showToast('请选择结束日期');
558 return; 675 return;
559 } 676 }
560 677
561 bool _permissionReady = await _checkPermission(); 678 bool _permissionReady = await _checkPermission();
562 if (_permissionReady) { 679 if (_permissionReady) {
563 await _prepareSaveDir(); 680 await _prepareSaveDir();
564 - }  
565 - // _delete();  
566 - String savePath = _localPath + "/fff.pdf";  
567 - Directory directory = new Directory(savePath);  
568 - if (directory.existsSync()) {  
569 - //删除历史  
570 - final List<FileSystemEntity> files = directory.listSync();  
571 - for (FileSystemEntity file in files) {  
572 - file.deleteSync();  
573 - }  
574 - }  
575 -  
576 - try {  
577 - Response response = await DioUtil().download(  
578 - 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',  
579 - savePath, onProgress: (received, total) {  
580 - if (progress != 100) {  
581 - progress = ((received / total) * 100).round();  
582 -  
583 - setState(() {});  
584 - }  
585 - if (received == total) {  
586 - //下载完成  
587 - print('xaizaiwancheng');  
588 -  
589 - DialogUtil.cupertinoAlertDialog(context,  
590 - title: '提示',  
591 - content: '文件下载完成,是否打开?',  
592 - lTitle: '取消',  
593 - rTitle: '打开', lCallback: () {  
594 - progress = null;  
595 - setState(() {});  
596 - }, rCallback: () async {  
597 - // Navigator.pop(context);  
598 -  
599 - // print(_localPath);  
600 -  
601 - // final tasks = await FlutterDownloader.loadTasks();  
602 - // String str = '';  
603 - // tasks.forEach((element) {  
604 - // str = element.savedDir + '/' + element.filename;  
605 - // });  
606 - // print(str);  
607 -  
608 - // if (str != '') {  
609 - print(savePath);  
610 - progress = null;  
611 - setState(() {});  
612 - OpenFile.open(savePath);  
613 - // _delete();  
614 - // }  
615 - });  
616 - } 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, '');
617 }); 692 });
618 - print(response);  
619 - } catch (e) {  
620 - print(e);  
621 - Utils.showToast('下载异常,请稍后重试');  
622 } 693 }
623 694
624 - // taskId = await FlutterDownloader.enqueue(  
625 - // url: 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 + // }
  705 +
  706 + // try {
  707 + // Response response = await DioUtil().download(
626 // 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf', 708 // 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
627 - // headers: {  
628 - // // 'auth': 'test_for_sql_encoding'  
629 - // }, // optional: header send with url (auth token etc)  
630 - // savedDir: _localPath,  
631 - // saveInPublicStorage: true,  
632 - // // fileName:  
633 - // // // showNotification:  
634 - // // // true, // show download progress in status bar (for Android)  
635 - // // openFileFromNotification:  
636 - // // true, // click on notification to open downloaded file (for Android)  
637 - // ); 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 + // }
638 }, 753 },
639 ) 754 )
640 ], 755 ],
@@ -557,9 +557,14 @@ class NoteBookItemFState extends State<NoteBookItemF> @@ -557,9 +557,14 @@ class NoteBookItemFState extends State<NoteBookItemF>
557 notebook.aname != null) 557 notebook.aname != null)
558 ? VEmptyView(18) 558 ? VEmptyView(18)
559 : SizedBox(), 559 : SizedBox(),
  560 + // canDo &&
  561 + // (Utils.getAuthority(context, '到店') ||
  562 + // notebook.uid == userModel.user.openid) &&
  563 + // (notebook.tid.split(",").length >= 2 ||
  564 + // (notebook.cusdem != null &&
  565 + // notebook.cusdem != '') ||
  566 + // notebook.aname != null)
560 canDo && 567 canDo &&
561 - (Utils.getAuthority(context, '到店') ||  
562 - notebook.uid == userModel.user.openid) &&  
563 (notebook.tid.split(",").length >= 2 || 568 (notebook.tid.split(",").length >= 2 ||
564 (notebook.cusdem != null && 569 (notebook.cusdem != null &&
565 notebook.cusdem != '') || 570 notebook.cusdem != '') ||
@@ -149,8 +149,8 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple> @@ -149,8 +149,8 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
149 params['note_name'] = userModel.user.account; 149 params['note_name'] = userModel.user.account;
150 NotebookDetailModel detailModel = 150 NotebookDetailModel detailModel =
151 Provider.of<NotebookDetailModel>(context, listen: false); 151 Provider.of<NotebookDetailModel>(context, listen: false);
152 - bool success =  
153 - await detailModel.setReserveStatus(context, params, ifPush: false,notebook: widget.notebook); 152 + bool success = await detailModel.setReserveStatus(context, params,
  153 + ifPush: false, notebook: widget.notebook);
154 if (success) { 154 if (success) {
155 bus.emit("refresh_book_list"); 155 bus.emit("refresh_book_list");
156 if (status == "4" && phone != null && phone != '') { 156 if (status == "4" && phone != null && phone != '') {
@@ -698,11 +698,13 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple> @@ -698,11 +698,13 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
698 fontSize: 698 fontSize:
699 ScreenUtil().setSp(24)), 699 ScreenUtil().setSp(24)),
700 )), 700 )),
701 - canDo &&  
702 - (Utils.getAuthority(  
703 - context, '到店') ||  
704 - notebook.uid ==  
705 - userModel.user.openid) 701 + // canDo &&
  702 + // (Utils.getAuthority(
  703 + // context, '到店') ||
  704 + // notebook.uid ==
  705 + // userModel.user.openid)
  706 + // ?
  707 + canDo
706 ? Row( 708 ? Row(
707 mainAxisAlignment: 709 mainAxisAlignment:
708 MainAxisAlignment.spaceEvenly, 710 MainAxisAlignment.spaceEvenly,
  1 +import 'package:flutter/services.dart';
  2 +
  3 + class MyNumberTextInputFormatter extends TextInputFormatter {
  4 + static const defaultDouble = 0.001;
  5 +
  6 + ///允许的小数位数,-1代表不限制位数
  7 + int digit;
  8 + MyNumberTextInputFormatter({this.digit = -1});
  9 + static double strToFloat(String str, [double defaultValue = defaultDouble]) {
  10 + try {
  11 + return double.parse(str);
  12 + } catch (e) {
  13 + return defaultValue;
  14 + }
  15 + }
  16 +
  17 + ///获取目前的小数位数
  18 + static int getValueDigit(String value) {
  19 + if (value.contains(".")) {
  20 + return value.split(".")[1].length;
  21 + } else {
  22 + return -1;
  23 + }
  24 + }
  25 +
  26 + @override
  27 + TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
  28 + String value = newValue.text;
  29 + int selectionIndex = newValue.selection.end;
  30 + if (value == ".") {
  31 + value = "0.";
  32 + selectionIndex++;
  33 + } else if (value == "-") {
  34 + value = "-";
  35 + selectionIndex++;
  36 + } else if (value != "" && value != defaultDouble.toString() && strToFloat(value, defaultDouble) == defaultDouble || getValueDigit(value) > digit) {
  37 + value = oldValue.text;
  38 + selectionIndex = oldValue.selection.end;
  39 + }
  40 + return new TextEditingValue(
  41 + text: value,
  42 + selection: new TextSelection.collapsed(offset: selectionIndex),
  43 + );
  44 + }
  45 + }
@@ -46,7 +46,7 @@ class RowMultiText extends StatelessWidget { @@ -46,7 +46,7 @@ class RowMultiText extends StatelessWidget {
46 child: Row( 46 child: Row(
47 mainAxisAlignment: MainAxisAlignment.end, 47 mainAxisAlignment: MainAxisAlignment.end,
48 children: [ 48 children: [
49 - if (imageName != null) 49 + if (imageName != null && content.length > 0)
50 Container( 50 Container(
51 margin: EdgeInsets.only(right: w(2)), 51 margin: EdgeInsets.only(right: w(2)),
52 child: Image.asset( 52 child: Image.asset(
@@ -421,6 +421,13 @@ packages: @@ -421,6 +421,13 @@ packages:
421 url: "https://pub.flutter-io.cn" 421 url: "https://pub.flutter-io.cn"
422 source: hosted 422 source: hosted
423 version: "2.0.5" 423 version: "2.0.5"
  424 + excel:
  425 + dependency: "direct main"
  426 + description:
  427 + name: excel
  428 + url: "https://pub.flutter-io.cn"
  429 + source: hosted
  430 + version: "3.0.0"
424 extended_image: 431 extended_image:
425 dependency: transitive 432 dependency: transitive
426 description: 433 description:
@@ -223,6 +223,8 @@ dependencies: @@ -223,6 +223,8 @@ dependencies:
223 223
224 # 通话记录 224 # 通话记录
225 call_log: ^4.0.0 225 call_log: ^4.0.0
  226 + # 生成excel
  227 + excel: ^3.0.0
226 # workmanager: ^0.5.1 228 # workmanager: ^0.5.1
227 229
228 230