Ver código fonte

导入导出接口分离server程序

vian 5 anos atrás
pai
commit
5e92c41d68

+ 3 - 0
importserver.js

@@ -43,6 +43,9 @@ app.use(bodyParser.json({limit: '100mb'}));
 fileUtils.getGlobbedFiles('./modules/import/routes/*.js').forEach(function(modelPath) {
     require(path.resolve(modelPath))(app);
 });
+//config.setupCache();
+let cfgCacheUtil = require("./config/cacheCfg");
+cfgCacheUtil.setupDftCache();
 
 //app.use(express.static(_rootDir+"/web"));
 //app.use(express.static(_rootDir+"/lib"));

+ 23 - 0
modules/import/controllers/import_controller.js

@@ -6,6 +6,8 @@
  */
 let logger = require("../../../logs/log_helper").logger;
 let pm_facade = require('../../pm/facade/pm_facade');
+const Project = require('../../main/models/project');
+const project_facade = require('../../main/facade/project_facade.js');
 let controller = {
     importProject:async function (req){
         let data = req.body;
@@ -26,6 +28,27 @@ let controller = {
         let data = JSON.parse(req.body.dataString);
         result.data = await pm_facade.copyProject(req.body.userID,req.body.compilationID,data);
         return result
+    },
+    async importInterface (req) {
+        const result = {
+            error: 0
+        };
+        result.data = await pm_facade.importInterface(req.body.key, req.body.session.sessionUser.id, req.body.session.sessionCompilation._id);
+        return result;
+    },
+    async getDataForInterface (req) {
+        const result = {
+            error: 0
+        };
+        result.data = await Project.getDataSync(req.body.project_id);
+        return result;
+    },
+    async loadSEIProjectData (req) {
+        const result = {
+            error: 0
+        };
+        result.data = await project_facade.loadSEIProjectData(req.body.projectID);
+        return result;
     }
 };
 

+ 3 - 0
modules/import/routes/import_route.js

@@ -9,6 +9,9 @@ module.exports = function (app) {
     importRouter.post('/importProject',importController.action);
     importRouter.post('/exportProject',importController.action);
     importRouter.post('/copyProject',importController.action);
+    importRouter.post('/importInterface',importController.action);
+    importRouter.post('/getDataForInterface',importController.action);
+    importRouter.post('/loadSEIProjectData',importController.action);
     importRouter.get('/test',function (req,res) {
         res.json("hello word");
     })

+ 21 - 8
modules/main/controllers/project_controller.js

@@ -4,6 +4,7 @@
 var Project = require('../models/project');
 let logger = require('../../../logs/log_helper').logger;
 let project_facade = require("../facade/project_facade");
+const redirectToImportServer = require('../../pm/controllers/pm_controller').redirectToImportServer;
 
 //统一回调函数
 var callback = function(req, res, err, message, data){
@@ -47,6 +48,20 @@ module.exports = {
             }
         });
     },
