Files
star 5060d027e5 feat: 多工厂/厂间调拨/替代料/流水台账折叠 + 重写 README
- 多工厂(factory 表) + 顶栏工厂下拉过滤, 库存按厂聚合
- 厂间调拨(transfer): 源厂减+目标厂加, 总库存不变, 双向流水对账
- 替代料关系(substitute): 出库/BOM领料/生产领料缺料时提示可替代料
- 流水台账(ledger): 入出按日期合并折叠, 按日期导出同一 Excel
- 生产订单增强: 编辑/删除(级联清关联流水)/调入数量/确认调入=厂间调拨
- 入库新增送货日期字段; 出库物料编码扫码定位
- 重写 README 补全全部模块; .gitignore 排除 dist_pkg/build_pkg/*.db
- 停止跟踪 instance/app.db(运行时自动生成)
2026-09-29 11:17:48 +08:00

86 lines
4.7 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{% extends "base.html" %}
{% block title %}流水台账{% endblock %}
{% block content %}
<div class="toolbar">
<h3 style="margin:0">流水台账(出库 + 入库 按日期合并)</h3>
<span class="badge ok">总入库 {{ '%.2f'|format(total_in) }}</span>
<span class="badge danger">总出库 {{ '%.2f'|format(total_out) }}</span>
</div>
<p class="muted" style="margin:6px 0 0">选择日期区间后点「导出 Excel」,系统会把该区间内的<b>出库与入库合并到同一个文件</b>(文件名自动带上日期)。同一天的出库与入库已按日期折叠在一起,点日期可展开当天的明细。</p>
<style>
details.date-group{margin:14px 0;border:1px solid #e6e9ef;border-radius:8px;overflow:hidden;background:#fff}
details.date-group>summary{list-style:none;cursor:pointer;padding:11px 14px;background:#f5f8fc;font-weight:600;display:flex;align-items:center;gap:8px;user-select:none}
details.date-group>summary::-webkit-details-marker{display:none}
details.date-group>summary::before{content:"\25B8";display:inline-block;transition:transform .15s;color:#8a94a6;font-size:12px}
details.date-group[open]>summary::before{content:"\25BE"}
details.date-group>table{margin:0;border:none}
details.date-group>table tr:first-child td,details.date-group>table tr:first-child th{border-top:none}
.fold-btns{margin:10px 0 2px;display:flex;gap:8px}
</style>
<div class="fold-btns">
<button type="button" class="btn" onclick="document.querySelectorAll('details.date-group').forEach(d=>d.open=true)">全部展开</button>
<button type="button" class="btn" onclick="document.querySelectorAll('details.date-group').forEach(d=>d.open=false)">全部折叠</button>
</div>
{% if factory %}
<div class="scope-banner">当前仅显示工厂:<b>{{ factory.code }}</b>(切换顶栏工厂可改变范围)</div>
{% else %}
<div class="scope-banner">当前显示:<b>全部工厂(汇总)</b></div>
{% endif %}
<form method="get" class="card" style="display:flex; gap:12px; align-items:flex-end; flex-wrap:wrap; margin-bottom:14px">
<label style="font-size:13px">起始日期<input type="date" name="from" value="{{ frm }}"></label>
<label style="font-size:13px">结束日期<input type="date" name="to" value="{{ to }}"></label>
<label style="font-size:13px">类型
<select name="type" style="margin-left:4px">
<option value="" {% if type=='' %}selected{% endif %}>全部</option>
<option value="in" {% if type=='in' %}selected{% endif %}>入库</option>
<option value="out" {% if type=='out' %}selected{% endif %}>出库</option>
<option value="transfer" {% if type=='transfer' %}selected{% endif %}>厂间调拨</option>
<option value="prod" {% if type=='prod' %}selected{% endif %}>生产相关</option>
<option value="other" {% if type=='other' %}selected{% endif %}>其他</option>
</select>
</label>
<label style="font-size:13px">调拨/关联单号<input type="text" name="q" value="{{ q }}" placeholder="如 TR... / WO..." style="width:140px"></label>
<button class="primary" type="submit">筛选</button>
<a class="btn" href="{{ url_for('ledger') }}">清除</a>
<a class="btn primary" href="{{ url_for('ledger_export') }}?from={{ frm|urlencode }}&amp;to={{ to|urlencode }}&amp;type={{ type|urlencode }}&amp;q={{ q|urlencode }}" title="按所选日期生成 Excel,出库与入库合并在同一文件">按日期生成 Excel</a>
</form>
{% if not date_groups %}
<p class="muted">暂无流水记录。</p>
{% endif %}
{% for d, items in date_groups %}
<details class="date-group" {{ 'open' if loop.first else '' }}>
<summary>
<span class="dg-date">{{ d }}</span>
<span class="small muted">({{ items|length }} 笔)</span>
</summary>
<table class="tbl">
<thead><tr>
<th style="width:48px">类型</th><th>业务类型</th><th>物料编号</th><th>型号</th>
<th class="num">数量</th><th>工厂</th><th>来源 / 用途</th><th>调拨/关联单号</th><th>经手人</th>
</tr></thead>
<tbody>
{% for r in items %}
<tr class="{{ 'row-in' if r.type=='入' else 'row-out' }}">
<td><span class="badge {{ 'ok' if r.type=='入' else 'danger' }}">{{ r.type }}</span></td>
<td>{{ r.cat }}</td>
<td>{% if r.m %}<a href="{{ url_for('material_detail', mid=r.m.id) }}">{{ r.m.part_number }}</a>{% else %}-{% endif %}</td>
<td>{{ r.m.manufacturer if r.m else '-' }}</td>
<td class="num">{{ '%.2f'|format(r.qty) }}</td>
<td>{{ r.fac.code if r.fac else '—' }}</td>
<td>{{ r.who or '-' }}</td>
<td>{{ r.ref or '-' }}</td>
<td>{{ r.op or '-' }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</details>
{% endfor %}
{% endblock %}