From 4e63ed0556a0519e475a221b577ca7220300d42a Mon Sep 17 00:00:00 2001 From: suvaissov Date: Tue, 24 Aug 2021 11:08:30 +0600 Subject: [PATCH] request and response dart files --- lib/core/models/flow/check_bean.dart | 26 ++++++++++++ lib/core/models/flow/info_bean.dart | 39 ++++++++++++++++++ lib/core/models/flow/items_bean.dart | 38 +++++++++++++++++ lib/core/models/flow/operator_bean.dart | 22 ++++++++++ lib/core/models/flow/rows_bean.dart | 33 +++++++++++++++ lib/core/models/flow/sell_request.dart | 43 ++++++++++++++++++++ lib/core/models/flow/sell_response.dart | 40 ++++++++++++++++++ lib/core/services/data_service.dart | 4 ++ lib/views/dictionaries/goods/goods_edit.dart | 3 -- 9 files changed, 245 insertions(+), 3 deletions(-) create mode 100644 lib/core/models/flow/check_bean.dart create mode 100644 lib/core/models/flow/info_bean.dart create mode 100644 lib/core/models/flow/items_bean.dart create mode 100644 lib/core/models/flow/operator_bean.dart create mode 100644 lib/core/models/flow/rows_bean.dart create mode 100644 lib/core/models/flow/sell_request.dart create mode 100644 lib/core/models/flow/sell_response.dart diff --git a/lib/core/models/flow/check_bean.dart b/lib/core/models/flow/check_bean.dart new file mode 100644 index 0000000..3cd52ad --- /dev/null +++ b/lib/core/models/flow/check_bean.dart @@ -0,0 +1,26 @@ + +import 'package:satu/core/models/flow/rows_bean.dart'; +import 'package:satu/core/utils/utils_parse.dart'; + +class CheckBean { + List rows =[]; + String? qr; + String? link; + + static CheckBean? fromMap(dynamic map) { + if (map == null) return null; + final CheckBean checkBean = CheckBean(); + checkBean.rows.addAll( + (map['rows'] as List ?? []).map((o) => CheckRowsBean.fromMap(o)) + ); + checkBean.qr = cast(map['qr']); + checkBean.link = cast(map['link']); + return checkBean; + } + + Map toJson() => { + 'rows': rows, + 'qr': qr, + 'link': link, + }; +} \ No newline at end of file diff --git a/lib/core/models/flow/info_bean.dart b/lib/core/models/flow/info_bean.dart new file mode 100644 index 0000000..ccd01e5 --- /dev/null +++ b/lib/core/models/flow/info_bean.dart @@ -0,0 +1,39 @@ +import 'package:satu/core/utils/utils_parse.dart'; + +/// sn : "SL00100003" +/// address : "" +/// ticket_ad_ofd : "" +/// name : "�������������� ��������������� «qwe»" +/// biniin : "123132131232" +/// kkmreg : "" + + +class InfoBean { + String? sn; + String? address; + String? ticketAdOfd; + String? name; + String? biniin; + String? kkmreg; + + static InfoBean? fromMap(dynamic map) { + if (map == null) return null; + final InfoBean infoBean = InfoBean(); + infoBean.sn = cast(map['sn']); + infoBean.address = cast(map['address']); + infoBean.ticketAdOfd = cast(map['ticket_ad_ofd']); + infoBean.name = cast(map['name']); + infoBean.biniin = cast(map['biniin']); + infoBean.kkmreg = cast(map['kkmreg']); + return infoBean; + } + + Map toJson() => { + 'sn': sn, + 'address': address, + 'ticket_ad_ofd': ticketAdOfd, + 'name': name, + 'biniin': biniin, + 'kkmreg': kkmreg, + }; +} \ No newline at end of file diff --git a/lib/core/models/flow/items_bean.dart b/lib/core/models/flow/items_bean.dart new file mode 100644 index 0000000..d6179f8 --- /dev/null +++ b/lib/core/models/flow/items_bean.dart @@ -0,0 +1,38 @@ + +import 'package:satu/core/utils/utils_parse.dart'; + +/// id : 6 +/// name : "test" +/// articul : "100" +/// cnt : 1 +/// price : 200 +/// excise : "000000000000_gs1_excise_code" + +class ItemsBean { + int? id; + String? name; + String? articul; + double? cnt; + double? price; + String? excise; + + static ItemsBean fromMap(dynamic map) { + final ItemsBean itemsBean = ItemsBean(); + itemsBean.id = cast(map['id']); + itemsBean.name = cast(map['name']); + itemsBean.articul = cast(map['articul']); + itemsBean.cnt = cast(map['cnt']); + itemsBean.price = cast(map['price']); + itemsBean.excise = cast(map['excise']); + return itemsBean; + } + + Map toJson() => { + 'id': id, + 'name': name, + 'articul': articul, + 'cnt': cnt, + 'price': price, + 'excise': excise, + }; +} \ No newline at end of file diff --git a/lib/core/models/flow/operator_bean.dart b/lib/core/models/flow/operator_bean.dart new file mode 100644 index 0000000..8c6c8ff --- /dev/null +++ b/lib/core/models/flow/operator_bean.dart @@ -0,0 +1,22 @@ +import 'package:satu/core/utils/utils_parse.dart'; + +/// code : 1 +/// name : "���� ��������" + +class OperatorBean { + int? code; + String? name; + + static OperatorBean? fromMap(dynamic map) { + if (map == null) return null; + OperatorBean operatorBean = OperatorBean(); + operatorBean.code = cast(map['code']); + operatorBean.name = cast(map['name']); + return operatorBean; + } + + Map toJson() => { + 'code': code, + 'name': name, + }; +} diff --git a/lib/core/models/flow/rows_bean.dart b/lib/core/models/flow/rows_bean.dart new file mode 100644 index 0000000..791fc7a --- /dev/null +++ b/lib/core/models/flow/rows_bean.dart @@ -0,0 +1,33 @@ +import 'package:satu/core/utils/utils_parse.dart'; + +/// size : 14 +/// text : null +/// center : true +/// name : "toptext" +/// value : null + +class CheckRowsBean { + late int size; + String? text; + late bool center; + String? name; + String? value; + + static CheckRowsBean fromMap(dynamic map) { + CheckRowsBean rowsBean = CheckRowsBean(); + rowsBean.size = cast(map['size']) ?? 14; + rowsBean.text = cast(map['text']); + rowsBean.center = cast(map['center']) ?? false; + rowsBean.name = cast(map['name']); + rowsBean.value = cast(map['value']); + return rowsBean; + } + + Map toJson() => { + 'size': size, + 'text': text, + 'center': center, + 'name': name, + 'value': value, + }; +} \ No newline at end of file diff --git a/lib/core/models/flow/sell_request.dart b/lib/core/models/flow/sell_request.dart new file mode 100644 index 0000000..26f935b --- /dev/null +++ b/lib/core/models/flow/sell_request.dart @@ -0,0 +1,43 @@ + +import 'package:satu/core/utils/utils_parse.dart'; + +import 'items_bean.dart'; +import 'operator_bean.dart'; + +class SellRequest { + String? type; + List items = []; + int card = 0; + int nal = 0; + String? invoiceId; + String? section; + OperatorBean? operator; + String? contragent; + + static SellRequest fromMap(dynamic map) { + final SellRequest sellRequestBean = SellRequest(); + sellRequestBean.type = cast(map['type']); + sellRequestBean.items.addAll( + (map['items'] as List ?? []).map((o) => ItemsBean.fromMap(o)) + ); + sellRequestBean.card = cast(map['card']) ?? 0; + sellRequestBean.nal = cast(map['nal']) ?? 0; + sellRequestBean.invoiceId = cast(map['invoice_id']); + sellRequestBean.section = cast(map['section']); + sellRequestBean.operator = OperatorBean.fromMap(map['operator']); + sellRequestBean.contragent = cast(map['contragent']); + return sellRequestBean; + } + + Map toJson() => { + 'type': type, + 'items': items, + 'card': card, + 'nal': nal, + 'invoice_id': invoiceId, + 'section': section, + 'operator': operator, + 'contragent': contragent, + }; +} + diff --git a/lib/core/models/flow/sell_response.dart b/lib/core/models/flow/sell_response.dart new file mode 100644 index 0000000..fe95a9c --- /dev/null +++ b/lib/core/models/flow/sell_response.dart @@ -0,0 +1,40 @@ +import 'package:satu/core/utils/utils_parse.dart'; + +import 'check_bean.dart'; +import 'info_bean.dart'; + +class SellResponse { + int? journalId; + CheckBean? check; + String? checkPng; + String? checkTxt; + InfoBean? info; + String? message; + late bool operation; + + static SellResponse? fromMap(dynamic map) { + if (map == null) return null; + final SellResponse sellResponseBean = SellResponse(); + sellResponseBean.journalId = cast(map['journal_id']); + sellResponseBean.check = CheckBean.fromMap(map['check']); + sellResponseBean.checkPng = cast(map['check_png']); + sellResponseBean.checkTxt = cast(map['check_txt']); + sellResponseBean.info = InfoBean.fromMap(map['info']); + sellResponseBean.message = cast(map['message']); + sellResponseBean.operation = cast(map['operation']) ?? false; + return sellResponseBean; + } + + Map toJson() => { + 'journal_id': journalId, + 'check': check, + 'check_png': checkPng, + 'check_txt': checkTxt, + 'info': info, + 'message': message, + 'operation': operation, + }; +} + + + diff --git a/lib/core/services/data_service.dart b/lib/core/services/data_service.dart index 4a516f9..e75e7b3 100644 --- a/lib/core/services/data_service.dart +++ b/lib/core/services/data_service.dart @@ -13,4 +13,8 @@ class DataService extends BaseService { + Future sellBtnHandler() async { + + return true; + } } diff --git a/lib/views/dictionaries/goods/goods_edit.dart b/lib/views/dictionaries/goods/goods_edit.dart index 2a0868f..32faa05 100644 --- a/lib/views/dictionaries/goods/goods_edit.dart +++ b/lib/views/dictionaries/goods/goods_edit.dart @@ -62,14 +62,11 @@ class _GoodEditState extends State { } else if (id == 0) { name = 'Корневая категория'; } else { - log.i('message $id'); final Category? category = await _dictionaryService.getCategoryById(id); if (category != null) { name = category.name; } - log.i('message $name'); } - setState(() { parentCategoryName = name; parentCategoryId = id;