From 8122dc94dbb4509d22c40bff058610a9bdb35f56 Mon Sep 17 00:00:00 2001 From: suvaysov Date: Mon, 21 Nov 2022 14:08:23 +0600 Subject: [PATCH] logout fix log disable bou summary information --- lib/core/redux/actions/sell_actions.dart | 2 -- lib/core/redux/actions/user_actions.dart | 7 +++-- lib/core/services/buy_service.dart | 5 +++- lib/views/login/login_view.dart | 6 ++-- lib/views/work/tabs/buy/buy_edit.dart | 36 +++++++++++++++++++----- lib/views/work/tabs/buy/buy_view.dart | 2 ++ lib/widgets/bar/products_header_bar.dart | 1 + 7 files changed, 45 insertions(+), 14 deletions(-) diff --git a/lib/core/redux/actions/sell_actions.dart b/lib/core/redux/actions/sell_actions.dart index e3e317e..a5366fd 100644 --- a/lib/core/redux/actions/sell_actions.dart +++ b/lib/core/redux/actions/sell_actions.dart @@ -60,7 +60,6 @@ ThunkAction counterOrEditSellItem( ThunkAction addSellItem({required Good good, String? excise}) { return (Store store) async { - log.i('addSellItem'); final int? appCompanyId = store.state.userState!.auth!.companyId; Transaction? transaction; @@ -135,7 +134,6 @@ ThunkAction addSellItem({required Good good, String? excise}) { ..data = jsonEncode(item.toMap()) ..transactionId = transaction.id ..createdAt = DateTime.now().toIso8601String(); - log.i(rec.toMap()); await _dbService.insert(transactionRecTableName, rec.toMap()); } diff --git a/lib/core/redux/actions/user_actions.dart b/lib/core/redux/actions/user_actions.dart index 9270ec9..4997500 100644 --- a/lib/core/redux/actions/user_actions.dart +++ b/lib/core/redux/actions/user_actions.dart @@ -110,8 +110,11 @@ Future logout(Store store) async { AuthResponse result = await _api.logout(); if (result.operation!) { _api.token = null; - store.dispatch(SetUserStateAction( - UserState(isLoading: false, auth: AuthResponse()))); + store.dispatch(SetUserStateAction(UserState( + isLoading: false, + auth: AuthResponse(), + defaultContragent: ContragentResponseEntity(), + ))); _navigation.replace(loginViewRoute); } else { _dialogService.showDialog( diff --git a/lib/core/services/buy_service.dart b/lib/core/services/buy_service.dart index e594d12..064cae8 100644 --- a/lib/core/services/buy_service.dart +++ b/lib/core/services/buy_service.dart @@ -23,6 +23,10 @@ class BuyService extends BaseService { } }; + if (filter != null) { + requestBody['filter'] = filter; + } + ResponseEntity categories = await _api.postRequest('/general_purchases_get', requestBody: requestBody); if (categories.original.data != null && @@ -111,7 +115,6 @@ class BuyService extends BaseService { ResponseEntity response = await _api.postRequest('/general_purchases_add_item', requestBody: requestBody); result = response.original.status == 'success'; - log.i(response.toJson()); } catch (e, stack) { log.e('getList', e, stack); } diff --git a/lib/views/login/login_view.dart b/lib/views/login/login_view.dart index fbe2776..59dbb30 100644 --- a/lib/views/login/login_view.dart +++ b/lib/views/login/login_view.dart @@ -31,8 +31,10 @@ class _LoginViewState extends State { @override void initState() { super.initState(); - emailController = TextEditingController(text: 'test11@gmail.com'); - passwordController = TextEditingController(text: 'qwe123'); + // emailController = TextEditingController(text: 'test11@gmail.com'); + // passwordController = TextEditingController(text: 'qwe123'); + emailController = TextEditingController(); + passwordController = TextEditingController(); } @override diff --git a/lib/views/work/tabs/buy/buy_edit.dart b/lib/views/work/tabs/buy/buy_edit.dart index c192605..b4d0d2f 100644 --- a/lib/views/work/tabs/buy/buy_edit.dart +++ b/lib/views/work/tabs/buy/buy_edit.dart @@ -18,6 +18,7 @@ import '../../../../routes/route_names.dart'; import '../../../../shared/app_colors.dart'; import '../../../../shared/ui_helpers.dart'; import '../../../../widgets/bar/products_app_bar.dart'; +import '../../../../widgets/bar/products_header_bar.dart'; class BuyEditView extends StatefulWidget { const BuyEditView({required this.invoice, Key? key}) : super(key: key); @@ -34,20 +35,20 @@ class _BuyEditViewState extends State { static const _pageSize = 20; + late double summ; + final PagingController _pagingController = PagingController(firstPageKey: 1); bool editable = false; - bool itemsExist = false; @override void initState() { - log('initState'); + summ = widget.invoice.summ ?? 0; _pagingController.addPageRequestListener((pageKey) { _fetchData(pageKey, _pageSize); }); - log('refBuyInvoiceStatusId: ${widget.invoice.refBuyInvoiceStatusId}'); if (widget.invoice.refBuyInvoiceStatusId == 1) { editable = true; } @@ -64,8 +65,14 @@ class _BuyEditViewState extends State { @override Widget build(BuildContext context) { return Scaffold( - appBar: const ProductsAppBar( + appBar: ProductsAppBar( title: 'Покупка', + backgroundColor: backgroundColor, + childHeight: 60, + child: ProductHeaderBar( + count: -1, + sum: summ, + ), ), body: Column( children: [ @@ -194,13 +201,14 @@ class _BuyEditViewState extends State { .getGoodsByNameOrEan(result as String, onlyEan: true); if (goods.isNotEmpty) { final Good good = goods.first; - bool result = await _service.addItem( - widget.invoice.id, good.id!); + bool result = + await _service.addItem(widget.invoice.id, good.id!); if (result) { _pagingController.refresh(); } else { _dialogService.showDialog( - description: 'Товара отсутсвует в остатке или ранее не' + description: + 'Товара отсутсвует в остатке или ранее не' ' использователся в системе', ); } @@ -236,6 +244,7 @@ class _BuyEditViewState extends State { itemsExist = true; }); } + updateSummary(); } void _editData(int id, double price, double count) { @@ -248,4 +257,17 @@ class _BuyEditViewState extends State { _pagingController.itemList = oldList; }); } + + Future updateSummary() async { + final List newItems = + await _service.getList(page: 1, perpage: 1, filter: [ + {'val': widget.invoice.docNumber, 'action': 'equals', 'col': 'doc_number'} + ]); + + if (newItems.isNotEmpty) { + setState(() { + summ = newItems.first.summ ?? 0; + }); + } + } } diff --git a/lib/views/work/tabs/buy/buy_view.dart b/lib/views/work/tabs/buy/buy_view.dart index 301f988..70cdfe6 100644 --- a/lib/views/work/tabs/buy/buy_view.dart +++ b/lib/views/work/tabs/buy/buy_view.dart @@ -160,4 +160,6 @@ class _BuyViewState extends State { _pagingController.appendPage(newItems, nextPageKey); } } + + } diff --git a/lib/widgets/bar/products_header_bar.dart b/lib/widgets/bar/products_header_bar.dart index 826084a..585cf4f 100644 --- a/lib/widgets/bar/products_header_bar.dart +++ b/lib/widgets/bar/products_header_bar.dart @@ -23,6 +23,7 @@ class ProductHeaderBar extends StatelessWidget { color: blackColor, fontSize: 20), ), + if(count > -1) Text( 'Товаров выбрано: $count', style: const TextStyle(