- 集成 ServerConnection 组件用于开发环境服务器切换 - 实现多服务器令牌隔离存储机制 - 添加 ArrivalOperation 屏幕处理到货和验收流程 - 支持待登记到货和待验收状态切换 - 优化库存操作界面的字段显示逻辑 - 增强 Excel 文件分片上传支持产品文件识别 - 添加 AI 助手会话滚动跟踪功能 - 实现开发服务器地址持久化存储 - 优化登录界面集成服务器连接组件 - 添加领用出库功能支持项目物资使用 - 改进盘点确认生效的操作流程 - 增强采购到货登记和验收的权限控制 - 优化移动端文件上传的断点续传机制 - 添加服务器切换时的数据清理保护机制 - 实现紧凑金额显示模式减少界面冗余 - 增强库存操作的数量验证和错误提示 - 优化 AI 助手的会话状态同步机制
31 lines
2.4 KiB
JavaScript
31 lines
2.4 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import {purchaseGridRange,selectedGridText,clipboardTableText} from '../../src/utils/purchase-grid-clipboard.js'
|
|
import {parseClipboardTable,pasteRectangle} from '../../src/utils/purchase-sheet.js'
|
|
const rows=[{_key:'a',materialName:'物品A',materialParams:'型号\tA',quantity:2},{_key:'b',materialName:'物品B',materialParams:'两行\n型号',quantity:0}],columns=['materialName','materialParams','quantity'].map(field=>({field}))
|
|
test('rectangle selection supports reversed corners and visible row ordering',()=>{
|
|
const selection={anchor:{key:'b',field:'quantity'},focus:{key:'a',field:'materialParams'}}
|
|
assert.deepEqual(purchaseGridRange(selection,rows,columns),{top:0,bottom:1,left:1,right:2})
|
|
assert.equal(purchaseGridRange(selection,[rows[0]],columns),null)
|
|
assert.deepEqual(purchaseGridRange(selection,[rows[1],rows[0]],columns),{top:0,bottom:1,left:1,right:2})
|
|
})
|
|
test('copy exports the chosen columns only, with Excel-compatible quoted multiline TSV and zero values',()=>{
|
|
const text=selectedGridText({top:0,bottom:1,left:1,right:2},rows,columns,(row,key)=>row[key])
|
|
assert.deepEqual(parseClipboardTable(text),[['型号\tA','2'],['两行\n型号','0']])
|
|
assert.deepEqual(parseClipboardTable(clipboardTableText([['a"b','c\nd','e\tf',''] ])),[['a"b','c\nd','e\tf','']])
|
|
})
|
|
test('paste respects visible sorted rows and never partially applies invalid data',()=>{
|
|
const source=rows.map(r=>({...r,unit:'个'})),context={readonly:()=>false,items:[],units:['个'],rowIndices:[1,0]}
|
|
const result=pasteRectangle(source,'3\n4',1,0,['quantity'],context)
|
|
assert.deepEqual(result.map(r=>r.quantity),[4,3]);assert.deepEqual(source.map(r=>r.quantity),[2,0])
|
|
assert.throws(()=>pasteRectangle(source,'3\n非法',1,0,['quantity'],context),/格式不正确/)
|
|
assert.deepEqual(source.map(r=>r.quantity),[2,0])
|
|
})
|
|
test('paste rejects ragged rectangles, missing anchors and permission-protected fields',()=>{
|
|
const source=[{_key:'a',quantity:1,unit:'个'}],context={readonly:()=>false,items:[],units:['个']}
|
|
assert.throws(()=>pasteRectangle(source,'1\t2\n3',0,0,['quantity','finalUnitPrice'],context),/矩形/)
|
|
assert.throws(()=>pasteRectangle(source,'1',0,-1,['quantity'],context),/起始/)
|
|
assert.throws(()=>pasteRectangle(source,'3',0,0,['quantity'],{...context,canEditField:()=>false}),/不可通过粘贴/)
|
|
assert.equal(source[0].quantity,1)
|
|
})
|