parent
b5f9291116
commit
8122dc94db
|
|
@ -60,7 +60,6 @@ ThunkAction<AppState> counterOrEditSellItem(
|
|||
|
||||
ThunkAction<AppState> addSellItem({required Good good, String? excise}) {
|
||||
return (Store<AppState> store) async {
|
||||
log.i('addSellItem');
|
||||
final int? appCompanyId = store.state.userState!.auth!.companyId;
|
||||
|
||||
Transaction? transaction;
|
||||
|
|
@ -135,7 +134,6 @@ ThunkAction<AppState> 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());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,8 +110,11 @@ Future<void> logout(Store<AppState> 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(
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,8 +31,10 @@ class _LoginViewState extends State<LoginView> {
|
|||
@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
|
||||
|
|
|
|||
|
|
@ -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<BuyEditView> {
|
|||
|
||||
static const _pageSize = 20;
|
||||
|
||||
late double summ;
|
||||
|
||||
final PagingController<int, BuyItemResponse> _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<BuyEditView> {
|
|||
@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<BuyEditView> {
|
|||
.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<BuyEditView> {
|
|||
itemsExist = true;
|
||||
});
|
||||
}
|
||||
updateSummary();
|
||||
}
|
||||
|
||||
void _editData(int id, double price, double count) {
|
||||
|
|
@ -248,4 +257,17 @@ class _BuyEditViewState extends State<BuyEditView> {
|
|||
_pagingController.itemList = oldList;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> updateSummary() async {
|
||||
final List<BuyInvoiceResponse> 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;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -160,4 +160,6 @@ class _BuyViewState extends State<BuyView> {
|
|||
_pagingController.appendPage(newItems, nextPageKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ class ProductHeaderBar extends StatelessWidget {
|
|||
color: blackColor,
|
||||
fontSize: 20),
|
||||
),
|
||||
if(count > -1)
|
||||
Text(
|
||||
'Товаров выбрано: $count',
|
||||
style: const TextStyle(
|
||||
|
|
|
|||
Loading…
Reference in New Issue