允许手动移除附加成本并保留草稿模板删除状态
This commit is contained in:
1 parent
5777036743
commit
a3262a455d
8 files changed
+109
-11
No files matched your search
@@ -45,10 +45,11 @@
|
||||
result.charges=rawCharges.map(rawCharge=>{
|
||||
const c=object(rawCharge,'附加项目'),old=string(c.id,'附加项目标识',36);if(old&&(!uuid.test(old)||seen.has(old)))throw new Error('附加项目标识无效或重复');if(old)seen.add(old);
|
||||
const name=string(c.name,'附加项目名称',40),nameType=pick(c.nameType,[...charges,'其他'],'附加项目',charges.includes(name)?name:name?'其他':'编绳');
|
||||
if(c.costRemoved!==undefined&&typeof c.costRemoved!=='boolean')throw new Error('内部成本移除标记无效');
|
||||
const id=newId();if(old)ids.set(old,id);
|
||||
const customName=string(c.customName??(nameType==='其他'?name:''),'附加项目名称',40),amount=numeric(c.amount,'附加金额');
|
||||
const prices={};if(c.chargePrices!=null){object(c.chargePrices,'附加项目预设报价');for(const key of [...charges,'其他'])if(Object.hasOwn(c.chargePrices,key))prices[key]=numeric(c.chargePrices[key],'附加项目报价');}
|
||||
return {id,nameType,customName,name:nameType==='其他'?customName:nameType,amount,chargePrices:{...prices,[nameType]:amount}};
|
||||
return {id,nameType,customName,name:nameType==='其他'?customName:nameType,amount,chargePrices:{...prices,[nameType]:amount},...(c.costRemoved===true?{costRemoved:true}:{})};
|
||||
});
|
||||
if(line.costParts!=null){
|
||||
object(line.costParts,'分项成本');const parts=Object.fromEntries(['material','labor','accessories','other'].map(key=>[key,numeric(line.costParts[key],'货品成本')]));
|
||||
|
||||
Reference in new issue
Block a user