|
@@ -91,7 +91,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
let unitPrice=null;
|
|
|
if(operation=='add'){//新增操作时,要把code也一起判断,是否完全一样
|
|
|
unitPrice = this.isPropertyInclude(unitPriceData,['code','name','specs','unit','type'],data);
|
|
|
- }else {//修改操作时,code不用加入判读,因为code是需要改变的
|
|
|
+ }else {//修改操作时,code不用加入判断,因为code是需要改变的
|
|
|
unitPrice = this.isPropertyInclude(unitPriceData,['name','specs','unit','type'],data);
|
|
|
}
|
|
|
if(unitPrice){
|
|
@@ -328,21 +328,27 @@ class UnitPriceModel extends BaseModel {
|
|
|
currentUnitList = JSON.parse(currentUnitList);
|
|
|
|
|
|
let codeList = [];
|
|
|
+ let nameList =[];
|
|
|
for (let tmp of currentUnitList) {
|
|
|
if (codeList.indexOf(tmp.code) >= 0) {
|
|
|
continue;
|
|
|
}
|
|
|
codeList.push(tmp.code);
|
|
|
+ if(nameList.indexOf(tmp.name)>=0){
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ nameList.push(tmp.name);
|
|
|
}
|
|
|
|
|
|
- // 查找即将更替的单价文件是否存在对应的工料机数据
|
|
|
- let condition = {unit_price_file_id: changeUnitPriceId, code: {"$in": codeList}};
|
|
|
- let targetUnitList = await this.findDataByCondition(condition, null, false, 'code');
|
|
|
+ // 查找即将更替的单价文件是否存在对应的工料机数据 -- (这里只根据code和名称初步过滤,因为其它的几项更改的概率不大,在下一步的比较中再精确匹配)
|
|
|
+ let condition = {unit_price_file_id: changeUnitPriceId, code: {"$in": codeList},name:{"$in": nameList}};
|
|
|
+ let targetUnitList = await this.findDataByCondition(condition, null, false, ['code','name','specs','unit','type']);
|
|
|
|
|
|
// 如果没有重叠的数据则原有的数据都复制一份
|
|
|
let insertData = [];
|
|
|
for (let tmp of currentUnitList) {
|
|
|
- if (targetUnitList !== null && targetUnitList[tmp.code] !== undefined) {
|
|
|
+ let t_index = this.getIndex(tmp,['code','name','specs','unit','type']);
|
|
|
+ if (targetUnitList !== null && targetUnitList[t_index] !== undefined) {
|
|
|
continue;
|
|
|
}
|
|
|
// 删除原有id信息
|
|
@@ -351,9 +357,7 @@ class UnitPriceModel extends BaseModel {
|
|
|
tmp.unit_price_file_id = changeUnitPriceId;
|
|
|
insertData.push(tmp);
|
|
|
}
|
|
|
-
|
|
|
- return insertData.length > 0 ? this.add(currentUnitList) : true;
|
|
|
-
|
|
|
+ return insertData.length > 0 ? this.add(insertData) : true;
|
|
|
}
|
|
|
|
|
|
|