重构 key manage record model

hmxc
张萌 3 years ago
parent 4f4b3b145d
commit 5905d35f5c

@ -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<String, dynamic> 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,
});
}

@ -0,0 +1,21 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'key_manage_record_list_model.dart';
// **************************************************************************
// JsonSerializableGenerator
// **************************************************************************
KeyManageRecordListModel _$KeyManageRecordListModelFromJson(
Map<String, dynamic> 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?,
);
}

@ -1,48 +1,47 @@
import 'package:common_utils/common_utils.dart'; // import 'package:common_utils/common_utils.dart';
//
class KeyManageRecordListModel { // class KeyManageRecordListModel {
int? id; // int? id;
String? code; // String? code;
int? status; // int? status;
String? facilityName; // String? facilityName;
String? correspondingPosition; // String? correspondingPosition;
String? storageLocation; // String? storageLocation;
String? auditDate; // String? auditDate;
String? reason; // String? reason;
//
KeyManageRecordListModel( // KeyManageRecordListModel(
{required this.id, // {required this.id,
this.code, // this.code,
this.status, // this.status,
this.facilityName, // this.facilityName,
this.correspondingPosition, // this.correspondingPosition,
this.storageLocation, // this.storageLocation,
this.auditDate, // this.auditDate,
this.reason}); // this.reason});
//
KeyManageRecordListModel.fromJson(Map<String, dynamic> json) { // KeyManageRecordListModel.fromJson(Map<String, dynamic> json) {
id = json['id']; // id = json['id'];
code = json['code']; // code = json['code'];
status = json['status']; // status = json['status'];
facilityName = json['facilityName']; // facilityName = json['facilityName'];
correspondingPosition = json['correspondingPosition']; // correspondingPosition = json['correspondingPosition'];
storageLocation = json['storageLocation']; // storageLocation = json['storageLocation'];
auditDate = json['auditDate']; // auditDate = json['auditDate'];
reason = json['reason']; // reason = json['reason'];
} // }
//
Map<String, dynamic> toJson() { // Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>(); // final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id; // data['id'] = this.id;
data['code'] = this.code; // data['code'] = this.code;
data['status'] = this.status; // data['status'] = this.status;
data['facilityName'] = this.facilityName; // data['facilityName'] = this.facilityName;
data['correspondingPosition'] = this.correspondingPosition; // data['correspondingPosition'] = this.correspondingPosition;
data['storageLocation'] = this.storageLocation; // data['storageLocation'] = this.storageLocation;
data['auditDate'] = this.auditDate; // data['auditDate'] = this.auditDate;
data['reason'] = this.reason; // data['reason'] = this.reason;
return data; // return data;
} // }
//
String get auditDateString => DateUtil.formatDateStr(this.auditDate!,format: 'yyyy-MM-dd HH:mm'); // }
}

@ -1,26 +1,26 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart'; 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/base_model.dart';
import 'package:aku_community_manager/utils/network/net_util.dart'; import 'package:aku_community_manager/utils/network/net_util.dart';
import 'package:bot_toast/bot_toast.dart'; import 'package:bot_toast/bot_toast.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
// Package imports: // Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:velocity_x/velocity_x.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 { class KeyApplyRecordCard extends StatefulWidget {
final int index; final int index;
final KeyManageRecordListModel model; final KeyManageRecordListModel model;
final VoidCallback? callRefresh; 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 @override
_KeyApplyRecordCardState createState() => _KeyApplyRecordCardState(); _KeyApplyRecordCardState createState() => _KeyApplyRecordCardState();
@ -39,16 +39,18 @@ class _KeyApplyRecordCardState extends State<KeyApplyRecordCard> {
children: [ children: [
Row( Row(
children: [ children: [
widget.model.facilityName!.text (widget.model.facilityName ?? '')
.text
.size(32.sp) .size(32.sp)
.color(kTextPrimaryColor) .color(kTextPrimaryColor)
.bold .bold
.make(), .make(),
Spacer(), Spacer(),
KeyManageMap.keyRecordStatus[widget.model.status!]!.text KeyManageMap.keyRecordStatus[widget.model.status]!.text
.size(28.sp) .size(28.sp)
.bold .bold
.color(KeyManageMap.keyRecordStatusColor[widget.model.status!]!) .color(
KeyManageMap.keyRecordStatusColor[widget.model.status]!)
.make() .make()
], ],
), ),
@ -59,14 +61,16 @@ class _KeyApplyRecordCardState extends State<KeyApplyRecordCard> {
_rowTile( _rowTile(
R.ASSETS_MANAGE_LOCK_PNG, R.ASSETS_MANAGE_LOCK_PNG,
'对应设备位置', '对应设备位置',
widget.model.correspondingPosition!.text (widget.model.correspondingPosition ?? '')
.text
.size(24.sp) .size(24.sp)
.color(kTextSubColor) .color(kTextSubColor)
.make()), .make()),
_rowTile( _rowTile(
R.ASSETS_OUTDOOR_IC_ADDRESS_PNG, R.ASSETS_OUTDOOR_IC_ADDRESS_PNG,
'存放地址', '存放地址',
widget.model.storageLocation!.text (widget.model.storageLocation ?? '')
.text
.size(24.sp) .size(24.sp)
.color(kTextSubColor) .color(kTextSubColor)
.make()), .make()),
@ -96,7 +100,7 @@ class _KeyApplyRecordCardState extends State<KeyApplyRecordCard> {
button = _bottomButton('重新申请', () async { button = _bottomButton('重新申请', () async {
BaseModel baseModel = await NetUtil() BaseModel baseModel = await NetUtil()
.post(API.manage.applyKey, params: {"keyId": widget.model.id}); .post(API.manage.applyKey, params: {"keyId": widget.model.id});
BotToast.showText(text: baseModel.message!); BotToast.showText(text: baseModel.message ?? '网络错误');
widget.callRefresh!(); widget.callRefresh!();
}, Colors.white, Colors.black) as MaterialButton?; }, Colors.white, Colors.black) as MaterialButton?;
break; break;

@ -1,15 +1,13 @@
// Flutter imports: // Flutter imports:
import 'package:aku_community_manager/const/api.dart'; 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:aku_community_manager/ui/widgets/common/bee_list_view.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart';
// Package imports: // Package imports:
import 'package:flutter_screenutil/flutter_screenutil.dart'; 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'; import 'package:velocity_x/velocity_x.dart';
class KeyApplyRecordView extends StatefulWidget { class KeyApplyRecordView extends StatefulWidget {

Loading…
Cancel
Save