Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 025f3b7bbc |
@@ -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/),
|
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).
|
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
|
## [1.0.64] - 2026-06-20
|
||||||
|
|
||||||
### 新功能
|
### 新功能
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import '../../models/stock_in.dart';
|
|||||||
import '../../core/config/app_constants.dart';
|
import '../../core/config/app_constants.dart';
|
||||||
import '../../providers/partner_provider.dart';
|
import '../../providers/partner_provider.dart';
|
||||||
import '../../providers/product_option_provider.dart';
|
import '../../providers/product_option_provider.dart';
|
||||||
import '../../providers/product_provider.dart';
|
|
||||||
import '../../providers/inventory_provider.dart';
|
import '../../providers/inventory_provider.dart';
|
||||||
import '../../providers/stock_in_provider.dart';
|
import '../../providers/stock_in_provider.dart';
|
||||||
import '../../providers/warehouse_provider.dart';
|
import '../../providers/warehouse_provider.dart';
|
||||||
@@ -306,58 +305,22 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
|
|
||||||
setState(() => _submitting = true);
|
setState(() => _submitting = true);
|
||||||
|
|
||||||
// Resolve product IDs for items where productId is null
|
// 入库每行 = 一个特有产品:明细只带 名称/系列/规格(字典文本) + 批次/生产日期,
|
||||||
|
// 由后端为每行新建独立产品(序列号),前端不再 findOrCreate 复用。
|
||||||
final nameOpts = ref.read(productNameListProvider).valueOrNull ?? [];
|
final nameOpts = ref.read(productNameListProvider).valueOrNull ?? [];
|
||||||
final seriesOpts = ref.read(productSeriesListProvider).valueOrNull ?? [];
|
final seriesOpts = ref.read(productSeriesListProvider).valueOrNull ?? [];
|
||||||
final specOpts = ref.read(productSpecListProvider).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) {
|
for (final item in _items) {
|
||||||
if (item.productId == null) {
|
if (optName(nameOpts, item.selectedNameId).isEmpty) {
|
||||||
final name = nameOpts
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
.where((o) => o.id == item.selectedNameId)
|
const SnackBar(
|
||||||
.firstOrNull
|
content: Text('请选择商品名称'), backgroundColor: AppTheme.danger),
|
||||||
?.name ??
|
);
|
||||||
'';
|
setState(() => _submitting = false);
|
||||||
final series = seriesOpts
|
return;
|
||||||
.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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -367,7 +330,9 @@ class _StockInFormScreenState extends ConsumerState<StockInFormScreen> {
|
|||||||
final batchNo = item.batchNoCtrl.text.trim();
|
final batchNo = item.batchNoCtrl.text.trim();
|
||||||
final productionDate = item.productionDateCtrl.text.trim();
|
final productionDate = item.productionDateCtrl.text.trim();
|
||||||
return {
|
return {
|
||||||
'product_id': item.productId ?? 0,
|
'product_name': optName(nameOpts, item.selectedNameId),
|
||||||
|
'series': optName(seriesOpts, item.selectedSeriesId),
|
||||||
|
'spec': optName(specOpts, item.selectedSpecId),
|
||||||
'quantity': qty,
|
'quantity': qty,
|
||||||
'unit_price': price,
|
'unit_price': price,
|
||||||
'total_price': qty * price,
|
'total_price': qty * price,
|
||||||
|
|||||||
Reference in New Issue
Block a user