Browse Source

update validate field

master
daivph 5 years ago
parent
commit
97440b1826
1 changed files with 24 additions and 8 deletions
  1. +24
    -8
      lib/presentation/screens/actions/dung/widget_dung_supply.dart

+ 24
- 8
lib/presentation/screens/actions/dung/widget_dung_supply.dart View File

class _WidgetDungSupplyState extends State<WidgetDungSupply> { class _WidgetDungSupplyState extends State<WidgetDungSupply> {
final _dosageController = TextEditingController(); final _dosageController = TextEditingController();
final _quantityController = TextEditingController(); final _quantityController = TextEditingController();
final _howToUseController = TextEditingController();
final changeSelectedSupply = Get.put(ChangeSupply()); final changeSelectedSupply = Get.put(ChangeSupply());
final changeSupplyUsing = Get.put(ChangeSupplyUsing()); final changeSupplyUsing = Get.put(ChangeSupplyUsing());
final changeUnit = Get.put(ChangeUnit()); final changeUnit = Get.put(ChangeUnit());
return Container(); return Container();
} else { } else {
return Container( return Container(
height: 80,
height: 100,
child: ListView.builder( child: ListView.builder(
physics: ClampingScrollPhysics(), physics: ClampingScrollPhysics(),
scrollDirection: Axis.horizontal, scrollDirection: Axis.horizontal,
.updateListByUnitName(editedSupplyUsing.supplyUnit); .updateListByUnitName(editedSupplyUsing.supplyUnit);
changeUnit.updateSelected(editedSupplyUsing.supplyUnit); changeUnit.updateSelected(editedSupplyUsing.supplyUnit);
_dosageController.text = editedSupplyUsing.dosage; _dosageController.text = editedSupplyUsing.dosage;
_howToUseController.text = editedSupplyUsing.howToUse;
_quantityController.text = editedSupplyUsing.quantity _quantityController.text = editedSupplyUsing.quantity
.formatNumtoStringDecimal(); .formatNumtoStringDecimal();
}, },
Flexible( Flexible(
child: Text( child: Text(
"${value.currentItems[index].quantity.formatNumtoStringDecimal() ?? ""} ${value.currentItems[index].supplyUnit ?? ""}")), "${value.currentItems[index].quantity.formatNumtoStringDecimal() ?? ""} ${value.currentItems[index].supplyUnit ?? ""}")),
Flexible(
child: Text(
"${value.currentItems[index].howToUse ?? ""}")),
], ],
), ),
), ),
borderRadius: new BorderRadius.circular(8.0)), borderRadius: new BorderRadius.circular(8.0)),
onPressed: () { onPressed: () {
var currentSupply = changeSelectedSupply.currentSupply; var currentSupply = changeSelectedSupply.currentSupply;
if (currentSupply.id != null) {
var currentQuantity =
_quantityController.text.parseDoubleThousand();
if (currentSupply.id != null && currentQuantity > 0) {
var quantityWithCurrentSupplyUnit = var quantityWithCurrentSupplyUnit =
UtilAction.convertUnit( UtilAction.convertUnit(
inputValue: _quantityController.text
.parseDoubleThousand(),
inputValue: currentQuantity,
oldUnit: changeUnit.selectedUnit, oldUnit: changeUnit.selectedUnit,
newUnit: newUnit:
changeSelectedSupply.currentSupply.unit); changeSelectedSupply.currentSupply.unit);
SuppliesUsing newSup = SuppliesUsing() SuppliesUsing newSup = SuppliesUsing()
..dosage = _dosageController.text ..dosage = _dosageController.text
..howToUse = _howToUseController.text
..quantity = quantityWithCurrentSupplyUnit ..quantity = quantityWithCurrentSupplyUnit
..tbSuppliesInWarehouseId = currentSupply.id ..tbSuppliesInWarehouseId = currentSupply.id
..suppliesInWarehouseId = currentSupply.id ..suppliesInWarehouseId = currentSupply.id
borderRadius: new BorderRadius.circular(8.0)), borderRadius: new BorderRadius.circular(8.0)),
onPressed: () { onPressed: () {
var currentSupply = changeSelectedSupply.currentSupply; var currentSupply = changeSelectedSupply.currentSupply;
if (currentSupply.id != null) {
var currentQuantity =
_quantityController.text.parseDoubleThousand();
if (currentSupply.id != null && currentQuantity > 0) {
var quantityWithCurrentSupplyUnit = var quantityWithCurrentSupplyUnit =
UtilAction.convertUnit( UtilAction.convertUnit(
inputValue: _quantityController.text
.parseDoubleThousand(),
inputValue: currentQuantity,
oldUnit: changeUnit.selectedUnit, oldUnit: changeUnit.selectedUnit,
newUnit: newUnit:
changeSelectedSupply.currentSupply.unit); changeSelectedSupply.currentSupply.unit);
SuppliesUsing newSup = SuppliesUsing() SuppliesUsing newSup = SuppliesUsing()
..dosage = _dosageController.text ..dosage = _dosageController.text
..howToUse = _howToUseController.text
..quantity = quantityWithCurrentSupplyUnit ..quantity = quantityWithCurrentSupplyUnit
..tbSuppliesInWarehouseId = currentSupply.id ..tbSuppliesInWarehouseId = currentSupply.id
..suppliesInWarehouseId = currentSupply.id ..suppliesInWarehouseId = currentSupply.id
Container( Container(
width: double.infinity, width: double.infinity,
child: Text( child: Text(
"Tên thương mại",
"Tên thương mại *",
style: TextStyle(color: Colors.black54, fontSize: 13.0), style: TextStyle(color: Colors.black54, fontSize: 13.0),
), ),
), ),
child: _dropdownUnitTypes(), child: _dropdownUnitTypes(),
)), )),
]), ]),
TextFormField(
keyboardType: TextInputType.text,
controller: _howToUseController,
decoration: InputDecoration(labelText: "Phương pháp sử dụng"),
onSaved: (newValue) {},
),
_buttonInForm() _buttonInForm()
], ],
)); ));
changeSupplyUsing.changeIndexEdit(-1); changeSupplyUsing.changeIndexEdit(-1);
changeButton.resetValue(); changeButton.resetValue();
_dosageController.text = ""; _dosageController.text = "";
_howToUseController.text = "";
_quantityController.text = ""; _quantityController.text = "";
changeUnit.initValue(); changeUnit.initValue();
changeSelectedSupply.initValue(); changeSelectedSupply.initValue();

Loading…
Cancel
Save