소스 검색

修改导出代码,适应重庆导出指标压缩包流程

vian 5 년 전
부모
커밋
db44a17473

+ 2 - 0
modules/pm/controllers/pm_controller.js

@@ -237,6 +237,8 @@ module.exports = {
             }
             //读取建设项目的项目属性
             let constructionProperty = await ProjectsData.getConstructionProperty(projectID);
+            // 文件类型(招/投标)
+            projInfo.property.fileKind = constructionProperty && constructionProperty.fileKind || 1;
             //基本信息
             projInfo.property.basicInformation = constructionProperty && constructionProperty.basicInformation ? constructionProperty.basicInformation : [];
             //编制说明

+ 36 - 1
web/building_saas/main/js/models/exportStdInterfaceBase.js

@@ -934,16 +934,51 @@ const XML_EXPORT_BASE = (() => {
                 fileName: extractObj.fileName
             };
         });
+        if (!saveAsFunc) {
+            return fileData;
+        }
         // 导出
         await saveAsFunc(fileData);
     }
 
+    // 提取xml数据,中间数据(目前为导出指标压缩包用)
+    async function getExtractData() {
+        const fileKind = projectObj.project.projectInfo.property.fileKind;
+        const projectID = projectObj.project.ID();
+        const extractData = await extractExportData(XMLStandard.entry, GRANULARITY.PROJECT, 
+            XMLStandard.summaryObj, fileKind, projectID, userID);
+        // projects表数据
+        const projectData = _.cloneDeep(_cache.projectData);
+        // 错误提示
+        const failList = deWeightHints(_.cloneDeep(_cache.failList));
+        // 清空缓存
+        clear();
+        reset
+        return {
+            extractData,
+            projectData,
+            failList
+        }
+    }
+
+    /**
+     * 提取qtf文件数据(目前为导出指标压缩包用)
+     * @param {Array} codes - 设置工程编号窗口获取到的编号数据 
+     * @param {Array} extractData - 提取的导出中间数据
+     * @return {Array} 
+     */
+    async function getExtractFile(codes, extractData) {
+        return await exportFile(codes, extractData, XMLStandard.resetContentCode);
+    }
+
     return {
         CONFIG,
         CACHE,
         UTIL,
         Element,
         extractExportData,
-        exportFile
+        exportFile,
+        getExtractData,
+        getExtractFile,
     };
 })();

+ 38 - 35
web/building_saas/main/js/views/export_view.js

@@ -75,6 +75,43 @@ const ExportView = (() => {
             $('#exportCode').modal('show');
         }
     }
+    // 确定导出
+    async function handleExportConfirm() {
+        if (!spread || !_exportCache || !_exportCache.length) {
+            return false;
+        }
+        if (STATE.confirming) {
+            return;
+        }
+        STATE.confirming = true;
+        let pr = new SCComponent.InitProgressBar();
+        try {
+            // 工程编号
+            let codes = getCodeFromSheet(spread.getSheet(0));
+            if (codes.includes('')) {
+                alert('单项、单位工程工程编号不可为空。');
+                STATE.confirming = false;
+                return false;
+            }
+            if ([...new Set(codes)].length !== codes.length) {
+                alert('单项、单位工程工程编号必须唯一。');
+                STATE.confirming = false;
+                return false;
+            }
+            pr.start('导出数据接口', '正在导出文件,请稍候……');
+            // 导出文件
+            await _base.exportFile(codes, _exportCache, XMLStandard.resetContentCode, XMLStandard.saveAsFile);
+        } catch (err) {
+            console.log(err);
+            alert(err);
+        }
+        pr.end();
+        $('#exportCode').modal('hide');
+        $('#export').modal('hide');
+        setTimeout(() => {
+            STATE.confirming = false;
+        }, 300);
+    }
     //事件监听
     function exportListener() {
         //导出接口-项目自检
@@ -189,41 +226,7 @@ const ExportView = (() => {
         });
         //设置完工程编号后,导出数据。如果选中多个文件,导出压缩包
         $('#exportCode-confirm').click(async function () {
-            if (!spread || !_exportCache || !_exportCache.length) {
-                return false;
-            }
-            if (STATE.confirming) {
-                return;
-            }
-            STATE.confirming = true;
-            let pr = new SCComponent.InitProgressBar();
-            try {
-                // 工程编号
-                let codes = getCodeFromSheet(spread.getSheet(0));
-                if (codes.includes('')) {
-                    alert('单项、单位工程工程编号不可为空。');
-                    STATE.confirming = false;
-                    return false;
-                }
-                if ([...new Set(codes)].length !== codes.length) {
-                    alert('单项、单位工程工程编号必须唯一。');
-                    STATE.confirming = false;
-                    return false;
-                }
-                pr.start('导出数据接口', '正在导出文件,请稍候……');
-                // 导出文件
-                await _base.exportFile(codes, _exportCache, XMLStandard.resetContentCode, XMLStandard.saveAsFile);
-            } catch (err) {
-                console.log(err);
-                alert(err);
-            }
-            pr.end();
-            $('#exportCode').modal('hide');
-            $('#export').modal('hide');
-            setTimeout(() => {
-                STATE.confirming = false;
-            }, 300);
-
+            await handleExportConfirm();
         });
         //导出窗口--------
         $('#export').on('hide.bs.modal', function() {