Selaa lähdekoodia

导出接口增加基本信息、工程特征必填项自检

vian 5 vuotta sitten
vanhempi
commit
6ef2f937f3

+ 1 - 1
public/common_util.js

@@ -46,7 +46,7 @@ function deleteEmptyObject(arr) {
         }
         return a == b;
     }
-    // 获取必填项(基本信息、工程特征)
+    // 递归获取必填项(基本信息、工程特征)
     function getRequired(rst, datas) {
         if (!datas) {
             return rst;

+ 42 - 12
web/building_saas/main/js/models/exportStdInterfaceBase.js

@@ -525,7 +525,7 @@ const XML_EXPORT_BASE = (() => {
         let projectData = _cache.projectData;
         // 没有数据,需要拉取
         if (!Object.keys(projectData).length) {
-            projectData = await ajaxPost('/pm/api/getProjectByGranularity', { user_id: userID, tenderID, granularity, summaryObj});
+            projectData = await ajaxPost('/pm/api/getProjectByGranularity', { user_id: userID, tenderID, granularity, summaryObj });
             _cache.projectData = projectData;
         }
         return projectData;
@@ -780,15 +780,44 @@ const XML_EXPORT_BASE = (() => {
      * 有错误的话,将先直接弹窗提示,不会进行其他的自检
      *   */
     function propertyCheck() {
-        const failtList = ['<span style="font-weight: bold>基本信息下:</span>'];
+        const type = {
+            info: '基本信息',
+            feature: '工程特征'
+        };
+        const failList = ['<span style="font-weight: bold">建设项目下:</span>'];
+        let haveHandledProjectData = false;
         const tenderDetailMap = _cache.tenderDetailMap;
+        // 按照获取顺序serialNo(根据树结构)排序
+        Object.values(tenderDetailMap)
+            .sort((a, b) => a.serialNo - b.serialNo)
+            .forEach(tenderDetail => {
+                if (!haveHandledProjectData) {
+                    haveHandledProjectData = true;
+                    const basicInformation = tenderDetail.projectInfo.property.basicInformation || [];
+                    const infoFailList = itemsCheck(basicInformation, type.info);
+                    if (!infoFailList.length) {
+                        failList.splice(0, failList.length);
+                    } else {
+                        failList.push(...infoFailList);
+                    }
+                }
+                failList.push(`<span style="font-weight: bold">单位工程“${tenderDetail.projectInfo.name}”下:</span>`);
+                const projectFeature = tenderDetail.projectInfo.property.projectFeature || [];
+                const featureFailList = itemsCheck(projectFeature, type.feature);
+                if (!featureFailList.length) {
+                    failList.splice(-1, 1);
+                } else {
+                    failList.push(...featureFailList);
+                }
+            });
+        return failList;
 
         // 条目检查
-        function itemsCheck(items) {
+        function itemsCheck(items, type) {
             const requiredData = commonUtil.getRequired([], items);
             return requiredData
                 .filter(item => commonUtil.isEmptyVal(item.value))
-                .map(item => `${item.dispName}不能为空` );
+                .map(item => `${type}-“${item.dispName}不能为空`);
         }
     }
 
@@ -803,12 +832,12 @@ const XML_EXPORT_BASE = (() => {
         // 检查清单综合单价是否大于最高限价,大于则提示
         function checkMaxPrice(tenderDetail) {
             return tenderDetail.mainTree.items
-                    .filter(node => calcTools.unitFeeGTMaxPrice(node, 'common.unitFee'))
-                    .map(node => {
-                        const code = node.data.code || '';
-                        const name = node.data.name || '';
-                        return `第${node.serialNo()}行“${code + name}”,清单综合单价 > 最高限价`;
-                    });
+                .filter(node => calcTools.unitFeeGTMaxPrice(node, 'common.unitFee'))
+                .map(node => {
+                    const code = node.data.code || '';
+                    const name = node.data.name || '';
+                    return `第${node.serialNo()}行“${code + name}”,清单综合单价 > 最高限价`;
+                });
         }
         const infos = [];
         // 按照获取顺序serialNo(根据树结构)排序
@@ -824,7 +853,7 @@ const XML_EXPORT_BASE = (() => {
             });
         return infos;
     }
-    
+
     const UTIL = Object.freeze({
         deWeightHints,
         isDef,
@@ -853,6 +882,7 @@ const XML_EXPORT_BASE = (() => {
         setAttr,
         getParsedData,
         setupCode,
+        propertyCheck,
         softCheck
     });
 
@@ -962,7 +992,7 @@ const XML_EXPORT_BASE = (() => {
     async function getExtractData() {
         const fileKind = projectObj.project.projectInfo.property.fileKind;
         const projectID = projectObj.project.ID();
-        const extractData = await extractExportData(XMLStandard.entry, GRANULARITY.PROJECT, 
+        const extractData = await extractExportData(XMLStandard.entry, GRANULARITY.PROJECT,
             XMLStandard.summaryObj, fileKind, projectID, userID);
         // projects表数据
         const projectData = _.cloneDeep(_cache.projectData);

+ 12 - 0
web/building_saas/main/js/views/export_view.js

@@ -124,6 +124,12 @@ const ExportView = (() => {
                         _exportCache.push(...exportData);
                     }
                 }
+                // 基本信息、工程特征必填项自检,这里的必填项不由xsd文件规定,而是后台根据业务需要配置
+                const requiredFails = _util.propertyCheck();
+                if (requiredFails.length) {
+                    setHeightByInfo(requiredFails);
+                    throw requiredFails.join('<br/>');
+                }
                 failList = _util.deWeightHints(failList);
                 if (failList.length) {
                     //设置提示弹窗
@@ -172,6 +178,12 @@ const ExportView = (() => {
                     }
                     pr.end();
                 }
+                // 基本信息、工程特征必填项自检,这里的必填项不由xsd文件规定,而是后台根据业务需要配置
+                const requiredFails = _util.propertyCheck();
+                if (requiredFails.length) {
+                    setHeightByInfo(requiredFails);
+                    throw requiredFails.join('<br/>');
+                }
                 failList = _util.deWeightHints(failList);
                 if (failList.length) {
                     //错误-设置提示弹窗