|
|
@@ -113,20 +113,20 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
return feesA;
|
|
|
}
|
|
|
|
|
|
- // 将A对象的一部分属性赋值到B对象上
|
|
|
+ // 将A对象的属性赋值到B对象上
|
|
|
function assignAttr(target, source, attrs) {
|
|
|
if (!source || !target) {
|
|
|
return;
|
|
|
}
|
|
|
const sourceAttrs = attrs || Object.keys(source);
|
|
|
for (const attr of sourceAttrs) {
|
|
|
- const attrName = attr.name;
|
|
|
- if (attr.soft && source[attrName] === undefined) {
|
|
|
+ // 如果值是undefined,则不进行赋值覆盖处理
|
|
|
+ if (attr === 'children' || source[attr] === undefined) {
|
|
|
continue;
|
|
|
}
|
|
|
- target[attrName] = attrName === 'fees'
|
|
|
- ? mergeFees(target[attrName], source[attrName]) // 如果是价格,不能简单地覆盖,要合并两个对象的价格
|
|
|
- : source[attrName];
|
|
|
+ target[attr] = attr === 'fees'
|
|
|
+ ? mergeFees(target[attr], source[attr]) // 如果是价格,不能简单地覆盖,要合并两个对象的价格
|
|
|
+ : source[attr];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -228,18 +228,6 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
* @return {void}
|
|
|
*/
|
|
|
function mergeBills(source, target, parent) {
|
|
|
- // 要赋值的字段
|
|
|
- const attrs = [
|
|
|
- { name: 'code' },
|
|
|
- { name: 'name' },
|
|
|
- { name: 'rowCode' },
|
|
|
- { name: 'unit' },
|
|
|
- { name: 'quantity' },
|
|
|
- { name: 'calcBase' },
|
|
|
- { name: 'specialProvisional' },
|
|
|
- { name: 'unitPriceAnalysis', soft: true }, // 不强制赋值:当源数据该字段的值为undefined的时候,不进行赋值
|
|
|
- { name: 'remark' },
|
|
|
- ];
|
|
|
source.forEach(bills => {
|
|
|
const simpleName = bills.name ? bills.name.replace(/\s/g, '') : '';
|
|
|
let matched;
|
|
|
@@ -270,7 +258,7 @@ const INTERFACE_EXPORT_BASE = (() => {
|
|
|
}
|
|
|
}
|
|
|
if (matched) {
|
|
|
- assignAttr(matched, bills, attrs);
|
|
|
+ assignAttr(matched, bills);
|
|
|
if (bills.children && bills.children.length) {
|
|
|
mergeBills(bills.children, matched.children, matched);
|
|
|
}
|