Compare commits

...

1 Commits

Author SHA1 Message Date
wangjia 025f3b7bbc feat(client): 入库录入去除按名称复用,明细带产品信息由后端建独立产品
Deploy Client / build-client-web (push) Successful in 40s
Deploy Client / build-macos (push) Successful in 2m14s
Deploy Client / build-android (push) Successful in 1m31s
Deploy Client / build-ios (push) Successful in 2m53s
Deploy Client / build-windows (push) Has been cancelled
Deploy Client / release-deploy-client (push) Has been cancelled
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
2026-06-21 16:30:37 +08:00
2 changed files with 19 additions and 49 deletions
+5
View File
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [1.0.65] - 2026-06-21
### 改进
- 入库录入改为「每行一个独立产品」:每条明细对应一个独立编号,同名同规格录多次也各自独立(配合后端 server-v1.0.69
## [1.0.64] - 2026-06-20
### 新功能
@@ -11,7 +11,6 @@ import '../../models/stock_in.dart';
import '../../core/config/app_constants.dart';
import '../../providers/partner_provider.dart';
import '../../providers/product_option_provider.dart';
import '../../providers/product_provider.dart';
import '../../providers/inventory_provider.dart';
import '../../providers/stock_in_provider.dart';
import '../../providers/warehouse_provider.dart';
@@ -306,58 +305,22 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
setState(() => _submitting = true);
// Resolve product IDs for items where productId is null
// 入库每行 = 一个特有产品:明细只带 名称/系列/规格(字典文本) + 批次/生产日期,
// 由后端为每行新建独立产品(序列号),前端不再 findOrCreate 复用。
final nameOpts = ref.read(productNameListProvider).valueOrNull ?? [];
final seriesOpts = ref.read(productSeriesListProvider).valueOrNull ?? [];
final specOpts = ref.read(productSpecListProvider).valueOrNull ?? [];
String optName(List<dynamic> opts, int? id) =>
opts.where((o) => o.id == id).firstOrNull?.name as String? ?? '';
for (final item in _items) {
if (item.productId == null) {
final name = nameOpts
.where((o) => o.id == item.selectedNameId)
.firstOrNull
?.name ??
'';
final series = seriesOpts
.where((o) => o.id == item.selectedSeriesId)
.firstOrNull
?.name ??
'';
final spec = specOpts
.where((o) => o.id == item.selectedSpecId)
.firstOrNull
?.name ??
'';
if (name.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('请选择商品名称'), backgroundColor: AppTheme.danger),
);
setState(() => _submitting = false);
return;
}
try {
final product =
await ref.read(productRepositoryProvider).findOrCreate(
name: name,
series: series,
spec: spec,
originId: item.selectedOriginId,
shelfLifeId: item.selectedShelfLifeId,
storageId: item.selectedStorageId,
descriptionDocId: item.selectedDescriptionDocId,
);
item.productId = product.id;
} catch (e) {
if (mounted) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('商品查找失败:$e'), backgroundColor: AppTheme.danger),
);
setState(() => _submitting = false);
}
return;
}
if (optName(nameOpts, item.selectedNameId).isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text('请选择商品名称'), backgroundColor: AppTheme.danger),
);
setState(() => _submitting = false);
return;
}
}
@@ -367,7 +330,9 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
final batchNo = item.batchNoCtrl.text.trim();
final productionDate = item.productionDateCtrl.text.trim();
return {
'product_id': item.productId ?? 0,
'product_name': optName(nameOpts, item.selectedNameId),
'series': optName(seriesOpts, item.selectedSeriesId),
'spec': optName(specOpts, item.selectedSpecId),
'quantity': qty,
'unit_price': price,
'total_price': qty * price,