+    getDataForInterface: async function (req, res) {
+        const data = JSON.parse(req.body.data);
+        let result={
+            error:0
+        };
+        try {
+            result = await redirectToImportServer(data,"getDataForInterface",req);
+        } catch (err) {
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+    },
     markUpdateProject:async function (req,res) {
         let result={
             error:0
@@ -179,16 +194,14 @@ module.exports = {
         res.json(result);
     },
     loadSEIProjectData:async function(req,res){
-        let data = JSON.parse(req.body.data);
+        const data = JSON.parse(req.body.data);
         let result={
-            error: 0,
-            data: null
+            error:0
         };
-        try{
-            result.data = await project_facade.loadSEIProjectData(data.projectID);
-        }
-        catch(err){
-            logger.err(err);
+        try {
+            result = await redirectToImportServer(data,"loadSEIProjectData",req);
+        } catch (err) {
+            console.log(err);
             result.error=1;
             result.message = err.message;
         }

+ 29 - 0
modules/main/models/project.js

@@ -131,6 +131,35 @@ Project.prototype.getData = function(projectID, callback){
     });
 };
 
+Project.prototype.getDataSync = function(projectID){
+    return new Promise((resolve, reject) => {
+        const functions = [];
+        const firstTime = +new Date();
+        for (const itemName in moduleMap){
+            functions.push((function(itemName){
+                return function (cb) {
+                    const startTime = +new Date();
+                    moduleMap[itemName].getData(projectID, function(err, moduleName, data){
+                        const endTime = +new Date();
+                        console.log(moduleName+'---------------'+(endTime - startTime));
+                        cb(err, {moduleName: moduleName, data: data})
+                    })
+                }
+            })(itemName))
+        }
+    
+        asyncTool.parallel(functions, function(err, results) {
+            if (!err) {
+                const lastTime = +new Date();
+                console.log('最后加载时间---------------'+(lastTime - firstTime));
+                resolve(results);
+            } else {
+                reject(err);
+            }
+        });
+    });
+};
+
 Project.prototype.getFilterData = function (projectID, filter, callback) {
     let functions = [];
     let getModuleData = function (moduleName) {

+ 1 - 0
modules/main/routes/project_route.js

@@ -9,6 +9,7 @@ module.exports = function (app) {
 
     projectRouter.post('/save', projectController.save);
     projectRouter.post('/getData', projectController.getData);
+    projectRouter.post('/getDataForInterface', projectController.getDataForInterface);
     projectRouter.post('/markUpdateProject', projectController.markUpdateProject);
     projectRouter.post('/removeProjectMark', projectController.removeProjectMark);
     projectRouter.post('/updateNodes', projectController.updateNodes);

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

@@ -820,7 +820,7 @@ module.exports = {
             callback(req, res, 1, err, null);
         }
     },
-    importInterface: async function(req, res) {
+    /* importInterface: async function(req, res) {
         logger.info(`${req.ip} importInterface`);
         const uploadOption = {
             uploadDir: './public'
@@ -851,7 +851,23 @@ module.exports = {
                 callback(req, res, 1, err, null);
             }
         });
-    }
+    } */
+    importInterface: async function (req, res) {
+        const data = JSON.parse(req.body.data);
+        let result={
+            error:0
+        };
+        try {
+            data.session = req.session;
+            result = await redirectToImportServer(data,"importInterface",req);
+        } catch (err) {
+            console.log(err);
+            result.error=1;
+            result.message = err.message;
+        }
+        res.json(result);
+    },
+    redirectToImportServer: redirectToImportServer
 };
 
 async function redirectToImportServer(data,action,req) {

+ 46 - 2
modules/pm/facade/pm_facade.js

@@ -35,7 +35,8 @@ module.exports={
     initOverHeightItems: initOverHeightItems,
     uploadToken:uploadToken,
     downLoadProjectFile:downLoadProjectFile,
-    importProcessChecking:importProcessChecking
+    importProcessChecking:importProcessChecking,
+    importInterface,
 };
 
 
@@ -1345,7 +1346,7 @@ async function getProjectPlaceholder(data) {
 }
 
 /*
-* 项目详细数据都导入完成了,再生成项目数据(项目管理界面数据)
+* 接口导入 项目详细数据都导入完成了,再生成项目数据(项目管理界面数据)
 * */
 async function importProject(importObj, userID, compilationID) {
     let toInsertProjects = [importObj];  //待新增项目数据
@@ -1814,6 +1815,49 @@ async function importProcessChecking(data){
 
 }
 
+// 从cdn服务器下载文件,key就是文件名
+async function downloadFileSync(key) {
+    const filePath = path.join(__dirname, '../../../tmp/', key);
+    const bucketManager2 = new qiniu.rs.BucketManager(mac, null);
+    const publicBucketDomain = qiniu_config.Domain; // "http://serverupdate.smartcost.com.cn";//这里不支持https
+    const deadline = parseInt(Date.now() / 1000) + 3600; // 1小时过期
+    const privateDownloadUrl = bucketManager2.privateDownloadUrl(publicBucketDomain, key, deadline);
+    const stream = fs.createWriteStream(filePath);
+    return new Promise((resolve, reject) => {
+        request(privateDownloadUrl)
+            .pipe(stream)
+            .on('close', () => {
+                // 读取文件返回字符串
+                const srcData = fs.readFileSync(stream.path,'utf-8');
+                resolve({
+                    path: stream.path,
+                    srcData: srcData
+                });
+            })
+            .on('error', reject);
+    });
+}
+
+// 导入接口
+async function importInterface(key, userID, compilationID) {
+    // 源文件内容文本
+    let downloadFilePath = '';
+    try {
+        const { path, srcData } = await downloadFileSync(key);
+        downloadFilePath = path;
+        if (!srcData) {
+            throw '无有效数据';
+        }
+        const importData = JSON.parse(srcData);
+        const projectData = await importProject(importData, userID, compilationID);
+        return projectData;
+    } catch (err) {
+        throw err;
+    } finally {
+        fs.unlinkSync(downloadFilePath);
+    }
+}
+
 async function importProjects(data,req,updateData) {
     let result = {error:0};
     let stringArr = data.split("|----|");

+ 4 - 3
public/web/common_ajax.js

@@ -173,11 +173,12 @@ async function ajaxPost(url, data, isPlainData = false) {
             cache: false,
             timeout: 200000,
             success: function(result){
-                if (!result.error || !result.err) {
+                if (!result.error ||  commonUtil.isDef(result.err) && !result.err) {
                     resolve(result.data);
                 } else {
-                    alert('error: ' + result.message);
-                    reject(result.message);
+                    const message = result.message || result.msg;
+                    alert('error: ' + message);
+                    reject(message);
                 }
             },
             error: function(jqXHR, textStatus, errorThrown){

+ 63 - 0
public/web/upload_cdn.js

@@ -0,0 +1,63 @@
+/*
+ * @Descripttion: 上传文件到cdn服务器
+ * @Author: Zhong
+ * @Date: 2019-12-31 15:38:44
+ */
+
+const UPLOAD_CDN = (() => {
+    
+    const config = {
+        useCdnDomain: true,
+        disableStatisticsReport: false,
+        retryCount: 6,
+        region: qiniu.region.z2
+    };
+
+    // 上传
+    function upload(file, key, token, callback, errCallback) {
+        const putExtra = {
+            fname: "",
+            params: {"x:name":key.split(".")[0]},
+            mimeType: null
+        };
+        const observable = qiniu.upload(file, key, token, putExtra, config);
+        observable.subscribe({
+            error:function (err) {
+                console.log(err);
+                if (errCallback) {
+                    errCallback(err);
+                }
+            },
+            complete:function(res){
+                if (callback) {
+                    callback(res);
+                }
+            }
+        })
+    }
+
+    // 同步上传
+    function uploadSync(file, key, token) {
+        return new Promise((resolve, reject) => {
+            const putExtra = {
+                fname: "",
+                params: {"x:name":key.split(".")[0]},
+                mimeType: null
+            };
+            const observable = qiniu.upload(file, key, token, putExtra, config);
+            observable.subscribe({
+                error:function (err) {
+                    reject(err);
+                },
+                complete:function(res){
+                    resolve(res);
+                }
+            })
+        });
+    }
+
+    return {
+        upload,
+        uploadSync,
+    };
+})();

+ 5 - 4
web/building_saas/main/js/models/calc_program.js

@@ -1503,9 +1503,10 @@ class CalcProgram {
         return ModuleNames.calc_program;
     };
     // 兼容Project框架方法
-    loadData (datas) {
+    // isInit:是否初始化,进入单位工程为true,导出接口为false,不需要存储费率临时数据
+    loadData (datas, isInit) {
         this.datas = datas;
-        this.compileAllTemps();
+        this.compileAllTemps(isInit);
     };
     // 兼容Project框架方法
     doAfterUpdate (err, data) {
@@ -1515,7 +1516,7 @@ class CalcProgram {
     };
 
     // 经测试,全部编译一次耗时0.003~0.004秒。耗时基本忽略不计。
-    compileAllTemps(){
+    compileAllTemps(isInit = false){
         let me = this;
         me.compiledFeeRates = {};
         me.compiledLabourCoes = {};
@@ -1543,7 +1544,7 @@ class CalcProgram {
 
 
         // 存储费率临时数据,报表用。
-        if (me.saveForReports.length > 0){
+        if (isInit && me.saveForReports.length > 0){
             let saveDatas = {};
             saveDatas.projectID = projectObj.project.projectInfo.ID;
             saveDatas.calcItems = me.saveForReports;

+ 9 - 8
web/building_saas/main/js/models/project.js

@@ -30,7 +30,8 @@ var PROJECT = {
             });
 
         };
-        tools.doAfterLoad = function(result, showProjectInfo, callback){
+        // isInit: 是否是初始化,导出接口用到getData,但是非初始化,多次调用getData不会覆盖原有缓存数据
+        tools.doAfterLoad = function(result, isInit, callback){
             var counter;
             //必须要先load ProjectInfo的信息
             let projectInfoModule = result.find(data => data.moduleName === ModuleNames.projectInfo);
@@ -41,7 +42,7 @@ var PROJECT = {
             result.forEach(function(item){
                 if (item.moduleName !== ModuleNames.projectInfo) {
                     if (me.modules[item.moduleName]){
-                        me.modules[item.moduleName].loadData(item.data);
+                        me.modules[item.moduleName].loadData(item.data, isInit);
                     } else if (item.moduleName === me.projCounter) {
                         counter = item.data;
                     } else if (item.moduleName === me.projSetting) {
@@ -57,7 +58,7 @@ var PROJECT = {
                     me.modules[module].setMaxID(counter[module]);
                 }
             }
-            if (showProjectInfo) {
+            if (isInit) {
                 projectInfoObj.showProjectInfo(me._project.projectInfo);
             }
             me._project.loadMainTree();
@@ -242,8 +243,8 @@ var PROJECT = {
                 timeout: 50000,
                 success: function (result) {
                     if (!result.error) {
-                        let showProjectInfo = true;
-                        tools.doAfterLoad(result.data, showProjectInfo, callback);
+                        const isInit = true;
+                        tools.doAfterLoad(result.data, isInit, callback);
                         // for test calc
                         //tools.doAfterLoad([{moduleName: 'bills', data: BillsData}, {'moduleName': 'ration', data: DrawingData}], callback);
                     } else {
@@ -257,10 +258,10 @@ var PROJECT = {
             });
         };
         project.prototype.loadDataSync = async function () {
-            let data = await ajaxPost('/project/getData', {user_id: tools._userID, project_id: tools._ID});
+            const data = await ajaxPost('/project/getDataForInterface', {user_id: tools._userID, project_id: tools._ID});
             if (data) {
-                let showProjectInfo = false;
-                tools.doAfterLoad(data, showProjectInfo);
+                const isInit = false;
+                tools.doAfterLoad(data, isInit);
             }
         };
 

+ 1 - 0
web/building_saas/pm/html/project-management.html

@@ -950,6 +950,7 @@
 <script src="/web/building_saas/js/global.js"></script>
 <script src="/public/web/uuid.js"></script>
 <script src="/public/web/date_util.js"></script>
+<script src="/public/web/upload_cdn.js"></script>
 <script src="/web/building_saas/pm/js/pm_tree.js"></script>
 <script src="/public/web/id_tree.js"></script>
 <script src="/public/web/tree_sheet/tree_sheet_helper.js"></script>

+ 38 - 51
web/building_saas/pm/js/pm_import.js

@@ -13,11 +13,11 @@ const importView = (() => {
     let xmlObj = null;  //导入xml转化后的对象
     let tbcObj = null;  //待确认对象
     //显示、隐藏提示上传文件窗口相关提示信息
-    function showUploadAlert(success, msg){
-        if(!success){
+    function showUploadAlert(success, msg) {
+        if (!success) {
             $('#uploadAlert').removeClass('alert-success');
             $('#uploadAlert').addClass('alert-danger');
-        } else{
+        } else {
             $('#uploadAlert').removeClass('alert-danger');
             $('#uploadAlert').addClass('alert-success');
         }
@@ -122,7 +122,7 @@ const importView = (() => {
             $('#tbc-tenderName').val(curData.name || '');
             $('#tbc-engineering').val(curData.engineering || '');
             curData.temp.confirmed = true;   //增加确认信息(已读)
-            if (this.curIdx === this.datas.length -1) { //到最后一个数据了,无法点击下一工程
+            if (this.curIdx === this.datas.length - 1) { //到最后一个数据了,无法点击下一工程
                 $('#tbc-next').prop('disabled', true);
             } else {
                 $('#tbc-next').prop('disabled', false);
@@ -150,7 +150,7 @@ const importView = (() => {
             } else {
                 $('#tbc-prev').prop('disabled', false);
             }
-            if (this.curIdx !== this.datas.length -1 ) {    //不为最后一个数据了,可以点击下一工程
+            if (this.curIdx !== this.datas.length - 1) {    //不为最后一个数据了,可以点击下一工程
                 $('#tbc-next').prop('disabled', false);
             } else {
                 $('#tbc-next').prop('disabled', true);
@@ -190,8 +190,8 @@ const importView = (() => {
             //工程专业名称去重
             let engineeringNames = [...new Set(this.engineeringList.map(data => data.lib.name))];
             let engineeringHtml = engineeringNames.map(name =>
-             `<option ${tenderData.temp.engineering === name ? 'selected' : ''} value="${name}">${name}</option>`);
-             $('#tbc-engineering').html(engineeringHtml);
+                `<option ${tenderData.temp.engineering === name ? 'selected' : ''} value="${name}">${name}</option>`);
+            $('#tbc-engineering').html(engineeringHtml);
             //$('#tbc-engineering').html(`<option selected value="${tenderData.engineering}">${tenderData.engineering}</option>`);
             //费用标准,若当前工程有费用标准数据(该数据本身没有费用标准数据,选择过了,就会记录),则选中该费用标准
             let feeOptsHtml = engineerings.map(data =>
@@ -218,12 +218,12 @@ const importView = (() => {
     function getTaxData(query, engineeringList) {
         //工程专业名称 + 费用标准名称 确定一个工程专业数据
         let engineering = engineeringList.find(data => query.engineeringName === data.lib.name &&
-                                                       query.feeStandard === data.lib.feeName);
+            query.feeStandard === data.lib.feeName);
         if (!engineering || !Array.isArray(engineering.lib.tax_group)) {
             return null;
         }
         return engineering.lib.tax_group.find(data => query.taxType == data.taxType &&
-                                                          query.calcProgram === data.program_lib.name);
+            query.calcProgram === data.program_lib.name);
     }
     //获取单位工程项目属性的一些数据(新建单位工程需要,前端能获取到的一些数据,还有一些数据需要后端获取: rootProjectID, projectFeature..)
     /*
@@ -247,7 +247,7 @@ const importView = (() => {
         }
         //当前工程专业数据
         let curEngineering = tbcObj.engineeringList.find(data => query.engineeringName === data.lib.name &&
-        query.feeStandard === data.lib.feeName);
+            query.feeStandard === data.lib.feeName);
         return {
             region: '全省',   //地区
             valuationType: tbcObj.valuationType,    //计价方式
@@ -264,19 +264,19 @@ const importView = (() => {
             indexName: curEngineering.lib.indexName,    // 指标名称
             engineerInfoLibID: curEngineering.lib.engineer_info_lib[0] ? curEngineering.lib.engineer_info_lib[0].id : '',   // 工程信息指标
             engineerFeatureLibID: curEngineering.lib.engineer_feature_lib[0] ? curEngineering.lib.engineer_feature_lib[0].id : '',  //工程特征指标
-            economicLibID: curEngineering.lib.economic_lib[0] ?  curEngineering.lib.economic_lib[0].id : '',    // 主要经济指标
+            economicLibID: curEngineering.lib.economic_lib[0] ? curEngineering.lib.economic_lib[0].id : '',    // 主要经济指标
             mainQuantityLibID: curEngineering.lib.main_quantity_lib[0] ? curEngineering.lib.main_quantity_lib[0].id : '',   // 主要工程量指标
             materialLibID: curEngineering.lib.material_lib[0] ? curEngineering.lib.material_lib[0].id : '', // 主要工料指标
-            calcProgram: {name: taxData.program_lib.name, id: taxData.program_lib.id},  //计算程序
+            calcProgram: { name: taxData.program_lib.name, id: taxData.program_lib.id },  //计算程序
             colLibID: taxData.col_lib.id,   //列设置
             templateLibID: taxData.template_lib.id, //清单模板
-            unitPriceFile: {name: curData.name, id: ''},    //新建单价文件
-            feeFile: {name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}`}  //新建费率文件
+            unitPriceFile: { name: curData.name, id: '' },    //新建单价文件
+            feeFile: { name: curData.name, id: `newFeeRate@@${taxData.fee_lib.id}` }  //新建费率文件
         };
     }
     function eventListen() {
         //选择文件
-        $('#customFile').change(async function() {
+        $('#customFile').change(async function () {
             let file = $(this)[0].files[0];
             $('#import-confirm').prop('disabled', true);    //确认导入无效
             $('.custom-file-label').text(`${file ? file.name : ''}`);   //设置选择框文本
@@ -285,7 +285,7 @@ const importView = (() => {
             hideTBCInfo();
             if (file) {
                 let reg = /(xml|XML|qtf|QTF)$/;
-                if(file.name && !reg.test(file.name)){
+                if (file.name && !reg.test(file.name)) {
                     $('.selFile').hide();
                     showUploadAlert(false, '请选择xml或qtf文件。');
                     return;
@@ -425,7 +425,7 @@ const importView = (() => {
                     data.property = getProperty(tbcObj, data);
                     //默认定额库
                     let curEngineering = tbcObj.engineeringList.find(enData => data.temp.engineering === enData.lib.name &&
-                    data.temp.feeStandard === enData.lib.feeName);
+                        data.temp.feeStandard === enData.lib.feeName);
                     let defaultLib = curEngineering.lib.ration_lib.find(data => data.isDefault) || curEngineering.lib.ration_lib[0];
                     data.defaultRationLib = parseInt(defaultLib.id);
                     //此费用定额下可用的定额库id,人材机库id
@@ -433,7 +433,7 @@ const importView = (() => {
                     data.gljLibIDs = curEngineering.lib.glj_lib.map(data => parseInt(data.id));
                 });
                 //确定生成建设项目的父、前、后节点ID
-                let {parentProjectID, preProjectID, nextProjectID} = projTreeObj.getRelProjectID(projTreeObj.tree.selected);
+                let { parentProjectID, preProjectID, nextProjectID } = projTreeObj.getRelProjectID(projTreeObj.tree.selected);
                 xmlObj.ParentID = parentProjectID;
                 xmlObj.preID = preProjectID;
                 xmlObj.NextSiblingID = nextProjectID;
@@ -443,44 +443,31 @@ const importView = (() => {
                     xmlObj.name += `(${moment(Date.now()).format('YYYY-MM-DD HH:mm:ss')})`;
                 }
                 $('#importInterface').modal('hide');
-                //TEST======================
-                /*let importData = await importXML.transformData(xmlObj);
-                console.log(importData);*/
-                //TEST======================
                 pr.start('导入文件', '正在生成文件,请稍候……');
                 let importData = await importXML.transformData(xmlObj);
-                let blob = new Blob([JSON.stringify(importData)], {type: 'text/plain;charset=utf-8'});
-                let formData = new FormData();
-                formData.append('file', blob);
-                $.ajax({
-                    url: '/pm/import/importInterface',
-                    type: 'POST',
-                    data: formData,
-                    cache: false,
-                    contentType: false,
-                    processData: false,
-                    timeout: 1000 * 60 * 3, //3分钟
-                    success: function(response){
-                        if (response.data && Array.isArray(response.data)) {
-                            doAfterImport(response.data);
-                        }
-                        pr.end();
-                        setTimeout(function () {
-                            STATE.importing = false;
-                        }, 500);
-                    },
-                    error: function(jqXHR){
-                        pr.end();
-                        throw `与服务器通信发生错误${jqXHR.status} ${jqXHR.statusText}`;
-                    }
-                });
+                let blob = new Blob([JSON.stringify(importData)], { type: 'text/plain;charset=utf-8' });
+                // 转换成File实例
+                const key = `${uuid.v1()}.json`;
+                const file = new File([blob], key);
+                // 上传文件
+                console.time();
+                await projTreeObj.getUploadToken();
+                await UPLOAD_CDN.uploadSync(file, key, projTreeObj.uptoken);
+                // 下载并处理文件
+                const rstData = await ajaxPost('/pm/import/importInterface', { key });
+                console.timeEnd();
+                if (Array.isArray(rstData)) {
+                    doAfterImport(rstData);
+                }
             } catch (err) {
+                console.log(err);
+                alert(err);
+            } finally {
+                projTreeObj.uptoken = null;
                 setTimeout(function () {
                     STATE.importing = false;
                 }, 500);
                 pr.end();
-                console.log(err);
-                alert(err);
             }
         });
         // 导入窗口激活
@@ -515,9 +502,9 @@ const importView = (() => {
                 next = projTreeObj.tree.items.find(node => node.data.ID === data.NextSiblingID);
             lastNode = projTreeObj.insert(data, parent, next);
         }
-        if(lastNode) {
+        if (lastNode) {
             projTreeObj.workBook.getSheet(0).showRow(lastNode.serialNo(), GC.Spread.Sheets.VerticalPosition.center);
         }
     }
-    return {eventListen};
+    return { eventListen };
 })();

+ 5 - 26
web/building_saas/pm/js/pm_newMain.js

@@ -4690,33 +4690,12 @@ $("#confirm-import").click(function() {
     let file = input.files[0];
     let key = uuid.v1() + ".ybp"; //file.name;
     if (file) {
-        let config = {
-            useCdnDomain: true,
-            disableStatisticsReport: false,
-            retryCount: 6,
-            region: qiniu.region.z2
+        const callback = () => {
+            $("#progress_modal_body").text("正在导入建设项目");
+            startImportProject(key);
+            projTreeObj.uptoken = null;
         };
-        let putExtra = {
-            fname: "",
-            params: {"x:name":key.split(".")[0]},
-            mimeType: null
-        };
-        // 添加上传dom面板
-        let observable = qiniu.upload(file, key, token, putExtra, config);
-        observable.subscribe({
-            next:function (reponse) {
-                console.log(reponse);
-            },
-            error:function (err) {
-                console.log(err);
-            },
-            complete:function(res){
-                console.log("complete")
-                $("#progress_modal_body").text("正在导入建设项目");
-                startImportProject(key);
-                projTreeObj.uptoken = null;
-            }
-        });
+        UPLOAD_CDN.upload(file, key, token, callback);
     }
 
     async function  startImportProject(key) {