#1790 - Камера EAN-Datamatrix для JS1

4.4
suvaissov 2021-01-15 11:11:44 +06:00
parent 746b7488dd
commit 07c661c994
9 changed files with 637 additions and 35 deletions

View File

@ -3,7 +3,8 @@ class CheckItem {
final num cnt;
final num price;
final int articul;
CheckItem({this.name, this.cnt, this.price, this.articul});
final String excise;
CheckItem({this.name, this.cnt, this.price, this.articul, this.excise});
static CheckItem fromJson(Map<String, dynamic> json) {
return CheckItem(
@ -11,6 +12,7 @@ class CheckItem {
cnt: json['cnt'],
price: json['price'],
articul: json['articul'],
excise: json['excise'],
);
}
Map<String, dynamic> toJson() =>
@ -18,6 +20,7 @@ class CheckItem {
'name': name,
'cnt': cnt,
'price': price,
'articul': articul
'articul': articul,
'excise' : excise
};
}

View File

@ -8,8 +8,9 @@ class ProductDao {
num total;
final Good good;
final Service service;
final String excise;
ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service });
ProductDao( {this.name, this.price, this.count, this.total, this.good, this.service, this.excise });
}

View File

@ -62,7 +62,9 @@ class DataService extends BaseService {
name: el.name ?? 'Позиция №$iterator',
cnt: el.count,
price: el.price,
articul: articul));
articul: articul,
excise: el.excise,
));
summ += el.total;
iterator++;
});

View File

