mirror of
https://git.meshkee.com/applications/cssd.git
synced 2026-10-13 02:38:56 +03:30
Fix barcode scanner bug in add package select item
This commit is contained in:
@@ -43,18 +43,11 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
// var isDuplicateItem = false;
|
|
||||||
changeItemVal(String value, int index) {
|
changeItemVal(String value, int index) {
|
||||||
for (var item in filteredItems!) {
|
for (var item in filteredItems!) {
|
||||||
// if(itemValues.length > 1 && value != itemValues[index-1].text){
|
|
||||||
if (item.udi_name == value) {
|
if (item.udi_name == value) {
|
||||||
itemValues[index].text = item.id;
|
itemValues[index].text = item.id;
|
||||||
}
|
}
|
||||||
// }else {
|
|
||||||
// // isDuplicateItem = true;
|
|
||||||
// print("it is a problem!!!!!!!!!!");
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
@@ -85,12 +78,13 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
changeItemValByScan(String value, int index) {
|
changeItemValByScan(String value, int index) async {
|
||||||
for (var item in filteredItems!) {
|
filteredItems?.forEach((item) {
|
||||||
if (item.udi == value) {
|
if (item.id == value) {
|
||||||
itemValues[index].text = "${item.name} - ${item.udi}";
|
itemValues[index].text = "${item.name} - ${item.udi}";
|
||||||
}
|
}
|
||||||
}
|
print("item value : ${itemValues[index].text}");
|
||||||
|
});
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -353,8 +347,7 @@ class PackageProvider extends ChangeNotifier {
|
|||||||
createdAt: item['created_at'],
|
createdAt: item['created_at'],
|
||||||
id: item['id'].toString(),
|
id: item['id'].toString(),
|
||||||
name: item['name'],
|
name: item['name'],
|
||||||
status: item['status']
|
status: item['status']),
|
||||||
),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pageNumber += 1;
|
pageNumber += 1;
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import 'package:cssd/models/item_model.dart';
|
|
||||||
import 'package:cssd/providers/packages.dart';
|
import 'package:cssd/providers/packages.dart';
|
||||||
import 'package:cssd/utils/scan.dart';
|
import 'package:cssd/utils/scan.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
@@ -23,6 +22,7 @@ class AddItemBox extends StatelessWidget {
|
|||||||
|
|
||||||
final double _deviceBlockSize;
|
final double _deviceBlockSize;
|
||||||
final TextEditingController values;
|
final TextEditingController values;
|
||||||
|
|
||||||
// final List<Map<String, dynamic>> vals;
|
// final List<Map<String, dynamic>> vals;
|
||||||
final List<String> vals;
|
final List<String> vals;
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ class AddItemBox extends StatelessWidget {
|
|||||||
final String text;
|
final String text;
|
||||||
final Color? iconColor;
|
final Color? iconColor;
|
||||||
final bool hasRemoveButton;
|
final bool hasRemoveButton;
|
||||||
|
|
||||||
// final List<ItemResultObject> filteredItems;
|
// final List<ItemResultObject> filteredItems;
|
||||||
// final String scanUdi;
|
// final String scanUdi;
|
||||||
|
|
||||||
@@ -117,9 +118,11 @@ class AddItemBox extends StatelessWidget {
|
|||||||
height: 70,
|
height: 70,
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.symmetric(horizontal: 0),
|
const EdgeInsets.symmetric(horizontal: 0),
|
||||||
child: Consumer<PackageProvider>(builder: (context, packageProvider, _) {
|
child: Consumer<PackageProvider>(
|
||||||
|
builder: (context, packageProvider, _) {
|
||||||
return TextFormField(
|
return TextFormField(
|
||||||
controller: values,
|
controller:
|
||||||
|
packageProvider.itemValues[index],
|
||||||
validator: (val) {
|
validator: (val) {
|
||||||
if (val!.isEmpty) {
|
if (val!.isEmpty) {
|
||||||
return 'Item required!';
|
return 'Item required!';
|
||||||
@@ -138,9 +141,11 @@ class AddItemBox extends StatelessWidget {
|
|||||||
fontSize: 4 * _deviceBlockSize,
|
fontSize: 4 * _deviceBlockSize,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},),
|
},
|
||||||
|
),
|
||||||
),
|
),
|
||||||
isDense: true,
|
isDense: true,
|
||||||
|
// selectedItemBuilder: packageProvider.itemValues[index].value,
|
||||||
items: vals.map((val) {
|
items: vals.map((val) {
|
||||||
return new DropdownMenuItem<String>(
|
return new DropdownMenuItem<String>(
|
||||||
enabled: isEnabled,
|
enabled: isEnabled,
|
||||||
@@ -166,7 +171,7 @@ class AddItemBox extends StatelessWidget {
|
|||||||
InkWell(
|
InkWell(
|
||||||
onTap: () {
|
onTap: () {
|
||||||
scan().then(
|
scan().then(
|
||||||
(String result) {
|
(String result) async {
|
||||||
if (result == 'cancel') {
|
if (result == 'cancel') {
|
||||||
print('cancel');
|
print('cancel');
|
||||||
} else if (result == 'error') {
|
} else if (result == 'error') {
|
||||||
@@ -174,8 +179,8 @@ class AddItemBox extends StatelessWidget {
|
|||||||
} else if (result == 'access') {
|
} else if (result == 'access') {
|
||||||
print('access');
|
print('access');
|
||||||
} else {
|
} else {
|
||||||
print(result);
|
await Provider.of<PackageProvider>(
|
||||||
Provider.of<PackageProvider>(context,
|
context,
|
||||||
listen: false)
|
listen: false)
|
||||||
.changeItemValByScan(result, index);
|
.changeItemValByScan(result, index);
|
||||||
isEnabled = false;
|
isEnabled = false;
|
||||||
|
|||||||
@@ -41,6 +41,14 @@ class PackageAddSaveButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
List<String> items = [];
|
List<String> items = [];
|
||||||
for (TextEditingController item in itemValues) {
|
for (TextEditingController item in itemValues) {
|
||||||
|
print(item.text);
|
||||||
|
if (item.text.toString().contains(" ")) {
|
||||||
|
packageProvider.filteredItems?.forEach((element) {
|
||||||
|
if (element.udi_name.toString() == item.text.toString()) {
|
||||||
|
items.add(element.id.toString());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else
|
||||||
items.add(item.text);
|
items.add(item.text);
|
||||||
}
|
}
|
||||||
items = items.toSet().toList();
|
items = items.toSet().toList();
|
||||||
|
|||||||
Reference in New Issue
Block a user