feat(client): 出库明细成本/售价/利润三列重设计 + 建单利润列 + 入库列头统一
- 出库详情抽屉(管理员):数量/成本价/售价/利润 + 合计金额/合计利润 双行; operator 见 售价/小计(服务端抹零+前端隐藏双保险);利润负数 danger - 出库建单:商品名称下带编码(字体同系列列);金额列→利润列(实时); 底栏合计利润(仅管理员);进价列仅管理员;提交发新 key(cost_price/sale_price) - 入库建单列头:进价(单瓶)/ 参考售价 / 总进价 - 退单弹窗金额改售价口径(与冲应收一致);打印保留待定价回退成本兼容 - models 字段随后端消歧改名;golden 重打;新增抽屉双形态 widget 测试 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJ1g8XV1YhhmHRzhwWEW7o
This commit is contained in:
@@ -55,6 +55,10 @@ class OrderLine {
|
||||
final String qty;
|
||||
final String price; // 已算好文案(或「待定价」)
|
||||
final String amount;
|
||||
// 出库管理员 6 列形态(2026-07 定价重设计):成本价 + 利润;
|
||||
// 两者非空时明细表渲染 数量/成本价/售价(price)/利润 四数值列,amount 不用。
|
||||
final String? cost;
|
||||
final String? profit;
|
||||
final bool pending; // 单价<=0:单价/金额显示待定价样式
|
||||
const OrderLine({
|
||||
required this.name,
|
||||
@@ -63,7 +67,9 @@ class OrderLine {
|
||||
required this.spec,
|
||||
required this.qty,
|
||||
required this.price,
|
||||
required this.amount,
|
||||
this.amount = '',
|
||||
this.cost,
|
||||
this.profit,
|
||||
this.pending = false,
|
||||
});
|
||||
}
|
||||
@@ -83,6 +89,9 @@ class OrderDetailDrawer extends StatelessWidget {
|
||||
final String linesLabel; // 入库明细 / 出库明细
|
||||
final List<OrderLine> lines;
|
||||
final String totalText; // 合计金额(已格式化)
|
||||
final String? profitText; // 合计利润(仅出库·管理员传入;null 不渲染)
|
||||
final String priceLabel; // 单价列头(入库=进价(单瓶)/出库=售价)
|
||||
final String amountLabel; // 金额列头(入库=总进价/出库 operator=小计)
|
||||
final List<DrawerActionGroup> actionGroups;
|
||||
|
||||
const OrderDetailDrawer({
|
||||
@@ -92,6 +101,9 @@ class OrderDetailDrawer extends StatelessWidget {
|
||||
required this.linesLabel,
|
||||
required this.lines,
|
||||
required this.totalText,
|
||||
this.profitText,
|
||||
this.priceLabel = '单价',
|
||||
this.amountLabel = '金额',
|
||||
required this.actionGroups,
|
||||
});
|
||||
|
||||
@@ -138,7 +150,10 @@ class OrderDetailDrawer extends StatelessWidget {
|
||||
child: Text(linesLabel,
|
||||
style: TextStyle(fontSize: AppDims.fsSm, color: t.muted)),
|
||||
),
|
||||
_LinesTable(lines: lines),
|
||||
_LinesTable(
|
||||
lines: lines,
|
||||
priceLabel: priceLabel,
|
||||
amountLabel: amountLabel),
|
||||
// ── 合计(.ltotal)──
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 8, 4, 0),
|
||||
@@ -159,6 +174,28 @@ class OrderDetailDrawer extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
),
|
||||
if (profitText != null)
|
||||
Padding(
|
||||
padding: const EdgeInsets.fromLTRB(4, 6, 4, 0),
|
||||
child: Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
Text('合计利润 ',
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsBody, color: t.muted)),
|
||||
const SizedBox(width: 6),
|
||||
Text(profitText!,
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsTitle,
|
||||
fontFamily: AppFonts.mono,
|
||||
fontFamilyFallback: AppFonts.monoFallback,
|
||||
fontWeight: FontWeight.w700,
|
||||
color: profitText!.startsWith('-')
|
||||
? t.danger
|
||||
: t.success)),
|
||||
],
|
||||
),
|
||||
),
|
||||
// ── 操作组(.dactions)──
|
||||
if (actionGroups.isNotEmpty) const SizedBox(height: 18),
|
||||
for (var i = 0; i < actionGroups.length; i++) ...[
|
||||
@@ -207,7 +244,15 @@ class _DrawerRow extends StatelessWidget {
|
||||
|
||||
class _LinesTable extends StatelessWidget {
|
||||
final List<OrderLine> lines;
|
||||
const _LinesTable({required this.lines});
|
||||
final String priceLabel;
|
||||
final String amountLabel;
|
||||
const _LinesTable(
|
||||
{required this.lines,
|
||||
required this.priceLabel,
|
||||
required this.amountLabel});
|
||||
|
||||
// 任一行带成本/利润 → 出库管理员 6 列形态
|
||||
bool get _withProfit => lines.any((l) => l.cost != null || l.profit != null);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -233,8 +278,17 @@ class _LinesTable extends StatelessWidget {
|
||||
style: _hStyle(t), overflow: TextOverflow.ellipsis),
|
||||
c2: Text('系列 / 规格', style: _hStyle(t)),
|
||||
c3: Text('数量', textAlign: TextAlign.right, style: _hStyle(t)),
|
||||
c4: Text('单价', textAlign: TextAlign.right, style: _hStyle(t)),
|
||||
c5: Text('金额', textAlign: TextAlign.right, style: _hStyle(t)),
|
||||
c4: _withProfit
|
||||
? Text('成本价', textAlign: TextAlign.right, style: _hStyle(t))
|
||||
: Text(priceLabel,
|
||||
textAlign: TextAlign.right, style: _hStyle(t)),
|
||||
c5: _withProfit
|
||||
? Text('售价', textAlign: TextAlign.right, style: _hStyle(t))
|
||||
: Text(amountLabel,
|
||||
textAlign: TextAlign.right, style: _hStyle(t)),
|
||||
c6: _withProfit
|
||||
? Text('利润', textAlign: TextAlign.right, style: _hStyle(t))
|
||||
: null,
|
||||
),
|
||||
),
|
||||
for (var i = 0; i < lines.length; i++)
|
||||
@@ -281,9 +335,18 @@ class _LinesTable extends StatelessWidget {
|
||||
style: const TextStyle(
|
||||
fontFamily: AppFonts.mono,
|
||||
fontFamilyFallback: AppFonts.monoFallback)),
|
||||
c4: _priceCell(context, lines[i].price, lines[i].pending),
|
||||
c5: _priceCell(context, lines[i].amount, lines[i].pending,
|
||||
accent: true),
|
||||
c4: _withProfit
|
||||
? _priceCell(
|
||||
context, lines[i].cost ?? '—', lines[i].pending)
|
||||
: _priceCell(context, lines[i].price, lines[i].pending),
|
||||
c5: _withProfit
|
||||
? _priceCell(context, lines[i].price, lines[i].pending)
|
||||
: _priceCell(context, lines[i].amount, lines[i].pending,
|
||||
accent: true),
|
||||
c6: _withProfit
|
||||
? _profitCell(
|
||||
context, lines[i].profit ?? '—', lines[i].pending)
|
||||
: null,
|
||||
),
|
||||
),
|
||||
],
|
||||
@@ -314,28 +377,56 @@ class _LinesTable extends StatelessWidget {
|
||||
color: accent ? t.text : t.text));
|
||||
}
|
||||
|
||||
// 5 列布局(对齐原型 grid 1fr 124 40 64 78)。
|
||||
// 5 列布局(对齐原型 grid 1fr 124 40 64 78);c6 非空时为出库 6 列形态
|
||||
// (数量/成本价/售价/利润,数值列等宽收窄)。
|
||||
Widget _lineRow(BuildContext context,
|
||||
{required Widget c1,
|
||||
required Widget c2,
|
||||
required Widget c3,
|
||||
required Widget c4,
|
||||
required Widget c5}) {
|
||||
required Widget c5,
|
||||
Widget? c6}) {
|
||||
final six = c6 != null;
|
||||
return Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Expanded(child: c1),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: 96, child: c2),
|
||||
SizedBox(width: six ? 84 : 96, child: c2),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: 34, child: c3),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: 60, child: c4),
|
||||
SizedBox(width: six ? 56 : 60, child: c4),
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: 72, child: c5),
|
||||
SizedBox(width: six ? 56 : 72, child: c5),
|
||||
if (six) ...[
|
||||
const SizedBox(width: 8),
|
||||
SizedBox(width: 56, child: c6),
|
||||
],
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
// 利润列:负数染 danger,正常 success;待定价沿 warn 样式
|
||||
Widget _profitCell(BuildContext context, String text, bool pending) {
|
||||
final t = context.tokens;
|
||||
if (pending) {
|
||||
return Text(text,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsXs,
|
||||
color: t.warn,
|
||||
fontWeight: FontWeight.w600));
|
||||
}
|
||||
return Text(text,
|
||||
textAlign: TextAlign.right,
|
||||
style: TextStyle(
|
||||
fontSize: AppDims.fsBody,
|
||||
fontFamily: AppFonts.mono,
|
||||
fontFamilyFallback: AppFonts.monoFallback,
|
||||
fontWeight: FontWeight.w600,
|
||||
color: text.startsWith('-') ? t.danger : t.success));
|
||||
}
|
||||
}
|
||||
|
||||
class _ActionGroup extends StatelessWidget {
|
||||
|
||||
Reference in New Issue
Block a user