- 添加移动工作空间对话框全屏样式支持 - 更新应用主视图以支持桌面视口布局 - 重构Excel导入对话框增加预览和校验功能 - 在移动端主页增加生产与交付模块和项目借还功能 - 移动端库存列表显示项目名称和成品标识 - 增加入库记录批量操作和撤销功能 - 优化分页组件在桌面视口中的滚动行为 - 更新路由配置和数据库连接配置 - 调整仓库领域模型移除预期日期字段 - 优化智能代理服务的正则匹配和出库类型处理
32 lines
3.3 KiB
JavaScript
32 lines
3.3 KiB
JavaScript
const assert = require('node:assert/strict')
|
|
const fs = require('node:fs')
|
|
const path = require('node:path')
|
|
;(async () => {
|
|
const source = fs.readFileSync(path.resolve(__dirname, '../../ruoyi-ui/src/utils/purchase-sheet.js'), 'utf8')
|
|
const {validateRows,pasteRectangle,resolveRow,candidates,itemKey} = await import('data:text/javascript;base64,'+Buffer.from(source).toString('base64'))
|
|
const items=[{id:1,productCode:'A',productName:'螺丝',brand:'甲',spec:'M4',unit:'个'},{id:2,productCode:'B',productName:'螺丝',brand:'甲',spec:'M5',unit:'个'},{id:3,productCode:'C',productName:'螺丝',brand:'乙',spec:'M4',unit:'个'},{id:4,productCode:'D',productName:'电机',brand:'乙',spec:'24V',unit:'台'}]
|
|
const emptyRow=()=>({projectId:10,expenseCategoryId:20,materialName:'',materialBrand:'',materialParams:'',unit:'',quantity:1,finalUnitPrice:null,purchaseLink:''})
|
|
const row=()=>({...emptyRow(),materialName:'螺丝',materialBrand:'甲',materialParams:'M4',unit:'个',category:'零件'})
|
|
assert.deepEqual(candidates(items,row(),'spec').map(i=>i.spec),['M4','M5'])
|
|
const matched=resolveRow(row(),items);assert.equal(matched.productId,1)
|
|
assert.throws(()=>validateRows([{...row(),category:''}],items),/请选择物品类别/)
|
|
assert.equal(validateRows([row()],items)[0].category,'零件','explicit category can fill a missing catalog category')
|
|
const unknown=resolveRow({...row(),materialParams:'M6',productId:1},items);assert.equal(unknown.productId,null)
|
|
assert.throws(()=>resolveRow({...row(),unit:'箱'},items),/单位/)
|
|
assert.throws(()=>validateRows([{...row(),materialParams:'M6'},{...row(),materialParams:'M6',unit:'箱'}],items),/不同单位/)
|
|
assert.notEqual(itemKey({...row(),materialName:'a|b',materialBrand:'c'}),itemKey({...row(),materialName:'a',materialBrand:'b|c'}))
|
|
const fields=['projectId','expenseCategoryId','materialName','materialBrand','materialParams','unit','quantity','finalUnitPrice','purchaseLink']
|
|
const context={items,projects:[{id:10,projectName:'研发',projectCode:'P1'},{id:11,projectName:'机器人',projectCode:'P2'}],categories:[{id:20,categoryName:'材料费',categoryCode:'MAT'}],plans:[],units:['个','台'],emptyRow,readonly:r=>!!r.priceLocked}
|
|
const original=[row()]
|
|
const copied=pasteRectangle(original,'机器人\t材料费\t螺丝\t甲\tM5\t个\t40\t0.5\thttps://jd.com',0,0,fields,context)
|
|
assert.equal(copied[0].projectId,11);assert.equal(copied[0].productId,2);assert.equal(copied[0].quantity,40);assert.equal(original[0].materialParams,'M4')
|
|
assert.throws(()=>pasteRectangle(original,'研发\t材料费\t螺丝\t甲\tM5\t个\t1\n错误项目\t材料费\t螺丝\t甲\tM5\t个\t1',0,0,fields,context),/项目/)
|
|
assert.equal(original[0].materialParams,'M4');assert.equal(original.length,1)
|
|
assert.throws(()=>pasteRectangle([{...row(),priceLocked:true}],'M5\t个',0,4,fields,context),/已确认/)
|
|
assert.throws(()=>validateRows([{...row(),quantity:1.00001}],items),/4位/)
|
|
assert.throws(()=>validateRows([{...row(),finalUnitPrice:-1}],items),/单价/)
|
|
const forty=Array.from({length:40},()=> '研发\t材料费\t螺丝\t甲\tM4\t个\t10').join('\n')
|
|
assert.equal(pasteRectangle([],forty,0,0,fields,context).length,40)
|
|
console.log('PASS: catalog linking, units, duplicate identity, atomic rectangular paste, read-only rows, multi-project 40-row input')
|
|
})().catch(e=>{console.error(e);process.exitCode=1})
|