Commit f376c56163ca6141c23acf8c32931107da1f9ff0

Authored by wdn127929
1 parent a924ed54

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

... ... @@ -111,6 +111,8 @@ PODS:
- Mantle/extobjc (= 2.2.0)
- Mantle/extobjc (2.2.0)
- MTBBarcodeScanner (5.0.11)
- open_file (0.0.1):
- Flutter
- OrderedSet (5.0.0)
- package_info (0.0.1):
- Flutter
... ... @@ -191,6 +193,7 @@ DEPENDENCIES:
- image_gallery_saver (from `.symlinks/plugins/image_gallery_saver/ios`)
- image_picker_ios (from `.symlinks/plugins/image_picker_ios/ios`)
- install_plugin (from `.symlinks/plugins/install_plugin/ios`)
- open_file (from `.symlinks/plugins/open_file/ios`)
- package_info (from `.symlinks/plugins/package_info/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/ios`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
... ... @@ -290,6 +293,8 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/image_picker_ios/ios"
install_plugin:
:path: ".symlinks/plugins/install_plugin/ios"
open_file:
:path: ".symlinks/plugins/open_file/ios"
package_info:
:path: ".symlinks/plugins/package_info/ios"
path_provider_foundation:
... ... @@ -362,6 +367,7 @@ SPEC CHECKSUMS:
libwebp: 33dc822fbbf4503668d09f7885bbfedc76c45e96
Mantle: c5aa8794a29a022dfbbfc9799af95f477a69b62d
MTBBarcodeScanner: f453b33c4b7dfe545d8c6484ed744d55671788cb
open_file: 02eb5cb6b21264bd3a696876f5afbfb7ca4f4b7d
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
package_info: 873975fc26034f0b863a300ad47e7f1ac6c7ec62
path_provider_foundation: 29f094ae23ebbca9d3d0cec13889cd9060c0e943
... ...
... ... @@ -355,6 +355,7 @@
"${BUILT_PRODUCTS_DIR}/image_picker_ios/image_picker_ios.framework",
"${BUILT_PRODUCTS_DIR}/install_plugin/install_plugin.framework",
"${BUILT_PRODUCTS_DIR}/libwebp/libwebp.framework",
"${BUILT_PRODUCTS_DIR}/open_file/open_file.framework",
"${BUILT_PRODUCTS_DIR}/package_info/package_info.framework",
"${BUILT_PRODUCTS_DIR}/path_provider_foundation/path_provider_foundation.framework",
"${BUILT_PRODUCTS_DIR}/photo_manager/photo_manager.framework",
... ... @@ -402,6 +403,7 @@
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/image_picker_ios.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/install_plugin.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/libwebp.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/open_file.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/package_info.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/path_provider_foundation.framework",
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/photo_manager.framework",
... ... @@ -548,7 +550,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
... ... @@ -694,7 +699,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
... ... @@ -730,7 +738,10 @@
);
INFOPLIST_FILE = Runner/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 12.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
... ...
import 'package:common_utils/common_utils.dart';
import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_picker/Picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/models/filter_btn_model.dart';
... ... @@ -16,6 +17,8 @@ import '../../provider/feast_model.dart';
import '../../provider/notebook_detail_model.dart';
import '../../provider/user_model.dart';
import '../../res/colors.dart';
import '../../utils/MyNumberTextInputFormatter.dart';
import '../../utils/NumLengthInputFormatter.dart';
import '../../utils/dialog_util.dart';
import '../../utils/event_bus.dart';
import '../../utils/screen_util.dart';
... ... @@ -231,7 +234,14 @@ class _BookDepositPageState extends State<BookDepositPage> {
// textAlign: TextAlign.right,
// textAlignVertical: TextAlignVertical.bottom,
maxLines: 1,
inputFormatters: [],
inputFormatters: title == '金额'
? [
FilteringTextInputFormatter(RegExp("[0-9.]"),
allow: true),
MyNumberTextInputFormatter(digit: 2),
]
: [],
// //光标颜色
// cursorColor:
... ...
... ... @@ -8,21 +8,27 @@ import 'package:dio/dio.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/Picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:one_key/provider/user_model.dart';
import 'package:one_key/res/colors.dart';
import 'package:one_key/widgets/round_button.dart';
import 'package:one_key/widgets/system_app_bar.dart';
import 'package:one_key/widgets/v_empty_view.dart';
import 'package:path_provider/path_provider.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:provider/provider.dart';
import '../../../../app.dart';
import '../../../../net/dio_util.dart';
import '../../../../utils/dialog_util.dart';
import '../../../../utils/screen_util.dart';
import '../../../../utils/utils.dart';
import '../../../../widgets/h_empty_view.dart';
import 'package:flutter_downloader/flutter_downloader.dart';
import 'package:android_path_provider/android_path_provider.dart';
// import 'package:flutter_downloader/flutter_downloader.dart';
// import 'package:android_path_provider/android_path_provider.dart';
import 'package:open_file/open_file.dart';
import 'package:excel/excel.dart' as excelUtil;
import '../../../../widgets/loading.dart';
/**
* 导出预订数据
... ... @@ -43,11 +49,11 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
List<String> data = ['到店时间', '下单时间'];
int timeIndex;
ReceivePort _port = ReceivePort();
// ReceivePort _port = ReceivePort();
String _localPath;
String taskId;
DownloadTaskStatus status;
// DownloadTaskStatus status;
int progress;
@override
... ... @@ -181,21 +187,21 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
super.dispose();
}
@pragma('vm:entry-point')
static void downloadCallback(
String id,
int status,
int progress,
) {
final SendPort send =
IsolateNameServer.lookupPortByName('downloader_send_port');
send.send([id, status, progress]);
}
// @pragma('vm:entry-point')
// static void downloadCallback(
// String id,
// int status,
// int progress,
// ) {
// final SendPort send =
// IsolateNameServer.lookupPortByName('downloader_send_port');
// send.send([id, status, progress]);
// }
// 根据taskId打开下载文件
Future<bool> _openDownloadedFile(taskId) {
return FlutterDownloader.open(taskId: taskId);
}
// // 根据taskId打开下载文件
// Future<bool> _openDownloadedFile(taskId) {
// return FlutterDownloader.open(taskId: taskId);
// }
// void _bindBackgroundIsolate() {
// final isSuccess = IsolateNameServer.registerPortWithName(
... ... @@ -270,17 +276,17 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
// }
// });
// }
Future<void> _delete() async {
final task = await FlutterDownloader.loadTasks();
if (task != null) {
task.forEach((element) {
FlutterDownloader.remove(
taskId: element.taskId,
shouldDeleteContent: true,
);
});
}
}
// Future<void> _delete() async {
// final task = await FlutterDownloader.loadTasks();
// if (task != null) {
// task.forEach((element) {
// FlutterDownloader.remove(
// taskId: element.taskId,
// shouldDeleteContent: true,
// );
// });
// }
// }
Future<void> _prepareSaveDir() async {
_localPath = (await _getSavedDir());
... ... @@ -299,9 +305,10 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
// } catch (err, st) {
// print('failed to get downloads path: $err, $st');
// if()/
final directory = await getExternalStorageDirectory();
externalStorageDirPath = directory?.path;
// }
} else if (Platform.isIOS) {
externalStorageDirPath =
(await getApplicationDocumentsDirectory()).absolute.path;
... ... @@ -325,6 +332,23 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
return true;
}
if (Platform.isAndroid) {
// try {
// externalStorageDirPath = await AndroidPathProvider.downloadsPath;
// } catch (err, st) {
// print('failed to get downloads path: $err, $st');
// if()/
PermissionStatus permissionStatus = await Permission.storage.status;
if (permissionStatus != PermissionStatus.permanentlyDenied) {
//全局提示权限使用目的
BuildContext context = App.navigatorKey.currentState.overlay.context;
DialogUtil.showAuthorityDestination(
context, 'h_storage', '存储权限使用说明', '用于存储下载的预订表。');
}
}
final result = await Permission.storage.request();
return result == PermissionStatus.granted;
}
... ... @@ -332,9 +356,9 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
throw StateError('unknown platform');
}
void _unbindBackgroundIsolate() {
IsolateNameServer.removePortNameMapping('downloader_send_port');
}
// void _unbindBackgroundIsolate() {
// IsolateNameServer.removePortNameMapping('downloader_send_port');
// }
///时间选择
Widget _select(String title, String hintText, GestureTapCallback onTap) {
... ... @@ -418,6 +442,86 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
return data;
}
void _download() async {
Loading.showLoading(
context,
);
Stopwatch stopwatch = new Stopwatch()..start();
excelUtil.Excel excel = excelUtil.Excel.createExcel();
excelUtil.Sheet sh = excel['Sheet1'];
//表头
for (int i = 0; i < 8; i++) {
sh
.cell(
excelUtil.CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i))
.value = 'Column $i';
//sh.cell(CellIndex.indexByColumnRow(rowIndex: 0, columnIndex: i)).cellStyle =CellStyle(bold: true);
}
for (int row = 1; row < 9; row++) {
for (int column = 0; column < 8; column++) {
sh
.cell(excelUtil.CellIndex.indexByColumnRow(
rowIndex: row, columnIndex: column))
.value = '$row$column value';
}
}
print('Generating executed in ${stopwatch.elapsed}');
stopwatch.reset();
var fileBytes = excel.encode();
print('Encoding executed in ${stopwatch.elapsed}');
stopwatch.reset();
String sellername =
Provider.of<UserModel>(context, listen: false).user.sellername;
String starttime = fromDate.replaceAll('-', '');
String endtime = endDate.replaceAll('-', '');
if (fileBytes != null) {
File file =
File(_localPath + "/${sellername}${starttime}至${endtime}预订.xlsx")
..createSync(recursive: true)
..writeAsBytesSync(fileBytes);
file.copy('/storage/emulated/0/Download/dongle.xlsx');
Loading.hideLoading(context);
DialogUtil.cupertinoAlertDialog(context,
title: '提示',
content: '文件下载完成,是否打开?',
lTitle: '取消',
rTitle: '打开', lCallback: () {
progress = null;
setState(() {});
}, rCallback: () async {
// Navigator.pop(context);
// print(_localPath);
// final tasks = await FlutterDownloader.loadTasks();
// String str = '';
// tasks.forEach((element) {
// str = element.savedDir + '/' + element.filename;
// });
// print(str);
// if (str != '') {
// print(savePath);
// progress = null;
// setState(() {});
OpenFile.open(
_localPath + "/${sellername}${starttime}至${endtime}预订.xlsx");
// _delete();
// }
});
} else {
Loading.hideLoading(context);
}
print('Downloaded executed in ${stopwatch.elapsed}');
}
Future<bool> openSetting() {
return openAppSettings();
}
@override
Widget build(BuildContext context) {
return Scaffold(
... ... @@ -554,87 +658,98 @@ class _ExportBookDataPageState extends State<ExportBookDataPage> {
fontSize: 32,
isBold: true,
onPressed: () async {
if (progress != null) {
// if (progress != null) {
// return;
// }
if (timeType == '点击选择') {
Utils.showToast('请选择时间类型');
return;
}
if (fromDate == '点击选择') {
Utils.showToast('请选择开始日期');
return;
}
if (endDate == '点击选择') {
Utils.showToast('请选择结束日期');
return;
}
bool _permissionReady = await _checkPermission();
if (_permissionReady) {
await _prepareSaveDir();
}
// _delete();
String savePath = _localPath + "/fff.pdf";
Directory directory = new Directory(savePath);
if (directory.existsSync()) {
//删除历史
final List<FileSystemEntity> files = directory.listSync();
for (FileSystemEntity file in files) {
file.deleteSync();
}
}
try {
Response response = await DioUtil().download(
'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
savePath, onProgress: (received, total) {
if (progress != 100) {
progress = ((received / total) * 100).round();
setState(() {});
}
if (received == total) {
//下载完成
print('xaizaiwancheng');
DialogUtil.cupertinoAlertDialog(context,
title: '提示',
content: '文件下载完成,是否打开?',
lTitle: '取消',
rTitle: '打开', lCallback: () {
progress = null;
setState(() {});
}, rCallback: () async {
// Navigator.pop(context);
// print(_localPath);
// final tasks = await FlutterDownloader.loadTasks();
// String str = '';
// tasks.forEach((element) {
// str = element.savedDir + '/' + element.filename;
// });
// print(str);
// if (str != '') {
print(savePath);
progress = null;
setState(() {});
OpenFile.open(savePath);
// _delete();
// }
});
}
_download();
} else {
String title = Platform.isAndroid ? '存储' : '相册';
//用户选择不在弹出权限提示框
print('never');
// Navigator.pop(context);
DialogUtil.openAlertDialog(context, '未获得${title}权限',
"请在手机的权限管理里,将${title}权限开启", '去设置', 340.0, onTap: () {
openSetting();
Navigator.pop(context, '');
});
print(response);
} catch (e) {
print(e);
Utils.showToast('下载异常,请稍后重试');
}
// taskId = await FlutterDownloader.enqueue(
// url:
// _delete();
// String savePath = _localPath + "/fff.pdf";
// Directory directory = new Directory(savePath);
// if (directory.existsSync()) {
// //删除历史
// final List<FileSystemEntity> files = directory.listSync();
// for (FileSystemEntity file in files) {
// file.deleteSync();
// }
// }
// try {
// Response response = await DioUtil().download(
// 'http://englishonlineclub.com/pdf/iOS%20Programming%20-%20The%20Big%20Nerd%20Ranch%20Guide%20(6th%20Edition)%20[EnglishOnlineClub.com].pdf',
// headers: {
// // 'auth': 'test_for_sql_encoding'
// }, // optional: header send with url (auth token etc)
// savedDir: _localPath,
// saveInPublicStorage: true,
// // fileName:
// // // showNotification:
// // // true, // show download progress in status bar (for Android)
// // openFileFromNotification:
// // true, // click on notification to open downloaded file (for Android)
// );
// savePath, onProgress: (received, total) {
// if (progress != 100) {
// progress = ((received / total) * 100).round();
// setState(() {});
// }
// if (received == total) {
// //下载完成
// print('xaizaiwancheng');
// DialogUtil.cupertinoAlertDialog(context,
// title: '提示',
// content: '文件下载完成,是否打开?',
// lTitle: '取消',
// rTitle: '打开', lCallback: () {
// progress = null;
// setState(() {});
// }, rCallback: () async {
// // Navigator.pop(context);
// // print(_localPath);
// // final tasks = await FlutterDownloader.loadTasks();
// // String str = '';
// // tasks.forEach((element) {
// // str = element.savedDir + '/' + element.filename;
// // });
// // print(str);
// // if (str != '') {
// print(savePath);
// progress = null;
// setState(() {});
// OpenFile.open(savePath);
// // _delete();
// // }
// });
// }
// });
// print(response);
// } catch (e) {
// print(e);
// Utils.showToast('下载异常,请稍后重试');
// }
},
)
],
... ...
... ... @@ -557,9 +557,14 @@ class NoteBookItemFState extends State<NoteBookItemF>
notebook.aname != null)
? VEmptyView(18)
: SizedBox(),
// canDo &&
// (Utils.getAuthority(context, '到店') ||
// notebook.uid == userModel.user.openid) &&
// (notebook.tid.split(",").length >= 2 ||
// (notebook.cusdem != null &&
// notebook.cusdem != '') ||
// notebook.aname != null)
canDo &&
(Utils.getAuthority(context, '到店') ||
notebook.uid == userModel.user.openid) &&
(notebook.tid.split(",").length >= 2 ||
(notebook.cusdem != null &&
notebook.cusdem != '') ||
... ...
... ... @@ -149,8 +149,8 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
params['note_name'] = userModel.user.account;
NotebookDetailModel detailModel =
Provider.of<NotebookDetailModel>(context, listen: false);
bool success =
await detailModel.setReserveStatus(context, params, ifPush: false,notebook: widget.notebook);
bool success = await detailModel.setReserveStatus(context, params,
ifPush: false, notebook: widget.notebook);
if (success) {
bus.emit("refresh_book_list");
if (status == "4" && phone != null && phone != '') {
... ... @@ -698,11 +698,13 @@ class NoteBookItemSimpleState extends State<NoteBookItemSimple>
fontSize:
ScreenUtil().setSp(24)),
)),
canDo &&
(Utils.getAuthority(
context, '到店') ||
notebook.uid ==
userModel.user.openid)
// canDo &&
// (Utils.getAuthority(
// context, '到店') ||
// notebook.uid ==
// userModel.user.openid)
// ?
canDo
? Row(
mainAxisAlignment:
MainAxisAlignment.spaceEvenly,
... ...
import 'package:flutter/services.dart';
class MyNumberTextInputFormatter extends TextInputFormatter {
static const defaultDouble = 0.001;
///允许的小数位数,-1代表不限制位数
int digit;
MyNumberTextInputFormatter({this.digit = -1});
static double strToFloat(String str, [double defaultValue = defaultDouble]) {
try {
return double.parse(str);
} catch (e) {
return defaultValue;
}
}
///获取目前的小数位数
static int getValueDigit(String value) {
if (value.contains(".")) {
return value.split(".")[1].length;
} else {
return -1;
}
}
@override
TextEditingValue formatEditUpdate(TextEditingValue oldValue, TextEditingValue newValue) {
String value = newValue.text;
int selectionIndex = newValue.selection.end;
if (value == ".") {
value = "0.";
selectionIndex++;
} else if (value == "-") {
value = "-";
selectionIndex++;
} else if (value != "" && value != defaultDouble.toString() && strToFloat(value, defaultDouble) == defaultDouble || getValueDigit(value) > digit) {
value = oldValue.text;
selectionIndex = oldValue.selection.end;
}
return new TextEditingValue(
text: value,
selection: new TextSelection.collapsed(offset: selectionIndex),
);
}
}
... ...
... ... @@ -46,7 +46,7 @@ class RowMultiText extends StatelessWidget {
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
if (imageName != null)
if (imageName != null && content.length > 0)
Container(
margin: EdgeInsets.only(right: w(2)),
child: Image.asset(
... ...
... ... @@ -421,6 +421,13 @@ packages:
url: "https://pub.flutter-io.cn"
source: hosted
version: "2.0.5"
excel:
dependency: "direct main"
description:
name: excel
url: "https://pub.flutter-io.cn"
source: hosted
version: "3.0.0"
extended_image:
dependency: transitive
description:
... ...
... ... @@ -223,6 +223,8 @@ dependencies:
# 通话记录
call_log: ^4.0.0
# 生成excel
excel: ^3.0.0
# workmanager: ^0.5.1
... ...