|
@@ -174,7 +174,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
this.setScene('add');
|
|
this.setScene('add');
|
|
|
- return this.db.model.create(data);
|
|
|
|
|
|
|
+ return await this.db.model.create(data);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -479,13 +479,13 @@ class UnitPriceModel extends BaseModel {
|
|
|
return uResult&&mResult&&cResult;
|
|
return uResult&&mResult&&cResult;
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
- async copyMaterialNotExist(currentUnitPriceId, changeUnitPriceId,gljMap){
|
|
|
|
|
- await this.copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,original_calc_model);//复制原价计算
|
|
|
|
|
- await this.copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,freight_calc_model);//复制运费计算
|
|
|
|
|
|
|
+ async copyMaterialNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,newFile = false){
|
|
|
|
|
+ await this.copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,original_calc_model,newFile);//复制原价计算
|
|
|
|
|
+ await this.copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,freight_calc_model,newFile);//复制运费计算
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- async copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,model){
|
|
|
|
|
|
|
+ async copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,model,newFile){
|
|
|
let currentMap = {},targetMap = {}, insertData = [];
|
|
let currentMap = {},targetMap = {}, insertData = [];
|
|
|
//取原单价文件所有的原价、运费计算计录
|
|
//取原单价文件所有的原价、运费计算计录
|
|
|
let currentList = await model.find({'unit_price_file_id':currentUnitPriceId}).lean();
|
|
let currentList = await model.find({'unit_price_file_id':currentUnitPriceId}).lean();
|
|
@@ -498,7 +498,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
if(targetMap[ckey]){//如果切换后已经存在,则不用复制
|
|
if(targetMap[ckey]){//如果切换后已经存在,则不用复制
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if(gljMap[ckey]){//在本项目中有用到并且复制标记为true
|
|
|
|
|
|
|
+ if(gljMap[ckey] || newFile == true){//在本项目中有用到 或者 新建的文件
|
|
|
for(let c of currentMap[ckey]){
|
|
for(let c of currentMap[ckey]){
|
|
|
delete c._id; // 删除原有id信息
|
|
delete c._id; // 删除原有id信息
|
|
|
c.ID = uuidV1();
|
|
c.ID = uuidV1();
|