Initial commit
This commit is contained in:
85
lib/models/event.dart
Normal file
85
lib/models/event.dart
Normal file
@@ -0,0 +1,85 @@
|
||||
class EventItem {
|
||||
final String id;
|
||||
final String entityName;
|
||||
final String description;
|
||||
final List<String> images;
|
||||
final DateTime publishTime;
|
||||
final DateTime? effectiveTime;
|
||||
final DateTime? endTime;
|
||||
final bool popupReminder;
|
||||
final String status;
|
||||
final String? creatorName;
|
||||
final DateTime createdAt;
|
||||
|
||||
const EventItem({
|
||||
required this.id,
|
||||
required this.entityName,
|
||||
required this.description,
|
||||
required this.images,
|
||||
required this.publishTime,
|
||||
this.effectiveTime,
|
||||
this.endTime,
|
||||
required this.popupReminder,
|
||||
required this.status,
|
||||
this.creatorName,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
EventItem copyWith({
|
||||
String? id,
|
||||
String? entityName,
|
||||
String? description,
|
||||
List<String>? images,
|
||||
DateTime? publishTime,
|
||||
DateTime? effectiveTime,
|
||||
DateTime? endTime,
|
||||
bool? popupReminder,
|
||||
String? status,
|
||||
String? creatorName,
|
||||
DateTime? createdAt,
|
||||
}) {
|
||||
return EventItem(
|
||||
id: id ?? this.id,
|
||||
entityName: entityName ?? this.entityName,
|
||||
description: description ?? this.description,
|
||||
images: images ?? this.images,
|
||||
publishTime: publishTime ?? this.publishTime,
|
||||
effectiveTime: effectiveTime ?? this.effectiveTime,
|
||||
endTime: endTime ?? this.endTime,
|
||||
popupReminder: popupReminder ?? this.popupReminder,
|
||||
status: status ?? this.status,
|
||||
creatorName: creatorName ?? this.creatorName,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'entityName': entityName,
|
||||
'description': description,
|
||||
'images': images,
|
||||
'publishTime': publishTime.toIso8601String(),
|
||||
'effectiveTime': effectiveTime?.toIso8601String(),
|
||||
'endTime': endTime?.toIso8601String(),
|
||||
'popupReminder': popupReminder,
|
||||
'status': status,
|
||||
'creatorName': creatorName,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
};
|
||||
|
||||
factory EventItem.fromJson(Map<String, dynamic> json) => EventItem(
|
||||
id: json['id'] ?? '',
|
||||
entityName: json['entityName'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
images: json['images'] != null ? List<String>.from(json['images']) : [],
|
||||
publishTime: DateTime.tryParse(json['publishTime'] ?? '') ?? DateTime.now(),
|
||||
effectiveTime: json['effectiveTime'] != null
|
||||
? DateTime.tryParse(json['effectiveTime'])
|
||||
: null,
|
||||
endTime: json['endTime'] != null ? DateTime.tryParse(json['endTime']) : null,
|
||||
popupReminder: json['popupReminder'] ?? false,
|
||||
status: json['status'] ?? 'draft',
|
||||
creatorName: json['creatorName'],
|
||||
createdAt: DateTime.tryParse(json['createdAt'] ?? '') ?? DateTime.now(),
|
||||
);
|
||||
}
|
||||
59
lib/models/message.dart
Normal file
59
lib/models/message.dart
Normal file
@@ -0,0 +1,59 @@
|
||||
enum MessageType { text, markdown, image, loading }
|
||||
|
||||
enum MessageSender { user, ai }
|
||||
|
||||
class ChatMessage {
|
||||
final String id;
|
||||
final String content;
|
||||
final MessageType type;
|
||||
final MessageSender sender;
|
||||
final DateTime timestamp;
|
||||
final List<String>? imageUrls;
|
||||
|
||||
const ChatMessage({
|
||||
required this.id,
|
||||
required this.content,
|
||||
required this.type,
|
||||
required this.sender,
|
||||
required this.timestamp,
|
||||
this.imageUrls,
|
||||
});
|
||||
|
||||
ChatMessage copyWith({
|
||||
String? id,
|
||||
String? content,
|
||||
MessageType? type,
|
||||
MessageSender? sender,
|
||||
DateTime? timestamp,
|
||||
List<String>? imageUrls,
|
||||
}) {
|
||||
return ChatMessage(
|
||||
id: id ?? this.id,
|
||||
content: content ?? this.content,
|
||||
type: type ?? this.type,
|
||||
sender: sender ?? this.sender,
|
||||
timestamp: timestamp ?? this.timestamp,
|
||||
imageUrls: imageUrls ?? this.imageUrls,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'content': content,
|
||||
'type': type.name,
|
||||
'sender': sender.name,
|
||||
'timestamp': timestamp.toIso8601String(),
|
||||
'imageUrls': imageUrls,
|
||||
};
|
||||
|
||||
factory ChatMessage.fromJson(Map<String, dynamic> json) => ChatMessage(
|
||||
id: json['id'] ?? '',
|
||||
content: json['content'] ?? '',
|
||||
type: MessageType.values.byName(json['type'] ?? 'text'),
|
||||
sender: MessageSender.values.byName(json['sender'] ?? 'user'),
|
||||
timestamp: DateTime.tryParse(json['timestamp'] ?? '') ?? DateTime.now(),
|
||||
imageUrls: json['imageUrls'] != null
|
||||
? List<String>.from(json['imageUrls'])
|
||||
: null,
|
||||
);
|
||||
}
|
||||
155
lib/models/order.dart
Normal file
155
lib/models/order.dart
Normal file
@@ -0,0 +1,155 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum OrderStatus {
|
||||
all,
|
||||
pendingPayment,
|
||||
pendingVerification,
|
||||
verified,
|
||||
pendingRefund,
|
||||
refunded,
|
||||
}
|
||||
|
||||
class OrderItem {
|
||||
final String id;
|
||||
final String orderNo;
|
||||
final String customerName;
|
||||
final String customerPhone;
|
||||
final String productName;
|
||||
final double amount;
|
||||
final OrderStatus status;
|
||||
final DateTime createdAt;
|
||||
final DateTime? paidAt;
|
||||
final DateTime? verifiedAt;
|
||||
final DateTime? refundedAt;
|
||||
final String? verifyCode;
|
||||
final int quantity;
|
||||
final String? remark;
|
||||
final String? scenicSpot;
|
||||
|
||||
const OrderItem({
|
||||
required this.id,
|
||||
required this.orderNo,
|
||||
required this.customerName,
|
||||
required this.customerPhone,
|
||||
required this.productName,
|
||||
required this.amount,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
this.paidAt,
|
||||
this.verifiedAt,
|
||||
this.refundedAt,
|
||||
this.verifyCode,
|
||||
required this.quantity,
|
||||
this.remark,
|
||||
this.scenicSpot,
|
||||
});
|
||||
|
||||
String get statusText {
|
||||
switch (status) {
|
||||
case OrderStatus.pendingPayment:
|
||||
return '待支付';
|
||||
case OrderStatus.pendingVerification:
|
||||
return '待核销';
|
||||
case OrderStatus.verified:
|
||||
return '已核销';
|
||||
case OrderStatus.pendingRefund:
|
||||
return '待退款';
|
||||
case OrderStatus.refunded:
|
||||
return '已退款';
|
||||
default:
|
||||
return '全部';
|
||||
}
|
||||
}
|
||||
|
||||
Color get statusColor {
|
||||
switch (status) {
|
||||
case OrderStatus.pendingPayment:
|
||||
return const Color(0xFFF59E0B);
|
||||
case OrderStatus.pendingVerification:
|
||||
return const Color(0xFF3B82F6);
|
||||
case OrderStatus.verified:
|
||||
return const Color(0xFF10B981);
|
||||
case OrderStatus.pendingRefund:
|
||||
return const Color(0xFFEF4444);
|
||||
case OrderStatus.refunded:
|
||||
return const Color(0xFF64748B);
|
||||
default:
|
||||
return const Color(0xFF64748B);
|
||||
}
|
||||
}
|
||||
|
||||
bool get canVerify => status == OrderStatus.pendingVerification;
|
||||
bool get canRefund => status == OrderStatus.pendingVerification || status == OrderStatus.verified;
|
||||
|
||||
OrderItem copyWith({
|
||||
String? id,
|
||||
String? orderNo,
|
||||
String? customerName,
|
||||
String? customerPhone,
|
||||
String? productName,
|
||||
double? amount,
|
||||
OrderStatus? status,
|
||||
DateTime? createdAt,
|
||||
DateTime? paidAt,
|
||||
DateTime? verifiedAt,
|
||||
DateTime? refundedAt,
|
||||
String? verifyCode,
|
||||
int? quantity,
|
||||
String? remark,
|
||||
String? scenicSpot,
|
||||
}) {
|
||||
return OrderItem(
|
||||
id: id ?? this.id,
|
||||
orderNo: orderNo ?? this.orderNo,
|
||||
customerName: customerName ?? this.customerName,
|
||||
customerPhone: customerPhone ?? this.customerPhone,
|
||||
productName: productName ?? this.productName,
|
||||
amount: amount ?? this.amount,
|
||||
status: status ?? this.status,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
paidAt: paidAt ?? this.paidAt,
|
||||
verifiedAt: verifiedAt ?? this.verifiedAt,
|
||||
refundedAt: refundedAt ?? this.refundedAt,
|
||||
verifyCode: verifyCode ?? this.verifyCode,
|
||||
quantity: quantity ?? this.quantity,
|
||||
remark: remark ?? this.remark,
|
||||
scenicSpot: scenicSpot ?? this.scenicSpot,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'orderNo': orderNo,
|
||||
'customerName': customerName,
|
||||
'customerPhone': customerPhone,
|
||||
'productName': productName,
|
||||
'amount': amount,
|
||||
'status': status.name,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'paidAt': paidAt?.toIso8601String(),
|
||||
'verifiedAt': verifiedAt?.toIso8601String(),
|
||||
'refundedAt': refundedAt?.toIso8601String(),
|
||||
'verifyCode': verifyCode,
|
||||
'quantity': quantity,
|
||||
'remark': remark,
|
||||
'scenicSpot': scenicSpot,
|
||||
};
|
||||
|
||||
factory OrderItem.fromJson(Map<String, dynamic> json) => OrderItem(
|
||||
id: json['id'] ?? '',
|
||||
orderNo: json['orderNo'] ?? '',
|
||||
customerName: json['customerName'] ?? '',
|
||||
customerPhone: json['customerPhone'] ?? '',
|
||||
productName: json['productName'] ?? '',
|
||||
amount: (json['amount'] ?? 0.0).toDouble(),
|
||||
status: OrderStatus.values.byName(json['status'] ?? 'pendingPayment'),
|
||||
createdAt: DateTime.tryParse(json['createdAt'] ?? '') ?? DateTime.now(),
|
||||
paidAt: json['paidAt'] != null ? DateTime.tryParse(json['paidAt']) : null,
|
||||
verifiedAt: json['verifiedAt'] != null ? DateTime.tryParse(json['verifiedAt']) : null,
|
||||
refundedAt: json['refundedAt'] != null ? DateTime.tryParse(json['refundedAt']) : null,
|
||||
verifyCode: json['verifyCode'],
|
||||
quantity: json['quantity'] ?? 1,
|
||||
remark: json['remark'],
|
||||
scenicSpot: json['scenicSpot'],
|
||||
);
|
||||
}
|
||||
69
lib/models/user.dart
Normal file
69
lib/models/user.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
enum UserRole { boss, employee }
|
||||
|
||||
class User {
|
||||
final String id;
|
||||
final String phone;
|
||||
final String name;
|
||||
final String avatar;
|
||||
final UserRole role;
|
||||
final String token;
|
||||
final String? hotelName;
|
||||
final String? scenicName;
|
||||
|
||||
const User({
|
||||
required this.id,
|
||||
required this.phone,
|
||||
required this.name,
|
||||
required this.avatar,
|
||||
required this.role,
|
||||
required this.token,
|
||||
this.hotelName,
|
||||
this.scenicName,
|
||||
});
|
||||
|
||||
bool get isBoss => role == UserRole.boss;
|
||||
|
||||
User copyWith({
|
||||
String? id,
|
||||
String? phone,
|
||||
String? name,
|
||||
String? avatar,
|
||||
UserRole? role,
|
||||
String? token,
|
||||
String? hotelName,
|
||||
String? scenicName,
|
||||
}) {
|
||||
return User(
|
||||
id: id ?? this.id,
|
||||
phone: phone ?? this.phone,
|
||||
name: name ?? this.name,
|
||||
avatar: avatar ?? this.avatar,
|
||||
role: role ?? this.role,
|
||||
token: token ?? this.token,
|
||||
hotelName: hotelName ?? this.hotelName,
|
||||
scenicName: scenicName ?? this.scenicName,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'phone': phone,
|
||||
'name': name,
|
||||
'avatar': avatar,
|
||||
'role': role.name,
|
||||
'token': token,
|
||||
'hotelName': hotelName,
|
||||
'scenicName': scenicName,
|
||||
};
|
||||
|
||||
factory User.fromJson(Map<String, dynamic> json) => User(
|
||||
id: json['id'] ?? '',
|
||||
phone: json['phone'] ?? '',
|
||||
name: json['name'] ?? '',
|
||||
avatar: json['avatar'] ?? '',
|
||||
role: UserRole.values.byName(json['role'] ?? 'employee'),
|
||||
token: json['token'] ?? '',
|
||||
hotelName: json['hotelName'],
|
||||
scenicName: json['scenicName'],
|
||||
);
|
||||
}
|
||||
121
lib/models/work_order.dart
Normal file
121
lib/models/work_order.dart
Normal file
@@ -0,0 +1,121 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
enum WorkOrderStatus { all, pending, processing, completed }
|
||||
|
||||
class WorkOrder {
|
||||
final String id;
|
||||
final String title;
|
||||
final String description;
|
||||
final WorkOrderStatus status;
|
||||
final String creatorName;
|
||||
final String? assigneeName;
|
||||
final DateTime createdAt;
|
||||
final DateTime? completedAt;
|
||||
final String priority;
|
||||
final String category;
|
||||
final List<String> images;
|
||||
final String? location;
|
||||
|
||||
const WorkOrder({
|
||||
required this.id,
|
||||
required this.title,
|
||||
required this.description,
|
||||
required this.status,
|
||||
required this.creatorName,
|
||||
this.assigneeName,
|
||||
required this.createdAt,
|
||||
this.completedAt,
|
||||
required this.priority,
|
||||
required this.category,
|
||||
required this.images,
|
||||
this.location,
|
||||
});
|
||||
|
||||
String get statusText {
|
||||
switch (status) {
|
||||
case WorkOrderStatus.pending:
|
||||
return '待处理';
|
||||
case WorkOrderStatus.processing:
|
||||
return '处理中';
|
||||
case WorkOrderStatus.completed:
|
||||
return '已完成';
|
||||
default:
|
||||
return '全部';
|
||||
}
|
||||
}
|
||||
|
||||
Color get statusColor {
|
||||
switch (status) {
|
||||
case WorkOrderStatus.pending:
|
||||
return const Color(0xFFF59E0B);
|
||||
case WorkOrderStatus.processing:
|
||||
return const Color(0xFF3B82F6);
|
||||
case WorkOrderStatus.completed:
|
||||
return const Color(0xFF10B981);
|
||||
default:
|
||||
return const Color(0xFF64748B);
|
||||
}
|
||||
}
|
||||
|
||||
WorkOrder copyWith({
|
||||
String? id,
|
||||
String? title,
|
||||
String? description,
|
||||
WorkOrderStatus? status,
|
||||
String? creatorName,
|
||||
String? assigneeName,
|
||||
DateTime? createdAt,
|
||||
DateTime? completedAt,
|
||||
String? priority,
|
||||
String? category,
|
||||
List<String>? images,
|
||||
String? location,
|
||||
}) {
|
||||
return WorkOrder(
|
||||
id: id ?? this.id,
|
||||
title: title ?? this.title,
|
||||
description: description ?? this.description,
|
||||
status: status ?? this.status,
|
||||
creatorName: creatorName ?? this.creatorName,
|
||||
assigneeName: assigneeName ?? this.assigneeName,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
completedAt: completedAt ?? this.completedAt,
|
||||
priority: priority ?? this.priority,
|
||||
category: category ?? this.category,
|
||||
images: images ?? this.images,
|
||||
location: location ?? this.location,
|
||||
);
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'id': id,
|
||||
'title': title,
|
||||
'description': description,
|
||||
'status': status.name,
|
||||
'creatorName': creatorName,
|
||||
'assigneeName': assigneeName,
|
||||
'createdAt': createdAt.toIso8601String(),
|
||||
'completedAt': completedAt?.toIso8601String(),
|
||||
'priority': priority,
|
||||
'category': category,
|
||||
'images': images,
|
||||
'location': location,
|
||||
};
|
||||
|
||||
factory WorkOrder.fromJson(Map<String, dynamic> json) => WorkOrder(
|
||||
id: json['id'] ?? '',
|
||||
title: json['title'] ?? '',
|
||||
description: json['description'] ?? '',
|
||||
status: WorkOrderStatus.values.byName(json['status'] ?? 'pending'),
|
||||
creatorName: json['creatorName'] ?? '',
|
||||
assigneeName: json['assigneeName'],
|
||||
createdAt: DateTime.tryParse(json['createdAt'] ?? '') ?? DateTime.now(),
|
||||
completedAt: json['completedAt'] != null
|
||||
? DateTime.tryParse(json['completedAt'])
|
||||
: null,
|
||||
priority: json['priority'] ?? 'normal',
|
||||
category: json['category'] ?? '',
|
||||
images: json['images'] != null ? List<String>.from(json['images']) : [],
|
||||
location: json['location'],
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user