Initial commit: 风影 OA 全栈源码(API/Web/Flutter/IM)
含 Phase 1.1 IM seq 排序、断线重连、多端已读同步与微信式语音转文字 UI。 排除 node_modules、构建产物、安装包与 .env 密钥。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,91 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import '../api/oa_client.dart';
|
||||
import '../labels.dart';
|
||||
import '../pages/record_detail_page.dart';
|
||||
import '../widgets/common.dart';
|
||||
|
||||
class TodosPage extends StatefulWidget {
|
||||
const TodosPage({super.key, required this.api, this.embedded = false});
|
||||
final OaClient api;
|
||||
final bool embedded;
|
||||
|
||||
@override
|
||||
State<TodosPage> createState() => _TodosPageState();
|
||||
}
|
||||
|
||||
class _TodosPageState extends State<TodosPage> {
|
||||
List<Map<String, dynamic>> _items = [];
|
||||
String _bucket = 'OPEN';
|
||||
bool _loading = true;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_load();
|
||||
}
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final data = await widget.api.get('/office/todos');
|
||||
if (!mounted) return;
|
||||
setState(() {
|
||||
_items = asMaps(data);
|
||||
_loading = false;
|
||||
});
|
||||
} catch (_) {
|
||||
if (mounted) setState(() => _loading = false);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final filtered = _bucket.isEmpty ? _items : _items.where((e) => '${e['status']}' == _bucket).toList();
|
||||
final body = Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: [
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.fromLTRB(16, 8, 16, 4),
|
||||
child: Row(
|
||||
children: [
|
||||
for (final it in [('OPEN', '待办'), ('DONE', '已办'), ('', '全部')])
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 8),
|
||||
child: ChoiceChip(
|
||||
label: Text(it.$2),
|
||||
selected: _bucket == it.$1,
|
||||
showCheckmark: false,
|
||||
visualDensity: VisualDensity.compact,
|
||||
onSelected: (_) => setState(() => _bucket = it.$1),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
if (_loading) const LinearProgressIndicator(minHeight: 2),
|
||||
Expanded(
|
||||
child: filtered.isEmpty
|
||||
? const EmptyHint('没有待办')
|
||||
: RefreshIndicator(
|
||||
onRefresh: _load,
|
||||
child: ListView.builder(
|
||||
itemCount: filtered.length,
|
||||
itemBuilder: (_, i) {
|
||||
final r = filtered[i];
|
||||
return KvTile(
|
||||
title: '${r['title'] ?? ''}',
|
||||
subtitle: '${zh(r['bizType'])} ${fmtTime(r['dueAt'] ?? r['createdAt'])}',
|
||||
status: r['status'],
|
||||
onTap: () => openRecord(context, widget.api, r),
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (widget.embedded) return body;
|
||||
return Scaffold(appBar: AppBar(title: const Text('待办事项')), body: body);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user