| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127 |
- import 'package:deus_app/common/style/TitleBar.dart';
- import 'package:deus_app/common/style/gsy_style.dart';
- import 'package:deus_app/common/utils/DioUtil.dart';
- import 'package:deus_app/common/utils/ToastUtils.dart';
- import 'package:deus_app/generated/json/repair_query_device_response_entity_helper.dart';
- import 'package:deus_app/main.dart';
- import 'package:deus_app/model/repair_query_device_response_entity.dart';
- import 'package:flutter/material.dart';
- class RepairJobDeviceList extends StatefulWidget {
- @override
- State createState() {
- return new _RepairJobDeviceList();
- }
- }
- class _RepairJobDeviceList extends State<RepairJobDeviceList> {
- RepairQueryDeviceResponseEntity data = RepairQueryDeviceResponseEntity();
- List<RepairQueryDeviceResponseDataList> mList = [];
- @override
- void initState() {
- super.initState();
- patrolItemModel();
- }
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: TitleBar().backAppbar("添加巡检项目"),
- backgroundColor: const Color(0xfff2f2f2),
- body: Container(
- child: ListView.builder(
- itemCount: mList.length,
- itemBuilder: (context, index) {
- return Container(
- margin: EdgeInsets.only(top: 12, left: 10, right: 10),
- padding: EdgeInsets.only(top: 12, bottom: 10),
- color: Colors.white,
- child: ListTile(
- title: Column(
- children: [
- Row(
- mainAxisAlignment: MainAxisAlignment.spaceBetween,
- children: [
- Container(
- child: Text(
- mList[index].showName,
- style: const TextStyle(
- color: Colors.black,
- fontSize: GSYConstant.middleTextWhiteSize,
- fontWeight: FontWeight.bold,
- ),
- ),
- ),
- Container(
- padding: EdgeInsets.only(
- top: 3, bottom: 3, left: 5, right: 5),
- child: Text(
- mList[index].status == 0
- ? '在线'
- : mList[index].status == 1
- ? '离线'
- : mList[index].status == 2
- ? '未激活'
- : '未知',
- textAlign: TextAlign.right,
- style: TextStyle(
- color: mList[index].status == 0
- ? Colors.blue
- : mList[index].status == 1
- ? Colors.orange
- : mList[index].status == 2
- ? Colors.red
- : Colors.black,
- fontSize: GSYConstant.minTextSize,
- ),
- ),
- decoration: BoxDecoration(
- border: new Border.all(
- color: mList[index].status == 0
- ? Colors.blue
- : mList[index].status == 1
- ? Colors.orange
- : mList[index].status == 2
- ? Colors.red
- : Colors.black, //边框颜色
- width: 1.0, //边框粗细
- ),
- borderRadius: const BorderRadius.all(
- const Radius.circular(3.0)), //边框的弧度
- ),
- )
- ]),
- SizedBox(
- height: 5,
- ),
- ],
- ),
- onTap: () {
- eventBus.fire(mList[index]);
- Navigator.pop(context);
- },
- ));
- },
- ),
- ));
- }
- patrolItemModel() async {
- var result = await DioUtil().request('repair-bill/query-device',
- method: DioMethod.post, data: {'query': {}});
- if (0 == result['code']) {
- setState(() {
- data = repairQueryDeviceResponseEntityFromJson(
- RepairQueryDeviceResponseEntity(), result);
- mList.clear();
- mList.addAll(data.data.xList);
- });
- } else {
- showToast(result['msg']);
- }
- }
- }
|