105 lines
No EOL
3.8 KiB
Dart
105 lines
No EOL
3.8 KiB
Dart
// Version: 3.0 - シンプル仕入先マスタ画面(簡素版、サンプルデータ固定)
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
class SupplierMasterScreen extends StatefulWidget {
|
|
const SupplierMasterScreen({super.key});
|
|
|
|
@override
|
|
State<SupplierMasterScreen> createState() => _SupplierMasterScreenState();
|
|
}
|
|
|
|
class _SupplierMasterScreenState extends State<SupplierMasterScreen> {
|
|
List<dynamic> _suppliers = [];
|
|
|
|
@override
|
|
void initState() {
|
|
super.initState();
|
|
// サンプルデータ(簡素版)
|
|
_suppliers = [
|
|
{'supplier_code': 'S001', 'name': 'サンプル仕入先 A'},
|
|
{'supplier_code': 'S002', 'name': 'サンプル仕入先 B'},
|
|
];
|
|
}
|
|
|
|
Future<void> _addSupplier() async {
|
|
await showDialog<dynamic>(
|
|
context: context,
|
|
builder: (ctx) => AlertDialog(
|
|
title: const Text('新規仕入先登録'),
|
|
content: SingleChildScrollView(
|
|
child: Column(
|
|
mainAxisSize: MainAxisSize.min,
|
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
|
children: [
|
|
TextField(decoration: const InputDecoration(labelText: 'コード', hintText: 'S003')),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '名称', hintText: '新仕入先名'), onChanged: (v) => setState(() {})),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '住所', hintText: '住所を入力')),
|
|
SizedBox(height: 8),
|
|
TextField(decoration: const InputDecoration(labelText: '電話番号', hintText: '03-1234-5678'), keyboardType: TextInputType.phone, onChanged: (v) => setState(() {})),
|
|
],
|
|
),
|
|
),
|
|
actions: [
|
|
TextButton(onPressed: () => Navigator.pop(ctx), child: const Text('キャンセル')),
|
|
ElevatedButton(
|
|
onPressed: () {
|
|
Navigator.pop(ctx);
|
|
},
|
|
child: const Text('登録'),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(title: const Text('/M1. 仕入先マスタ')),
|
|
body: _suppliers.isEmpty ? Center(
|
|
child: Column(
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
children: [
|
|
Icon(Icons.inbox_outlined, size: 64, color: Colors.grey[300]),
|
|
SizedBox(height: 16),
|
|
Text('仕入先データがありません', style: TextStyle(color: Colors.grey)),
|
|
SizedBox(height: 16),
|
|
FloatingActionButton.extended(
|
|
icon: Icon(Icons.add, color: Theme.of(context).primaryColor),
|
|
label: const Text('新規登録'),
|
|
onPressed: _addSupplier,
|
|
),
|
|
],
|
|
),
|
|
) : ListView.builder(
|
|
padding: const EdgeInsets.all(8),
|
|
itemCount: _suppliers.length,
|
|
itemBuilder: (context, index) {
|
|
final supplier = _suppliers[index];
|
|
return Card(
|
|
margin: EdgeInsets.zero,
|
|
clipBehavior: Clip.antiAlias,
|
|
child: ListTile(
|
|
leading: CircleAvatar(backgroundColor: Colors.orange.shade100, child: Text(supplier['supplier_code'] ?? '-', style: const TextStyle(fontWeight: FontWeight.bold))),
|
|
title: Text(supplier['name'] ?? '未入力'),
|
|
subtitle: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
if (supplier['phone'] != null) Text('電話:${supplier['phone']}', style: const TextStyle(fontSize: 12)),
|
|
],
|
|
),
|
|
),
|
|
);
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
icon: const Icon(Icons.add),
|
|
label: const Text('新規登録'),
|
|
onPressed: _addSupplier,
|
|
),
|
|
);
|
|
}
|
|
} |