增加库存流水Excel导出,支持筛选后全量下载

This commit is contained in:
summer committed 2026-10-31 14:59:30 +08:00
1 parent 49b7018f21
commit c25f529b20
10 files changed
+196 -10

No files matched your search

+6
View File
@@ -5,6 +5,7 @@ const path=require('node:path');
const crypto=require('node:crypto');
const {DatabaseSync,backup}=require('node:sqlite');
const TeamMembers=require('./team-members');
const {inventoryMovementsFile}=require('./inventory-movements-export');
const {Ledger,ACTIVE_POCKETS,ACCOUNTS,today,fail,text,owner}=require('./ledger');
const {receipt,settings,defaults}=require('./printing');
const {recoveryCustomerPrintDocument,exchangeCustomerPrintDocument}=require('./recovery-printing');
@@ -153,6 +154,11 @@ function createApp(options={}){
const lockMatch=route.match(/^\/api\/price-locks\/([a-f0-9-]+)(?:\/(deliver))?$/);
if(lockMatch&&!isPost){if(lockMatch[2])fail('地址不存在',404);return send(res,200,actorLedger.priceLockDetail(lockMatch[1]));}
if(route==='/api/inventory'&&!isPost)return send(res,200,{...actorLedger.inventoryStatus(actor),automaticSnapshot:automaticSnapshots.status()});
if(route==='/api/inventory/movements/export.xlsx'&&!isPost){
const file=inventoryMovementsFile(actorLedger.inventoryMovementsExport(Object.fromEntries(url.searchParams)),today());
res.setHeader('Content-Disposition',`attachment; filename="inventory-movements-${today()}.xlsx"; filename*=UTF-8''${encodeURIComponent(file.filename)}`);res.setHeader('Content-Length',file.buffer.length);
return send(res,200,file.buffer,file.contentType);
}
if(route==='/api/inventory/movements'&&!isPost)return send(res,200,actorLedger.inventoryMovements(Object.fromEntries(url.searchParams)));
const inventoryMovementMatch=route.match(/^\/api\/inventory\/movements\/([a-f0-9-]{36})(?:\/(update|delete))?$/);
if(inventoryMovementMatch&&!isPost){if(inventoryMovementMatch[2])fail('地址不存在',404);return send(res,200,actorLedger.inventoryMovement(inventoryMovementMatch[1],actor));}