@ -43,15 +43,15 @@ ThunkAction<AppState> addCustomProductToKassaItems(String name, int count, doubl
}
ThunkAction<AppState> addProductToKassaItems(Good good) {
ThunkAction<AppState> addProductToKassaItems(Good good, String excise) {
return (Store<AppState> store) async {
List<ProductDao> items = store.state.kassaState.kassaItems;
int index = items.indexWhere((element) => element.good?.id == good.id);
if (index > -1) {
int index = items.indexWhere((element) => element.excise == null && element.good?.id == good.id);
if (index > -1 && excise == null) {
store.dispatch(counterProductFromKassaItems(index, 1));
} else {
items.add(new ProductDao(
name: good.name, good: good, count: 1, price: good.price, total: good.price));
name: good.name, good: good, count: 1, price: good.price, total: good.price, excise: excise));
store.dispatch(SetKassaStateAction(KassaState(kassaItems: items)));
}
};

11
lib/test/foo.dart Normal file
View File

@ -0,0 +1,11 @@
// Define a function.
void printInteger(int aNumber) {
print('The number is $aNumber.'); // Print to console.
}
// This is where the app starts executing.
void main() {
String dataMatrix = "00000046208262nZ2qnLHODVFWktT";
String numberText = dataMatrix.replaceAll(RegExp("[a-zA-Z]"), '');
print(int.parse(numberText));
}

View File

@ -189,25 +189,43 @@ class KassaTab extends StatelessWidget {
"flash_off": 'Выкл фонарик',
});
var result = await BarcodeScanner.scan(options: options);
// print(result.type); // The result type (barcode, cancelled, failed)
// print(result.rawContent); // The barcode content
// print(result.format); // The barcode format (as enum)
// print(result.formatNote); // If a unknown format was scanned this field contains a note
if (result.type == ResultType.Barcode &&
(result.format == BarcodeFormat.ean13 ||
result.format == BarcodeFormat.ean8)) {
String barcode = result.rawContent;
List<Good> goods =
await _dataService.getGoodsByBarcode(barcode: barcode);
if (goods != null && goods.isNotEmpty) {
Redux.store.dispatch(addProductToKassaItems(goods.first));
} else {
_dialogService.showDialog(
description: 'Товар не найден: ${result.rawContent}');
// print(result.type); // The result type (barcode, cancelled, failed)
// print(result.rawContent); // The barcode content
// print(result.format); // The barcode format (as enum)
// print(result.formatNote); // If a unknown format was scanned this field contains a note
// print(result.rawContent); // content
if (result.type == ResultType.Barcode ) {
String barcode;
String dataMatrix;
if(result.format == BarcodeFormat.ean13 || result.format == BarcodeFormat.ean8) {
barcode = result.rawContent;
} else if( result.format == BarcodeFormat.dataMatrix ) {
dataMatrix = result.rawContent;
if(dataMatrix!= null && dataMatrix.length >15) {
try {
String numberText = dataMatrix.substring(0, dataMatrix.length - 15 ).replaceAll(RegExp("[a-zA-Z]"), '');
barcode = int.parse(numberText).toString();
} catch (e) {
}
}
// 00000046208262 nZ2qnLH ODVFWktT
// 00000046208262 tjKDqfu UzVSeFE5
}
} else if (result.type == ResultType.Error) {
_dialogService.showDialog(description: 'Не верный формат QR кода');
}
if(barcode != null) {
List<Good> goods =
await _dataService.getGoodsByBarcode(barcode: barcode);
if (goods != null && goods.isNotEmpty) {
Redux.store.dispatch(addProductToKassaItems(goods.first, dataMatrix));
} else {
_dialogService.showDialog(
description: 'Товар не найден: $barcode');
}
} else if (result.type == ResultType.Error) {
_dialogService.showDialog(description: 'Не верный формат QR кода');
}
}
} on PlatformException catch (e) {
var result = ScanResult.create();
result.type = ResultType.Error;

View File

@ -95,7 +95,7 @@ class CatalogBottomSheet extends StatelessWidget {
.dispatch(selectBottomElement(el.id));
} else if (el is Good) {
await Redux.store
.dispatch(addProductToKassaItems(el));
.dispatch(addProductToKassaItems(el, null));
Navigator.pop(context);
} else if (el is Service) {
await Redux.store

View File

@ -52,16 +52,25 @@ class ProductListItem extends StatelessWidget {
Expanded(
flex: 1,
child: Container(
//margin: const EdgeInsets.symmetric(horizontal: 4),
margin: const EdgeInsets.symmetric(horizontal: 4),
child: Row(
children: <Widget>[
buildClipRect(primaryColor, Icons.edit, () {
editCountForm(context, item.count);
}),
// buildClipRect(primaryColor, Icons.add, () {
// Redux.store
// .dispatch(counterProductFromKassaItems(index, 1));
// }),
// buildClipRect(primaryColor, Icons.edit, () {
// editCountForm(context, item.count);
// }),
if(item.excise == null)
buildClipRect(primaryColor, Icons.remove, () {
Redux.store
.dispatch(
counterProductFromKassaItems(index, -1));
}),
if(item.excise == null)
buildClipRect(primaryColor, Icons.add, () {
Redux.store
.dispatch(
counterProductFromKassaItems(index, 1));
}),
Expanded(
child: Container(),
),

558
pubspec.lock Normal file
View File

@ -0,0 +1,558 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.5.0-nullsafety.1"
auto_size_text:
dependency: "direct main"
description:
name: auto_size_text
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
barcode_scan:
dependency: "direct main"
description:
name: barcode_scan
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
characters:
dependency: transitive
description:
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.3"
charcode:
dependency: transitive
description:
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
clock:
dependency: transitive
description:
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
collection:
dependency: transitive
description:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0-nullsafety.3"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.5"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
device_info:
dependency: "direct main"
description:
name: device_info
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.2+10"
device_info_platform_interface:
dependency: transitive
description:
name: device_info_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.1"
equatable:
dependency: "direct main"
description:
name: equatable
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.5"
esys_flutter_share:
dependency: "direct main"
description:
name: esys_flutter_share
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
ffi:
dependency: transitive
description:
name: ffi
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
file:
dependency: transitive
description:
name: file
url: "https://pub.dartlang.org"
source: hosted
version: "5.2.1"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.11"
flutter:
dependency: "direct main"
description: flutter
source: sdk
version: "0.0.0"
flutter_redux:
dependency: "direct main"
description:
name: flutter_redux
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.0"
flutter_screenutil:
dependency: "direct main"
description:
name: flutter_screenutil
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.1"
flutter_test:
dependency: "direct dev"
description: flutter
source: sdk
version: "0.0.0"
flutter_web_plugins:
dependency: transitive
description: flutter
source: sdk
version: "0.0.0"
get_it:
dependency: "direct main"
description:
name: get_it
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.4"
google_fonts:
dependency: "direct main"
description:
name: google_fonts
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.1"
http:
dependency: "direct main"
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.2"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.4"
intl:
dependency: "direct main"
description:
name: intl
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
logger:
dependency: "direct main"
description:
name: logger
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.4"
mask_text_input_formatter:
dependency: "direct main"
description:
name: mask_text_input_formatter
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.1"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.10-nullsafety.1"
material_design_icons_flutter:
dependency: "direct main"
description:
name: material_design_icons_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.5855"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
nested:
dependency: transitive
description:
name: nested
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.1"
path_provider:
dependency: "direct main"
description:
name: path_provider
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.27"
path_provider_linux:
dependency: transitive
description:
name: path_provider_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+2"
path_provider_macos:
dependency: transitive
description:
name: path_provider_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+8"
path_provider_platform_interface:
dependency: transitive
description:
name: path_provider_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
path_provider_windows:
dependency: transitive
description:
name: path_provider_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.4+3"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.2"
platform:
dependency: transitive
description:
name: platform
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.1"
plugin_platform_interface:
dependency: transitive
description:
name: plugin_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
process:
dependency: transitive
description:
name: process
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.13"
protobuf:
dependency: transitive
description:
name: protobuf
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
provider:
dependency: "direct main"
description:
name: provider
url: "https://pub.dartlang.org"
source: hosted
version: "4.3.2+4"
qr:
dependency: transitive
description:
name: qr
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
qr_flutter:
dependency: "direct main"
description:
name: qr_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
redux:
dependency: "direct main"
description:
name: redux
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0+3"
redux_persist:
dependency: "direct main"
description:
name: redux_persist
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.4"
redux_persist_flutter:
dependency: "direct main"
description:
name: redux_persist_flutter
url: "https://pub.dartlang.org"
source: hosted
version: "0.8.3"
redux_thunk:
dependency: "direct main"
description:
name: redux_thunk
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.0"
responsive_builder:
dependency: "direct main"
description:
name: responsive_builder
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+2"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
url: "https://pub.dartlang.org"
source: hosted
version: "0.5.12+4"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.2+4"
shared_preferences_macos:
dependency: transitive
description:
name: shared_preferences_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+11"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2+7"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+3"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_span:
dependency: transitive
description:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0-nullsafety.2"
sqflite:
dependency: "direct main"
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.2+2"
sqflite_common:
dependency: transitive
description:
name: sqflite_common
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.3"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.10.0-nullsafety.1"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.1"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0-nullsafety.1"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.0+2"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0-nullsafety.1"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.19-nullsafety.2"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0-nullsafety.3"
url_launcher:
dependency: "direct main"
description:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "5.7.10"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+4"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+9"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.9"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5+1"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.1+3"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0-nullsafety.3"
win32:
dependency: transitive
description:
name: win32
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.4"
xdg_directories:
dependency: transitive
description:
name: xdg_directories
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
sdks:
dart: ">=2.10.2 <2.11.0"
flutter: ">=1.22.2 <2.0.0"