Selaa lähdekoodia

fix:导入接口,清单匹配赋值时,如果源数据字段值为undefined,则不再进行赋值覆盖了

vian 5 vuotta sitten
vanhempi
commit
c20c1e16be

+ 1 - 2
web/building_saas/standard_interface/import/anhui_maanshan.js

@@ -66,7 +66,7 @@ INTERFACE_IMPORT = (() => {
       const feeRateItems = arrayValue(tenderSrc, ['Qfxx', 'JjFlx', 'JjFlxMx']);
       const locationItem = feeRateItems.find(item => getValue(item, ['_Mc']) === '工程所在地');
       if (locationItem) {
-        feature.push(locationItem);
+        feature.push({ key: 'location', value: getValue(locationItem, ['_ShuZhi']) });
       }
       return feature;
     }
@@ -210,7 +210,6 @@ INTERFACE_IMPORT = (() => {
           arrayValue(midSrc, ['Dwgcxx'])
             .forEach(tenderSrc => tenders.push(setupTender(midSrc, tenderSrc)))
         });
-
       return {
         name: getValue(projectSrc, ['_Xmmc']),
         info: setupInformation(projectSrc),

+ 7 - 19
web/building_saas/standard_interface/import/base.js

@@ -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);
         }