device_manage_update_page.dart 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. import 'package:deus_app/common/dialog/CloseTaskDialog.dart';
  2. import 'package:deus_app/common/style/TitleBar.dart';
  3. import 'package:deus_app/common/style/gsy_style.dart';
  4. import 'package:deus_app/common/utils/ConstantString.dart';
  5. import 'package:deus_app/common/utils/DioUtil.dart';
  6. import 'package:deus_app/common/utils/ToastUtils.dart';
  7. import 'package:deus_app/main.dart';
  8. import 'package:deus_app/model/equipment_info_entity.dart';
  9. import 'package:deus_app/widget/gsy_flex_button.dart';
  10. import 'package:flutter/material.dart';
  11. class DeviceManageUpdatePage extends StatefulWidget {
  12. final EquipmentInfoData data;
  13. const DeviceManageUpdatePage({super.key, required this.data});
  14. @override
  15. State createState() {
  16. return _DeviceManageUpdatePage(data);
  17. }
  18. }
  19. class _DeviceManageUpdatePage extends State<DeviceManageUpdatePage>{
  20. EquipmentInfoData data;
  21. _DeviceManageUpdatePage(this.data);
  22. TextEditingController _finenessAController= TextEditingController();
  23. TextEditingController _finenessBController= TextEditingController();
  24. TextEditingController _holeCountAController= TextEditingController();
  25. TextEditingController _holeCountBController= TextEditingController();
  26. TextEditingController _speedAController= TextEditingController();
  27. TextEditingController _speedBController= TextEditingController();
  28. @override
  29. Widget build(BuildContext context) {
  30. return Scaffold(
  31. appBar: TitleBar().backAppbar("修改参数"),
  32. backgroundColor: const Color(0xfff2f2f2),
  33. body: SingleChildScrollView (
  34. child: Column(
  35. crossAxisAlignment: CrossAxisAlignment.center,
  36. children:<Widget> [
  37. Padding(
  38. padding: const EdgeInsets.only(top: 50.0, left: 10, right: 10),
  39. child: Row(children: [
  40. Expanded(
  41. flex: 1,
  42. child: Text(
  43. 'A测速度:',
  44. style: TextStyle(
  45. color: Colors.black,
  46. fontSize: GSYConstant.smallTextSize,
  47. fontWeight: FontWeight.bold,
  48. ),
  49. ),
  50. ),
  51. Expanded(
  52. child: Container(
  53. height: 40,
  54. child: TextField(
  55. decoration: InputDecoration(
  56. border: OutlineInputBorder(),
  57. ),
  58. controller: _speedAController,
  59. style: TextStyle(fontSize: 14),
  60. onChanged: (value) {
  61. setState(() {
  62. data.speedA=value;
  63. });
  64. },
  65. ),
  66. ),
  67. flex: 3,
  68. ),
  69. ]),
  70. ),
  71. Padding(
  72. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  73. child: Row(children: [
  74. Expanded(
  75. flex: 1,
  76. child: Text(
  77. 'B侧速度:',
  78. style: TextStyle(
  79. color: Colors.black,
  80. fontSize: GSYConstant.smallTextSize,
  81. fontWeight: FontWeight.bold,
  82. ),
  83. ),
  84. ),
  85. Expanded(
  86. child: Container(
  87. height: 40,
  88. child: TextField(
  89. controller: _speedBController,
  90. decoration: InputDecoration(border: OutlineInputBorder()),
  91. style: TextStyle(fontSize: 14),
  92. onChanged: (value) {
  93. setState(() {
  94. data.speedB=value;
  95. });
  96. },
  97. ),
  98. ),
  99. flex: 3,
  100. ),
  101. ]),
  102. ),
  103. Padding(
  104. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  105. child: Row(children: [
  106. Expanded(
  107. flex: 1,
  108. child: Text(
  109. 'A侧纤度:',
  110. style: TextStyle(
  111. color: Colors.black,
  112. fontSize: GSYConstant.smallTextSize,
  113. fontWeight: FontWeight.bold,
  114. ),
  115. ),
  116. ),
  117. Expanded(
  118. child: Container(
  119. height: 40,
  120. child: TextField(
  121. controller: _finenessAController,
  122. decoration: InputDecoration(border: OutlineInputBorder()),
  123. style: TextStyle(fontSize: 14),
  124. onChanged: (value) {
  125. setState(() {
  126. data.finenessA=value;
  127. });
  128. },
  129. ),
  130. ),
  131. flex: 3,
  132. ),
  133. ]),
  134. ),
  135. Padding(
  136. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  137. child: Row(children: [
  138. Expanded(
  139. flex: 1,
  140. child: Text(
  141. 'B侧纤度:',
  142. style: TextStyle(
  143. color: Colors.black,
  144. fontSize: GSYConstant.smallTextSize,
  145. fontWeight: FontWeight.bold,
  146. ),
  147. ),
  148. ),
  149. Expanded(
  150. flex: 3,
  151. child: Container(
  152. height: 40,
  153. child: TextField(
  154. controller: _finenessBController,
  155. decoration: InputDecoration(border: OutlineInputBorder()),
  156. style: TextStyle(fontSize: 14),
  157. onChanged: (value) {
  158. setState(() {
  159. data.finenessB=value;
  160. });
  161. },
  162. ),
  163. ),
  164. ),
  165. ]),
  166. ),
  167. Padding(
  168. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  169. child: Row(children: [
  170. Expanded(
  171. flex: 1,
  172. child: Text(
  173. 'A侧孔数:',
  174. style: TextStyle(
  175. color: Colors.black,
  176. fontSize: GSYConstant.smallTextSize,
  177. fontWeight: FontWeight.bold,
  178. ),
  179. ),
  180. ),
  181. Expanded(
  182. flex: 3,
  183. child: Container(
  184. height: 40,
  185. child: TextField(
  186. controller: _holeCountAController,
  187. decoration: InputDecoration(border: OutlineInputBorder()),
  188. style: TextStyle(fontSize: 14),
  189. onChanged: (value) {
  190. setState(() {
  191. data.holeCountA=value;
  192. });
  193. },
  194. ),
  195. ),
  196. ),
  197. ]),
  198. ),
  199. Padding(
  200. padding: const EdgeInsets.only(top: 20.0, left: 10, right: 10),
  201. child: Row(children: [
  202. Expanded(
  203. flex: 1,
  204. child: Text(
  205. 'B侧孔数:',
  206. style: TextStyle(
  207. color: Colors.black,
  208. fontSize: GSYConstant.smallTextSize,
  209. fontWeight: FontWeight.bold,
  210. ),
  211. ),
  212. ),
  213. Expanded(
  214. flex: 3,
  215. child: Container(
  216. height: 40,
  217. child: TextField(
  218. controller: _holeCountBController,
  219. decoration: InputDecoration(border: OutlineInputBorder()),
  220. style: TextStyle(fontSize: 14),
  221. onChanged: (value) {
  222. setState(() {
  223. data.holeCountB=value;
  224. });
  225. },
  226. ),
  227. ),
  228. ),
  229. ]),
  230. ),
  231. SizedBox(
  232. height: 30,
  233. ),
  234. _getButton()
  235. ],
  236. ),
  237. ),
  238. );
  239. }
  240. parameter() async {
  241. var result = await DioUtil().request("equipment/parameter",
  242. method: DioMethod.post, data: {'id':data.id,'finenessA':data.finenessA,'finenessB':data.finenessB
  243. ,'holeCountA':data.holeCountA,'holeCountB':data.holeCountB,'speedA':data.speedA,'speedB':data.speedB});
  244. if (result['code']== 0) {
  245. setState(() {
  246. //发出事件
  247. eventBus.fire(Object());
  248. Navigator.pop(context);
  249. });
  250. } else {
  251. showToast(result['msg']);
  252. }
  253. }
  254. @override
  255. void initState() {
  256. super.initState();
  257. _finenessAController=TextEditingController(text: data.finenessA);
  258. _finenessBController=TextEditingController(text: data.finenessB);
  259. _holeCountAController=TextEditingController(text: data.holeCountA);
  260. _holeCountBController=TextEditingController(text: data.holeCountB);
  261. _speedAController=TextEditingController(text: data.speedA);
  262. _speedBController=TextEditingController(text: data.speedB);
  263. }
  264. Widget _getButton() {
  265. return Container(
  266. height: 50,
  267. width: double.infinity,
  268. margin: EdgeInsets.all(10),
  269. decoration: BoxDecoration(
  270. borderRadius: BorderRadius.circular(4.0),
  271. ),
  272. child: GSYFlexButton(
  273. text: ConstantString.updateText,
  274. color: Color(0xFF4875EC),
  275. textColor: GSYColors.textWhite,
  276. fontSize: 16,
  277. onPress: (){
  278. CloseTaskDialog.showAlertDialog(context, () {
  279. parameter();
  280. }, '您确认修改参数?');
  281. },
  282. ),
  283. );
  284. }
  285. }