重构 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';
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<String, dynamic> 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<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
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<String, dynamic> 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<String, dynamic> toJson() {
// final Map<String, dynamic> data = new Map<String, dynamic>();
// 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;
// }
//
// }

@ -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<KeyApplyRecordCard> {
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<KeyApplyRecordCard> {
_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<KeyApplyRecordCard> {
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;

@ -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 {

Loading…
Cancel
Save