|
|
@@ -165,9 +165,10 @@ class UnitPriceModel extends BaseModel {
|
|
|
let counterModel = new CounterModel();
|
|
|
if (data instanceof Array) {
|
|
|
// 如果是批量新增
|
|
|
- for(let tmp in data) {
|
|
|
+ await this.setIDfromCounter(collectionName,data);
|
|
|
+ /* for(let tmp in data) {
|
|
|
data[tmp].id = await counterModel.getId(collectionName);
|
|
|
- }
|
|
|
+ } */
|
|
|
} else {
|
|
|
data.id = await counterModel.getId(collectionName);
|
|
|
}
|
|
|
@@ -432,7 +433,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- let gljList = await gljListModel.find({'project_id':projectId});
|
|
|
+ let gljList = await gljListModel.find({'project_id':projectId}).lean();
|
|
|
let gljMap = {};//用来记录glj的映射表,本项目有使用的工料机才需要copy过去
|
|
|
for(let g of gljList){
|
|
|
let g_index = this.getIndex(g,['code','name','specs','unit','type']);
|
|
|
@@ -460,6 +461,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
let insertData = [];
|
|
|
for (let tmp of currentUnitList) {
|
|
|
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) {
|
|
|
continue;
|
|
|
}
|
|
|
@@ -468,7 +470,6 @@ class UnitPriceModel extends BaseModel {
|
|
|
delete tmp.id;
|
|
|
tmp.unit_price_file_id = changeUnitPriceId;
|
|
|
insertData.push(tmp);
|
|
|
- gljMap[t_index].copy = true;//复制标记,用于组成物,材料计算等的复制
|
|
|
}
|
|
|
}
|
|
|
let uResult = insertData.length > 0 ? this.add(insertData) : true;
|