init
This commit is contained in:
42
lib/logistics.dart
Normal file
42
lib/logistics.dart
Normal file
@ -0,0 +1,42 @@
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class Logistics extends StatefulWidget {
|
||||
const Logistics({super.key});
|
||||
|
||||
@override
|
||||
State<Logistics> createState() => _LogisticsState();
|
||||
}
|
||||
|
||||
class _LogisticsState extends State<Logistics> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: const Text("填写物流信息"),
|
||||
),
|
||||
body: Container(
|
||||
padding: const EdgeInsets.all(40),
|
||||
width: double.infinity,
|
||||
child: Card(
|
||||
color: Colors.white,
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(20),
|
||||
child: Column(
|
||||
children: [
|
||||
Container(
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(),
|
||||
borderRadius: const BorderRadius.all(Radius.circular(8))),
|
||||
child: SizedBox(
|
||||
height: 50,
|
||||
width: 120,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
));
|
||||
}
|
||||
}
|
@ -1,17 +1,29 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:logistics_tools/logistics.dart';
|
||||
import 'package:logistics_tools/order_list.dart';
|
||||
|
||||
void main() {
|
||||
runApp(const MyApp());
|
||||
runApp(MyApp());
|
||||
}
|
||||
|
||||
class MyApp extends StatelessWidget {
|
||||
const MyApp({super.key});
|
||||
MyApp({super.key});
|
||||
|
||||
final _router = GoRouter(
|
||||
routes: [
|
||||
GoRoute(
|
||||
path: '/',
|
||||
builder: (context, state) => const OrderList(),
|
||||
),
|
||||
GoRoute(path: '/logistics', builder: (context, state) => const Logistics())
|
||||
],
|
||||
);
|
||||
|
||||
// This widget is the root of your application.
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
return MaterialApp.router(
|
||||
title: 'Flutter Demo',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: ThemeData(
|
||||
@ -33,7 +45,8 @@ class MyApp extends StatelessWidget {
|
||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blueAccent),
|
||||
useMaterial3: true,
|
||||
),
|
||||
home: const OrderList(),
|
||||
// home: const OrderList(),
|
||||
routerConfig: _router,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:excel/excel.dart';
|
||||
import 'package:file_picker/file_picker.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
class OrderList extends StatefulWidget {
|
||||
const OrderList({super.key});
|
||||
@ -15,6 +15,8 @@ class OrderList extends StatefulWidget {
|
||||
class _OrderListState extends State<OrderList> {
|
||||
final List lst = [];
|
||||
List<String> headers = [];
|
||||
List<List<dynamic>> data = [];
|
||||
|
||||
ScrollController scrollController = ScrollController();
|
||||
|
||||
@override
|
||||
@ -43,57 +45,78 @@ class _OrderListState extends State<OrderList> {
|
||||
color: Colors.white,
|
||||
margin: EdgeInsets.zero,
|
||||
child: headers.isNotEmpty
|
||||
? Scrollbar(
|
||||
controller: scrollController,
|
||||
child: SingleChildScrollView(
|
||||
? /*Scrollbar(
|
||||
// controller: scrollController,
|
||||
child:*/
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
padding: const EdgeInsets.all(12.0),
|
||||
child: DataTable(
|
||||
columns: headers.map((el) {
|
||||
return DataColumn(label: Text(el));
|
||||
}).toList() /*const [
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"下单时间",
|
||||
)),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"物流公司",
|
||||
)),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"付款方式",
|
||||
)),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"金额",
|
||||
)),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"物流包裹",
|
||||
)),
|
||||
DataColumn(
|
||||
label: Text(
|
||||
"操作",
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
]*/
|
||||
,
|
||||
rows: [], /* rows: [
|
||||
DataRow(cells: [
|
||||
const DataCell(Text("2024-01-12")),
|
||||
const DataCell(Text("圆通速递")),
|
||||
const DataCell(Text("套餐券")),
|
||||
const DataCell(Text("12")),
|
||||
DataCell(ElevatedButton(
|
||||
onPressed: () {}, child: const Text("编辑包裹"))),
|
||||
DataCell(ElevatedButton(
|
||||
onPressed: () {}, child: const Text("编辑"))),
|
||||
]),
|
||||
]*/
|
||||
}).toList(),
|
||||
rows: data.map((row) {
|
||||
return DataRow(
|
||||
cells: row.asMap().entries.map((col) {
|
||||
String col_title = headers[col.key];
|
||||
return DataCell(col_title == "物流名称"
|
||||
? Row(
|
||||
children: [
|
||||
Text("${col.value}"),
|
||||
IconButton(
|
||||
// padding: EdgeInsets.all(2),
|
||||
iconSize: 12,
|
||||
onPressed: () {
|
||||
// Dialog()
|
||||
showDialog(
|
||||
context: context,
|
||||
builder: (BuildContext
|
||||
context) =>
|
||||
AlertDialog(
|
||||
// icon: const Icon(Icons.edit),
|
||||
title: const Text(
|
||||
"填写物流公司"),
|
||||
content: const Column(
|
||||
mainAxisSize:
|
||||
MainAxisSize.min,
|
||||
children: [
|
||||
TextField(
|
||||
decoration:
|
||||
InputDecoration(
|
||||
labelText:
|
||||
"物流公司"),
|
||||
)
|
||||
],
|
||||
),
|
||||
))
|
||||
: Text("empty"),
|
||||
actions: [
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"取消")),
|
||||
ElevatedButton(
|
||||
onPressed: () {},
|
||||
child: const Text(
|
||||
"确认")),
|
||||
],
|
||||
));
|
||||
},
|
||||
icon: const Icon(Icons.edit))
|
||||
],
|
||||
)
|
||||
: col_title == "物流信息"
|
||||
? ElevatedButton(
|
||||
onPressed: () {
|
||||
context.push("/logistics");
|
||||
},
|
||||
child: const Text("填写"),
|
||||
)
|
||||
: Text("${col.value}"));
|
||||
}).toList());
|
||||
}).toList(),
|
||||
),
|
||||
)
|
||||
/*)*/
|
||||
: const Text("empty"),
|
||||
)
|
||||
],
|
||||
),
|
||||
@ -112,8 +135,16 @@ class _OrderListState extends State<OrderList> {
|
||||
return el?.value.toString() ?? "";
|
||||
}).toList() ??
|
||||
[];
|
||||
List<List<dynamic>> _data =
|
||||
excel.tables[tableKey]?.rows.sublist(1).map((row) {
|
||||
return row.map((col) {
|
||||
return col?.value ?? "";
|
||||
}).toList();
|
||||
}).toList() ??
|
||||
[];
|
||||
setState(() {
|
||||
headers = _headers;
|
||||
data = _data;
|
||||
});
|
||||
} else {
|
||||
// 取消选择
|
||||
|
16
pubspec.lock
16
pubspec.lock
@ -152,6 +152,14 @@ packages:
|
||||
description: flutter
|
||||
source: sdk
|
||||
version: "0.0.0"
|
||||
go_router:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: go_router
|
||||
sha256: cdae1b9c8bd7efadcef6112e81c903662ef2ce105cbd220a04bbb7c3425b5554
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.0"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
@ -192,6 +200,14 @@ packages:
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
@ -37,6 +37,7 @@ dependencies:
|
||||
cupertino_icons: ^1.0.6
|
||||
excel: ^4.0.3
|
||||
file_picker: ^8.0.5
|
||||
go_router: ^14.2.0
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
@ -13,7 +13,7 @@ import 'package:logistics_tools/main.dart';
|
||||
void main() {
|
||||
testWidgets('Counter increments smoke test', (WidgetTester tester) async {
|
||||
// Build our app and trigger a frame.
|
||||
await tester.pumpWidget(const MyApp());
|
||||
await tester.pumpWidget(MyApp());
|
||||
|
||||
// Verify that our counter starts at 0.
|
||||
expect(find.text('0'), findsOneWidget);
|
||||
|
Reference in New Issue
Block a user