cmvr-wms/scripts/projectdev/business-home-check.cjs
lixiaolong ca1f5a27f9 feat(mobile): 优化移动端界面和功能
- 添加移动工作空间对话框全屏样式支持
- 更新应用主视图以支持桌面视口布局
- 重构Excel导入对话框增加预览和校验功能
- 在移动端主页增加生产与交付模块和项目借还功能
- 移动端库存列表显示项目名称和成品标识
- 增加入库记录批量操作和撤销功能
- 优化分页组件在桌面视口中的滚动行为
- 更新路由配置和数据库连接配置
- 调整仓库领域模型移除预期日期字段
- 优化智能代理服务的正则匹配和出库类型处理
2026-10-12 16:41:42 +08:00

35 lines
4.8 KiB
JavaScript

const assert=require('node:assert/strict'),fs=require('node:fs'),path=require('node:path')
;(async()=>{
const code=fs.readFileSync(path.resolve(__dirname,'../../ruoyi-ui/src/utils/business-home.js'),'utf8')
const {homeQueues,homeTarget,homeOverview,homeQueueTarget}=await import('data:text/javascript;base64,'+Buffer.from(code).toString('base64'))
const base={projectId:1,projectName:'研发',quantity:10,acceptedQuantity:3,pendingArrivalQuantity:2,remainingQuantity:5,purchaseStatus:0,materialName:'电机',purchaseBatchId:12,purchaseBatchNo:'B12',requestNo:'P1'}
const input={purchases:[{...base,id:1,finalUnitPrice:null},{...base,id:2,purchaseBatchId:13,purchaseBatchNo:'B13',finalUnitPrice:0},{...base,id:3,priceLocked:true,finalUnitPrice:10},{...base,id:4,historical:true},{...base,id:5,purchaseStatus:5}],receipts:[{inStatus:0,inNo:'IN1',sourceProjectId:2},{inStatus:1}],tasks:[{id:9,status:'OPEN',project_id:1,planned_quantity:2,good_quantity:2},{id:10,status:'SETTLED'},{id:11,status:'OPEN',planned_quantity:10,good_quantity:1}],loans:[{active:true,outstandingQuantity:2,itemId:8,borrowerProjectId:2},{active:true,outstandingQuantity:0},{active:false,outstandingQuantity:4}]}
const queues=homeQueues(input),find=key=>queues.find(q=>q.key===key)
assert.equal(find('quote').rows.length,1);assert.equal(find('confirm').rows.length,1,'zero is a valid final quote')
assert.equal(find('arrival').rows.length,1);assert.equal(find('acceptance').rows.length,2,'three material rows form two batches')
assert.equal(find('receipt').rows.length,1);assert.equal(find('production').rows.length,1);assert.equal(find('loan').rows.length,1)
assert.equal(homeQueues({...input,purchases:null})[0].rows,null,'failure must not look like zero pending')
assert.deepEqual(homeTarget(find('quote').rows[0],'quote').query,{projectId:1,purchaseBatchId:12,legacy:undefined,requestNo:undefined})
assert.equal(homeTarget(find('acceptance').rows[0],'acceptance').query.queue,'pending')
assert.equal(homeTarget(find('receipt').rows[0],'receipt').query.projectId,2)
assert.equal(homeTarget(find('production').rows[0],'production').query.taskId,9)
assert.equal(homeTarget(find('loan').rows[0],'loan').query.outstandingOnly,'1')
const projects=[{projectCode:'P1',projectStatus:1,totalAmount:100,spentAmount:30,availableAmount:70,currency:'CNY'},{projectCode:'P2',projectStatus:2,totalAmount:200,spentAmount:240,availableAmount:-40,currency:'CNY'},{projectCode:'LEGACY',projectStatus:3,totalAmount:0,spentAmount:0,availableAmount:0,currency:'CNY'}]
const overview=homeOverview(projects,input.purchases,input.tasks)
assert.equal(overview.projectCount,2,'historical holding pool is not a real project')
assert.deepEqual(overview.statuses.map(s=>s.count),[0,1,1,0])
assert.equal(overview.budget,300);assert.equal(overview.locked,270);assert.equal(overview.remaining,30);assert.equal(overview.budgetRate,90);assert.equal(overview.overBudget,1)
assert.equal(overview.purchaseCount,3,'one record counts once despite overlapping queues');assert.equal(overview.batchCount,2);assert.equal(overview.productionCount,2)
assert.equal(homeOverview(null,null,null).projectCount,null);assert.equal(homeOverview(null,null,null).budget,null);assert.equal(homeOverview(null,null,null).purchaseCount,null)
assert.equal(homeOverview([{...projects[0],totalAmount:null}],[],[]).budget,null)
assert.equal(homeOverview([{...projects[0],totalAmount:0}],[],[]).budgetRate,null,'zero budget is not a fabricated percentage')
assert.equal(homeOverview([projects[0],{...projects[1],currency:'USD'}],[],[]).budget,null,'different currencies must not be mixed')
assert.deepEqual(homeQueueTarget('acceptance',2),{path:'/procurement/arrival',query:{projectId:2,queue:'pending'}})
assert.equal(homeQueueTarget('loan').query.outstandingOnly,'1')
const mixed=homeQueues({...input,purchases:[{...base,id:1,finalUnitPrice:null,projectId:1,projectName:'研发'},{...base,id:2,finalUnitPrice:0,projectId:2,projectName:'产品'}]})
assert.equal(mixed.find(q=>q.key==='quote').rows.length,1);assert.equal(mixed.find(q=>q.key==='confirm').rows.length,0,'mixed quotation batch is not duplicated across quote/confirm')
assert.equal(mixed.find(q=>q.key==='quote').rows[0].project,'研发、产品');assert.equal(homeTarget(mixed[0].rows[0],'quote').query.projectId,undefined,'multi-project batch must not be narrowed to its first project')
assert.equal(homeQueues({...input,tasks:[...input.tasks,{id:12,parent_task_id:9,status:'OPEN',planned_quantity:1,good_quantity:0}]}).find(q=>q.key==='production').rows.length,0,'unfinished child prevents ready-to-settle notification')
console.log('PASS: batch-grouped procurement, zero-price quote, mixed-project links, completed-only production todo, waiting follow-ups, missing-data/currency safeguards and workflow destinations')
})().catch(e=>{console.error(e);process.exitCode=1})