refactor(client): 入库域颜色迁移到 context.tokens
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -3,7 +3,7 @@ import 'package:flutter/services.dart';
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import '../../core/responsive/responsive.dart';
|
import '../../core/responsive/responsive.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import '../../core/theme/app_theme.dart';
|
import '../../core/theme/context_tokens.dart';
|
||||||
import '../../core/auth/auth_state.dart';
|
import '../../core/auth/auth_state.dart';
|
||||||
import '../../core/utils/date_util.dart';
|
import '../../core/utils/date_util.dart';
|
||||||
import '../../widgets/order_print_preview_dialog.dart';
|
import '../../widgets/order_print_preview_dialog.dart';
|
||||||
@@ -165,7 +165,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('加载失败:$e'), backgroundColor: AppTheme.danger),
|
SnackBar(content: Text('加载失败:$e'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -234,15 +234,15 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
if (!asDraft && !_formKey.currentState!.validate()) return;
|
if (!asDraft && !_formKey.currentState!.validate()) return;
|
||||||
if (_warehouseId == null) {
|
if (_warehouseId == null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('请选择入库仓库'), backgroundColor: AppTheme.danger),
|
content: const Text('请选择入库仓库'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_items.isEmpty) {
|
if (_items.isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('请添加商品明细'), backgroundColor: AppTheme.danger),
|
content: const Text('请添加商品明细'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -252,7 +252,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${invalidQtyIndex + 1} 行数量必须大于 0'),
|
content: Text('第 ${invalidQtyIndex + 1} 行数量必须大于 0'),
|
||||||
backgroundColor: AppTheme.danger,
|
backgroundColor: context.tokens.danger,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
@@ -261,8 +261,8 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
if (!asDraft) {
|
if (!asDraft) {
|
||||||
if (_partnerId == null) {
|
if (_partnerId == null) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('请选择供应商'), backgroundColor: AppTheme.danger),
|
content: const Text('请选择供应商'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -272,7 +272,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${i + 1} 行请选择商品名称'),
|
content: Text('第 ${i + 1} 行请选择商品名称'),
|
||||||
backgroundColor: AppTheme.danger),
|
backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -280,7 +280,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${i + 1} 行请选择系列'),
|
content: Text('第 ${i + 1} 行请选择系列'),
|
||||||
backgroundColor: AppTheme.danger),
|
backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -288,7 +288,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${i + 1} 行请选择规格'),
|
content: Text('第 ${i + 1} 行请选择规格'),
|
||||||
backgroundColor: AppTheme.danger),
|
backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -296,7 +296,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${i + 1} 行请填写生产日期'),
|
content: Text('第 ${i + 1} 行请填写生产日期'),
|
||||||
backgroundColor: AppTheme.danger),
|
backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -304,7 +304,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text('第 ${i + 1} 行请填写批次号'),
|
content: Text('第 ${i + 1} 行请填写批次号'),
|
||||||
backgroundColor: AppTheme.danger),
|
backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -324,8 +324,8 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
for (final item in _items) {
|
for (final item in _items) {
|
||||||
if (optName(nameOpts, item.selectedNameId).isEmpty) {
|
if (optName(nameOpts, item.selectedNameId).isEmpty) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(
|
SnackBar(
|
||||||
content: Text('请选择商品名称'), backgroundColor: AppTheme.danger),
|
content: const Text('请选择商品名称'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
setState(() => _submitting = false);
|
setState(() => _submitting = false);
|
||||||
return;
|
return;
|
||||||
@@ -371,7 +371,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(
|
SnackBar(
|
||||||
content: Text(asDraft ? '已保存为草稿' : '入库单已提交审核'),
|
content: Text(asDraft ? '已保存为草稿' : '入库单已提交审核'),
|
||||||
backgroundColor: AppTheme.success,
|
backgroundColor: context.tokens.success,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
context.go('/stock-in');
|
context.go('/stock-in');
|
||||||
@@ -379,7 +379,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('操作失败:$e'), backgroundColor: AppTheme.danger),
|
SnackBar(content: Text('操作失败:$e'), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
@@ -422,7 +422,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
),
|
),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop('discard'),
|
onPressed: () => Navigator.of(ctx).pop('discard'),
|
||||||
child: const Text('放弃', style: TextStyle(color: AppTheme.danger)),
|
child: Text('放弃', style: TextStyle(color: context.tokens.danger)),
|
||||||
),
|
),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop('draft'),
|
onPressed: () => Navigator.of(ctx).pop('draft'),
|
||||||
@@ -452,12 +452,12 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
if (!didPop) _handleExit();
|
if (!didPop) _handleExit();
|
||||||
},
|
},
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
backgroundColor: AppTheme.background,
|
backgroundColor: context.tokens.bg,
|
||||||
body: Column(
|
body: Column(
|
||||||
children: [
|
children: [
|
||||||
Container(
|
Container(
|
||||||
height: 52,
|
height: 52,
|
||||||
color: AppTheme.surface,
|
color: context.tokens.surface,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 16),
|
padding: const EdgeInsets.symmetric(horizontal: 16),
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
children: [
|
||||||
@@ -559,11 +559,11 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text('基本信息',
|
Text('基本信息',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppTheme.primaryDark)),
|
color: context.tokens.primaryDark)),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
Wrap(
|
Wrap(
|
||||||
spacing: 16,
|
spacing: 16,
|
||||||
@@ -681,11 +681,11 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
const Text('商品明细',
|
Text('商品明细',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppTheme.primaryDark)),
|
color: context.tokens.primaryDark)),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
ElevatedButton.icon(
|
ElevatedButton.icon(
|
||||||
onPressed: _addItem,
|
onPressed: _addItem,
|
||||||
@@ -731,10 +731,10 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
fontWeight: FontWeight.w500)),
|
fontWeight: FontWeight.w500)),
|
||||||
Text(
|
Text(
|
||||||
'¥${_totalAmount.toStringAsFixed(2)}',
|
'¥${_totalAmount.toStringAsFixed(2)}',
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 18,
|
fontSize: 18,
|
||||||
fontWeight: FontWeight.w700,
|
fontWeight: FontWeight.w700,
|
||||||
color: AppTheme.danger),
|
color: context.tokens.danger),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -978,10 +978,10 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
Widget th(String s) => Padding(
|
Widget th(String s) => Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 10),
|
||||||
child: Text(s,
|
child: Text(s,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppTheme.primaryDark)),
|
color: context.tokens.primaryDark)),
|
||||||
);
|
);
|
||||||
return Container(
|
return Container(
|
||||||
color: const Color(0xFFF0F4FF),
|
color: const Color(0xFFF0F4FF),
|
||||||
@@ -1029,7 +1029,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
Row(crossAxisAlignment: CrossAxisAlignment.center, children: [
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: 36,
|
width: 36,
|
||||||
child: tc('${index + 1}', color: AppTheme.textSecondary)),
|
child: tc('${index + 1}', color: context.tokens.muted)),
|
||||||
Expanded(
|
Expanded(
|
||||||
flex: 18,
|
flex: 18,
|
||||||
child: Padding(
|
child: Padding(
|
||||||
@@ -1078,8 +1078,8 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
item.expanded ? Icons.expand_less : Icons.expand_more,
|
item.expanded ? Icons.expand_less : Icons.expand_more,
|
||||||
size: 18,
|
size: 18,
|
||||||
color: hasOptional
|
color: hasOptional
|
||||||
? AppTheme.primary
|
? context.tokens.primary
|
||||||
: AppTheme.textSecondary,
|
: context.tokens.muted,
|
||||||
),
|
),
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
setState(() => item.expanded = !item.expanded),
|
setState(() => item.expanded = !item.expanded),
|
||||||
@@ -1092,8 +1092,8 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
SizedBox(
|
SizedBox(
|
||||||
width: 44,
|
width: 44,
|
||||||
child: IconButton(
|
child: IconButton(
|
||||||
icon: const Icon(Icons.delete_outline,
|
icon: Icon(Icons.delete_outline,
|
||||||
size: 18, color: AppTheme.danger),
|
size: 18, color: context.tokens.danger),
|
||||||
onPressed:
|
onPressed:
|
||||||
_items.length > 1 ? () => _removeItem(index) : null,
|
_items.length > 1 ? () => _removeItem(index) : null,
|
||||||
tooltip: '删除',
|
tooltip: '删除',
|
||||||
@@ -1114,18 +1114,18 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
// ── 可折叠选填区(桌面) ──────────────────────────────────────────────────
|
// ── 可折叠选填区(桌面) ──────────────────────────────────────────────────
|
||||||
Widget _buildOptionalSection(_ItemRow item) {
|
Widget _buildOptionalSection(_ItemRow item) {
|
||||||
return Container(
|
return Container(
|
||||||
decoration: const BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: Color(0xFFF0F6FF),
|
color: const Color(0xFFF0F6FF),
|
||||||
border: Border(left: BorderSide(color: AppTheme.primary, width: 3)),
|
border: Border(left: BorderSide(color: context.tokens.primary, width: 3)),
|
||||||
),
|
),
|
||||||
padding: const EdgeInsets.fromLTRB(16, 10, 16, 14),
|
padding: const EdgeInsets.fromLTRB(16, 10, 16, 14),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
const Text('选填信息',
|
Text('选填信息',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
color: AppTheme.textSecondary,
|
color: context.tokens.muted,
|
||||||
fontWeight: FontWeight.w500)),
|
fontWeight: FontWeight.w500)),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
Wrap(
|
Wrap(
|
||||||
@@ -1158,7 +1158,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
title: Text('商品 ${index + 1}'),
|
title: Text('商品 ${index + 1}'),
|
||||||
trailing: IconButton(
|
trailing: IconButton(
|
||||||
icon:
|
icon:
|
||||||
const Icon(Icons.delete_outline, size: 20, color: AppTheme.danger),
|
Icon(Icons.delete_outline, size: 20, color: context.tokens.danger),
|
||||||
onPressed: _items.length > 1 ? () => _removeItem(index) : null,
|
onPressed: _items.length > 1 ? () => _removeItem(index) : null,
|
||||||
tooltip: '删除',
|
tooltip: '删除',
|
||||||
visualDensity: VisualDensity.compact,
|
visualDensity: VisualDensity.compact,
|
||||||
@@ -1181,7 +1181,7 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
style: TextButton.styleFrom(
|
style: TextButton.styleFrom(
|
||||||
padding: EdgeInsets.zero,
|
padding: EdgeInsets.zero,
|
||||||
minimumSize: const Size(0, 32),
|
minimumSize: const Size(0, 32),
|
||||||
foregroundColor: AppTheme.textSecondary,
|
foregroundColor: context.tokens.muted,
|
||||||
),
|
),
|
||||||
)),
|
)),
|
||||||
if (item.expanded)
|
if (item.expanded)
|
||||||
@@ -1199,10 +1199,10 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
|
|
||||||
Widget _buildInventoryCell(int? productId) {
|
Widget _buildInventoryCell(int? productId) {
|
||||||
if (productId == null) {
|
if (productId == null) {
|
||||||
return const Padding(
|
return Padding(
|
||||||
padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
||||||
child: Text('-',
|
child: Text('-',
|
||||||
style: TextStyle(color: AppTheme.textSecondary, fontSize: 13)),
|
style: TextStyle(color: context.tokens.muted, fontSize: 13)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
final qty = _inventoryMap[productId];
|
final qty = _inventoryMap[productId];
|
||||||
@@ -1210,10 +1210,10 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
? qty.toStringAsFixed(0)
|
? qty.toStringAsFixed(0)
|
||||||
: (_warehouseId == null ? '选仓库后显示' : '-');
|
: (_warehouseId == null ? '选仓库后显示' : '-');
|
||||||
final color = qty == null
|
final color = qty == null
|
||||||
? AppTheme.textSecondary
|
? context.tokens.muted
|
||||||
: qty <= 0
|
: qty <= 0
|
||||||
? AppTheme.danger
|
? context.tokens.danger
|
||||||
: AppTheme.primary;
|
: context.tokens.primary;
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 12),
|
||||||
child: Text(text,
|
child: Text(text,
|
||||||
@@ -1271,7 +1271,7 @@ class _OptionalField extends StatelessWidget {
|
|||||||
children: [
|
children: [
|
||||||
Text(label,
|
Text(label,
|
||||||
style:
|
style:
|
||||||
const TextStyle(fontSize: 12, color: AppTheme.textSecondary)),
|
TextStyle(fontSize: 12, color: context.tokens.muted)),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
child,
|
child,
|
||||||
],
|
],
|
||||||
@@ -1307,11 +1307,11 @@ class _FormField extends StatelessWidget {
|
|||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
if (required)
|
if (required)
|
||||||
const Text('*',
|
Text('*',
|
||||||
style: TextStyle(color: AppTheme.danger, fontSize: 13)),
|
style: TextStyle(color: context.tokens.danger, fontSize: 13)),
|
||||||
Text(label,
|
Text(label,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13, color: AppTheme.textSecondary)),
|
fontSize: 13, color: context.tokens.muted)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import 'package:flutter/material.dart';
|
|||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:go_router/go_router.dart';
|
import 'package:go_router/go_router.dart';
|
||||||
import '../../core/responsive/responsive.dart';
|
import '../../core/responsive/responsive.dart';
|
||||||
import '../../core/theme/app_theme.dart';
|
import '../../core/theme/context_tokens.dart';
|
||||||
import '../../models/stock_in.dart';
|
import '../../models/stock_in.dart';
|
||||||
import '../../providers/stock_in_provider.dart';
|
import '../../providers/stock_in_provider.dart';
|
||||||
import '../../repositories/stock_in_repository.dart';
|
import '../../repositories/stock_in_repository.dart';
|
||||||
@@ -154,10 +154,10 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
const Icon(Icons.cloud_off, size: 40, color: AppTheme.textSecondary),
|
Icon(Icons.cloud_off, size: 40, color: context.tokens.muted),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
const Text('暂无数据,网络不可用',
|
Text('暂无数据,网络不可用',
|
||||||
style: const TextStyle(color: AppTheme.textSecondary)),
|
style: TextStyle(color: context.tokens.muted)),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () =>
|
onPressed: () =>
|
||||||
@@ -273,8 +273,8 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
return DataCell(GestureDetector(
|
return DataCell(GestureDetector(
|
||||||
onTap: () => _showDetail(context, o.id),
|
onTap: () => _showDetail(context, o.id),
|
||||||
child: Text(o.orderNo,
|
child: Text(o.orderNo,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
color: AppTheme.primary,
|
color: context.tokens.primary,
|
||||||
fontFamily: 'monospace',
|
fontFamily: 'monospace',
|
||||||
fontSize: 12,
|
fontSize: 12,
|
||||||
decoration: TextDecoration.underline)),
|
decoration: TextDecoration.underline)),
|
||||||
@@ -320,8 +320,8 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
cells: List.generate(
|
cells: List.generate(
|
||||||
visibleCols.length,
|
visibleCols.length,
|
||||||
(i) => i == 0
|
(i) => i == 0
|
||||||
? const DataCell(Text('暂无入库单',
|
? DataCell(Text('暂无入库单',
|
||||||
style: TextStyle(color: AppTheme.textSecondary)))
|
style: TextStyle(color: context.tokens.muted)))
|
||||||
: const DataCell(SizedBox()),
|
: const DataCell(SizedBox()),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -562,8 +562,8 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
child: const Text('打标签',
|
child: Text('打标签',
|
||||||
style: TextStyle(fontSize: 12, color: AppTheme.primary)),
|
style: TextStyle(fontSize: 12, color: context.tokens.primary)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
onSettle: () => _confirmSettle(context, o.id, 'stock_in'),
|
onSettle: () => _confirmSettle(context, o.id, 'stock_in'),
|
||||||
@@ -643,7 +643,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
|
TextButton(onPressed: () => Navigator.pop(ctx, false), child: const Text('取消')),
|
||||||
TextButton(
|
TextButton(
|
||||||
onPressed: () => Navigator.pop(ctx, true),
|
onPressed: () => Navigator.pop(ctx, true),
|
||||||
child: const Text('确认结清', style: TextStyle(color: AppTheme.accent)),
|
child: Text('确认结清', style: TextStyle(color: context.tokens.accent)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@@ -653,13 +653,13 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
await ref.read(financeRepositoryProvider).closeByRef(refType, orderId);
|
await ref.read(financeRepositoryProvider).closeByRef(refType, orderId);
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
const SnackBar(content: Text('已结清'), backgroundColor: AppTheme.success),
|
SnackBar(content: const Text('已结清'), backgroundColor: context.tokens.success),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (context.mounted) {
|
if (context.mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text(e.toString()), backgroundColor: AppTheme.danger),
|
SnackBar(content: Text(e.toString()), backgroundColor: context.tokens.danger),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -678,7 +678,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppTheme.danger,
|
backgroundColor: context.tokens.danger,
|
||||||
foregroundColor: Colors.white),
|
foregroundColor: Colors.white),
|
||||||
child: const Text('删除'),
|
child: const Text('删除'),
|
||||||
),
|
),
|
||||||
@@ -689,14 +689,14 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
try {
|
try {
|
||||||
await ref.read(stockInListProvider.notifier).deleteOrder(o.id);
|
await ref.read(stockInListProvider.notifier).deleteOrder(o.id);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('已删除'), backgroundColor: AppTheme.success));
|
content: const Text('已删除'), backgroundColor: context.tokens.success));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('删除失败:$e'),
|
content: Text('删除失败:$e'),
|
||||||
backgroundColor: AppTheme.danger));
|
backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -724,15 +724,15 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
.read(stockInListProvider.notifier)
|
.read(stockInListProvider.notifier)
|
||||||
.submitOrder(o.id);
|
.submitOrder(o.id);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('已提交审核'),
|
content: const Text('已提交审核'),
|
||||||
backgroundColor: AppTheme.success));
|
backgroundColor: context.tokens.success));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('提交失败:$e'),
|
content: Text('提交失败:$e'),
|
||||||
backgroundColor: AppTheme.danger));
|
backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -751,7 +751,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppTheme.success,
|
backgroundColor: context.tokens.success,
|
||||||
foregroundColor: Colors.white),
|
foregroundColor: Colors.white),
|
||||||
child: const Text('通过'),
|
child: const Text('通过'),
|
||||||
),
|
),
|
||||||
@@ -764,14 +764,14 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
.read(stockInListProvider.notifier)
|
.read(stockInListProvider.notifier)
|
||||||
.approveOrder(o.id);
|
.approveOrder(o.id);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('审核通过'), backgroundColor: AppTheme.success));
|
content: const Text('审核通过'), backgroundColor: context.tokens.success));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('审核失败:$e'),
|
content: Text('审核失败:$e'),
|
||||||
backgroundColor: AppTheme.danger));
|
backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -790,7 +790,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppTheme.danger,
|
backgroundColor: context.tokens.danger,
|
||||||
foregroundColor: Colors.white),
|
foregroundColor: Colors.white),
|
||||||
child: const Text('拒绝'),
|
child: const Text('拒绝'),
|
||||||
),
|
),
|
||||||
@@ -801,14 +801,14 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
try {
|
try {
|
||||||
await ref.read(stockInListProvider.notifier).rejectOrder(o.id);
|
await ref.read(stockInListProvider.notifier).rejectOrder(o.id);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('已拒绝'), backgroundColor: AppTheme.accent));
|
content: const Text('已拒绝'), backgroundColor: context.tokens.accent));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('操作失败:$e'),
|
content: Text('操作失败:$e'),
|
||||||
backgroundColor: AppTheme.danger));
|
backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -827,7 +827,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppTheme.accent,
|
backgroundColor: context.tokens.accent,
|
||||||
foregroundColor: Colors.white),
|
foregroundColor: Colors.white),
|
||||||
child: const Text('撤回'),
|
child: const Text('撤回'),
|
||||||
),
|
),
|
||||||
@@ -838,14 +838,14 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
try {
|
try {
|
||||||
await ref.read(stockInListProvider.notifier).withdrawOrder(o.id);
|
await ref.read(stockInListProvider.notifier).withdrawOrder(o.id);
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(const SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('已撤回为草稿'), backgroundColor: AppTheme.accent));
|
content: const Text('已撤回为草稿'), backgroundColor: context.tokens.accent));
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(SnackBar(
|
||||||
content: Text('撤回失败:$e'),
|
content: Text('撤回失败:$e'),
|
||||||
backgroundColor: AppTheme.danger));
|
backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -864,7 +864,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
ElevatedButton(
|
ElevatedButton(
|
||||||
onPressed: () => Navigator.of(ctx).pop(true),
|
onPressed: () => Navigator.of(ctx).pop(true),
|
||||||
style: ElevatedButton.styleFrom(
|
style: ElevatedButton.styleFrom(
|
||||||
backgroundColor: AppTheme.danger, foregroundColor: Colors.white),
|
backgroundColor: context.tokens.danger, foregroundColor: Colors.white),
|
||||||
child: const Text('确认'),
|
child: const Text('确认'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -877,7 +877,7 @@ class _StockInListScreenState extends ConsumerState<StockInListScreen> {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (mounted) {
|
if (mounted) {
|
||||||
ScaffoldMessenger.of(context).showSnackBar(
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
SnackBar(content: Text('加载明细失败:$e'), backgroundColor: AppTheme.danger));
|
SnackBar(content: Text('加载明细失败:$e'), backgroundColor: context.tokens.danger));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1089,14 +1089,14 @@ class _StockInDetailDialogState extends ConsumerState<_StockInDetailDialog> {
|
|||||||
return const Center(child: CircularProgressIndicator());
|
return const Center(child: CircularProgressIndicator());
|
||||||
}
|
}
|
||||||
if (snap.hasError) {
|
if (snap.hasError) {
|
||||||
return const Center(
|
return Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: [
|
children: [
|
||||||
Icon(Icons.cloud_off, size: 40, color: AppTheme.textSecondary),
|
Icon(Icons.cloud_off, size: 40, color: context.tokens.muted),
|
||||||
SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
Text('暂无数据,网络不可用',
|
Text('暂无数据,网络不可用',
|
||||||
style: TextStyle(color: AppTheme.textSecondary)),
|
style: TextStyle(color: context.tokens.muted)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
@@ -1134,15 +1134,15 @@ class _StockInDetailDialogState extends ConsumerState<_StockInDetailDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 20),
|
const SizedBox(height: 20),
|
||||||
const Text('商品明细',
|
Text('商品明细',
|
||||||
style: TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppTheme.primaryDark)),
|
color: context.tokens.primaryDark)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
if (o.items.isEmpty)
|
if (o.items.isEmpty)
|
||||||
const Text('无商品明细',
|
Text('无商品明细',
|
||||||
style: TextStyle(color: AppTheme.textSecondary))
|
style: TextStyle(color: context.tokens.muted))
|
||||||
else if (context.isMobile)
|
else if (context.isMobile)
|
||||||
// 窄屏:每个商品渲染为卡片,字段竖排
|
// 窄屏:每个商品渲染为卡片,字段竖排
|
||||||
Column(
|
Column(
|
||||||
@@ -1186,7 +1186,7 @@ class _StockInDetailDialogState extends ConsumerState<_StockInDetailDialog> {
|
|||||||
else
|
else
|
||||||
// 宽屏:保持原有表格展示
|
// 宽屏:保持原有表格展示
|
||||||
Table(
|
Table(
|
||||||
border: TableBorder.all(color: AppTheme.border, width: 0.5),
|
border: TableBorder.all(color: context.tokens.border, width: 0.5),
|
||||||
columnWidths: const {
|
columnWidths: const {
|
||||||
0: FixedColumnWidth(36),
|
0: FixedColumnWidth(36),
|
||||||
1: FlexColumnWidth(1.2),
|
1: FlexColumnWidth(1.2),
|
||||||
@@ -1207,10 +1207,10 @@ class _StockInDetailDialogState extends ConsumerState<_StockInDetailDialog> {
|
|||||||
padding: const EdgeInsets.symmetric(
|
padding: const EdgeInsets.symmetric(
|
||||||
horizontal: 8, vertical: 10),
|
horizontal: 8, vertical: 10),
|
||||||
child: Text(h,
|
child: Text(h,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 13,
|
fontSize: 13,
|
||||||
fontWeight: FontWeight.w600,
|
fontWeight: FontWeight.w600,
|
||||||
color: AppTheme.primaryDark)),
|
color: context.tokens.primaryDark)),
|
||||||
))
|
))
|
||||||
.toList(),
|
.toList(),
|
||||||
),
|
),
|
||||||
@@ -1278,9 +1278,9 @@ class _StockInDetailDialogState extends ConsumerState<_StockInDetailDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 4),
|
const SizedBox(height: 4),
|
||||||
const Text(
|
Text(
|
||||||
'该单含「待定价」明细:价格确定后补填真实进价,将自动回填库存成本、已出库成本快照与应付差额(不影响售价/应收)。',
|
'该单含「待定价」明细:价格确定后补填真实进价,将自动回填库存成本、已出库成本快照与应付差额(不影响售价/应收)。',
|
||||||
style: TextStyle(fontSize: 12, color: AppTheme.textSecondary),
|
style: TextStyle(fontSize: 12, color: context.tokens.muted),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
@@ -1316,8 +1316,8 @@ class _InfoField extends StatelessWidget {
|
|||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text(label,
|
Text(label,
|
||||||
style: const TextStyle(
|
style: TextStyle(
|
||||||
fontSize: 12, color: AppTheme.textSecondary)),
|
fontSize: 12, color: context.tokens.muted)),
|
||||||
const SizedBox(height: 2),
|
const SizedBox(height: 2),
|
||||||
Text(value,
|
Text(value,
|
||||||
style: const TextStyle(
|
style: const TextStyle(
|
||||||
@@ -1356,22 +1356,22 @@ class _StatusFilterDropdown extends StatelessWidget {
|
|||||||
height: 36,
|
height: 36,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
border: Border.all(color: AppTheme.border),
|
border: Border.all(color: context.tokens.border),
|
||||||
borderRadius: BorderRadius.circular(4),
|
borderRadius: BorderRadius.circular(4),
|
||||||
color: AppTheme.surface,
|
color: context.tokens.surface,
|
||||||
),
|
),
|
||||||
child: DropdownButtonHideUnderline(
|
child: DropdownButtonHideUnderline(
|
||||||
child: DropdownButton<String>(
|
child: DropdownButton<String>(
|
||||||
value: value.isEmpty ? '' : value,
|
value: value.isEmpty ? '' : value,
|
||||||
items: [
|
items: const [
|
||||||
const DropdownMenuItem(value: '', child: Text('全部状态', style: TextStyle(fontSize: 13))),
|
DropdownMenuItem(value: '', child: Text('全部状态', style: TextStyle(fontSize: 13))),
|
||||||
const DropdownMenuItem(value: 'draft', child: Text('草稿', style: TextStyle(fontSize: 13))),
|
DropdownMenuItem(value: 'draft', child: Text('草稿', style: TextStyle(fontSize: 13))),
|
||||||
const DropdownMenuItem(value: 'pending', child: Text('待审核', style: TextStyle(fontSize: 13))),
|
DropdownMenuItem(value: 'pending', child: Text('待审核', style: TextStyle(fontSize: 13))),
|
||||||
const DropdownMenuItem(value: 'approved', child: Text('已审核', style: TextStyle(fontSize: 13))),
|
DropdownMenuItem(value: 'approved', child: Text('已审核', style: TextStyle(fontSize: 13))),
|
||||||
const DropdownMenuItem(value: 'rejected', child: Text('已拒绝', style: TextStyle(fontSize: 13))),
|
DropdownMenuItem(value: 'rejected', child: Text('已拒绝', style: TextStyle(fontSize: 13))),
|
||||||
],
|
],
|
||||||
onChanged: onChanged,
|
onChanged: onChanged,
|
||||||
style: const TextStyle(fontSize: 13, color: AppTheme.textPrimary),
|
style: TextStyle(fontSize: 13, color: context.tokens.text),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user