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