feat: P0-3 打印模板体系(区块化模板CRUD+打印中心重构)
This commit is contained in:
@@ -117,6 +117,35 @@ async def seed() -> None:
|
||||
await db.commit()
|
||||
print("价格脚本就绪")
|
||||
|
||||
# 7) 打印模板(幂等:按名称去重)
|
||||
async with SessionLocal() as db:
|
||||
from huamenchuang.models.extend import OrderFormat
|
||||
FORMATS = [
|
||||
("标准生产订单", [
|
||||
{"type": "title", "text": "生产订单"},
|
||||
{"type": "info", "fields": ["order_no", "customer_name", "phone", "address", "count", "money"]},
|
||||
{"type": "image"},
|
||||
{"type": "table", "kind": "process"},
|
||||
{"type": "sign"},
|
||||
], 1),
|
||||
("生产订单+BOM下料单", [
|
||||
{"type": "title", "text": "生产订单"},
|
||||
{"type": "info", "fields": ["order_no", "customer_name", "phone", "address",
|
||||
"count", "area", "money", "created_at"]},
|
||||
{"type": "image"},
|
||||
{"type": "table", "kind": "bom"},
|
||||
{"type": "table", "kind": "process"},
|
||||
{"type": "sign"},
|
||||
], 0),
|
||||
]
|
||||
existing = {n for (n,) in (await db.execute(select(OrderFormat.name))).all()}
|
||||
for i, (name, blocks, is_default) in enumerate(FORMATS):
|
||||
if name not in existing:
|
||||
db.add(OrderFormat(name=name, order_type=0, sort=i, is_default=is_default,
|
||||
blocks=__import__("json").dumps(blocks, ensure_ascii=False)))
|
||||
await db.commit()
|
||||
print("打印模板就绪")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(seed())
|
||||
|
||||
Reference in New Issue
Block a user