|
@@ -461,7 +461,6 @@ class UnitPriceModel extends BaseModel {
|
|
|
let insertData = [];
|
|
let insertData = [];
|
|
|
for (let tmp of currentUnitList) {
|
|
for (let tmp of currentUnitList) {
|
|
|
let t_index = this.getIndex(tmp,['code','name','specs','unit','type']);
|
|
let t_index = this.getIndex(tmp,['code','name','specs','unit','type']);
|
|
|
- if(gljMap[t_index]) gljMap[t_index].copy = true;//复制标记,用于组成物,材料计算等的复制
|
|
|
|
|
if (targetUnitList !== null && targetUnitList[t_index] !== undefined) {
|
|
if (targetUnitList !== null && targetUnitList[t_index] !== undefined) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
@@ -489,10 +488,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
async copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,model){
|
|
async copyCalcNotExist(currentUnitPriceId, changeUnitPriceId,gljMap,model){
|
|
|
let currentMap = {},targetMap = {}, insertData = [];
|
|
let currentMap = {},targetMap = {}, insertData = [];
|
|
|
//取原单价文件所有的原价、运费计算计录
|
|
//取原单价文件所有的原价、运费计算计录
|
|
|
- let currentList = await model.find({'unit_price_file_id':currentUnitPriceId});
|
|
|
|
|
- // 过滤mongoose格式
|
|
|
|
|
- currentList = JSON.stringify(currentList);
|
|
|
|
|
- currentList = JSON.parse(currentList);
|
|
|
|
|
|
|
+ let currentList = await model.find({'unit_price_file_id':currentUnitPriceId}).lean();
|
|
|
currentMap = _.groupBy(currentList,"connect_key");
|
|
currentMap = _.groupBy(currentList,"connect_key");
|
|
|
|
|
|
|
|
//切换后的单价文件所有的的组成物
|
|
//切换后的单价文件所有的的组成物
|
|
@@ -502,11 +498,24 @@ class UnitPriceModel extends BaseModel {
|
|
|
if(targetMap[ckey]){//如果切换后已经存在,则不用复制
|
|
if(targetMap[ckey]){//如果切换后已经存在,则不用复制
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if(gljMap[ckey] && gljMap[ckey].copy == true){//在本项目中有用到并且复制标记为true
|
|
|
|
|
|
|
+ if(gljMap[ckey]){//在本项目中有用到并且复制标记为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();
|
|
|
c.unit_price_file_id = changeUnitPriceId;
|
|
c.unit_price_file_id = changeUnitPriceId;
|
|
|
|
|
+ //更改下挂的定额工料机与项目工料机的关联关系
|
|
|
|
|
+ if(c.ration_gljs){
|
|
|
|
|
+ for(let rg of c.ration_gljs){
|
|
|
|
|
+ rg.ID = uuidV1();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if(c.rations){
|
|
|
|
|
+ for(let r of c.rations){
|
|
|
|
|
+ r.ID = uuidV1();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
insertData.push(c);
|
|
insertData.push(c);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|