Browse Source

fix Bug #7905

master
daivph 5 years ago
parent
commit
5aa9e94117
6 changed files with 91 additions and 21 deletions
  1. +10
    -3
      lib/presentation/screens/actions/dung/widget_dung_supply.dart
  2. +10
    -3
      lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart
  3. +3
    -1
      lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart
  4. +10
    -3
      lib/presentation/screens/actions/plant/widget_plant_supply.dart
  5. +10
    -3
      lib/presentation/screens/actions/spraying/widget_spraying_supply.dart
  6. +48
    -8
      lib/presentation/screens/resources/sc_resource_helper.dart

+ 10
- 3
lib/presentation/screens/actions/dung/widget_dung_supply.dart View File

padding: padding:
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
onPressed: () { onPressed: () {
var currentIndexEdit = changeSupplyUsing.currentIndex;
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute( .push(MaterialPageRoute(
builder: (_) => ResourceHelperScreen( builder: (_) => ResourceHelperScreen(
titleName: "Phân bón",
type: ConstCommon.supplyTypeDung,
selectedId: changeSelectedSupply.selectedSupplyId),
titleName: "Phân bón",
type: ConstCommon.supplyTypeDung,
selectedId: changeSelectedSupply.selectedSupplyId,
currentItems: changeSupplyUsing.currentItems,
currentEditId: (currentIndexEdit >= 0)
? changeSupplyUsing.currentItems[currentIndexEdit]
.tbSuppliesInWarehouseId
: -1,
),
fullscreenDialog: false)) fullscreenDialog: false))
.then((value) { .then((value) {
if (value != null) { if (value != null) {

+ 10
- 3
lib/presentation/screens/actions/harvest_process/widget_harvest_process_supply.dart View File

padding: padding:
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
onPressed: () { onPressed: () {
var currentIndexEdit = changeSupplyUsing.currentIndex;
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute( .push(MaterialPageRoute(
builder: (_) => ResourceHelperScreen( builder: (_) => ResourceHelperScreen(
titleName: "Hoá chất xử lý",
type: ConstCommon.supplyTypeAll,
selectedId: changeSelectedSupply.selectedSupplyId),
titleName: "Hoá chất xử lý",
type: ConstCommon.supplyTypeAll,
selectedId: changeSelectedSupply.selectedSupplyId,
currentItems: changeSupplyUsing.currentItems,
currentEditId: (currentIndexEdit >= 0)
? changeSupplyUsing.currentItems[currentIndexEdit]
.tbSuppliesInWarehouseId
: -1,
),
fullscreenDialog: false)) fullscreenDialog: false))
.then((value) { .then((value) {
if (value != null) { if (value != null) {

+ 3
- 1
lib/presentation/screens/actions/nursery/sc_edit_action_nursery.dart View File

builder: (_) => ResourceHelperScreen( builder: (_) => ResourceHelperScreen(
titleName: "Giá thể", titleName: "Giá thể",
type: ConstCommon.supplyTypeSubStrate, type: ConstCommon.supplyTypeSubStrate,
selectedId: Get.find<ChangeSupply>().selectedSupplyId),
selectedId: Get.find<ChangeSupply>().selectedSupplyId,
currentItems: [],
currentEditId: -1),
fullscreenDialog: false)) fullscreenDialog: false))
.then((value) { .then((value) {
if (value != null) { if (value != null) {

+ 10
- 3
lib/presentation/screens/actions/plant/widget_plant_supply.dart View File

padding: padding:
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
onPressed: () { onPressed: () {
var currentIndexEdit = changeSupplyUsing.currentIndex;
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute( .push(MaterialPageRoute(
builder: (_) => ResourceHelperScreen( builder: (_) => ResourceHelperScreen(
titleName: "Hoá chất xử lý",
type: ConstCommon.supplyTypeAll,
selectedId: changeSelectedSupply.selectedSupplyId),
titleName: "Hoá chất xử lý",
type: ConstCommon.supplyTypeAll,
selectedId: changeSelectedSupply.selectedSupplyId,
currentItems: changeSupplyUsing.currentItems,
currentEditId: (currentIndexEdit >= 0)
? changeSupplyUsing.currentItems[currentIndexEdit]
.tbSuppliesInWarehouseId
: -1,
),
fullscreenDialog: false)) fullscreenDialog: false))
.then((value) { .then((value) {
if (value != null) { if (value != null) {

+ 10
- 3
lib/presentation/screens/actions/spraying/widget_spraying_supply.dart View File

padding: padding:
EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0), EdgeInsets.only(top: 0.0, right: 0.0, bottom: 0.0, left: 0.0),
onPressed: () { onPressed: () {
var currentIndexEdit = changeSupplyUsing.currentIndex;
Navigator.of(context) Navigator.of(context)
.push(MaterialPageRoute( .push(MaterialPageRoute(
builder: (_) => ResourceHelperScreen( builder: (_) => ResourceHelperScreen(
titleName: "Thuốc BVTV",
type: ConstCommon.supplyTypeProtectPlant,
selectedId: changeSelectedSupply.selectedSupplyId),
titleName: "Thuốc BVTV",
type: ConstCommon.supplyTypeProtectPlant,
selectedId: changeSelectedSupply.selectedSupplyId,
currentItems: changeSupplyUsing.currentItems,
currentEditId: (currentIndexEdit >= 0)
? changeSupplyUsing.currentItems[currentIndexEdit]
.tbSuppliesInWarehouseId
: -1,
),
fullscreenDialog: false)) fullscreenDialog: false))
.then((value) { .then((value) {
if (value != null) { if (value != null) {

+ 48
- 8
lib/presentation/screens/resources/sc_resource_helper.dart View File

import 'package:farm_tpf/custom_model/SuppliesUsing.dart';
import 'package:farm_tpf/custom_model/Supply.dart'; import 'package:farm_tpf/custom_model/Supply.dart';
import 'package:farm_tpf/data/repository/repository.dart'; import 'package:farm_tpf/data/repository/repository.dart';
import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart'; import 'package:farm_tpf/presentation/custom_widgets/bottom_loader.dart';
final String type; final String type;
final int selectedId; final int selectedId;
final String titleName; final String titleName;
final List<SuppliesUsing> currentItems;
final int currentEditId;
ResourceHelperScreen( ResourceHelperScreen(
{@required this.type, {@required this.type,
@required this.selectedId, @required this.selectedId,
@required this.titleName});
@required this.titleName,
@required this.currentItems,
@required this.currentEditId});
@override @override
_ResourceHelperScreenState createState() => _ResourceHelperScreenState(); _ResourceHelperScreenState createState() => _ResourceHelperScreenState();
} }
selectedId: widget.selectedId, selectedId: widget.selectedId,
type: widget.type, type: widget.type,
titleName: widget.titleName, titleName: widget.titleName,
currentItems: widget.currentItems,
currentEditId: widget.currentEditId,
), ),
); );
} }
final int selectedId; final int selectedId;
final String type; final String type;
final String titleName; final String titleName;
final List<SuppliesUsing> currentItems;
final int currentEditId;
HoldInfinityWidget( HoldInfinityWidget(
{@required this.selectedId, {@required this.selectedId,
@required this.type, @required this.type,
@required this.titleName});
@required this.titleName,
@required this.currentItems,
@required this.currentEditId});
final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>(); final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
child: InfinityView( child: InfinityView(
selectedId: selectedId, selectedId: selectedId,
type: type, type: type,
currentItems: currentItems,
currentEditId: currentEditId,
)) ))
], ],
)); ));
class InfinityView extends StatefulWidget { class InfinityView extends StatefulWidget {
final int selectedId; final int selectedId;
final String type; final String type;
InfinityView({@required this.selectedId, @required this.type});
final List<SuppliesUsing> currentItems;
final int currentEditId;
InfinityView(
{@required this.selectedId,
@required this.type,
@required this.currentItems,
@required this.currentEditId});
@override @override
_InfinityViewState createState() => _InfinityViewState(); _InfinityViewState createState() => _InfinityViewState();
} }
itemBuilder: (BuildContext context, int index) { itemBuilder: (BuildContext context, int index) {
return index >= state.items.length return index >= state.items.length
? BottomLoader() ? BottomLoader()
: ItemInfinityWidget(item: state.items[index]);
: ItemInfinityWidget(
item: state.items[index],
currentItems: widget.currentItems,
currentEditId: widget.currentEditId,
);
}, },
itemCount: state.items.length), itemCount: state.items.length),
onRefresh: () async { onRefresh: () async {


class ItemInfinityWidget extends StatelessWidget { class ItemInfinityWidget extends StatelessWidget {
final Supply item; final Supply item;
final List<SuppliesUsing> currentItems;
final int currentEditId;


const ItemInfinityWidget({Key key, @required this.item}) : super(key: key);
const ItemInfinityWidget(
{Key key,
@required this.item,
@required this.currentItems,
@required this.currentEditId})
: super(key: key);


@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
if (value.quantity <= 0) { if (value.quantity <= 0) {
Utils.showSnackBarWarning(message: "Vật tư đã hết"); Utils.showSnackBarWarning(message: "Vật tư đã hết");
} else { } else {
//close nackbar if open
if (Get.isSnackbarOpen) Get.back();
Navigator.of(context).pop(value);
var editedId = (currentEditId > 0) ? currentEditId : -1;
if (currentItems
.map((e) => e.tbSuppliesInWarehouseId)
.contains(item.id) &&
item.id != editedId) {
Utils.showSnackBarWarning(
message:
"Vật tư đã được thêm, vui lòng chọn vật tư khác");
} else {
//close nackbar if open
if (Get.isSnackbarOpen) Get.back();
Navigator.of(context).pop(value);
}
} }
}), }),
)), )),

Loading…
Cancel
Save