Bläddra i källkod

导入、复制项目增加检测机制

vian 5 år sedan
förälder
incheckning
630bd3b68e

+ 6 - 2
modules/all_models/import_logs.js

@@ -9,9 +9,13 @@ let collectionName = 'import_logs';
 let modelSchema = {
     // 日志类型
     key: {type: String, index: true},
-    // 日志内容
-    userID: String,
+    // 日志简单内容
+    content: String,
     // 关联用户id
+    userID: String,
+    // 费用定额Id
+    compilationID: String,
+    // 状态
     status:String,
     // 建设项目ID
     projectID: Number,

+ 5 - 1
modules/import/controllers/import_controller.js

@@ -11,6 +11,10 @@ let controller = {
         let data = req.body;
         return await pm_facade.downLoadProjectFile(data);
     },
+    prepareInitialData: async function(req) {
+        const data = req.body;
+        return await pm_facade.prepareInitialData(data.userID, data.compilationID, data.example);
+    },
     exportProject:async function(req){
         let result={
             error:0
@@ -24,7 +28,7 @@ let controller = {
             error:0
         };
         let data = JSON.parse(req.body.dataString);
-        result.data = await pm_facade.copyProject(req.body.userID,req.body.compilationID,data);
+        result.data = await pm_facade.accessToCopyProject(req.body.userID,req.body.compilationID,data);
         return result
     }
 };

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

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

+ 9 - 3
modules/pm/controllers/pm_controller.js

@@ -330,12 +330,16 @@ module.exports = {
     //第一次进入该费用定额时准备的初始数据
     prepareInitialData: async function(request, response) {
         try {
-            let sessionCompilation = request.session.sessionCompilation;
-            await pm_facade.prepareInitialData(request.session.sessionUser.id, sessionCompilation._id, sessionCompilation.example);
+            const data = {
+                userID: request.session.sessionUser.id,
+                compilationID: request.session.sessionCompilation._id,
+                example: request.session.sessionCompilation.example
+            };
+            await redirectToImportServer(data, 'prepareInitialData', request);
             callback(request, response, 0, 'success', null);
         } catch(err) {
             console.log(err);
-            callback(request, response, 1, err.message, null);
+            callback(request, response, 1, err.toString(), null);
         }
     },
     // 获取单价文件列表
@@ -808,6 +812,8 @@ module.exports = {
         };
         try{
             let data = JSON.parse(req.body.data);
+            data.userID = req.session.sessionUser.id;
+            data.compilationID = req.session.sessionCompilation._id;
             result.data = await pm_facade.importProcessChecking(data);
         } catch (err){
             console.log(err);

+ 95 - 26
modules/pm/facade/pm_facade.js

@@ -17,6 +17,7 @@ module.exports={
     getShareInfoMap,
     getRecentShareList,
     moveProject:moveProject,
+    accessToCopyProject,
     copyProject:copyProject,
     copyExample: copyExample,
     setupSummaryFields: setupSummaryFields,
@@ -279,6 +280,7 @@ async function copyExample(userID, compilation, projIDs){
     //设置新的树结构数据
     let newDate = new Date(),
         parentBulks = [];
+    const projectMaps = [];
     for (let data of allProjs) {
         let orgID = data.ID;
         data.ID = IDMapping[data.ID];
@@ -302,7 +304,8 @@ async function copyExample(userID, compilation, projIDs){
                                 compilation: compilation, fileVer: data.fileVer, projType: data.projType, property: {rootProjectID: rootProjectID}}
                 }
             };
-            await copyProject(userID, compilation, {projectMap}, data.ID);
+            await copyProject(userID, compilation, {projectMap}, data.ID, true);
+            projectMaps.push(projectMap);
         }
     }
     //最末顶层项目(兼容测试时已存在有项目,正常用户第一次进费用定额,该费用定额不存在项目)
@@ -310,12 +313,40 @@ async function copyExample(userID, compilation, projIDs){
     if (lastProj) {
         parentBulks.push({updateOne: {filter: {ID: lastProj.ID}, update: {$set: {NextSiblingID: parentExample[0].ID}}}});
     }
-    //拷贝父级文件
-    await projectModel.bulkWrite(parentBulks);
+    // 处理项目数据
+    const projectTasks = [projectModel.bulkWrite(parentBulks), createProject(projectMaps)];
+    await Promise.all(projectTasks);
     return true;
 }
 
-async function copyProject(userID, compilationID,data,newProjectID = null) {
+async function accessToCopyProject(userID, compilationID, data, newProjectID) {
+    const logData = {
+        key: uuidV1(),
+        content: '正在拷贝项目,请稍候……',
+        userID,
+        compilationID,
+        status: 'start',
+        create_time: +new Date()
+    };
+    await importLogsModel.create(logData);
+    handleCopyProject(logData.key, userID, compilationID,data,newProjectID);
+    return 'copying project';
+}
+
+async function handleCopyProject(key, userID, compilationID, data, newProjectID) {
+    const doc = { status: 'finish' };
+    try {
+        const projectMap = await copyProject(userID, compilationID, data, newProjectID);
+        doc.projectID = projectMap.copy.document.ID;
+    } catch (err) {
+        doc.status = 'error';
+        doc.errorMsg = String(err);
+    } finally {
+        await importLogsModel.update({ key }, doc);
+    }
+}
+
+async function copyProject(userID, compilationID, data, newProjectID = null, delayProjectTask = false) {
     let projectMap = data.projectMap;
     let originalID = projectMap['copy'].document.ID;
     if (!newProjectID) {
@@ -376,7 +407,6 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
     let [billMap,rationMap,projectGLJMap] = await Promise.all(IDtasks);
     //所有复制任务异步处理,提升效率  复制清单,定额,4个文件,项目工料机, 定额工料机,人工系数,工程量明细,定额安装增加费,安装增加费
     let copyTasks = [
-        createProject(projectMap),
         copyProjectSetting(originalID,newProjectID),
         copyBills(newProjectID,billMap),
         copyRations(newProjectID,billMap.uuidMaping,rationMap,projectGLJMap.IDMap),
@@ -400,8 +430,15 @@ async function copyProject(userID, compilationID,data,newProjectID = null) {
     if(originalProperty.unitPriceFile){
         copyTasks.push(copyUnitPriceFile(newProjectID,originalProperty.rootProjectID,userID,originalProperty.unitPriceFile.id,unitPriceFileID,newUnitName));
     }
-    let p = await Promise.all(copyTasks);
-    return p[0];
+    await Promise.all(copyTasks);
+    // 最后再处理项目数据
+    // 可能会有最后再在外层方法插入项目数据的需求,如拷贝例题,暂时先不在这里插入项目数据
+    if (delayProjectTask) {
+        return [projectMap];
+    } else {
+        const projectMaps = await createProject([projectMap]);
+        return projectMaps[0];
+    }
 }
 
 async function createIDsAndReturn(originalID,model) {
@@ -434,14 +471,16 @@ async function getProjectGLJIDAndReturn(originalID,newProjectID) {
     return{IDMap:IDMap,datas:datas};
 }
 
-async function createProject(projectMap) {//复制项目
+async function createProject(projectMaps) {//复制项目
     let tasks = [];
-    if(projectMap['update']){//如果复制后存在前一个节点,则更新其NextSiblingID
-        tasks.push({updateOne:{filter : projectMap['update'].query, update : {NextSiblingID:projectMap['copy'].document.ID}}});
+    for (const projectMap of projectMaps) {
+        if(projectMap['update']){//如果复制后存在前一个节点,则更新其NextSiblingID
+            tasks.push({updateOne:{filter : projectMap['update'].query, update : {NextSiblingID:projectMap['copy'].document.ID}}});
+        }
+        tasks.push({insertOne: {document: projectMap['copy'].document}});//复制任务
     }
-    tasks.push({insertOne: {document: projectMap['copy'].document}});//复制任务
     await projectModel.bulkWrite(tasks);
-    return projectMap;
+    return projectMaps;
 }
 
 async function copyProjectSetting(originalID,newProjectID) {
@@ -1164,19 +1203,44 @@ async function isFirst(userId, compilationId) {
     return isFirst;
 }
 
+function testTimeout(time) {
+    return new Promise(resolve => setTimeout(resolve, time));
+}
+
 //用户第一次进入费用定额的数据准备
 async function prepareInitialData(userId, compilation, example) {
     let first = await isFirst(userId, compilation);
     if (first) {
         await updateUsedList(userId, compilation);
-        let prepareTask = [
-            copyCompleRationSection(userId, compilation),
-            copyCompleGljSection(userId, compilation)
-        ];
-        if (example && example.length > 0) {
-            prepareTask.push(copyExample(userId, compilation, example));
+        const logData = {
+            key: uuidV1(),
+            content: '正在加载例题,请稍候……',
+            userID: userId,
+            compilationID: compilation,
+            status: 'start',
+            create_time: +new Date()
+        };
+        await importLogsModel.create(logData);
+        initData(logData.key, userId, compilation, example);
+        return 'start prepareInitialData';
+    }
+    async function initData(key, userId, compilation, example) {
+        const doc = { status: 'finish' };
+        try {
+            let prepareTask = [
+                copyCompleRationSection(userId, compilation),
+                copyCompleGljSection(userId, compilation)
+            ];
+            if (example && example.length > 0) {
+                prepareTask.push(copyExample(userId, compilation, example));
+            }
+            await Promise.all(prepareTask);
+        } catch (error) {
+            doc.errorMsg = '加载例题失败,请检查例题项目是否存在!';
+            doc.status = 'error';
+        } finally {
+            await importLogsModel.update({ key }, doc);
         }
-        await Promise.all(prepareTask);
     }
 }
 
@@ -1339,7 +1403,9 @@ async function downLoadProjectFile(info) {
 
     let data = {
         key:info.key,
+        content: '正在导入建设项目,请稍候……',
         userID:info.session.sessionUser.id,
+        compilationID: info.session.sessionCompilation._id,
         status:"start",
         create_time:+new Date()
     };
@@ -1375,28 +1441,31 @@ async function doDownLoadAndImport(privateDownloadUrl,info) {
 
 async function importProcessChecking(data){
     let result = {error:0};
-    let log = await importLogsModel.findOne({key:data.key});
+    const query = data.key ? { key: data.key } : { userID: data.userID, compilationID: data.compilationID };
+    let log = await importLogsModel.findOne(query);
     if(log){
         if(log.status == "finish"){
             result.status = "complete";
-            await importLogsModel.remove({key:data.key});
+            await importLogsModel.remove(query);
             // 获取导入的项目数据
             if (log.projectID) {
                 const projects = await getPosterityProjects([log.projectID], true);
-                const summaryInfo = await getSummaryInfo([log.projectID]);
-                setupSummaryFields(summaryInfo, projects);
+                if (!(projects.length === 1 && projects[0].projType === projectType.tender)) { // 处理的是建设项目数据
+                    const summaryInfo = await getSummaryInfo([log.projectID]);
+                    setupSummaryFields(summaryInfo, projects);
+                }
                 result.data = projects;
             }
         }else if(log.status == "start"){
             result.status = "processing";
+            result.content = log.content;
         }else if(log.status == "error"){
             result.error = 1;
             result.msg = log.errorMsg;
-            await importLogsModel.remove({key:data.key});
+            await importLogsModel.remove(query);
         }
     }else {
-        result.error = 1;
-        result.msg = `导入过程中发生错误!`;
+        result.status = "complete";
     }
     return result;
 

+ 5 - 3
public/web/PerfectLoad.js

@@ -122,8 +122,10 @@ jQuery.bootstrapLoading = {
         }
     },
     progressEnd:function () {
-        $("#progress_modal_bar").css('width','100%');
-        $.bootstrapLoading.progressStop = true;
-        $("#progressModal").modal('hide');
+        if ($('#progressModal').is(':visible')) {
+            $("#progress_modal_bar").css('width','100%');
+            $.bootstrapLoading.progressStop = true;
+            $("#progressModal").modal('hide');
+        }
     }
 };

+ 2 - 2
public/web/common_ajax.js

@@ -163,7 +163,7 @@ $.ajaxSetup({
 
 
 
-async function ajaxPost(url, data) {
+async function ajaxPost(url, data, timeout = 200000) {
     return new Promise(function (resolve, reject) {
         $.ajax({
             type:"POST",
@@ -171,7 +171,7 @@ async function ajaxPost(url, data) {
             data: {'data': JSON.stringify(data)},
             dataType: 'json',
             cache: false,
-            timeout: 200000,
+            timeout,
             success: function(result){
                 let message = "";
                 if(result) message = result.message?result.message:result.msg;

+ 6 - 0
web/building_saas/css/custom.css

@@ -425,4 +425,10 @@ input.text-right{
     .middle-modal-height {
         height: 350px;
     }
+}
+
+/* 初始样式,防止projspread初始化完后背景从白突然变灰 */
+.poj-list {
+    height: 1000px; 
+    background: #f7f7f9;
 }

+ 116 - 87
web/building_saas/pm/js/pm_newMain.js

@@ -2109,37 +2109,37 @@ $(document).ready(function() {
         });
     });
     // 复制到操作
-    $("#copy-to-confirm").click(function() {
-        let originalNode = projTreeObj.tree.selected;
-        let toNode = projTreeObj.copySelected;
-        let parent = null,next = null,projectMap={};
-        if(toNode.data.projType == projectType.project){//复制为目标的子节点
-            parent = toNode;
-            next = toNode.firstChild();
-        }else if(toNode.data.projType == projectType.tender){//复制为目标的后兄弟
-            parent = toNode.parent;
-            next = toNode.nextSibling;
-            projectMap['update'] = {query:{ID:toNode.id()}};//前一节点的下一个节点更新;
-        }
-        let nextID = next?next.id():-1;
-        let projectData = _.cloneDeep(originalNode.data);
-        projectData['ParentID'] = parent.id();
-        projectData['NextSiblingID'] = nextID;
-        projectData['property'] ={};
-        projectData['property']['rootProjectID'] = parent.id();
-        projectData['shareInfo'] = [];
-        let rename = projTreeObj.projectNameChecking(parent,originalNode,"复制");//重名检查
-        rename? projectData['name'] = rename:'';
-        projectMap['copy'] = {document:projectData};
-        $("#copy-to-dialog").modal('hide');
-        $.bootstrapLoading.start();
-        CommonAjax.post('/pm/api/copyProjects',{projectMap:projectMap,user_id: userID, tenderCount: 1},function (result) {
-            let newNode = projTreeObj.insert(result['copy'].document,parent,next);
-            let refreshNodes = projTreeObj.calEngineeringCost(newNode);
-            projTreeObj.refreshNodeData(refreshNodes);
-            $.bootstrapLoading.end();
-        }, null, 1000 * 60 * 5);
-
+    $("#copy-to-confirm").click(async function () {
+        try {
+            let originalNode = projTreeObj.tree.selected;
+            let toNode = projTreeObj.copySelected;
+            let parent = null, next = null, projectMap = {};
+            if (toNode.data.projType == projectType.project) {//复制为目标的子节点
+                parent = toNode;
+                next = toNode.firstChild();
+            } else if (toNode.data.projType == projectType.tender) {//复制为目标的后兄弟
+                parent = toNode.parent;
+                next = toNode.nextSibling;
+                projectMap['update'] = { query: { ID: toNode.id() } };//前一节点的下一个节点更新;
+            }
+            let nextID = next ? next.id() : -1;
+            let projectData = _.cloneDeep(originalNode.data);
+            projectData['ParentID'] = parent.id();
+            projectData['NextSiblingID'] = nextID;
+            projectData['property'] = {};
+            projectData['property']['rootProjectID'] = parent.id();
+            projectData['shareInfo'] = [];
+            let rename = projTreeObj.projectNameChecking(parent, originalNode, "复制");//重名检查
+            rename ? projectData['name'] = rename : '';
+            projectMap['copy'] = { document: projectData };
+            $("#copy-to-dialog").modal('hide');
+            $.bootstrapLoading.progressStart('拷贝项目', true);
+            $("#progress_modal_body").text('正在拷贝项目,请稍候……');
+            await ajaxPost('/pm/api/copyProjects', {projectMap:projectMap,user_id: userID, tenderCount: 1});
+            await importProcessChecking(null, null, (newProjectData) => handleTenderAfterChecking(newProjectData, projectData));
+        } catch (err) {
+            alert(err);
+        }
     });
     $('#selectSameTypeProject').click(function(){
         let value = $(this).prop('checked') == true?1:0;
@@ -2338,35 +2338,34 @@ function initProjects(callback) {
 
 /**
  * 初始化数据
- *
- * @return {void}
- */
-function init(refresh = false) {//refresh是刷新页面时才使用的
-    billValuation = billValuation.replace(/\n/g, '\\n');
-    rationValuation = rationValuation.replace(/\n/g, '\\n');
-    //init spread and pmTree
-    if(refresh == false) socketObject.connect('pm');//socket 连接;
-    if (isFirst) {
-        isFirst = false;
-        $('#progress').modal('show');
-        let intervalTime = prepareInitialTimer();
-        CommonAjax.post('/pm/api/prepareInitialData', {user_id: userID}, function () {
-            initProjects(function () {
-                clearInterval(intervalTime.outer);
-                clearInterval(intervalTime.inner);
-                $('#progressBar').css('width', '100%');
-                setTimeout(function () {
-                    $('#progress').modal('hide');
-                }, 500);
-            });
-        });
-    } else {
-        $.bootstrapLoading.start();
-        initProjects(function () {
-            $.bootstrapLoading.end();
-        })
+ * @return {void} */
+async function init(refresh = false) {//refresh是刷新页面时才使用的
+    try {
+        billValuation = billValuation.replace(/\n/g, '\\n');
+        rationValuation = rationValuation.replace(/\n/g, '\\n');
+        //init spread and pmTree
+        if (refresh == false) socketObject.connect('pm');//socket 连接;
+        if (isFirst) {
+            isFirst = false;
+            $.bootstrapLoading.progressStart('欢迎使用纵横公路养护造价', true);
+            $("#progress_modal_body").text('首次加载例题,请稍候……');
+            await ajaxPost('/pm/api/prepareInitialData', { user_id: userID });
+            await importProcessChecking(null, null, () => {
+                initProjects(() => $.bootstrapLoading.progressEnd());
+            }, true);
+        } else {
+            await importProcessChecking(null, ({ content }) => {
+                $.bootstrapLoading.progressStart('欢迎使用纵横公路养护造价', true);
+                $("#progress_modal_body").text(content);
+            }, () => {
+                $.bootstrapLoading.start();
+                initProjects(() => $.bootstrapLoading.end());
+            }, true);
+        }
+        engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
+    } catch (err) {
+        alert(err);
     }
-    engineering = engineeringList !== null && engineeringList !== undefined ? JSON.parse(engineeringList) : [];
 }
 
 function refreshAllPage(){
@@ -3959,45 +3958,75 @@ $("#confirm-import").click(function() {
              }
          });
     }
+});
 
-    async function  startImportProject(key) {
-        try {
-            console.log("start Import");
-            let result = await ajaxPost("/pm/api/importProject",{key:key,updateData:projTreeObj.getImportProjectDate()});
-            setTimeout(importProcessChecking,2000);
-        }catch (error){
-            alert(error);
-            $.bootstrapLoading.end();
-        }finally {
-            STATE.importing = false;
-        }
+async function startImportProject(key) {
+    try {
+        console.log("start Import");
+        let result = await ajaxPost("/pm/api/importProject", { key: key, updateData: projTreeObj.getImportProjectDate() });
+        importProcessChecking(key, null, (projectData) => handleProjectAfterChecking(projectData));
+    } catch (error) {
+        alert(error);
+        $.bootstrapLoading.end();
+    } finally {
+        STATE.importing = false;
     }
+}
 
-    async function importProcessChecking() {
-        let result = await ajaxPost("/pm/api/importProcessChecking",{key:key,user_id:userID});
-        if(result.error == 1){
-            let message = result.msg?result.msg:result.message;
+// 导入检查完成时,对新增建设项目的处理
+function handleProjectAfterChecking(projectData) {
+    if (!projectData) {
+        return;
+    }
+    const rootData = projectData.find(item => item.projType === projectType.project);
+    const sorted = commonUtil.getSortedTreeData(rootData.ParentID, projectData);
+    doAfterImport(sorted);
+}
+// 导入检查完成时,对新增单位工程的处理
+function handleTenderAfterChecking(projectData, orgTender) {
+    if (!projectData) {
+        return;
+    }
+    const tenderData = { ...orgTender, ...projectData[0] };
+    const parent = projTreeObj.tree.findNode(tenderData.ParentID);
+    const next = projTreeObj.tree.findNode(tenderData.NextSiblingID);
+    const newNode = projTreeObj.insert(tenderData, parent, next);
+    const refreshNodes = projTreeObj.calEngineeringCost(newNode);
+    projTreeObj.refreshNodeData(refreshNodes);
+}
+
+async function importProcessChecking(key, processingFunc = null, completeFunc = null, immediately = false) {
+    let count = 0;
+    immediately ? checking() : setTimeout(checking, 2000);
+    async function checking() {
+        let result = await ajaxPost("/pm/api/importProcessChecking", { key: key, user_id: userID });
+        if (result.error == 1) {
+            let message = result.msg ? result.msg : result.message;
             setTimeout(function () {
                 $.bootstrapLoading.progressEnd();//不做这个的话太快,页面不会自动关闭
-            },500);
-            alert(message)
-        }else if(result.error == 0){
-            if(result.status == "processing"){
-                setTimeout(importProcessChecking,2000);
-            }else if(result.status == "complete"){
-                if (Array.isArray(result.data)) {
-                    const rootData = result.data.find(item => item.projType === projectType.project);
-                    const sorted = commonUtil.getSortedTreeData(rootData.ParentID, result.data);
-                    doAfterImport(sorted);
+            }, 500);
+            alert(message);
+            if (completeFunc) {
+                completeFunc(result.data);
+            }
+        } else if (result.error == 0) {
+            if (result.status == "processing") {
+                // 只调用一次
+                if (processingFunc && count === 0) {
+                    processingFunc(result);
+                }
+                count++;
+                setTimeout(checking, 2000);
+            } else if (result.status == "complete") {
+                if (completeFunc) {
+                    completeFunc(result.data);
                 }
                 $.bootstrapLoading.progressEnd();
                 //refreshAllPage();
             }
         }
     }
-    
-    
-});
+}
 
 $("#import_project_data").change(function(){
     let file = $(this)[0];

+ 23 - 23
web/building_saas/pm/js/pm_share.js

@@ -904,29 +904,30 @@ const pmShare = (function () {
     }
     //拷贝分享的工程
     //@param {Object}selected {Number}parentID @return {void}
-    function copyShareProject(selected, projID){
-        if(!projID || !selected){
-            return;
-        }
-        let copyMap = {copy: null, update: null};
-        let newName = getCopyName(selected);
-        //获取建设项目的分段
-        let tenderQuery = {$or: [{deleteInfo: null}, {'deleteInfo.deleted': false}], userID: userID, ParentID: projID};
-        CommonAjax.post('/pm/api/getProjectsByQuery', {user_id: userID, query: tenderQuery, options: '-_id -property'}, function (rstData) {
+    async function copyShareProject(selected, projID) {
+        try {
+            if (!projID || !selected) {
+                return;
+            }
+            let copyMap = { copy: null, update: null };
+            let newName = getCopyName(selected);
+            //获取建设项目的分段
+            let tenderQuery = { $or: [{ deleteInfo: null }, { 'deleteInfo.deleted': false }], userID: userID, ParentID: projID };
+            const rstData = await ajaxPost('/pm/api/getProjectsByQuery', { user_id: userID, query: tenderQuery, options: '-_id -property' }, 10000);
             let updateTender = null;
-            for(let tender of rstData){
-                if(tender.name === newName){
+            for (let tender of rstData) {
+                if (tender.name === newName) {
                     $('#copyShare_name').text('已存在此单位工程。');
                     $('#copyShare_name').addClass('text-danger');
                     return;
                 }
-                if(tender.NextSiblingID == -1){
+                if (tender.NextSiblingID == -1) {
                     updateTender = tender;
                 }
             }
             //更新前节点
-            if(updateTender){
-                copyMap.update = {query: {ID: updateTender.ID}};
+            if (updateTender) {
+                copyMap.update = { query: { ID: updateTender.ID } };
             }
             //拷贝
             let copyData = {
@@ -945,16 +946,15 @@ const pmShare = (function () {
                 fullFolder: selected.data.fullFolder
             };
             copyData.property.rootProjectID = projID;
-            copyMap.copy = {document: copyData};
+            copyMap.copy = { document: copyData };
             $('#copyShare').modal('hide');
-            $.bootstrapLoading.start();
-            CommonAjax.post('/pm/api/copyProjects', {projectMap: copyMap, user_id: userID, tenderCount: 1}, function (rstData) {
-                $.bootstrapLoading.end();
-            }, function () {
-                $.bootstrapLoading.end();
-            },  1000 * 60 * 5);
-        });
-
+            $.bootstrapLoading.progressStart('拷贝项目', true);
+            $("#progress_modal_body").text('正在拷贝项目,请稍候……');
+            await ajaxPost('/pm/api/copyProjects', { projectMap: copyMap, user_id: userID, tenderCount: 1 });
+            importProcessChecking();
+        } catch (err) {
+            alert(err);
+        }
     }
     //获取拷贝后的名称
     //@param {Object}node @return {String}