- 添加生产环境服务器地址配置支持内外网切换 - 实现采购列表只看我创建的功能开关 - 更新构建脚本中的默认生产环境API地址 - 优化采购单表格单元格编辑体验改用自动补全组件 - 调整应用更新检查逻辑增强生产环境兼容性 - 修复开发服务器切换时的一些验证问题 - 增强应用启动时的服务地址配置灵活性
35 lines
3.4 KiB
JavaScript
35 lines
3.4 KiB
JavaScript
import test from 'node:test'
|
|
import assert from 'node:assert/strict'
|
|
import fs from 'node:fs'
|
|
import {supplierInquiryRows,supplierInquirySelection,quotationReady,quotationSummary,quotationUploadError} from '../../src/utils/supplier-quotation.js'
|
|
|
|
test('selected inquiry IDs never expand into other same-product rows or invalid lines',()=>{
|
|
const row={id:1,productCode:'A',quantity:2};const all=[row,{...row,id:2,quantity:8},{...row,id:3,historical:true},{...row,id:4,receivedQuantity:1},{...row,id:5,purchaseStatus:5}]
|
|
assert.deepEqual(supplierInquirySelection([all[1]]),[2]);assert.equal(supplierInquiryRows([all[1]])[0].quantity,8)
|
|
assert.deepEqual(supplierInquirySelection(all),[1,2]);assert.deepEqual(supplierInquirySelection([]),[]);assert.deepEqual(supplierInquirySelection([row,row]),[1])
|
|
})
|
|
test('supplier inquiry merges only eligible same-item rows across projects without modifying original data',()=>{
|
|
const row={productCode:'A',materialName:'垫片',materialParams:'M4',materialBrand:'品牌',unit:'包',quantity:0.1,projectId:1}
|
|
const source=[row,{...row,quantity:0.2,projectId:2},{...row,receivedQuantity:1},{...row,historical:true},{...row,purchaseStatus:5},{...row,productCode:'B',materialParams:'M5',quantity:2}]
|
|
const groups=supplierInquiryRows(source);assert.equal(groups.length,2);assert.equal(groups[0].quantity,0.3);assert.equal(groups[0].rowCount,2);assert.equal(groups[1].spec,'M5');assert.equal(source[0].quantity,0.1)
|
|
})
|
|
test('blank, invalid and unmatchable prices cannot be applied while a real zero price can',()=>{
|
|
const valid={unitPrice:0,rowIds:[1,2],error:null},skip={...valid,unitPrice:null,skipped:true},bad={...valid,error:'错误'}
|
|
assert.equal(quotationReady(valid),true);for(const row of [skip,bad,{...valid,rowIds:[]},...[undefined,'',' ',false,-1,'abc'].map(unitPrice=>({...valid,unitPrice}))])assert.equal(quotationReady(row),false)
|
|
assert.deepEqual(quotationSummary([valid,skip,bad]),{ready:1,errors:1,skipped:1})
|
|
})
|
|
test('quote upload validates type and size and accepts ordinary Excel files',()=>{
|
|
for(const name of ['报价.xlsx','报价.XLS'])assert.equal(quotationUploadError({name,size:1024}),'')
|
|
for(const file of [{name:'报价.pdf',size:1},{name:'报价.xlsx',size:0},{name:'报价.xlsx',size:10485761}])assert.ok(quotationUploadError(file))
|
|
})
|
|
test('supplier workflow uses readable identity columns, a real Excel export, a quote preview, export-column selection and explicit partial confirmation',()=>{
|
|
const dialog=fs.readFileSync(new URL('../../src/components/PurchaseSheet/SupplierQuotation.vue',import.meta.url),'utf8')
|
|
assert.match(dialog,/inquiry-export/);assert.match(dialog,/上传供应商报价/);assert.match(dialog,/物品名称/);assert.match(dialog,/规格型号/)
|
|
assert.doesNotMatch(dialog,/label="物品编码"/);assert.equal((dialog.match(/title="供应商询价与报价回填"/g)||[]).length,1);assert.match(dialog,/title="选择询价单导出列"/)
|
|
assert.match(dialog,/summary\.errors>0 && !allowPartial/);assert.match(dialog,/保存清单/)
|
|
assert.ok(dialog.indexOf('label="供应商报价"')<dialog.indexOf('label="原报价"'))
|
|
const parent=fs.readFileSync(new URL('../../src/components/PurchaseSheet/index.vue',import.meta.url),'utf8')
|
|
assert.match(parent,/导出询价单/);assert.match(parent,/回填供应商报价/);assert.doesNotMatch(parent,/复制填写格式/)
|
|
assert.match(parent,/supplierName\(\)\{return this\.sheet\?\.batch\?\.supplierName/)
|
|
})
|