修复:分类规则仅处理未分类并保留已有归属
This commit is contained in:
@@ -2,7 +2,7 @@ import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { configurationTables, importConfigurationTables, createConfigurationWorkbook, readConfigurationWorkbook } from '../src/configurationWorkbook.ts';
|
||||
|
||||
const rule={id:'rule_001',name:'指定分类',priority:-9900,stage:'all',enabled:true,target:'group',value:'G',conditions:[{field:'PDT代码',operator:'EQUALS',value:'00001'},{field:'销售片区',operator:'IS_BLANK',value:''}]};
|
||||
const rule={onlyUnclassified:true,id:'rule_001',name:'指定分类',priority:-9900,stage:'all',enabled:true,target:'group',value:'G',conditions:[{field:'PDT代码',operator:'EQUALS',value:'00001'},{field:'销售片区',operator:'IS_BLANK',value:''}]};
|
||||
const base={schemaVersion:3,unknown:{retain:[1,null]},masterData:{departments:[{code:'0001',name:'A',enabled:true}],groups:[{code:'002',name:'G',enabled:true,department:'A',unknown:'keep'}],products:[],projectGroups:[]},
|
||||
categoryLookup:{'00001|欧洲':'G','00002|空':null},projectGroupLookup:{'00003|G':'P'},departmentLookup:{raw:'A'},productLookup:{RAW:'P'},disabledMappings:{categoryLookup:['00002|空']},matchRules:[rule],organizationHierarchy:[{code:'A',parentCode:'',name:'保留名称'}],effectiveRanges:[{mappingType:'CATEGORY',sourceKey:'00001|欧洲',fromMonth:'2026-01',toMonth:'2026-12',mappedValue:null}]};
|
||||
|
||||
@@ -46,3 +46,8 @@ test('query fields and calculation definitions round-trip, preserve formulas as
|
||||
tables.find(t=>t.name==='指标计算公式').rows[0][1]='qualified/(qualified+scrap)';const imported=importConfigurationTables(rules,tables,'rules','MERGE').definition;assert.equal(imported.metricRules.RATE.formula,'qualified/(qualified+scrap)');assert.equal(imported.metricRules.RATE.nullPolicy,undefined);
|
||||
const fields={filterFields:[{key:'0001',label:'客户',blackColumn:'客户代码',brightColumn:'客户代码',enabled:false,allowEmpty:true,sortOrder:1}]};const book=await createConfigurationWorkbook(fields,'filterFields');tables=await readConfigurationWorkbook(await book.xlsx.writeBuffer());assert.deepEqual(importConfigurationTables(fields,tables,'filterFields','REPLACE').definition,fields);
|
||||
});
|
||||
|
||||
test('legacy twelve-column workbooks preserve the existing unclassified-only restriction',()=>{
|
||||
const tables=configurationTables(base,'matchRules');tables[0].headers.pop();tables[0].rows.forEach(row=>row.pop());
|
||||
for(const mode of ['MERGE','REPLACE'])assert.equal(importConfigurationTables(base,tables,'matchRules',mode).definition.matchRules[0].onlyUnclassified,true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user