h-1.flutter.4/lib/screens/order_screen.dart

97 lines
No EOL
3.1 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Version: 1.5 - 受注画面(簡易実装)
import 'package:flutter/material.dart';
import '../models/customer.dart';
/// 受注作成画面
class OrderScreen extends StatefulWidget {
const OrderScreen({super.key});
@override
State<OrderScreen> createState() => _OrderScreenState();
}
class _OrderScreenState extends State<OrderScreen> {
Customer? _selectedCustomer;
List<Customer> _customers = [];
String _orderNumber = ''; // 受注番号(自動生成)
@override
void initState() {
super.initState();
_loadCustomers();
_generateOrderNumber();
}
Future<void> _loadCustomers() async {
// TODO: DatabaseHelper.instance.getCustomers() を使用
setState(() => _customers = []);
}
/// 受注番号を自動生成YMM-0001 形式)
void _generateOrderNumber() {
final now = DateTime.now();
final yearMonth = '${now.year}${now.month.toString().padLeft(2, '0')}';
final nextNumber = '0001';
setState(() => _orderNumber = '$yearMonth-$nextNumber');
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('受注')),
body: _selectedCustomer == null
? const Center(child: Text('得意先を選択してください'))
: SingleChildScrollView(
child: Padding(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
// 受注番号表示
ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('受注番号'),
subtitle: Text(_orderNumber),
),
const Divider(),
// 得意先名表示
ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('得意先名'),
subtitle: Text(_selectedCustomer!.name),
),
const SizedBox(height: 16),
// 合計金額表示(簡易)
Card(
child: ListTile(
contentPadding: EdgeInsets.zero,
title: const Text('受注合計'),
subtitle: const Text('¥0.00'),
trailing: IconButton(icon: const Icon(Icons.edit), onPressed: () {}),
),
),
const SizedBox(height: 16),
// PDF 帳票出力ボタン(簡易)
TextButton.icon(
onPressed: () {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(content: Text('PDF 帳票生成中...')),
);
},
icon: const Icon(Icons.download),
label: const Text('PDF をダウンロード'),
),
],
),
),
),
);
}
}