From 5905d35f5c5e5fa92ac3836c24732345b5fce653 Mon Sep 17 00:00:00 2001 From: zhangmeng <494089941@qq.com> Date: Mon, 30 Aug 2021 15:35:20 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=20key=20manage=20record=20mo?= =?UTF-8?q?del?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../key_manage_record_list_model.dart | 31 ++++++ .../key_manage_record_list_model.g.dart | 21 ++++ .../key_manage_record_list_model.dart | 95 +++++++++---------- .../key_manage/key_apply_record_card.dart | 34 ++++--- .../key_manage/key_apply_record_view.dart | 8 +- 5 files changed, 121 insertions(+), 68 deletions(-) create mode 100644 lib/json_models/manager/key_manage/key_manage_record_list_model.dart create mode 100644 lib/json_models/manager/key_manage/key_manage_record_list_model.g.dart diff --git a/lib/json_models/manager/key_manage/key_manage_record_list_model.dart b/lib/json_models/manager/key_manage/key_manage_record_list_model.dart new file mode 100644 index 0000000..3f19309 --- /dev/null +++ b/lib/json_models/manager/key_manage/key_manage_record_list_model.dart @@ -0,0 +1,31 @@ +import 'package:common_utils/common_utils.dart'; +import 'package:json_annotation/json_annotation.dart'; + +part 'key_manage_record_list_model.g.dart'; + +@JsonSerializable() +class KeyManageRecordListModel { + int id; + String code; + int status; + String? facilityName; + String? correspondingPosition; + String? storageLocation; + String? auditDate; + String? reason; + factory KeyManageRecordListModel.fromJson(Map json) => + _$KeyManageRecordListModelFromJson(json); + String get auditDateString => + DateUtil.formatDateStr(auditDate ?? '', format: 'yyyy-MM-dd HH:mm'); + + KeyManageRecordListModel({ + required this.id, + required this.code, + required this.status, + this.facilityName, + this.correspondingPosition, + this.storageLocation, + this.auditDate, + this.reason, + }); +} diff --git a/lib/json_models/manager/key_manage/key_manage_record_list_model.g.dart b/lib/json_models/manager/key_manage/key_manage_record_list_model.g.dart new file mode 100644 index 0000000..1d2acbe --- /dev/null +++ b/lib/json_models/manager/key_manage/key_manage_record_list_model.g.dart @@ -0,0 +1,21 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'key_manage_record_list_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +KeyManageRecordListModel _$KeyManageRecordListModelFromJson( + Map json) { + return KeyManageRecordListModel( + id: json['id'] as int, + code: json['code'] as String, + status: json['status'] as int, + facilityName: json['facilityName'] as String?, + correspondingPosition: json['correspondingPosition'] as String?, + storageLocation: json['storageLocation'] as String?, + auditDate: json['auditDate'] as String?, + reason: json['reason'] as String?, + ); +} diff --git a/lib/models/manager/key_manage/key_manage_record_list_model.dart b/lib/models/manager/key_manage/key_manage_record_list_model.dart index f4ca7cd..3e1029b 100644 --- a/lib/models/manager/key_manage/key_manage_record_list_model.dart +++ b/lib/models/manager/key_manage/key_manage_record_list_model.dart @@ -1,48 +1,47 @@ -import 'package:common_utils/common_utils.dart'; - -class KeyManageRecordListModel { - int? id; - String? code; - int? status; - String? facilityName; - String? correspondingPosition; - String? storageLocation; - String? auditDate; - String? reason; - - KeyManageRecordListModel( - {required this.id, - this.code, - this.status, - this.facilityName, - this.correspondingPosition, - this.storageLocation, - this.auditDate, - this.reason}); - - KeyManageRecordListModel.fromJson(Map json) { - id = json['id']; - code = json['code']; - status = json['status']; - facilityName = json['facilityName']; - correspondingPosition = json['correspondingPosition']; - storageLocation = json['storageLocation']; - auditDate = json['auditDate']; - reason = json['reason']; - } - - Map toJson() { - final Map data = new Map(); - data['id'] = this.id; - data['code'] = this.code; - data['status'] = this.status; - data['facilityName'] = this.facilityName; - data['correspondingPosition'] = this.correspondingPosition; - data['storageLocation'] = this.storageLocation; - data['auditDate'] = this.auditDate; - data['reason'] = this.reason; - return data; - } - - String get auditDateString => DateUtil.formatDateStr(this.auditDate!,format: 'yyyy-MM-dd HH:mm'); -} +// import 'package:common_utils/common_utils.dart'; +// +// class KeyManageRecordListModel { +// int? id; +// String? code; +// int? status; +// String? facilityName; +// String? correspondingPosition; +// String? storageLocation; +// String? auditDate; +// String? reason; +// +// KeyManageRecordListModel( +// {required this.id, +// this.code, +// this.status, +// this.facilityName, +// this.correspondingPosition, +// this.storageLocation, +// this.auditDate, +// this.reason}); +// +// KeyManageRecordListModel.fromJson(Map json) { +// id = json['id']; +// code = json['code']; +// status = json['status']; +// facilityName = json['facilityName']; +// correspondingPosition = json['correspondingPosition']; +// storageLocation = json['storageLocation']; +// auditDate = json['auditDate']; +// reason = json['reason']; +// } +// +// Map toJson() { +// final Map data = new Map(); +// data['id'] = this.id; +// data['code'] = this.code; +// data['status'] = this.status; +// data['facilityName'] = this.facilityName; +// data['correspondingPosition'] = this.correspondingPosition; +// data['storageLocation'] = this.storageLocation; +// data['auditDate'] = this.auditDate; +// data['reason'] = this.reason; +// return data; +// } +// +// } diff --git a/lib/ui/manage_pages/key_manage/key_apply_record_card.dart b/lib/ui/manage_pages/key_manage/key_apply_record_card.dart index cbda4a8..db92cb3 100644 --- a/lib/ui/manage_pages/key_manage/key_apply_record_card.dart +++ b/lib/ui/manage_pages/key_manage/key_apply_record_card.dart @@ -1,26 +1,26 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; -import 'package:aku_community_manager/models/manager/key_manage/key_manage_record_list_model.dart'; +import 'package:aku_community_manager/json_models/manager/key_manage/key_manage_record_list_model.dart'; +// Project imports: +import 'package:aku_community_manager/style/app_style.dart'; +import 'package:aku_community_manager/tools/aku_divider.dart'; +import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_map.dart'; import 'package:aku_community_manager/utils/network/base_model.dart'; import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; - // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:velocity_x/velocity_x.dart'; -// Project imports: -import 'package:aku_community_manager/style/app_style.dart'; -import 'package:aku_community_manager/tools/aku_divider.dart'; -import 'package:aku_community_manager/tools/extensions/list_extension_tool.dart'; -import 'package:aku_community_manager/ui/manage_pages/key_manage/key_manage_map.dart'; - class KeyApplyRecordCard extends StatefulWidget { final int index; final KeyManageRecordListModel model; final VoidCallback? callRefresh; - KeyApplyRecordCard({Key? key, required this.index, required this.model, this.callRefresh}) : super(key: key); + KeyApplyRecordCard( + {Key? key, required this.index, required this.model, this.callRefresh}) + : super(key: key); @override _KeyApplyRecordCardState createState() => _KeyApplyRecordCardState(); @@ -39,16 +39,18 @@ class _KeyApplyRecordCardState extends State { children: [ Row( children: [ - widget.model.facilityName!.text + (widget.model.facilityName ?? '') + .text .size(32.sp) .color(kTextPrimaryColor) .bold .make(), Spacer(), - KeyManageMap.keyRecordStatus[widget.model.status!]!.text + KeyManageMap.keyRecordStatus[widget.model.status]!.text .size(28.sp) .bold - .color(KeyManageMap.keyRecordStatusColor[widget.model.status!]!) + .color( + KeyManageMap.keyRecordStatusColor[widget.model.status]!) .make() ], ), @@ -59,14 +61,16 @@ class _KeyApplyRecordCardState extends State { _rowTile( R.ASSETS_MANAGE_LOCK_PNG, '对应设备位置', - widget.model.correspondingPosition!.text + (widget.model.correspondingPosition ?? '') + .text .size(24.sp) .color(kTextSubColor) .make()), _rowTile( R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, '存放地址', - widget.model.storageLocation!.text + (widget.model.storageLocation ?? '') + .text .size(24.sp) .color(kTextSubColor) .make()), @@ -96,7 +100,7 @@ class _KeyApplyRecordCardState extends State { button = _bottomButton('重新申请', () async { BaseModel baseModel = await NetUtil() .post(API.manage.applyKey, params: {"keyId": widget.model.id}); - BotToast.showText(text: baseModel.message!); + BotToast.showText(text: baseModel.message ?? '网络错误'); widget.callRefresh!(); }, Colors.white, Colors.black) as MaterialButton?; break; diff --git a/lib/ui/manage_pages/key_manage/key_apply_record_view.dart b/lib/ui/manage_pages/key_manage/key_apply_record_view.dart index 853a0f0..100d119 100644 --- a/lib/ui/manage_pages/key_manage/key_apply_record_view.dart +++ b/lib/ui/manage_pages/key_manage/key_apply_record_view.dart @@ -1,15 +1,13 @@ // Flutter imports: import 'package:aku_community_manager/const/api.dart'; -import 'package:aku_community_manager/models/manager/key_manage/key_manage_record_list_model.dart'; +import 'package:aku_community_manager/json_models/manager/key_manage/key_manage_record_list_model.dart'; +// Project imports: +import 'package:aku_community_manager/ui/manage_pages/key_manage/key_apply_record_card.dart'; import 'package:aku_community_manager/ui/widgets/common/bee_list_view.dart'; import 'package:flutter/material.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; - // Package imports: import 'package:flutter_screenutil/flutter_screenutil.dart'; - -// Project imports: -import 'package:aku_community_manager/ui/manage_pages/key_manage/key_apply_record_card.dart'; import 'package:velocity_x/velocity_x.dart'; class KeyApplyRecordView extends StatefulWidget {