普通订单取消须麦麦审批并按录错作废冲回
This commit is contained in:
1 parent
46530c29b8
commit
27a11e9b35
28 files changed
+759
-60
No files matched your search
+8
-2
@@ -76,6 +76,9 @@ function createApp(options={}){
|
||||
const materialPoolMatch=route.match(/^\/api\/material-pools\/(\d{4}-\d{2}-\d{2})(?:\/(settlement))?$/);
|
||||
if(materialPoolMatch&&!isPost){if(materialPoolMatch[2])fail('地址不存在',404);return send(res,200,ledger.materialPoolDetail(materialPoolMatch[1]));}
|
||||
if(route==='/api/price-locks'&&!isPost)return send(res,200,ledger.priceLocks(Object.fromEntries(url.searchParams)));
|
||||
if(route==='/api/order-cancellations'&&!isPost)return send(res,200,ledger.orderCancellations(Object.fromEntries(url.searchParams),actor));
|
||||
const cancellationMatch=route.match(/^\/api\/order-cancellations\/([a-f0-9-]{36})(?:\/(approve|reject))?$/);
|
||||
if(cancellationMatch&&!isPost){if(cancellationMatch[2])fail('地址不存在',404);return send(res,200,ledger.orderCancellationRequest(cancellationMatch[1],actor));}
|
||||
const lockMatch=route.match(/^\/api\/price-locks\/([a-f0-9-]+)(?:\/(deliver))?$/);
|
||||
if(lockMatch&&!isPost){if(lockMatch[2])fail('地址不存在',404);return send(res,200,ledger.priceLockDetail(lockMatch[1]));}
|
||||
if(route==='/api/inventory'&&!isPost)return send(res,200,ledger.inventoryStatus(actor));
|
||||
@@ -87,7 +90,7 @@ function createApp(options={}){
|
||||
if(route==='/api/people-count'&&!isPost)return send(res,200,ledger.peopleCount(url.searchParams.get('date')??today()));
|
||||
if(route==='/api/paper-number'&&!isPost)return send(res,200,{number:ledger.paperNumber(url.searchParams.get('date')||today())});
|
||||
const match=route.match(/^\/api\/orders\/([a-f0-9-]+)(?:\/([a-z]+))?$/);
|
||||
if(match&&!isPost){if(match[2]==='public')return send(res,200,ledger.publicOrder(match[1]));if(match[2]==='edit')return send(res,200,ledger.orderEdit(match[1],actor));if(!match[2])return send(res,200,ledger.detail(match[1]));fail('地址不存在',404);}
|
||||
if(match&&!isPost){if(match[2]==='public')return send(res,200,ledger.publicOrder(match[1]));if(match[2]==='edit')return send(res,200,ledger.orderEdit(match[1],actor));if(match[2]==='cancellation')return send(res,200,ledger.orderCancellation(match[1],actor));if(!match[2])return send(res,200,ledger.detail(match[1]));fail('地址不存在',404);}
|
||||
if(route.startsWith('/print/')&&!isPost){const id=route.slice(7);return send(res,200,receipt(ledger.publicOrder(id),ledger.meta('printing',defaults),url.searchParams.get('mode')),'text/html; charset=utf-8');}
|
||||
if(route==='/api/report'&&!isPost){
|
||||
const basis=url.searchParams.get('basis');if(basis!==null&&basis!=='orderDate')fail('对账日期口径无效');
|
||||
@@ -113,6 +116,9 @@ function createApp(options={}){
|
||||
if(route==='/api/price-locks')return ledger.createPriceLock(b,actor);
|
||||
if(lockMatch&&lockMatch[2]==='deliver')return ledger.deliverPriceLock(lockMatch[1],b,actor);
|
||||
if(route==='/api/after-sales')return ledger.saveAfterSale(b,actor);
|
||||
if(cancellationMatch&&cancellationMatch[2]==='approve')return ledger.approveOrderCancellation(cancellationMatch[1],b,actor);
|
||||
if(cancellationMatch&&cancellationMatch[2]==='reject')return ledger.rejectOrderCancellation(cancellationMatch[1],b,actor);
|
||||
if(match&&match[2]==='cancellation')return ledger.requestOrderCancellation(match[1],b,actor);
|
||||
if(route==='/api/people-count')return ledger.savePeopleCount(b,actor);
|
||||
if(match&&match[2]==='edit')return ledger.editOrder(match[1],b,actor);
|
||||
if(match&&match[2])return ledger.action(match[1],match[2],b,actor);
|
||||
@@ -124,7 +130,7 @@ function createApp(options={}){
|
||||
fail('地址不存在',404);
|
||||
});return send(res,200,result);
|
||||
}
|
||||
const assets={'/':'index.html','/app.js':'app.js','/order-copy.js':'order-copy.js','/order-templates.js':'order-templates.js','/order-templates-ui.js':'order-templates-ui.js','/order-edit-ui.js':'order-edit-ui.js','/price-locks-ui.js':'price-locks-ui.js','/material-pools-ui.js':'material-pools-ui.js','/calculations.js':'calculations.js','/fee-estimates.js':'fee-estimates.js','/app.css':'app.css','/print.js':'print.js'};const file=assets[route];if(!file||isPost)fail('地址不存在',404);
|
||||
const assets={'/':'index.html','/app.js':'app.js','/order-copy.js':'order-copy.js','/order-templates.js':'order-templates.js','/order-templates-ui.js':'order-templates-ui.js','/order-edit-ui.js':'order-edit-ui.js','/order-cancellations-ui.js':'order-cancellations-ui.js','/price-locks-ui.js':'price-locks-ui.js','/material-pools-ui.js':'material-pools-ui.js','/calculations.js':'calculations.js','/fee-estimates.js':'fee-estimates.js','/app.css':'app.css','/print.js':'print.js'};const file=assets[route];if(!file||isPost)fail('地址不存在',404);
|
||||
send(res,200,fs.readFileSync(path.join(__dirname,'public',file)),file.endsWith('.js')?'application/javascript; charset=utf-8':file.endsWith('.css')?'text/css; charset=utf-8':'text/html; charset=utf-8');
|
||||
}catch(e){if(!res.headersSent)send(res,e.status||400,{error:e.status||e.message?.startsWith('打印')?e.message:(e.code?.startsWith('SQLITE')?'保存失败,请保留操作内容并联系维护者':e.message||'操作失败')});else res.end();}
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user