parent
b5f9291116
commit
8122dc94db
|
|
@ -60,7 +60,6 @@ ThunkAction<AppState> counterOrEditSellItem(
|
||||||
|
|
||||||
ThunkAction<AppState> addSellItem({required Good good, String? excise}) {
|
ThunkAction<AppState> addSellItem({required Good good, String? excise}) {
|
||||||
return (Store<AppState> store) async {
|
return (Store<AppState> store) async {
|
||||||
log.i('addSellItem');
|
|
||||||
final int? appCompanyId = store.state.userState!.auth!.companyId;
|
final int? appCompanyId = store.state.userState!.auth!.companyId;
|
||||||
|
|
||||||
Transaction? transaction;
|
Transaction? transaction;
|
||||||
|
|
@ -135,7 +134,6 @@ ThunkAction<AppState> addSellItem({required Good good, String? excise}) {
|
||||||
..data = jsonEncode(item.toMap())
|
..data = jsonEncode(item.toMap())
|
||||||
..transactionId = transaction.id
|
..transactionId = transaction.id
|
||||||
..createdAt = DateTime.now().toIso8601String();
|
..createdAt = DateTime.now().toIso8601String();
|
||||||
log.i(rec.toMap());
|
|
||||||
await _dbService.insert(transactionRecTableName, rec.toMap());
|
await _dbService.insert(transactionRecTableName, rec.toMap());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,8 +110,11 @@ Future<void> logout(Store<AppState> store) async {
|
||||||
AuthResponse result = await _api.logout();
|
AuthResponse result = await _api.logout();
|
||||||
if (result.operation!) {
|
if (result.operation!) {
|
||||||
_api.token = null;
|
_api.token = null;
|
||||||
store.dispatch(SetUserStateAction(
|
store.dispatch(SetUserStateAction(UserState(
|
||||||
UserState(isLoading: false, auth: AuthResponse())));
|
isLoading: false,
|
||||||
|
auth: AuthResponse(),
|
||||||
|
defaultContragent: ContragentResponseEntity(),
|
||||||
|
)));
|
||||||
_navigation.replace(loginViewRoute);
|
_navigation.replace(loginViewRoute);
|
||||||
} else {
|
} else {
|
||||||
_dialogService.showDialog(
|
_dialogService.showDialog(
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,10 @@ class BuyService extends BaseService {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (filter != null) {
|
||||||
|
requestBody['filter'] = filter;
|
||||||
|
}
|
||||||
|
|
||||||
ResponseEntity categories = await _api.postRequest('/general_purchases_get',
|
ResponseEntity categories = await _api.postRequest('/general_purchases_get',
|
||||||
requestBody: requestBody);
|
requestBody: requestBody);
|
||||||
if (categories.original.data != null &&
|
if (categories.original.data != null &&
|
||||||
|
|
@ -111,7 +115,6 @@ class BuyService extends BaseService {
|
||||||
ResponseEntity response = await _api.postRequest('/general_purchases_add_item',
|
ResponseEntity response = await _api.postRequest('/general_purchases_add_item',
|
||||||
requestBody: requestBody);
|
requestBody: requestBody);
|
||||||
result = response.original.status == 'success';
|
result = response.original.status == 'success';
|
||||||
log.i(response.toJson());
|
|
||||||
} catch (e, stack) {
|
} catch (e, stack) {
|
||||||
log.e('getList', e, stack);
|
log.e('getList', e, stack);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,8 +31,10 @@ class _LoginViewState extends State<LoginView> {
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
emailController = TextEditingController(text: 'test11@gmail.com');
|
// emailController = TextEditingController(text: 'test11@gmail.com');
|
||||||
passwordController = TextEditingController(text: 'qwe123');
|
// passwordController = TextEditingController(text: 'qwe123');
|
||||||
|
emailController = TextEditingController();
|
||||||
|
passwordController = TextEditingController();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
|
||||||
|
|
@ -18,6 +18,7 @@ import '../../../../routes/route_names.dart';
|
||||||
import '../../../../shared/app_colors.dart';
|
import '../../../../shared/app_colors.dart';
|
||||||
import '../../../../shared/ui_helpers.dart';
|
import '../../../../shared/ui_helpers.dart';
|
||||||
import '../../../../widgets/bar/products_app_bar.dart';
|
import '../../../../widgets/bar/products_app_bar.dart';
|
||||||
|
import '../../../../widgets/bar/products_header_bar.dart';
|
||||||
|
|
||||||
class BuyEditView extends StatefulWidget {
|
class BuyEditView extends StatefulWidget {
|
||||||
const BuyEditView({required this.invoice, Key? key}) : super(key: key);
|
const BuyEditView({required this.invoice, Key? key}) : super(key: key);
|
||||||
|
|
@ -34,20 +35,20 @@ class _BuyEditViewState extends State<BuyEditView> {
|
||||||
|
|
||||||
static const _pageSize = 20;
|
static const _pageSize = 20;
|
||||||
|
|
||||||
|
late double summ;
|
||||||
|
|
||||||
final PagingController<int, BuyItemResponse> _pagingController =
|
final PagingController<int, BuyItemResponse> _pagingController =
|
||||||
PagingController(firstPageKey: 1);
|
PagingController(firstPageKey: 1);
|
||||||
|
|
||||||
bool editable = false;
|
bool editable = false;
|
||||||
|
|
||||||
bool itemsExist = false;
|
bool itemsExist = false;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
log('initState');
|
summ = widget.invoice.summ ?? 0;
|
||||||
_pagingController.addPageRequestListener((pageKey) {
|
_pagingController.addPageRequestListener((pageKey) {
|
||||||
_fetchData(pageKey, _pageSize);
|
_fetchData(pageKey, _pageSize);
|
||||||
});
|
});
|
||||||
log('refBuyInvoiceStatusId: ${widget.invoice.refBuyInvoiceStatusId}');
|
|
||||||
if (widget.invoice.refBuyInvoiceStatusId == 1) {
|
if (widget.invoice.refBuyInvoiceStatusId == 1) {
|
||||||
editable = true;
|
editable = true;
|
||||||
}
|
}
|
||||||
|
|
@ -64,8 +65,14 @@ class _BuyEditViewState extends State<BuyEditView> {
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: const ProductsAppBar(
|
appBar: ProductsAppBar(
|
||||||
title: 'Покупка',
|
title: 'Покупка',
|
||||||
|
backgroundColor: backgroundColor,
|
||||||
|
childHeight: 60,
|
||||||
|
child: ProductHeaderBar(
|
||||||
|
count: -1,
|
||||||
|
sum: summ,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
|
|
@ -194,13 +201,14 @@ class _BuyEditViewState extends State<BuyEditView> {
|
||||||
.getGoodsByNameOrEan(result as String, onlyEan: true);
|
.getGoodsByNameOrEan(result as String, onlyEan: true);
|
||||||
if (goods.isNotEmpty) {
|
if (goods.isNotEmpty) {
|
||||||
final Good good = goods.first;
|
final Good good = goods.first;
|
||||||
bool result = await _service.addItem(
|
bool result =
|
||||||
widget.invoice.id, good.id!);
|
await _service.addItem(widget.invoice.id, good.id!);
|
||||||
if (result) {
|
if (result) {
|
||||||
_pagingController.refresh();
|
_pagingController.refresh();
|
||||||
} else {
|
} else {
|
||||||
_dialogService.showDialog(
|
_dialogService.showDialog(
|
||||||
description: 'Товара отсутсвует в остатке или ранее не'
|
description:
|
||||||
|
'Товара отсутсвует в остатке или ранее не'
|
||||||
' использователся в системе',
|
' использователся в системе',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -236,6 +244,7 @@ class _BuyEditViewState extends State<BuyEditView> {
|
||||||
itemsExist = true;
|
itemsExist = true;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
updateSummary();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _editData(int id, double price, double count) {
|
void _editData(int id, double price, double count) {
|
||||||
|
|
@ -248,4 +257,17 @@ class _BuyEditViewState extends State<BuyEditView> {
|
||||||
_pagingController.itemList = oldList;
|
_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);
|
_pagingController.appendPage(newItems, nextPageKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@ class ProductHeaderBar extends StatelessWidget {
|
||||||
color: blackColor,
|
color: blackColor,
|
||||||
fontSize: 20),
|
fontSize: 20),
|
||||||
),
|
),
|
||||||
|
if(count > -1)
|
||||||
Text(
|
Text(
|
||||||
'Товаров выбрано: $count',
|
'Товаров выбрано: $count',
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue