1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159 |
- import 'package:flutter/cupertino.dart';
- import 'package:flutter/foundation.dart';
- import 'package:flutter/material.dart';
- import 'package:flutter_datetime_picker/flutter_datetime_picker.dart';
- import 'package:keyboard_actions/keyboard_actions.dart';
- import 'package:liftmanager/internal/lift/lift_router.dart';
- import 'package:liftmanager/internal/lift/model/lift_brand_entity.dart';
- import 'package:liftmanager/internal/lift/model/lift_item.dart';
- import 'package:liftmanager/internal/project/project_router.dart';
- import 'package:liftmanager/net/api_service.dart';
- import 'package:liftmanager/res/resources.dart';
- import 'package:liftmanager/routers/fluro_navigator.dart';
- import 'package:liftmanager/utils/theme_utils.dart';
- import 'package:liftmanager/utils/toast.dart';
- import 'package:liftmanager/widgets/app_bar.dart';
- import 'package:liftmanager/widgets/click_item.dart';
- import 'package:liftmanager/widgets/text_field_item.dart';
- class LiftCreatePage extends StatefulWidget {
- LiftCreatePage(this.projectId, {this.item});
- final String projectId;
- LiftItem item;
- @override
- State<StatefulWidget> createState() {
- if (item == null) {
- item = LiftItem();
- }
- return LiftCreatePageState(this.item);
- }
- }
- class LiftCreatePageState extends State<LiftCreatePage> {
- LiftCreatePageState(this.item);
- List<Widget> liftData = [];
- var liftTypeArr = ["曳引梯", "液压梯", "杂物梯", "自动扶梯", "自动人行道"];
- var clampTypeArr = ["瞬时式安全钳", "渐进式安全钳"];
- var liftUsageArr = ["货梯", "客梯", "医梯", "观光梯", "杂物梯", "别墅梯", "扶梯", "人行道"];
- LiftItem item;
- @override
- void initState() {
- super.initState();
- liftNotif();
- }
- liftNotif() {
- liftData.clear();
- liftData = _commontHeader();
- if (item.category == 1) {
- liftData.addAll(_yeyintiList());
- } else if (item.category == 2) {
- liftData.addAll(_yeyatiList());
- } else if (item.category == 3) {
- liftData.addAll(_zawutiList());
- } else if (item.category == 4) {
- liftData.addAll(_ftList());
- } else if (item.category == 5) {
- liftData.addAll(_ftList());
- liftData.addAll(_ftrxd());
- }
- liftData.addAll(_commontFooter());
- setState(() {});
- }
- _commontHeader() {
- return [
- TextFieldItem(
- title: "设备注册代码",
- isMust: true,
- enabled: item.id.length == 0,
- content: "${item.registrationCode}",
- controller: TextEditingController(),
- hintText: "请填写设备注册代码",
- focusNode: FocusNode(),
- onChanged: (res) {
- print(res);
- item.registrationCode = res;
- setState(() {});
- },
- ),
- ClickItem(
- title: "电梯类别",
- isMust: true,
- content: item.getCategoryName(),
- hintText: "请选择电梯类别",
- onTap: () {
- _showBottomSheet(liftTypeArr, (index) {
- item.category = index + 1;
- if (item.category > 3) {
- item.liftType = 2;
- } else {
- item.liftType = 1;
- }
- liftNotif();
- });
- }),
- ClickItem(
- title: "地图位置",
- content: "${item.coordinate.length > 0 ? "已定位" : "未定位"}",
- hintText: "请选择地图位置",
- onTap: () {
- NavigatorUtils.pushResult(
- context,
- "${LiftRouter.liftMapPage}?type=check&coordinate=" +
- item.coordinate, (result) {
- print(result);
- if (result != null && "${result}".contains(",")) {
- setState(() {
- item.coordinate = result;
- liftNotif();
- });
- }
- });
- }),
- TextFieldItem(
- title: "设备出厂编号",
- content: "${item.factoryCode}",
- controller: TextEditingController(),
- hintText: "请填写设备出厂编号",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.factoryCode = res;
- },
- ),
- TextFieldItem(
- title: "设备型号",
- content: "${item.liftModel}",
- controller: TextEditingController(),
- hintText: "请填写设备型号",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.liftModel = res;
- },
- ),
- TextFieldItem(
- title: "设备安装地址",
- isMust: true,
- content: "${item.devicePosition}",
- controller: TextEditingController(),
- hintText: "请填写设备安装地址",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.devicePosition = res;
- },
- ),
- TextFieldItem(
- title: "设备内部编号",
- isMust: true,
- content: "${item.useCompanyCode}",
- controller: TextEditingController(),
- hintText: "请填写设备注册代码",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.useCompanyCode = res;
- },
- ),
- TextFieldItem(
- title: "设备制造商",
- content: "${item.factory}",
- controller: TextEditingController(),
- hintText: "请填写设备制造商",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.factory = res;
- },
- ),
- TextFieldItem(
- title: "进口设备代理商",
- content: "${item.agency}",
- controller: TextEditingController(),
- hintText: "请填写进口设备代理商",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.agency = res;
- },
- ),
- TextFieldItem(
- title: "自定义编号",
- content: "${item.customNumber}",
- controller: TextEditingController(),
- hintText: "请填写自定义编号",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.customNumber = res;
- },
- ),
- ClickItem(
- title: "设备出厂日期",
- content: "${item.manufactureDate}",
- hintText: "请选择设备出厂日期",
- onTap: () {
- _selectTime((String time) {
- setState(() {
- item.manufactureDate = time.split(" ")[0];
- liftNotif();
- });
- });
- }),
- TextFieldItem(
- title: "设备改造单位",
- content: "${item.reformCompany}",
- controller: TextEditingController(),
- hintText: "请填写设备改造单位",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.reformCompany = res;
- },
- ),
- ClickItem(
- title: "设备改造日期",
- content: "${item.reformDate}",
- hintText: "请选择设备改造日期",
- onTap: () {
- _selectTime((String time) {
- setState(() {
- item.reformDate = time.split(" ")[0];
- liftNotif();
- });
- });
- }),
- TextFieldItem(
- title: "设备安装单位",
- content: "${item.installCompany}",
- controller: TextEditingController(),
- hintText: "请填写设备安装单位",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.installCompany = res;
- },
- ),
- ClickItem(
- title: "设备安装日期",
- isMust: true,
- content: "${item.installDate}",
- hintText: "请选择安装日期",
- onTap: () {
- _selectTime((String time) {
- setState(() {
- item.installDate = time.split(" ")[0];
- liftNotif();
- });
- });
- }),
- ClickItem(
- title: "电梯维保负责人",
- isMust: true,
- content: "${item.workerName}",
- hintText: "请选择电梯维保负责人",
- onTap: () {
- NavigatorUtils.pushResult(context,
- "${ProjectRouter.projectUsersPage}?id=${widget.projectId}&type=1",
- (res) {
- Map map = res;
- print(item.workerName);
- item.workerName = map["name"];
- item.workerId = map["id"];
- liftNotif();
- });
- }),
- ClickItem(
- title: "设备用途",
- isMust: true,
- content: item.getDeviceUsageName(),
- hintText: "请选择设备用途",
- onTap: () {
- _showBottomSheet(liftUsageArr, (index) {
- int key = 0;
- // 11:货梯;12:客梯;13:医梯;14:观光梯;15:杂物梯;16:别墅梯;21:扶梯;22:人行道
- switch (index) {
- case 0:
- key = 11;
- break;
- case 1:
- key = 12;
- break;
- case 2:
- key = 13;
- break;
- case 3:
- key = 14;
- break;
- case 4:
- key = 15;
- break;
- case 5:
- key = 16;
- break;
- case 6:
- key = 21;
- break;
- case 7:
- key = 22;
- break;
- }
- item.deviceUsage = key;
- print("deviceUsage");
- print(item.deviceUsage);
- // item.deviceUsageName = liftUsageArr[index];
- liftNotif();
- });
- }),
- ClickItem(
- title: "电梯品牌",
- isMust: true,
- content: "${item.liftBrandName}",
- hintText: "请选择电梯品牌",
- onTap: () {
- NavigatorUtils.pushResult(context, LiftRouter.liftBrandPage,
- (result) {
- setState(() {
- LiftBrandEntity model = result;
- item.liftBrand = model.code;
- item.liftBrandName = model.name;
- liftNotif();
- });
- });
- }),
- ClickItem(
- title: "年检日期",
- isMust: true,
- content: "${item.annualInspectionDate}",
- hintText: "请选择年检日期",
- onTap: () {
- _selectTime((String time) {
- setState(() {
- item.annualInspectionDate = time.split(" ")[0];
- liftNotif();
- });
- });
- }),
- ];
- }
- _yeyintiList() {
- return [
- TextFieldItem(
- title: "显示楼层",
- content: "${item.innerFloor}",
- keyboardType: TextInputType.number,
- controller: TextEditingController(),
- hintText: "请填写显示楼层",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.innerFloor = res;
- },
- ),
- TextFieldItem(
- title: "曳引轮直径(mm)",
- content: "${item.pulleyDiameter}",
- controller: TextEditingController(),
- hintText: "请填写曳引轮直径",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.pulleyDiameter = res;
- },
- ),
- TextFieldItem(
- title: "曳引绳根数",
- content: "${item.ropeNum}",
- keyboardType: TextInputType.number,
- controller: TextEditingController(),
- hintText: "请填写曳引绳根数",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ropeNum = res;
- },
- ),
- TextFieldItem(
- title: "门锁型号",
- content: "${item.lockModel}",
- controller: TextEditingController(),
- hintText: "请填写门锁型号",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.lockModel = res;
- },
- ),
- TextFieldItem(
- title: "层站门",
- isMust: true,
- content: "${item.layerStationDoor}",
- controller: TextEditingController(),
- hintText: "层/站/门",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.layerStationDoor = res;
- },
- ),
- ClickItem(
- title: "安全钳类型",
- isMust: true,
- content:
- "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
- hintText: "请选择安全钳类型",
- onTap: () {
- _showBottomSheet(clampTypeArr, (index) {
- item.clampType = index + 1;
- liftNotif();
- });
- }),
- TextFieldItem(
- title: "电梯载重",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedLoad}",
- controller: TextEditingController(),
- hintText: "电梯载重(kg)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedLoad = res;
- },
- ),
- TextFieldItem(
- title: "提升高度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.promoteHeight}",
- controller: TextEditingController(),
- hintText: "请输入提升高度(m)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.promoteHeight = res;
- },
- ),
- TextFieldItem(
- title: "电动机功率",
- content: "${item.motorPower}",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- controller: TextEditingController(),
- hintText: "请输入电动机功率(KW)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.motorPower = res;
- },
- ),
- TextFieldItem(
- title: "钢带",
- content: "${item.steelBelt}",
- controller: TextEditingController(),
- hintText: "请输入",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.steelBelt = res;
- },
- ),
- TextFieldItem(
- title: "控制方式",
- content: "${item.controlType}",
- controller: TextEditingController(),
- hintText: "请输入控制方式",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.controlType = res;
- },
- ),
- TextFieldItem(
- title: "额定速度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedSpeed}",
- controller: TextEditingController(),
- hintText: "请输入额定速度",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedSpeed = res;
- },
- ),
- ];
- }
- _yeyatiList() {
- return [
- TextFieldItem(
- title: "显示楼层",
- content: "${item.innerFloor}",
- keyboardType: TextInputType.number,
- controller: TextEditingController(),
- hintText: "请填写显示楼层",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.innerFloor = res;
- },
- ),
- TextFieldItem(
- title: "门锁型号",
- content: "${item.lockModel}",
- controller: TextEditingController(),
- hintText: "请输入",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.lockModel = res;
- },
- ),
- TextFieldItem(
- title: "电梯载重",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedLoad}",
- controller: TextEditingController(),
- hintText: "请输入电梯载重(kg)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedLoad = res;
- },
- ),
- TextFieldItem(
- title: "提升高度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.promoteHeight}",
- controller: TextEditingController(),
- hintText: "请输入提升高度(m)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.promoteHeight = res;
- },
- ),
- TextFieldItem(
- title: "电动机功率",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.motorPower}",
- controller: TextEditingController(),
- hintText: "请输入电动机功率(KW)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.motorPower = res;
- },
- ),
- TextFieldItem(
- title: "额定速度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedSpeed}",
- controller: TextEditingController(),
- hintText: "请输入额定速度",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedSpeed = res;
- },
- ),
- TextFieldItem(
- title: "层站门",
- isMust: true,
- content: "${item.layerStationDoor}",
- controller: TextEditingController(),
- hintText: "层/站/门",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.layerStationDoor = res;
- },
- ),
- ClickItem(
- title: "安全钳类型",
- isMust: true,
- content:
- "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
- hintText: "请选择安全钳类型",
- onTap: () {
- _showBottomSheet(clampTypeArr, (index) {
- item.clampType = index + 1;
- liftNotif();
- });
- }),
- TextFieldItem(
- title: "控制方式",
- isMust: true,
- content: "${item.controlType}",
- controller: TextEditingController(),
- hintText: "请输入控制方式",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.controlType = res;
- },
- ),
- TextFieldItem(
- title: "油缸数量",
- isMust: true,
- keyboardType: TextInputType.number,
- content: "${item.cylinderNum}",
- controller: TextEditingController(),
- hintText: "请输入油缸数量",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.cylinderNum = res;
- },
- ),
- TextFieldItem(
- title: "油缸型式",
- isMust: true,
- content: "${item.cylinderType}",
- controller: TextEditingController(),
- hintText: "请输入油缸型式",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.cylinderType = res;
- },
- ),
- TextFieldItem(
- title: "顶升型式",
- isMust: true,
- content: "${item.topType}",
- controller: TextEditingController(),
- hintText: "请输入顶升型式",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.topType = res;
- },
- ),
- TextFieldItem(
- title: "液压系统满负荷值",
- content: "${item.mpa}",
- controller: TextEditingController(),
- hintText: "请输入液压系统满负荷值(MPa)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.mpa = res;
- },
- ),
- ];
- }
- _zawutiList() {
- return [
- TextFieldItem(
- title: "显示楼层",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.innerFloor}",
- controller: TextEditingController(),
- hintText: "请填写显示楼层",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.innerFloor = res;
- },
- ),
- TextFieldItem(
- title: "门锁型号",
- content: "${item.lockModel}",
- controller: TextEditingController(),
- hintText: "请输入",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.lockModel = res;
- },
- ),
- TextFieldItem(
- title: "电梯载重",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedLoad}",
- controller: TextEditingController(),
- hintText: "请输入电梯载重(kg)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedLoad = res;
- },
- ),
- TextFieldItem(
- title: "提升高度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.promoteHeight}",
- controller: TextEditingController(),
- hintText: "请输入提升高度(m)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.promoteHeight = res;
- },
- ),
- TextFieldItem(
- title: "电动机功率",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.motorPower}",
- controller: TextEditingController(),
- hintText: "请输入电动机功率(KW)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.motorPower = res;
- },
- ),
- TextFieldItem(
- title: "额定速度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedSpeed}",
- controller: TextEditingController(),
- hintText: "请输入额定速度",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedSpeed = res;
- },
- ),
- TextFieldItem(
- title: "层站门",
- isMust: true,
- content: "${item.layerStationDoor}",
- controller: TextEditingController(),
- hintText: "层/站/门",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.layerStationDoor = res;
- },
- ),
- ClickItem(
- title: "安全钳类型",
- isMust: true,
- content:
- "${item.clampType == 1 ? '瞬时式安全钳' : item.clampType == 2 ? '渐进式安全钳' : ''}",
- hintText: "请选择安全钳类型",
- onTap: () {
- _showBottomSheet(clampTypeArr, (index) {
- item.clampType = index + 1;
- liftNotif();
- });
- }),
- TextFieldItem(
- title: "控制方式",
- content: "${item.controlType}",
- controller: TextEditingController(),
- hintText: "请输入控制方式",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.controlType = res;
- },
- ),
- TextFieldItem(
- title: "钢带",
- content: "${item.steelBelt}",
- controller: TextEditingController(),
- hintText: "请输入",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.steelBelt = res;
- },
- )
- ];
- }
- _ftList() {
- return [
- TextFieldItem(
- title: "电梯载重",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedLoad}",
- controller: TextEditingController(),
- hintText: "电梯载重(kg)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedLoad = res;
- },
- ),
- TextFieldItem(
- title: "提升高度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.promoteHeight}",
- controller: TextEditingController(),
- hintText: "请输入提升高度(m)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.promoteHeight = res;
- },
- ),
- TextFieldItem(
- title: "梯级宽度",
- isMust: true,
- content: "${item.stepWidth}",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- controller: TextEditingController(),
- hintText: "请输入梯级宽度(mm)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.stepWidth = res;
- },
- ),
- TextFieldItem(
- title: "倾斜角度",
- isMust: true,
- content: "${item.tiltAngle}",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- controller: TextEditingController(),
- hintText: "请输入倾斜角度(°)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.tiltAngle = res;
- },
- ),
- TextFieldItem(
- title: "电动机功率",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.motorPower}",
- controller: TextEditingController(),
- hintText: "请输入电动机功率(kw)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.motorPower = res;
- },
- ),
- TextFieldItem(
- title: "额定速度",
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.ratedSpeed}",
- controller: TextEditingController(),
- hintText: "请输入额定速度(m/s)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.ratedSpeed = res;
- },
- ),
- ];
- }
- _ftrxd() {
- return [
- TextFieldItem(
- title: "人行道长度",
- isMust: true,
- keyboardType: TextInputType.numberWithOptions(decimal: true),
- content: "${item.sidewalkLength}",
- controller: TextEditingController(),
- hintText: "请输入人行道长度(m)",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.sidewalkLength = res;
- },
- ),
- ];
- }
- _commontFooter() {
- return [
- TextFieldItem(
- title: "备注",
- content: "${item.remarks}",
- controller: TextEditingController(),
- hintText: "请填写备注",
- focusNode: FocusNode(),
- onChanged: (res) {
- item.remarks = res;
- },
- ),
- ];
- }
- /// 选择时间
- Future<void> _selectTime(Function callback) async {
- DatePicker.showDatePicker(context,
- showTitleActions: true, onChanged: (date) {}, onConfirm: (date) {
- callback("${date.toString().split(".")[0]}");
- }, currentTime: DateTime.now(), locale: LocaleType.zh);
- }
- _showBottomSheet(list, Function callback) {
- showModalBottomSheet(
- context: context,
- builder: (BuildContext context) {
- return SizedBox(
- height: 360.0,
- child: ListView.builder(
- itemExtent: 48.0,
- itemBuilder: (_, index) {
- return InkWell(
- child: Container(
- padding: const EdgeInsets.symmetric(horizontal: 16.0),
- alignment: Alignment.centerLeft,
- child: Text(list[index]),
- ),
- onTap: () {
- setState(() {
- callback(index);
- });
- NavigatorUtils.goBack(context);
- },
- );
- },
- itemCount: list.length,
- ),
- );
- },
- );
- }
- ///保存电梯
- _saveLift() {
- if (!_checkData()) {
- return;
- }
- showLoading(context, "正在保存");
- if (item.id.length > 0) {
- ApiService(context: context).liftEdit(
- widget.projectId, item.workerId, item.toJson(), onSuccess: (data) {
- dismissLoading(context);
- showAlert(context, "提示", "保存成功", "确定", () {
- NavigatorUtils.goBack(context);
- // NavigatorUtils.goBack(context);
- NavigatorUtils.goBackWithParams(context, true);
- });
- }, onError: (code, msg) {
- dismissLoading(context);
- toasts(msg);
- });
- } else {
- ApiService(context: context).liftAdd(
- widget.projectId, item.workerId, item.toJson(), onSuccess: (data) {
- dismissLoading(context);
- showAlert(context, "提示", "保存成功", "确定", () {
- NavigatorUtils.goBack(context);
- // NavigatorUtils.goBack(context);
- NavigatorUtils.goBackWithParams(context, true);
- });
- }, onError: (code, msg) {
- dismissLoading(context);
- toasts(msg);
- });
- }
- }
- ///检查数据
- _checkData() {
- if (item.registrationCode.length == 0) {
- toasts("请填写设备注册代码");
- return false;
- }
- if (item.category == 0) {
- toasts("请选择电梯类别");
- return false;
- }
- if (item.devicePosition.length == 0) {
- toasts("请填写设备安装地址");
- return false;
- }
- if (item.useCompanyCode.length == 0) {
- toasts("请填写设备内部编号");
- return false;
- }
- if (item.installDate.length == 0) {
- toasts("请选择设备安装日期");
- return false;
- }
- if (item.workerId.length == 0) {
- toasts("请选择维保负责人");
- return false;
- }
- if (item.deviceUsage < 0) {
- toasts("请选择设备用途");
- return false;
- }
- if (item.liftBrand.length == 0) {
- toasts("请选择电梯品牌");
- return false;
- }
- if (item.annualInspectionDate.length == 0) {
- toasts("请选择年检日期");
- return false;
- }
- switch (item.category) {
- case 1:
- if (item.layerStationDoor.length == 0) {
- toasts("请填写层站门");
- return false;
- }
- if (item.clampType == 0) {
- toasts("请选择安全钳类型");
- return false;
- }
- if (item.ratedLoad.length == 0) {
- toasts("请填写电梯载重");
- return false;
- }
- if (item.promoteHeight.length == 0) {
- toasts("请填写提升高度");
- return false;
- }
- if (item.ratedSpeed.length == 0) {
- toasts("请填写额定速度");
- return false;
- }
- break;
- case 2:
- if (item.ratedLoad.length == 0) {
- toasts("请填写电梯载重");
- return false;
- }
- if (item.promoteHeight.length == 0) {
- toasts("请填写提升高度");
- return false;
- }
- if (item.motorPower.length == 0) {
- toasts("请填写电动机功率");
- return false;
- }
- if (item.ratedSpeed.length == 0) {
- toasts("请填写额定速度");
- return false;
- }
- if (item.layerStationDoor.length == 0) {
- toasts("请填写层站门");
- return false;
- }
- if (item.clampType == 0) {
- toasts("请选择安全钳类型");
- return false;
- }
- if (item.controlType.length == 0) {
- toasts("请选择控制方式");
- return false;
- }
- if (item.cylinderNum.length == 0) {
- toasts("请填写油缸数量");
- return false;
- }
- if (item.cylinderType.length == 0) {
- toasts("请填写油缸型式");
- return false;
- }
- if (item.topType.length == 0) {
- toasts("请填写顶升型式");
- return false;
- }
- break;
- case 3:
- if (item.ratedLoad.length == 0) {
- toasts("请填写电梯载重");
- return false;
- }
- if (item.promoteHeight.length == 0) {
- toasts("请填写提升高度");
- return false;
- }
- if (item.motorPower.length == 0) {
- toasts("请填写电动机功率");
- return false;
- }
- if (item.ratedSpeed.length == 0) {
- toasts("请填写额定速度");
- return false;
- }
- if (item.layerStationDoor.length == 0) {
- toasts("请填写层站门");
- return false;
- }
- if (item.clampType == 0) {
- toasts("请选择安全钳类型");
- return false;
- }
- break;
- case 4:
- if (item.ratedLoad.length == 0) {
- toasts("请填写电梯载重");
- return false;
- }
- if (item.promoteHeight.length == 0) {
- toasts("请填写提升高度");
- return false;
- }
- if (item.stepWidth.length == 0) {
- toasts("请填写梯级宽度");
- return false;
- }
- if (item.tiltAngle.length == 0) {
- toasts("请填写倾斜角度");
- return false;
- }
- break;
- case 5:
- if (item.ratedLoad.length == 0) {
- toasts("请填写电梯载重");
- return false;
- }
- if (item.promoteHeight.length == 0) {
- toasts("请填写提升高度");
- return false;
- }
- if (item.stepWidth.length == 0) {
- toasts("请填写梯级宽度");
- return false;
- }
- if (item.sidewalkLength.length == 0) {
- toasts("请填写人行道长度");
- return false;
- }
- if (item.tiltAngle.length == 0) {
- toasts("请填写倾斜角度");
- return false;
- }
- break;
- default:
- break;
- }
- return true;
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- backgroundColor: ThemeUtils.getTabsBg(context),
- //resizeToAvoidBottomPadding: false,
- appBar: MyAppBar(
- centerTitle: item.id.length > 0 ? "编辑电梯" : "新建电梯",
- actions: <Widget>[
- FlatButton(
- onPressed: () {
- _saveLift();
- },
- child: Text(
- "保存",
- style: TextStyle(color: Colours.blue_app_main),
- ),
- textColor: Colours.text,
- highlightColor: Colors.transparent)
- ],
- ),
- body: SafeArea(
- child: Column(
- children: <Widget>[
- Expanded(
- flex: 1,
- child: defaultTargetPlatform == TargetPlatform.iOS
- ? FormKeyboardActions(child: _buildBody())
- : SingleChildScrollView(child: _buildBody()),
- )
- ],
- ),
- ),
- );
- }
- _buildBody() {
- return Column(
- crossAxisAlignment: CrossAxisAlignment.start,
- children: liftData.map((item) {
- return item;
- // return item["controller"] != null
- // ? TextFieldItem(
- //// key: Key(item['key']),
- // isMust: item["isMust"],
- // content: item["content"],
- // controller: item["controller"],
- // hintText: "${item["hintText"] ?? "请填写"}",
- // title: "${item["title"]}",
- // onChanged: item["onChanged"],
- // )
- // : ClickItem(
- //// key: Key(item['key']),
- // title: item["title"],
- // hintText: "请选择",
- // content: item["content"],
- // isMust: item["isMust"],
- // onTap: item["onTap"],
- // );
- }).toList(),
- );
- }
- }
|