开放团队共享库存流水,保留订单和修改审批权限
This commit is contained in:
1 parent
7d894ea449
commit
49b7018f21
10 files changed
+65
-20
No files matched your search
+4
-3
@@ -489,7 +489,8 @@ class Ledger {
|
||||
if(typeof kind!=='string'||!['all','increase','decrease','transfer','manual'].includes(kind))fail('筛选流水类型无效');
|
||||
if(!['string','number'].includes(typeof pageValue)||!Number.isSafeInteger(Number(pageValue))||Number(pageValue)<1||String(Number(pageValue))!==String(pageValue))fail('流水页码须为正整数');
|
||||
const allRows=this.rows('SELECT * FROM movements ORDER BY created DESC,rowid DESC');
|
||||
const visible=allRows.filter(row=>this.canAccess('movement',row.id,actor));
|
||||
// 库存及盘点流水三人共用;业务详情、修改和审批仍由原权限控制。
|
||||
const visible=allRows;
|
||||
const historical=new Set(visible.map(r=>r.pocket));
|
||||
const pockets=POCKETS.filter(pocket=>ACTIVE_POCKETS.includes(pocket)||historical.has(pocket)).map(pocket=>({pocket,active:ACTIVE_POCKETS.includes(pocket)}));
|
||||
const pocket=query.pocket===undefined?'':query.pocket;
|
||||
@@ -497,8 +498,8 @@ class Ledger {
|
||||
const manualKinds=kind==='all'?null:InventoryChanges.manualMovementKinds(this,allRows,visible);
|
||||
const filtered=visible.filter(row=>(!pocket||row.pocket===pocket)&&(kind==='all'||(kind==='manual'?manualKinds.has(row.id):manualKinds.get(row.id)===kind)));
|
||||
const total=filtered.length,limit=100,totalPages=Math.max(1,Math.ceil(total/limit)),page=Math.min(Number(pageValue),totalPages);
|
||||
// 权限与所有筛选之后再分页;同一毫秒的流水按实际录入顺序稳定排列。
|
||||
const movements=InventoryChanges.decorate(this,filtered.slice((page-1)*limit,page*limit),actor,priceLockEnv);
|
||||
// 共享范围内筛选后分页;返回专门的盘点投影,不扩展原业务访问权限。
|
||||
const movements=InventoryChanges.decorate(this,filtered.slice((page-1)*limit,page*limit),actor,priceLockEnv,{shared:true});
|
||||
return {pocket,pockets,kind,total,shown:movements.length,limit,pageSize:limit,page,totalPages,hasPrev:page>1,hasNext:page<totalPages,movements};
|
||||
}
|
||||
inventorySnapshots(query={}){
|
||||
|
||||
Reference in new issue
Block a user