所有一级页面和不分二级页面
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../../domain/entities/workorder_entity.dart';
|
||||
|
||||
/// 工单统计卡片组件
|
||||
class WorkOrderCountCard extends StatelessWidget {
|
||||
final WorkOrderCountEntity count;
|
||||
|
||||
const WorkOrderCountCard({
|
||||
Key? key,
|
||||
required this.count,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: AppConstants.horizontalPadding,
|
||||
vertical: AppConstants.moduleSpacing / 2,
|
||||
),
|
||||
padding: const EdgeInsets.all(20),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.backgroundColor,
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
boxShadow: AppConstants.cardShadow,
|
||||
),
|
||||
child: Row(
|
||||
children: [
|
||||
_buildCountItem(
|
||||
label: '待处理',
|
||||
value: count.pendingCount.toString(),
|
||||
valueColor: WorkOrderColors.primaryText,
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildCountItem(
|
||||
label: '执行中',
|
||||
value: count.executingCount.toString(),
|
||||
valueColor: WorkOrderColors.primaryText,
|
||||
),
|
||||
_buildDivider(),
|
||||
_buildCountItem(
|
||||
label: '今日完成',
|
||||
value: count.todayCompletedCount.toString(),
|
||||
valueColor: WorkOrderColors.primary,
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildCountItem({
|
||||
required String label,
|
||||
required String value,
|
||||
required Color valueColor,
|
||||
}) {
|
||||
return Expanded(
|
||||
child: Column(
|
||||
children: [
|
||||
Text(
|
||||
label,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 28,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: valueColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDivider() {
|
||||
return Container(
|
||||
width: 1,
|
||||
height: 40,
|
||||
color: const Color(0xFFF0F0F0),
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,252 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
import '../../domain/entities/workorder_entity.dart';
|
||||
|
||||
/// 工单项卡片组件
|
||||
class WorkOrderItemCard extends StatelessWidget {
|
||||
final WorkOrderEntity workOrder;
|
||||
final VoidCallback? onTap;
|
||||
|
||||
const WorkOrderItemCard({
|
||||
Key? key,
|
||||
required this.workOrder,
|
||||
this.onTap,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return GestureDetector(
|
||||
onTap: onTap,
|
||||
child: Container(
|
||||
margin: EdgeInsets.symmetric(
|
||||
horizontal: AppConstants.horizontalPadding,
|
||||
vertical: 8,
|
||||
),
|
||||
padding: const EdgeInsets.all(16),
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.backgroundColor,
|
||||
borderRadius: BorderRadius.circular(AppConstants.borderRadius),
|
||||
boxShadow: AppConstants.cardShadow,
|
||||
),
|
||||
child: Stack(
|
||||
children: [
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
// 标题和状态标签
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
Expanded(
|
||||
child: Text(
|
||||
workOrder.title,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: AppConstants.primaryTextColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
_buildStatusTag(),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
|
||||
// 详情信息
|
||||
_buildDetailRow('工单号', workOrder.orderNo),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// 优先级
|
||||
_buildDetailRow(
|
||||
'优先级',
|
||||
_getPriorityText(workOrder.priority),
|
||||
valueColor: _getPriorityColor(workOrder.priority),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
|
||||
// 根据状态显示不同信息
|
||||
if (workOrder.status == WorkOrderStatus.pending) ...[
|
||||
_buildDetailRow(
|
||||
'创建时间',
|
||||
_formatDateTime(workOrder.createTime),
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
] else if (workOrder.status == WorkOrderStatus.executing) ...[
|
||||
_buildDetailRow('执行人', workOrder.executor ?? '-'),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
if (workOrder.progress != null) ...[
|
||||
const SizedBox(height: 12),
|
||||
_buildProgressBar(),
|
||||
],
|
||||
] else if (workOrder.status == WorkOrderStatus.completed) ...[
|
||||
_buildDetailRow(
|
||||
'完成时间',
|
||||
workOrder.completeTime != null
|
||||
? _formatDateTime(workOrder.completeTime!)
|
||||
: '-',
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
_buildDetailRow('地点', workOrder.location),
|
||||
],
|
||||
],
|
||||
),
|
||||
// 已完成水印
|
||||
if (workOrder.status == WorkOrderStatus.completed)
|
||||
Positioned(
|
||||
right: 8,
|
||||
bottom: 8,
|
||||
child: Opacity(
|
||||
opacity: 0.3,
|
||||
child: Image.asset(
|
||||
'assets/images/yiwancheng.png',
|
||||
width: 60,
|
||||
height: 60,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildStatusTag() {
|
||||
Color color;
|
||||
String text;
|
||||
|
||||
switch (workOrder.status) {
|
||||
case WorkOrderStatus.pending:
|
||||
color = AppConstants.pendingColor;
|
||||
text = '待处理';
|
||||
break;
|
||||
case WorkOrderStatus.executing:
|
||||
color = AppConstants.executingColor;
|
||||
text = '执行中';
|
||||
break;
|
||||
case WorkOrderStatus.completed:
|
||||
color = AppConstants.completedColor;
|
||||
text = '已完成';
|
||||
break;
|
||||
default:
|
||||
color = AppConstants.auxiliaryTextColor;
|
||||
text = '未知';
|
||||
}
|
||||
|
||||
return Row(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
children: [
|
||||
Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 4),
|
||||
decoration: BoxDecoration(
|
||||
color: color.withOpacity(0.1),
|
||||
borderRadius: BorderRadius.circular(12),
|
||||
),
|
||||
child: Text(
|
||||
text,
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
),
|
||||
if (workOrder.status == WorkOrderStatus.executing &&
|
||||
workOrder.progress != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(left: 8),
|
||||
child: Text(
|
||||
'${workOrder.progress!.toInt()}%',
|
||||
style: TextStyle(
|
||||
fontSize: 12,
|
||||
color: color,
|
||||
fontWeight: FontWeight.bold,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDetailRow(
|
||||
String label,
|
||||
String value, {
|
||||
Color? valueColor,
|
||||
}) {
|
||||
return Row(
|
||||
children: [
|
||||
Text(
|
||||
'$label:',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
),
|
||||
),
|
||||
Text(
|
||||
value,
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: valueColor ?? AppConstants.secondaryTextColor,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildProgressBar() {
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Row(
|
||||
children: [
|
||||
Text(
|
||||
'进度:',
|
||||
style: TextStyle(
|
||||
fontSize: 13,
|
||||
color: AppConstants.auxiliaryTextColor,
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: LinearProgressIndicator(
|
||||
value: workOrder.progress! / 100,
|
||||
backgroundColor: const Color(0xFFF0F0F0),
|
||||
valueColor: AlwaysStoppedAnimation<Color>(
|
||||
AppConstants.primaryColor,
|
||||
),
|
||||
minHeight: 6,
|
||||
borderRadius: BorderRadius.circular(3),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
String _getPriorityText(WorkOrderPriority priority) {
|
||||
switch (priority) {
|
||||
case WorkOrderPriority.high:
|
||||
return '高';
|
||||
case WorkOrderPriority.medium:
|
||||
return '中';
|
||||
case WorkOrderPriority.low:
|
||||
return '低';
|
||||
}
|
||||
}
|
||||
|
||||
Color _getPriorityColor(WorkOrderPriority priority) {
|
||||
switch (priority) {
|
||||
case WorkOrderPriority.high:
|
||||
return AppConstants.pendingColor;
|
||||
case WorkOrderPriority.medium:
|
||||
return AppConstants.pendingColor;
|
||||
case WorkOrderPriority.low:
|
||||
return AppConstants.auxiliaryTextColor;
|
||||
}
|
||||
}
|
||||
|
||||
String _formatDateTime(DateTime dateTime) {
|
||||
return '${dateTime.month.toString().padLeft(2, '0')}-${dateTime.day.toString().padLeft(2, '0')} ${dateTime.hour.toString().padLeft(2, '0')}:${dateTime.minute.toString().padLeft(2, '0')}';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../../../../core/consts/workorder_consts.dart';
|
||||
|
||||
/// 工单标签栏组件
|
||||
class WorkOrderTabBar extends StatelessWidget {
|
||||
final WorkOrderStatus currentStatus;
|
||||
final Function(WorkOrderStatus) onTabChanged;
|
||||
|
||||
const WorkOrderTabBar({
|
||||
Key? key,
|
||||
required this.currentStatus,
|
||||
required this.onTabChanged,
|
||||
}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final tabs = [
|
||||
{'label': '待处理', 'status': WorkOrderStatus.pending, 'badge': false},
|
||||
{'label': '执行中', 'status': WorkOrderStatus.executing, 'badge': true},
|
||||
{'label': '已完成', 'status': WorkOrderStatus.completed, 'badge': false},
|
||||
{'label': '全部', 'status': WorkOrderStatus.all, 'badge': true},
|
||||
];
|
||||
|
||||
return Container(
|
||||
height: 44,
|
||||
child: ListView.builder(
|
||||
scrollDirection: Axis.horizontal,
|
||||
itemCount: tabs.length,
|
||||
itemBuilder: (context, index) {
|
||||
final tab = tabs[index];
|
||||
final isSelected = currentStatus == tab['status'];
|
||||
|
||||
return GestureDetector(
|
||||
onTap: () => onTabChanged(tab['status'] as WorkOrderStatus),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
Stack(
|
||||
clipBehavior: Clip.none,
|
||||
children: [
|
||||
Text(
|
||||
tab['label'] as String,
|
||||
style: TextStyle(
|
||||
fontSize: 15,
|
||||
fontWeight: isSelected ? FontWeight.bold : FontWeight.normal,
|
||||
color: isSelected
|
||||
? AppConstants.primaryColor
|
||||
: AppConstants.secondaryTextColor,
|
||||
),
|
||||
),
|
||||
if (tab['badge'] as bool)
|
||||
Positioned(
|
||||
right: -8,
|
||||
top: -4,
|
||||
child: Container(
|
||||
width: 6,
|
||||
height: 6,
|
||||
decoration: const BoxDecoration(
|
||||
color: Colors.red,
|
||||
shape: BoxShape.circle,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
if (isSelected)
|
||||
Container(
|
||||
margin: const EdgeInsets.only(top: 4),
|
||||
width: 24,
|
||||
height: 3,
|
||||
decoration: BoxDecoration(
|
||||
color: AppConstants.primaryColor,
|
||||
borderRadius: BorderRadius.circular(1.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user