|
@@ -91,14 +91,8 @@ class GLJListModel extends BaseModel {
|
|
|
|
|
|
// 整理获取工料机ID list
|
|
|
let gljIdList = [];
|
|
|
- // 整理获取有组成物的项目工料机编码
|
|
|
- let projectGLJCode = [];
|
|
|
for(let tmp of gljData) {
|
|
|
gljIdList.push(tmp.id);
|
|
|
- // 有组成物的类型才入数组
|
|
|
- if (this.ownCompositionTypes.indexOf(tmp.type)) {
|
|
|
- projectGLJCode.push(tmp.code);
|
|
|
- }
|
|
|
}
|
|
|
// 从定额工料机库中获取消耗量
|
|
|
condition = {
|
|
@@ -116,9 +110,15 @@ class GLJListModel extends BaseModel {
|
|
|
} else {
|
|
|
quantityList[tmp.projectGLJID] += tmp.quantity * tmpNum;
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
+ // 整理获取有组成物的项目工料机编码
|
|
|
+ let projectGLJCode = [];
|
|
|
+ for(let tmp of gljData) {
|
|
|
+ // 有组成物的类型且消耗量大于0才查找
|
|
|
+ if (quantityList[tmp.id] !== undefined) {
|
|
|
+ projectGLJCode.push(tmp.code);
|
|
|
+ }
|
|
|
+ }
|
|
|
// 查找组成物的消耗量
|
|
|
let totalComposition = {};
|
|
|
let mixRatioData = {};
|
|
@@ -145,8 +145,7 @@ class GLJListModel extends BaseModel {
|
|
|
}
|
|
|
}
|
|
|
// 组合单价数据
|
|
|
- this.combineData(gljData, unitPriceList, quantityList, mixRatioData, totalComposition);
|
|
|
-
|
|
|
+ gljData = this.combineData(gljData, unitPriceList, quantityList, mixRatioData, totalComposition);
|
|
|
// 排序
|
|
|
gljData.sort(function (a, b) {
|
|
|
a.unit_price = a.unit_price === null ? 0 : a.unit_price;
|
|
@@ -170,7 +169,7 @@ class GLJListModel extends BaseModel {
|
|
|
* @param {object} quantityList
|
|
|
* @param {object} mixRatioData 组合物明细数据
|
|
|
* @param {object} totalComposition 组合物父工料机统计数据
|
|
|
- * @return {void}
|
|
|
+ * @return {Array}
|
|
|
*/
|
|
|
combineData(gljList, unitPriceList, quantityList = {}, mixRatioData = {}, totalComposition = {}) {
|
|
|
// 整理组成物消耗量(只有在总列表显示的时候才需用到,获取单项项目工料机内容则忽略)
|
|
@@ -184,8 +183,10 @@ class GLJListModel extends BaseModel {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+ let result = [];
|
|
|
// 循环组合数据
|
|
|
- for(let glj of gljList) {
|
|
|
+ for(let index in gljList) {
|
|
|
+ let glj = gljList[index];
|
|
|
if (glj.code === undefined) {
|
|
|
continue;
|
|
|
}
|
|
@@ -196,13 +197,20 @@ class GLJListModel extends BaseModel {
|
|
|
}
|
|
|
|
|
|
let gljId = glj.glj_id + '';
|
|
|
+ let projectGljId = glj.id + '';
|
|
|
+
|
|
|
// 消耗量赋值
|
|
|
- glj.quantity = quantityList[glj.id] !== undefined ? quantityList[glj.id] : 0;
|
|
|
+ glj.quantity = quantityList[projectGljId] !== undefined ? quantityList[projectGljId] : 0;
|
|
|
glj.quantity = totalComposition[glj.code] !== undefined ? totalComposition[glj.code] : glj.quantity;
|
|
|
glj.quantity = compositionConsumption[gljId] !== undefined ? glj.quantity + compositionConsumption[gljId] : glj.quantity;
|
|
|
|
|
|
+ // 消耗值为0的数据不显示
|
|
|
+ if (glj.quantity === 0) {
|
|
|
+ delete gljList[index];
|
|
|
+ continue;
|
|
|
+ }
|
|
|
// 组成物数据
|
|
|
- glj.ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
|
|
|
+ gljList[index].ratio_data = mixRatioData[gljId] !== undefined ? mixRatioData[gljId] : [];
|
|
|
|
|
|
// 计算调整基价
|
|
|
switch (glj.unit_price.type + '') {
|
|
@@ -218,8 +226,9 @@ class GLJListModel extends BaseModel {
|
|
|
default:
|
|
|
glj.adjust_price = glj.unit_price.base_price;
|
|
|
}
|
|
|
-
|
|
|
+ result.push(glj);
|
|
|
}
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -540,7 +549,7 @@ class GLJListModel extends BaseModel {
|
|
|
unitPriceData[tmp.code + tmp.name] = tmp;
|
|
|
}
|
|
|
|
|
|
- this.combineData(gljData, unitPriceData, [], mixRatioData);
|
|
|
+ gljData = this.combineData(gljData, unitPriceData, [], mixRatioData);
|
|
|
|
|
|
// 排序
|
|
|
gljData.sort(function (a, b) {
|