- 在 DetailItemScreen 中添加删除物品的按钮和确认对话框 - 在 ItemProvider 中实现删除物品的方法 - 在 ItemRepository 中实现删除物品的数据库操作 - 在 ItemModel 中添加 status 字段,用于标记物品状态
63 lines
1.4 KiB
Dart
63 lines
1.4 KiB
Dart
class Item {
|
|
int? id;
|
|
// 名称
|
|
final String name;
|
|
// 分类
|
|
final int? categoryId;
|
|
// 位置
|
|
final int? locationId;
|
|
// 描述
|
|
final String? description;
|
|
// 购买日期
|
|
final DateTime? purchaseDate;
|
|
// 是否使用
|
|
final String? isInUse;
|
|
// 数据状态 -normal -deleted
|
|
final String? status;
|
|
// 创建时间
|
|
final DateTime? createdAt;
|
|
// 更新时间
|
|
final DateTime? updatedAt;
|
|
|
|
Item({
|
|
this.id,
|
|
required this.name,
|
|
this.categoryId,
|
|
this.locationId,
|
|
this.description,
|
|
this.purchaseDate,
|
|
this.isInUse = 'no',
|
|
this.status = 'normal',
|
|
this.createdAt,
|
|
this.updatedAt,
|
|
});
|
|
|
|
Map<String, dynamic> toMap() {
|
|
return {
|
|
'name': name,
|
|
'category_id': categoryId,
|
|
'location_id': locationId,
|
|
'description': description,
|
|
'purchase_date': purchaseDate,
|
|
'is_in_use': isInUse,
|
|
'status': status,
|
|
'created_at': createdAt,
|
|
'updated_at': updatedAt,
|
|
};
|
|
}
|
|
|
|
factory Item.fromMap(Map<String, dynamic> map) {
|
|
return Item(
|
|
id: map['id'],
|
|
name: map['name'],
|
|
categoryId: map['category_id'],
|
|
locationId: map['location_id'],
|
|
description: map['description'],
|
|
purchaseDate: map['purchase_date'],
|
|
isInUse: map['is_in_use'],
|
|
status: map['status'],
|
|
createdAt: map['created_at'],
|
|
updatedAt: map['updated_at'],
|
|
);
|
|
}
|
|
} |