chore: release client-v1.0.72
Deploy Client / build-client-web (push) Successful in 41s
Deploy Client / build-windows (push) Successful in 2m34s
Deploy Client / build-macos (push) Successful in 2m17s
Deploy Client / build-android (push) Successful in 1m26s
Deploy Client / build-ios (push) Successful in 2m42s
Deploy Client / release-deploy-client (push) Successful in 1m35s

出库售价可编辑列(应收按售价) + 退单按钮红色实心 + 库存列表隐藏数量列

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YZ4DskSRKsSiheQonFtQvx
This commit is contained in:
wangjia
2026-06-22 13:02:29 +08:00
parent 3641f1cf16
commit 6b0b2645ce
4 changed files with 69 additions and 38 deletions
@@ -83,6 +83,7 @@ class _ItemRow {
final String spec;
final double? unitPrice;
final TextEditingController qtyCtrl;
final TextEditingController salePriceCtrl;
_ItemRow({
this.productId,
@@ -91,9 +92,19 @@ class _ItemRow {
this.series = '',
this.spec = '',
this.unitPrice,
}) : qtyCtrl = TextEditingController(text: '1');
double? salePrice,
}) : qtyCtrl = TextEditingController(text: '1'),
// 售价默认带出成本单价(无历史售价时),可手工改成实际卖价
salePriceCtrl = TextEditingController(
text: ((salePrice != null && salePrice > 0)
? salePrice
: (unitPrice ?? 0))
.toStringAsFixed(2));
void dispose() => qtyCtrl.dispose();
void dispose() {
qtyCtrl.dispose();
salePriceCtrl.dispose();
}
}
class StockOutFormScreen extends ConsumerStatefulWidget {
@@ -152,6 +163,7 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
series: item.productSeries ?? '',
spec: item.productSpec ?? '',
unitPrice: item.unitPrice,
salePrice: item.salePrice,
);
row.qtyCtrl.text = item.quantity.toStringAsFixed(0);
_items.add(row);
@@ -178,11 +190,13 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
super.dispose();
}
// 出库单总金额 = 应收 = Σ(售价×数量)
double get _totalAmount {
double total = 0;
for (final item in _items) {
final qty = double.tryParse(item.qtyCtrl.text) ?? 0;
total += qty * (item.unitPrice ?? 0);
final sale = double.tryParse(item.salePriceCtrl.text) ?? 0;
total += qty * sale;
}
return total;
}
@@ -280,10 +294,12 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
final itemsData = _items.map((item) {
final qty = double.tryParse(item.qtyCtrl.text) ?? 0;
final price = item.unitPrice ?? 0;
final sale = double.tryParse(item.salePriceCtrl.text) ?? 0;
return {
'product_id': item.productId ?? 0,
'quantity': qty,
'unit_price': price,
'sale_price': sale,
'total_price': qty * price,
};
}).toList();
@@ -647,10 +663,11 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
2: FlexColumnWidth(2.0), // 商品名称
3: FlexColumnWidth(1.2), // 系列
4: FlexColumnWidth(1.2), // 规格
5: FlexColumnWidth(1.0), //
6: FlexColumnWidth(0.8), // 数量
7: FlexColumnWidth(1.0), // 金额
8: FixedColumnWidth(48), // 操作
5: FlexColumnWidth(1.0), // 成本
6: FlexColumnWidth(1.0), // 售价
7: FlexColumnWidth(0.8), // 数量
8: FlexColumnWidth(1.0), // 金额
9: FixedColumnWidth(48), // 操作
},
children: [
TableRow(
@@ -662,7 +679,8 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
'商品名称',
'系列',
'规格',
'',
'成本',
'售价',
'数量',
'金额',
'操作',
@@ -734,7 +752,8 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
final item = _items[index];
final qty = double.tryParse(item.qtyCtrl.text) ?? 0;
final price = item.unitPrice ?? 0;
final amount = qty * price;
final sale = double.tryParse(item.salePriceCtrl.text) ?? 0;
final amount = qty * sale;
return TableRow(
decoration: BoxDecoration(
@@ -761,12 +780,16 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
_cell(Text(item.spec,
style:
const TextStyle(fontSize: 12, color: AppTheme.textSecondary))),
//
// 成本
_cell(Text(price > 0 ? '¥${price.toStringAsFixed(2)}' : '-',
style: const TextStyle(fontSize: 13))),
style: const TextStyle(
fontSize: 13, color: AppTheme.textSecondary))),
// 售价(可编辑)
Padding(
padding: const EdgeInsets.all(4), child: _salePriceField(item)),
// 数量
Padding(padding: const EdgeInsets.all(4), child: _qtyField(item)),
// 金额
// 金额=售价×数量)
_cell(Text('¥${amount.toStringAsFixed(2)}',
style: const TextStyle(fontSize: 13, fontWeight: FontWeight.w500))),
// 操作
@@ -803,12 +826,27 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
);
}
// 售价输入:可编辑,金额(应收)按 售价×数量 联动
Widget _salePriceField(_ItemRow item) {
return TextFormField(
controller: item.salePriceCtrl,
decoration: const InputDecoration(hintText: '0.00', isDense: true),
style: const TextStyle(fontSize: 13),
keyboardType: const TextInputType.numberWithOptions(decimal: true),
inputFormatters: [
FilteringTextInputFormatter.allow(RegExp(r'^\d+\.?\d{0,2}'))
],
onChanged: (_) => setState(() {}),
);
}
/// 窄屏(手机):每个明细行渲染为一张卡片,字段竖排,避免表格横向溢出。
Widget _buildItemCard(int index) {
final item = _items[index];
final qty = double.tryParse(item.qtyCtrl.text) ?? 0;
final price = item.unitPrice ?? 0;
final amount = qty * price;
final sale = double.tryParse(item.salePriceCtrl.text) ?? 0;
final amount = qty * sale;
return MobileListCard(
title: Text(item.productName),
@@ -824,7 +862,9 @@ class _StockOutFormScreenState extends ConsumerState<StockOutFormScreen> {
fields: [
if (item.series.isNotEmpty) MobileCardField('系列', item.series),
if (item.spec.isNotEmpty) MobileCardField('规格', item.spec),
MobileCardField('单价', price > 0 ? '¥${price.toStringAsFixed(2)}' : '-'),
MobileCardField(
'成本价', price > 0 ? '¥${price.toStringAsFixed(2)}' : '-'),
MobileCardField('售价', null, valueWidget: _salePriceField(item)),
MobileCardField('数量', null, valueWidget: _qtyField(item)),
MobileCardField('金额', '¥${amount.toStringAsFixed(2)}'),
],