lift_create_page.dart 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159
  1. import 'package:flutter/cupertino.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:flutter/material.dart';
  4. import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
  5. import 'package:keyboard_actions/keyboard_actions.dart';
  6. import 'package:liftmanager/internal/lift/lift_router.dart';
  7. import 'package:liftmanager/internal/lift/model/lift_brand_entity.dart';
  8. import 'package:liftmanager/internal/lift/model/lift_item.dart';
  9. import 'package:liftmanager/internal/project/project_router.dart';
  10. import 'package:liftmanager/net/api_service.dart';
  11. import 'package:liftmanager/res/resources.dart';
  12. import 'package:liftmanager/routers/fluro_navigator.dart';
  13. import 'package:liftmanager/utils/theme_utils.dart';
  14. import 'package:liftmanager/utils/toast.dart';
  15. import 'package:liftmanager/widgets/app_bar.dart';
  16. import 'package:liftmanager/widgets/click_item.dart';
  17. import 'package:liftmanager/widgets/text_field_item.dart';
  18. class LiftCreatePage extends StatefulWidget {
  19. LiftCreatePage(this.projectId, {this.item});
  20. final String projectId;
  21. LiftItem item;
  22. @override
  23. State<StatefulWidget> createState() {
  24. if (item == null) {
  25. item = LiftItem();
  26. }
  27. return LiftCreatePageState(this.item);
  28. }
  29. }
  30. class LiftCreatePageState extends State<LiftCreatePage> {
  31. LiftCreatePageState(this.item);
  32. List<Widget> liftData = [];
  33. var liftTypeArr = ["曳引梯", "液压梯", "杂物梯", "自动扶梯", "自动人行道"];
  34. var clampTypeArr = ["瞬时式安全钳", "渐进式安全钳"];
  35. var liftUsageArr = ["货梯", "客梯", "医梯", "观光梯", "杂物梯", "别墅梯", "扶梯", "人行道"];
  36. LiftItem item;
  37. @override
  38. void initState() {
  39. super.initState();
  40. liftNotif();
  41. }
  42. liftNotif() {
  43. liftData.clear();
  44. liftData = _commontHeader();
  45. if (item.category == 1) {
  46. liftData.addAll(_yeyintiList());
  47. } else if (item.category == 2) {
  48. liftData.addAll(_yeyatiList());
  49. } else if (item.category == 3) {
  50. liftData.addAll(_zawutiList());
  51. } else if (item.category == 4) {
  52. liftData.addAll(_ftList());
  53. } else if (item.category == 5) {
  54. liftData.addAll(_ftList());
  55. liftData.addAll(_ftrxd());
  56. }
  57. liftData.addAll(_commontFooter());
  58. setState(() {});
  59. }
  60. _commontHeader() {
  61. return [
  62. TextFieldItem(
  63. title: "设备注册代码",
  64. isMust: true,
  65. enabled: item.id.length == 0,
  66. content: "${item.registrationCode}",
  67. controller: TextEditingController(),
  68. hintText: "请填写设备注册代码",
  69. focusNode: FocusNode(),
  70. onChanged: (res) {
  71. print(res);
  72. item.registrationCode = res;
  73. setState(() {});
  74. },
  75. ),
  76. ClickItem(
  77. title: "电梯类别",
  78. isMust: true,
  79. content: item.getCategoryName(),
  80. hintText: "请选择电梯类别",
  81. onTap: () {
  82. _showBottomSheet(liftTypeArr, (index) {
  83. item.category = index + 1;
  84. if (item.category > 3) {
  85. item.liftType = 2;
  86. } else {
  87. item.liftType = 1;
  88. }
  89. liftNotif();
  90. });
  91. }),
  92. ClickItem(
  93. title: "地图位置",
  94. content: "${item.coordinate.length > 0 ? "已定位" : "未定位"}",
  95. hintText: "请选择地图位置",
  96. onTap: () {
  97. NavigatorUtils.pushResult(
  98. context,
  99. "${LiftRouter.liftMapPage}?type=check&coordinate=" +
  100. item.coordinate, (result) {
  101. print(result);
  102. if (result != null && "${result}".contains(",")) {
  103. setState(() {
  104. item.coordinate = result;
  105. liftNotif();
  106. });
  107. }
  108. });
  109. }),
  110. TextFieldItem(
  111. title: "设备出厂编号",
  112. content: "${item.factoryCode}",
  113. controller: TextEditingController(),
  114. hintText: "请填写设备出厂编号",
  115. focusNode: FocusNode(),
  116. onChanged: (res) {
  117. item.factoryCode = res;
  118. },
  119. ),
  120. TextFieldItem(
  121. title: "设备型号",
  122. content: "${item.liftModel}",
  123. controller: TextEditingController(),
  124. hintText: "请填写设备型号",
  125. focusNode: FocusNode(),
  126. onChanged: (res) {
  127. item.liftModel = res;
  128. },
  129. ),
  130. TextFieldItem(
  131. title: "设备安装地址",
  132. isMust: true,
  133. content: "${item.devicePosition}",
  134. controller: TextEditingController(),
  135. hintText: "请填写设备安装地址",
  136. focusNode: FocusNode(),
  137. onChanged: (res) {
  138. item.devicePosition = res;
  139. },
  140. ),
  141. TextFieldItem(
  142. title: "设备内部编号",
  143. isMust: true,
  144. content: "${item.useCompanyCode}",
  145. controller: TextEditingController(),
  146. hintText: "请填写设备注册代码",
  147. focusNode: FocusNode(),
  148. onChanged: (res) {
  149. item.useCompanyCode = res;
  150. },
  151. ),
  152. TextFieldItem(
  153. title: "设备制造商",
  154. content: "${item.factory}",
  155. controller: TextEditingController(),
  156. hintText: "请填写设备制造商",
  157. focusNode: FocusNode(),
  158. onChanged: (res) {
  159. item.factory = res;
  160. },
  161. ),
  162. TextFieldItem(
  163. title: "进口设备代理商",
  164. content: "${item.agency}",
  165. controller: TextEditingController(),
  166. hintText: "请填写进口设备代理商",
  167. focusNode: FocusNode(),
  168. onChanged: (res) {
  169. item.agency = res;
  170. },
  171. ),
  172. TextFieldItem(
  173. title: "自定义编号",
  174. content: "${item.customNumber}",
  175. controller: TextEditingController(),
  176. hintText: "请填写自定义编号",
  177. focusNode: FocusNode(),
  178. onChanged: (res) {
  179. item.customNumber = res;
  180. },
  181. ),
  182. ClickItem(
  183. title: "设备出厂日期",
  184. content: "${item.manufactureDate}",
  185. hintText: "请选择设备出厂日期",
  186. onTap: () {
  187. _selectTime((String time) {
  188. setState(() {
  189. item.manufactureDate = time.split(" ")[0];
  190. liftNotif();
  191. });
  192. });
  193. }),
  194. TextFieldItem(
  195. title: "设备改造单位",
  196. content: "${item.reformCompany}",
  197. controller: TextEditingController(),
  198. hintText: "请填写设备改造单位",
  199. focusNode: FocusNode(),
  200. onChanged: (res) {
  201. item.reformCompany = res;
  202. },
  203. ),
  204. ClickItem(
  205. title: "设备改造日期",
  206. content: "${item.reformDate}",
  207. hintText: "请选择设备改造日期",
  208. onTap: () {
  209. _selectTime((String time) {
  210. setState(() {
  211. item.reformDate = time.split(" ")[0];
  212. liftNotif();
  213. });
  214. });
  215. }),
  216. TextFieldItem(
  217. title: "设备安装单位",
  218. content: "${item.installCompany}",
  219. controller: TextEditingController(),
  220. hintText: "请填写设备安装单位",
  221. focusNode: FocusNode(),
  222. onChanged: (res) {
  223. item.installCompany = res;
  224. },
  225. ),
  226. ClickItem(
  227. title: "设备安装日期",
  228. isMust: true,
  229. content: "${item.installDate}",
  230. hintText: "请选择安装日期",
  231. onTap: () {
  232. _selectTime((String time) {
  233. setState(() {
  234. item.installDate = time.split(" ")[0];
  235. liftNotif();
  236. });
  237. });
  238. }),
  239. ClickItem(
  240. title: "电梯维保负责人",
  241. isMust: true,
  242. content: "${item.workerName}",
  243. hintText: "请选择电梯维保负责人",
  244. onTap: () {
  245. NavigatorUtils.pushResult(context,
  246. "${ProjectRouter.projectUsersPage}?id=${widget.projectId}&type=1",
  247. (res) {
  248. Map map = res;
  249. print(item.workerName);
  250. item.workerName = map["name"];
  251. item.workerId = map["id"];
  252. liftNotif();
  253. });
  254. }),
  255. ClickItem(
  256. title: "设备用途",
  257. isMust: true,
  258. content: item.getDeviceUsageName(),
  259. hintText: "请选择设备用途",
  260. onTap: () {
  261. _showBottomSheet(liftUsageArr, (index) {
  262. int key = 0;
  263. // 11:货梯;12:客梯;13:医梯;14:观光梯;15:杂物梯;16:别墅梯;21:扶梯;22:人行道
  264. switch (index) {
  265. case 0:
  266. key = 11;
  267. break;
  268. case 1:
  269. key = 12;
  270. break;
  271. case 2:
  272. key = 13;
  273. break;
  274. case 3:
  275. key = 14;
  276. break;
  277. case 4:
  278. key = 15;
  279. break;
  280. case 5:
  281. key = 16;
  282. break;
  283. case 6:
  284. key = 21;
  285. break;
  286. case 7:
  287. key = 22;
  288. break;
  289. }
  290. item.deviceUsage = key;
  291. print("deviceUsage");
  292. print(item.deviceUsage);
  293. // item.deviceUsageName = liftUsageArr[index];
  294. liftNotif();
  295. });
  296. }),
  297. ClickItem(
  298. title: "电梯品牌",
  299. isMust: true,
  300. content: "${item.liftBrandName}",
  301. hintText: "请选择电梯品牌",
  302. onTap: () {
  303. NavigatorUtils.pushResult(context, LiftRouter.liftBrandPage,
  304. (result) {
  305. setState(() {
  306. LiftBrandEntity model = result;
  307. item.liftBrand = model.code;
  308. item.liftBrandName = model.name;
  309. liftNotif();
  310. });
  311. });
  312. }),
  313. ClickItem(
  314. title: "年检日期",
  315. isMust: true,
  316. content: "${item.annualInspectionDate}",
  317. hintText: "请选择年检日期",
  318. onTap: () {
  319. _selectTime((String time) {
  320. setState(() {
  321. item.annualInspectionDate = time.split(" ")[0];
  322. liftNotif();
  323. });
  324. });
  325. }),
  326. ];
  327. }
  328. _yeyintiList() {
  329. return [
  330. TextFieldItem(
  331. title: "显示楼层",
  332. content: "${item.innerFloor}",
  333. keyboardType: TextInputType.number,
  334. controller: TextEditingController(),
  335. hintText: "请填写显示楼层",
  336. focusNode: FocusNode(),
  337. onChanged: (res) {
  338. item.innerFloor = res;
  339. },
  340. ),
  341. TextFieldItem(
  342. title: "曳引轮直径(mm)",
  343. content: "${item.pulleyDiameter}",
  344. controller: TextEditingController(),
  345. hintText: "请填写曳引轮直径",
  346. focusNode: FocusNode(),
  347. onChanged: (res) {
  348. item.pulleyDiameter = res;
  349. },
  350. ),
  351. TextFieldItem(
  352. title: "曳引绳根数",
  353. content: "${item.ropeNum}",
  354. keyboardType: TextInputType.number,
  355. controller: TextEditingController(),
  356. hintText: "请填写曳引绳根数",
  357. focusNode: FocusNode(),
  358. onChanged: (res) {
  359. item.ropeNum = res;
  360. },
  361. ),
  362. TextFieldItem(
  363. title: "门锁型号",
  364. content: "${item.lockModel}",
  365. controller: TextEditingController(),
  366. hintText: "请填写门锁型号",
  367. focusNode: FocusNode(),
  368. onChanged: (res) {
  369. item.lockModel = res;
  370. },
  371. ),
  372. TextFieldItem(
  373. title: "层站门",
  374. isMust: true,
  375. content: "${item.layerStationDoor}",
  376. controller: TextEditingController(),
  377. hintText: "层/站/门",
  378. focusNode: FocusNode(),
  379. onChanged: (res) {
  380. item.layerStationDoor = res;
  381. },
  382. ),
  383. ClickItem(
  384. title: "安全钳类型",
  385. isMust: true,
  386. content:
  387. "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
  388. hintText: "请选择安全钳类型",
  389. onTap: () {
  390. _showBottomSheet(clampTypeArr, (index) {
  391. item.clampType = index + 1;
  392. liftNotif();
  393. });
  394. }),
  395. TextFieldItem(
  396. title: "电梯载重",
  397. isMust: true,
  398. keyboardType: TextInputType.numberWithOptions(decimal: true),
  399. content: "${item.ratedLoad}",
  400. controller: TextEditingController(),
  401. hintText: "电梯载重(kg)",
  402. focusNode: FocusNode(),
  403. onChanged: (res) {
  404. item.ratedLoad = res;
  405. },
  406. ),
  407. TextFieldItem(
  408. title: "提升高度",
  409. isMust: true,
  410. keyboardType: TextInputType.numberWithOptions(decimal: true),
  411. content: "${item.promoteHeight}",
  412. controller: TextEditingController(),
  413. hintText: "请输入提升高度(m)",
  414. focusNode: FocusNode(),
  415. onChanged: (res) {
  416. item.promoteHeight = res;
  417. },
  418. ),
  419. TextFieldItem(
  420. title: "电动机功率",
  421. content: "${item.motorPower}",
  422. keyboardType: TextInputType.numberWithOptions(decimal: true),
  423. controller: TextEditingController(),
  424. hintText: "请输入电动机功率(KW)",
  425. focusNode: FocusNode(),
  426. onChanged: (res) {
  427. item.motorPower = res;
  428. },
  429. ),
  430. TextFieldItem(
  431. title: "钢带",
  432. content: "${item.steelBelt}",
  433. controller: TextEditingController(),
  434. hintText: "请输入",
  435. focusNode: FocusNode(),
  436. onChanged: (res) {
  437. item.steelBelt = res;
  438. },
  439. ),
  440. TextFieldItem(
  441. title: "控制方式",
  442. content: "${item.controlType}",
  443. controller: TextEditingController(),
  444. hintText: "请输入控制方式",
  445. focusNode: FocusNode(),
  446. onChanged: (res) {
  447. item.controlType = res;
  448. },
  449. ),
  450. TextFieldItem(
  451. title: "额定速度",
  452. isMust: true,
  453. keyboardType: TextInputType.numberWithOptions(decimal: true),
  454. content: "${item.ratedSpeed}",
  455. controller: TextEditingController(),
  456. hintText: "请输入额定速度",
  457. focusNode: FocusNode(),
  458. onChanged: (res) {
  459. item.ratedSpeed = res;
  460. },
  461. ),
  462. ];
  463. }
  464. _yeyatiList() {
  465. return [
  466. TextFieldItem(
  467. title: "显示楼层",
  468. content: "${item.innerFloor}",
  469. keyboardType: TextInputType.number,
  470. controller: TextEditingController(),
  471. hintText: "请填写显示楼层",
  472. focusNode: FocusNode(),
  473. onChanged: (res) {
  474. item.innerFloor = res;
  475. },
  476. ),
  477. TextFieldItem(
  478. title: "门锁型号",
  479. content: "${item.lockModel}",
  480. controller: TextEditingController(),
  481. hintText: "请输入",
  482. focusNode: FocusNode(),
  483. onChanged: (res) {
  484. item.lockModel = res;
  485. },
  486. ),
  487. TextFieldItem(
  488. title: "电梯载重",
  489. isMust: true,
  490. keyboardType: TextInputType.numberWithOptions(decimal: true),
  491. content: "${item.ratedLoad}",
  492. controller: TextEditingController(),
  493. hintText: "请输入电梯载重(kg)",
  494. focusNode: FocusNode(),
  495. onChanged: (res) {
  496. item.ratedLoad = res;
  497. },
  498. ),
  499. TextFieldItem(
  500. title: "提升高度",
  501. isMust: true,
  502. keyboardType: TextInputType.numberWithOptions(decimal: true),
  503. content: "${item.promoteHeight}",
  504. controller: TextEditingController(),
  505. hintText: "请输入提升高度(m)",
  506. focusNode: FocusNode(),
  507. onChanged: (res) {
  508. item.promoteHeight = res;
  509. },
  510. ),
  511. TextFieldItem(
  512. title: "电动机功率",
  513. isMust: true,
  514. keyboardType: TextInputType.numberWithOptions(decimal: true),
  515. content: "${item.motorPower}",
  516. controller: TextEditingController(),
  517. hintText: "请输入电动机功率(KW)",
  518. focusNode: FocusNode(),
  519. onChanged: (res) {
  520. item.motorPower = res;
  521. },
  522. ),
  523. TextFieldItem(
  524. title: "额定速度",
  525. isMust: true,
  526. keyboardType: TextInputType.numberWithOptions(decimal: true),
  527. content: "${item.ratedSpeed}",
  528. controller: TextEditingController(),
  529. hintText: "请输入额定速度",
  530. focusNode: FocusNode(),
  531. onChanged: (res) {
  532. item.ratedSpeed = res;
  533. },
  534. ),
  535. TextFieldItem(
  536. title: "层站门",
  537. isMust: true,
  538. content: "${item.layerStationDoor}",
  539. controller: TextEditingController(),
  540. hintText: "层/站/门",
  541. focusNode: FocusNode(),
  542. onChanged: (res) {
  543. item.layerStationDoor = res;
  544. },
  545. ),
  546. ClickItem(
  547. title: "安全钳类型",
  548. isMust: true,
  549. content:
  550. "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
  551. hintText: "请选择安全钳类型",
  552. onTap: () {
  553. _showBottomSheet(clampTypeArr, (index) {
  554. item.clampType = index + 1;
  555. liftNotif();
  556. });
  557. }),
  558. TextFieldItem(
  559. title: "控制方式",
  560. isMust: true,
  561. content: "${item.controlType}",
  562. controller: TextEditingController(),
  563. hintText: "请输入控制方式",
  564. focusNode: FocusNode(),
  565. onChanged: (res) {
  566. item.controlType = res;
  567. },
  568. ),
  569. TextFieldItem(
  570. title: "油缸数量",
  571. isMust: true,
  572. keyboardType: TextInputType.number,
  573. content: "${item.cylinderNum}",
  574. controller: TextEditingController(),
  575. hintText: "请输入油缸数量",
  576. focusNode: FocusNode(),
  577. onChanged: (res) {
  578. item.cylinderNum = res;
  579. },
  580. ),
  581. TextFieldItem(
  582. title: "油缸型式",
  583. isMust: true,
  584. content: "${item.cylinderType}",
  585. controller: TextEditingController(),
  586. hintText: "请输入油缸型式",
  587. focusNode: FocusNode(),
  588. onChanged: (res) {
  589. item.cylinderType = res;
  590. },
  591. ),
  592. TextFieldItem(
  593. title: "顶升型式",
  594. isMust: true,
  595. content: "${item.topType}",
  596. controller: TextEditingController(),
  597. hintText: "请输入顶升型式",
  598. focusNode: FocusNode(),
  599. onChanged: (res) {
  600. item.topType = res;
  601. },
  602. ),
  603. TextFieldItem(
  604. title: "液压系统满负荷值",
  605. content: "${item.mpa}",
  606. controller: TextEditingController(),
  607. hintText: "请输入液压系统满负荷值(MPa)",
  608. focusNode: FocusNode(),
  609. onChanged: (res) {
  610. item.mpa = res;
  611. },
  612. ),
  613. ];
  614. }
  615. _zawutiList() {
  616. return [
  617. TextFieldItem(
  618. title: "显示楼层",
  619. keyboardType: TextInputType.numberWithOptions(decimal: true),
  620. content: "${item.innerFloor}",
  621. controller: TextEditingController(),
  622. hintText: "请填写显示楼层",
  623. focusNode: FocusNode(),
  624. onChanged: (res) {
  625. item.innerFloor = res;
  626. },
  627. ),
  628. TextFieldItem(
  629. title: "门锁型号",
  630. content: "${item.lockModel}",
  631. controller: TextEditingController(),
  632. hintText: "请输入",
  633. focusNode: FocusNode(),
  634. onChanged: (res) {
  635. item.lockModel = res;
  636. },
  637. ),
  638. TextFieldItem(
  639. title: "电梯载重",
  640. isMust: true,
  641. keyboardType: TextInputType.numberWithOptions(decimal: true),
  642. content: "${item.ratedLoad}",
  643. controller: TextEditingController(),
  644. hintText: "请输入电梯载重(kg)",
  645. focusNode: FocusNode(),
  646. onChanged: (res) {
  647. item.ratedLoad = res;
  648. },
  649. ),
  650. TextFieldItem(
  651. title: "提升高度",
  652. isMust: true,
  653. keyboardType: TextInputType.numberWithOptions(decimal: true),
  654. content: "${item.promoteHeight}",
  655. controller: TextEditingController(),
  656. hintText: "请输入提升高度(m)",
  657. focusNode: FocusNode(),
  658. onChanged: (res) {
  659. item.promoteHeight = res;
  660. },
  661. ),
  662. TextFieldItem(
  663. title: "电动机功率",
  664. isMust: true,
  665. keyboardType: TextInputType.numberWithOptions(decimal: true),
  666. content: "${item.motorPower}",
  667. controller: TextEditingController(),
  668. hintText: "请输入电动机功率(KW)",
  669. focusNode: FocusNode(),
  670. onChanged: (res) {
  671. item.motorPower = res;
  672. },
  673. ),
  674. TextFieldItem(
  675. title: "额定速度",
  676. isMust: true,
  677. keyboardType: TextInputType.numberWithOptions(decimal: true),
  678. content: "${item.ratedSpeed}",
  679. controller: TextEditingController(),
  680. hintText: "请输入额定速度",
  681. focusNode: FocusNode(),
  682. onChanged: (res) {
  683. item.ratedSpeed = res;
  684. },
  685. ),
  686. TextFieldItem(
  687. title: "层站门",
  688. isMust: true,
  689. content: "${item.layerStationDoor}",
  690. controller: TextEditingController(),
  691. hintText: "层/站/门",
  692. focusNode: FocusNode(),
  693. onChanged: (res) {
  694. item.layerStationDoor = res;
  695. },
  696. ),
  697. ClickItem(
  698. title: "安全钳类型",
  699. isMust: true,
  700. content:
  701. "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
  702. hintText: "请选择安全钳类型",
  703. onTap: () {
  704. _showBottomSheet(clampTypeArr, (index) {
  705. item.clampType = index + 1;
  706. liftNotif();
  707. });
  708. }),
  709. TextFieldItem(
  710. title: "控制方式",
  711. content: "${item.controlType}",
  712. controller: TextEditingController(),
  713. hintText: "请输入控制方式",
  714. focusNode: FocusNode(),
  715. onChanged: (res) {
  716. item.controlType = res;
  717. },
  718. ),
  719. TextFieldItem(
  720. title: "钢带",
  721. content: "${item.steelBelt}",
  722. controller: TextEditingController(),
  723. hintText: "请输入",
  724. focusNode: FocusNode(),
  725. onChanged: (res) {
  726. item.steelBelt = res;
  727. },
  728. )
  729. ];
  730. }
  731. _ftList() {
  732. return [
  733. TextFieldItem(
  734. title: "电梯载重",
  735. isMust: true,
  736. keyboardType: TextInputType.numberWithOptions(decimal: true),
  737. content: "${item.ratedLoad}",
  738. controller: TextEditingController(),
  739. hintText: "电梯载重(kg)",
  740. focusNode: FocusNode(),
  741. onChanged: (res) {
  742. item.ratedLoad = res;
  743. },
  744. ),
  745. TextFieldItem(
  746. title: "提升高度",
  747. isMust: true,
  748. keyboardType: TextInputType.numberWithOptions(decimal: true),
  749. content: "${item.promoteHeight}",
  750. controller: TextEditingController(),
  751. hintText: "请输入提升高度(m)",
  752. focusNode: FocusNode(),
  753. onChanged: (res) {
  754. item.promoteHeight = res;
  755. },
  756. ),
  757. TextFieldItem(
  758. title: "梯级宽度",
  759. isMust: true,
  760. content: "${item.stepWidth}",
  761. keyboardType: TextInputType.numberWithOptions(decimal: true),
  762. controller: TextEditingController(),
  763. hintText: "请输入梯级宽度(mm)",
  764. focusNode: FocusNode(),
  765. onChanged: (res) {
  766. item.stepWidth = res;
  767. },
  768. ),
  769. TextFieldItem(
  770. title: "倾斜角度",
  771. isMust: true,
  772. content: "${item.tiltAngle}",
  773. keyboardType: TextInputType.numberWithOptions(decimal: true),
  774. controller: TextEditingController(),
  775. hintText: "请输入倾斜角度(°)",
  776. focusNode: FocusNode(),
  777. onChanged: (res) {
  778. item.tiltAngle = res;
  779. },
  780. ),
  781. TextFieldItem(
  782. title: "电动机功率",
  783. keyboardType: TextInputType.numberWithOptions(decimal: true),
  784. content: "${item.motorPower}",
  785. controller: TextEditingController(),
  786. hintText: "请输入电动机功率(kw)",
  787. focusNode: FocusNode(),
  788. onChanged: (res) {
  789. item.motorPower = res;
  790. },
  791. ),
  792. TextFieldItem(
  793. title: "额定速度",
  794. keyboardType: TextInputType.numberWithOptions(decimal: true),
  795. content: "${item.ratedSpeed}",
  796. controller: TextEditingController(),
  797. hintText: "请输入额定速度(m/s)",
  798. focusNode: FocusNode(),
  799. onChanged: (res) {
  800. item.ratedSpeed = res;
  801. },
  802. ),
  803. ];
  804. }
  805. _ftrxd() {
  806. return [
  807. TextFieldItem(
  808. title: "人行道长度",
  809. isMust: true,
  810. keyboardType: TextInputType.numberWithOptions(decimal: true),
  811. content: "${item.sidewalkLength}",
  812. controller: TextEditingController(),
  813. hintText: "请输入人行道长度(m)",
  814. focusNode: FocusNode(),
  815. onChanged: (res) {
  816. item.sidewalkLength = res;
  817. },
  818. ),
  819. ];
  820. }
  821. _commontFooter() {
  822. return [
  823. TextFieldItem(
  824. title: "备注",
  825. content: "${item.remarks}",
  826. controller: TextEditingController(),
  827. hintText: "请填写备注",
  828. focusNode: FocusNode(),
  829. onChanged: (res) {
  830. item.remarks = res;
  831. },
  832. ),
  833. ];
  834. }
  835. /// 选择时间
  836. Future<void> _selectTime(Function callback) async {
  837. DatePicker.showDatePicker(context,
  838. showTitleActions: true, onChanged: (date) {}, onConfirm: (date) {
  839. callback("${date.toString().split(".")[0]}");
  840. }, currentTime: DateTime.now(), locale: LocaleType.zh);
  841. }
  842. _showBottomSheet(list, Function callback) {
  843. showModalBottomSheet(
  844. context: context,
  845. builder: (BuildContext context) {
  846. return SizedBox(
  847. height: 360.0,
  848. child: ListView.builder(
  849. itemExtent: 48.0,
  850. itemBuilder: (_, index) {
  851. return InkWell(
  852. child: Container(
  853. padding: const EdgeInsets.symmetric(horizontal: 16.0),
  854. alignment: Alignment.centerLeft,
  855. child: Text(list[index]),
  856. ),
  857. onTap: () {
  858. setState(() {
  859. callback(index);
  860. });
  861. NavigatorUtils.goBack(context);
  862. },
  863. );
  864. },
  865. itemCount: list.length,
  866. ),
  867. );
  868. },
  869. );
  870. }
  871. ///保存电梯
  872. _saveLift() {
  873. if (!_checkData()) {
  874. return;
  875. }
  876. showLoading(context, "正在保存");
  877. if (item.id.length > 0) {
  878. ApiService(context: context).liftEdit(
  879. widget.projectId, item.workerId, item.toJson(), onSuccess: (data) {
  880. dismissLoading(context);
  881. showAlert(context, "提示", "保存成功", "确定", () {
  882. NavigatorUtils.goBack(context);
  883. // NavigatorUtils.goBack(context);
  884. NavigatorUtils.goBackWithParams(context, true);
  885. });
  886. }, onError: (code, msg) {
  887. dismissLoading(context);
  888. toasts(msg);
  889. });
  890. } else {
  891. ApiService(context: context).liftAdd(
  892. widget.projectId, item.workerId, item.toJson(), onSuccess: (data) {
  893. dismissLoading(context);
  894. showAlert(context, "提示", "保存成功", "确定", () {
  895. NavigatorUtils.goBack(context);
  896. // NavigatorUtils.goBack(context);
  897. NavigatorUtils.goBackWithParams(context, true);
  898. });
  899. }, onError: (code, msg) {
  900. dismissLoading(context);
  901. toasts(msg);
  902. });
  903. }
  904. }
  905. ///检查数据
  906. _checkData() {
  907. if (item.registrationCode.length == 0) {
  908. toasts("请填写设备注册代码");
  909. return false;
  910. }
  911. if (item.category == 0) {
  912. toasts("请选择电梯类别");
  913. return false;
  914. }
  915. if (item.devicePosition.length == 0) {
  916. toasts("请填写设备安装地址");
  917. return false;
  918. }
  919. if (item.useCompanyCode.length == 0) {
  920. toasts("请填写设备内部编号");
  921. return false;
  922. }
  923. if (item.installDate.length == 0) {
  924. toasts("请选择设备安装日期");
  925. return false;
  926. }
  927. if (item.workerId.length == 0) {
  928. toasts("请选择维保负责人");
  929. return false;
  930. }
  931. if (item.deviceUsage < 0) {
  932. toasts("请选择设备用途");
  933. return false;
  934. }
  935. if (item.liftBrand.length == 0) {
  936. toasts("请选择电梯品牌");
  937. return false;
  938. }
  939. if (item.annualInspectionDate.length == 0) {
  940. toasts("请选择年检日期");
  941. return false;
  942. }
  943. switch (item.category) {
  944. case 1:
  945. if (item.layerStationDoor.length == 0) {
  946. toasts("请填写层站门");
  947. return false;
  948. }
  949. if (item.clampType == 0) {
  950. toasts("请选择安全钳类型");
  951. return false;
  952. }
  953. if (item.ratedLoad.length == 0) {
  954. toasts("请填写电梯载重");
  955. return false;
  956. }
  957. if (item.promoteHeight.length == 0) {
  958. toasts("请填写提升高度");
  959. return false;
  960. }
  961. if (item.ratedSpeed.length == 0) {
  962. toasts("请填写额定速度");
  963. return false;
  964. }
  965. break;
  966. case 2:
  967. if (item.ratedLoad.length == 0) {
  968. toasts("请填写电梯载重");
  969. return false;
  970. }
  971. if (item.promoteHeight.length == 0) {
  972. toasts("请填写提升高度");
  973. return false;
  974. }
  975. if (item.motorPower.length == 0) {
  976. toasts("请填写电动机功率");
  977. return false;
  978. }
  979. if (item.ratedSpeed.length == 0) {
  980. toasts("请填写额定速度");
  981. return false;
  982. }
  983. if (item.layerStationDoor.length == 0) {
  984. toasts("请填写层站门");
  985. return false;
  986. }
  987. if (item.clampType == 0) {
  988. toasts("请选择安全钳类型");
  989. return false;
  990. }
  991. if (item.controlType.length == 0) {
  992. toasts("请选择控制方式");
  993. return false;
  994. }
  995. if (item.cylinderNum.length == 0) {
  996. toasts("请填写油缸数量");
  997. return false;
  998. }
  999. if (item.cylinderType.length == 0) {
  1000. toasts("请填写油缸型式");
  1001. return false;
  1002. }
  1003. if (item.topType.length == 0) {
  1004. toasts("请填写顶升型式");
  1005. return false;
  1006. }
  1007. break;
  1008. case 3:
  1009. if (item.ratedLoad.length == 0) {
  1010. toasts("请填写电梯载重");
  1011. return false;
  1012. }
  1013. if (item.promoteHeight.length == 0) {
  1014. toasts("请填写提升高度");
  1015. return false;
  1016. }
  1017. if (item.motorPower.length == 0) {
  1018. toasts("请填写电动机功率");
  1019. return false;
  1020. }
  1021. if (item.ratedSpeed.length == 0) {
  1022. toasts("请填写额定速度");
  1023. return false;
  1024. }
  1025. if (item.layerStationDoor.length == 0) {
  1026. toasts("请填写层站门");
  1027. return false;
  1028. }
  1029. if (item.clampType == 0) {
  1030. toasts("请选择安全钳类型");
  1031. return false;
  1032. }
  1033. break;
  1034. case 4:
  1035. if (item.ratedLoad.length == 0) {
  1036. toasts("请填写电梯载重");
  1037. return false;
  1038. }
  1039. if (item.promoteHeight.length == 0) {
  1040. toasts("请填写提升高度");
  1041. return false;
  1042. }
  1043. if (item.stepWidth.length == 0) {
  1044. toasts("请填写梯级宽度");
  1045. return false;
  1046. }
  1047. if (item.tiltAngle.length == 0) {
  1048. toasts("请填写倾斜角度");
  1049. return false;
  1050. }
  1051. break;
  1052. case 5:
  1053. if (item.ratedLoad.length == 0) {
  1054. toasts("请填写电梯载重");
  1055. return false;
  1056. }
  1057. if (item.promoteHeight.length == 0) {
  1058. toasts("请填写提升高度");
  1059. return false;
  1060. }
  1061. if (item.stepWidth.length == 0) {
  1062. toasts("请填写梯级宽度");
  1063. return false;
  1064. }
  1065. if (item.sidewalkLength.length == 0) {
  1066. toasts("请填写人行道长度");
  1067. return false;
  1068. }
  1069. if (item.tiltAngle.length == 0) {
  1070. toasts("请填写倾斜角度");
  1071. return false;
  1072. }
  1073. break;
  1074. default:
  1075. break;
  1076. }
  1077. return true;
  1078. }
  1079. @override
  1080. Widget build(BuildContext context) {
  1081. return Scaffold(
  1082. backgroundColor: ThemeUtils.getTabsBg(context),
  1083. //resizeToAvoidBottomPadding: false,
  1084. appBar: MyAppBar(
  1085. centerTitle: item.id.length > 0 ? "编辑电梯" : "新建电梯",
  1086. actions: <Widget>[
  1087. FlatButton(
  1088. onPressed: () {
  1089. _saveLift();
  1090. },
  1091. child: Text(
  1092. "保存",
  1093. style: TextStyle(color: Colours.blue_app_main),
  1094. ),
  1095. textColor: Colours.text,
  1096. highlightColor: Colors.transparent)
  1097. ],
  1098. ),
  1099. body: SafeArea(
  1100. child: Column(
  1101. children: <Widget>[
  1102. Expanded(
  1103. flex: 1,
  1104. child: defaultTargetPlatform == TargetPlatform.iOS
  1105. ? FormKeyboardActions(child: _buildBody())
  1106. : SingleChildScrollView(child: _buildBody()),
  1107. )
  1108. ],
  1109. ),
  1110. ),
  1111. );
  1112. }
  1113. _buildBody() {
  1114. return Column(
  1115. crossAxisAlignment: CrossAxisAlignment.start,
  1116. children: liftData.map((item) {
  1117. return item;
  1118. // return item["controller"] != null
  1119. // ? TextFieldItem(
  1120. //// key: Key(item['key']),
  1121. // isMust: item["isMust"],
  1122. // content: item["content"],
  1123. // controller: item["controller"],
  1124. // hintText: "${item["hintText"] ?? "请填写"}",
  1125. // title: "${item["title"]}",
  1126. // onChanged: item["onChanged"],
  1127. // )
  1128. // : ClickItem(
  1129. //// key: Key(item['key']),
  1130. // title: item["title"],
  1131. // hintText: "请选择",
  1132. // content: item["content"],
  1133. // isMust: item["isMust"],
  1134. // onTap: item["onTap"],
  1135. // );
  1136. }).toList(),
  1137. );
  1138. }
  1139. }