Browse Source

单价费率文件重命名重复请求bug

zhongzewei 6 years ago
parent
commit
97468bcf7d
2 changed files with 20 additions and 71 deletions
  1. 1 1
      modules/pm/facade/pm_facade.js
  2. 19 70
      web/building_saas/pm/js/pm_newMain.js

+ 1 - 1
modules/pm/facade/pm_facade.js

@@ -872,7 +872,7 @@ async function getPosterityProjects(projectIDs) {
     return rst;
     return rst;
 }
 }
 
 
-//打开的单位工程是否是被分享的
+//打开的单位工程是否是被分享的.
 async function isShare(userId, project){
 async function isShare(userId, project){
     //判断是否是打开分享的项目,属于分享文件的子项也算
     //判断是否是打开分享的项目,属于分享文件的子项也算
     while (project) {
     while (project) {

+ 19 - 70
web/building_saas/pm/js/pm_newMain.js

@@ -3131,14 +3131,14 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
         });
         });
     }
     }
     //重命名
     //重命名
+    let fileObjs = getFileObj(targetBody, type),
+        fileDiv = $(jqS + ' div:eq(0)'),
+        renameDiv = $(jqS + ' div:eq(1)'),
+        hintText = $(jqS).find('span'),
+        postFix = '';
     $(jqS + ' p a:eq(1)').on('click', function () {
     $(jqS + ' p a:eq(1)').on('click', function () {
-        let fileObjs = getFileObj(targetBody, type);
         let orgDispName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
         let orgDispName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
-        let postFix = '';
         let orgName = orgDispName;
         let orgName = orgDispName;
-        let hintText = $(jqS).find('span');
-        let fileDiv = $(jqS + ' div:eq(0)');
-        let renameDiv = $(jqS + ' div:eq(1)');
         $(jqS + ' input').val(orgName);
         $(jqS + ' input').val(orgName);
         fileDiv.hide();
         fileDiv.hide();
         renameDiv.show();
         renameDiv.show();
@@ -3148,62 +3148,17 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
             renameDiv.hide();
             renameDiv.hide();
             hintText.hide();
             hintText.hide();
         });
         });
-        //确认重命名
-        //回车键
-        $(jqS).find('input:eq(0)').keypress(function (e) {
-            if(e.keyCode === 13){
-                let attrId = $(jqS).attr('id');
-                let id = attrId.slice(5, attrId.length);
-                let newName = $(jqS + ' input').val().trim();
-                if(newName !== orgName){
-                    if(hasThisFileName(fileObjs, newName)){
-                        hintText.show();
-                        //$(jqS + ' input').val(orgName);
-                        return;
-                    }
-                    if(newName.trim().length === 0){
-                        alert('文件名不可为空!');
-                        $(jqS + ' input').val(orgName);
-                        return;
-                    }
-                    //ajax
-                    let updateObj = Object.create(null);
-                    updateObj.fileType = type;
-                    updateObj.updateType = 'update';
-                    updateObj.updateData = Object.create(null);
-                    if(type === fileType.unitPriceFile){
-                        updateObj.updateData.id = parseInt(id);
-                        //updateObj.updateData.id = id;
-                    }
-                    else if(type === fileType.feeRateFile){
-                        updateObj.updateData.ID = id;
-                    }
-                    updateObj.updateData.name = newName;
-                    a_updateFiles([updateObj], function () {
-                        let newDispName = newName + postFix;
-                        fileDiv[0].childNodes[0].textContent = newDispName;
-                        fileDiv.show();
-                        renameDiv.hide();
-                        //refresh tender
-                        refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
-                    });
-                }
-                let newDispName = newName + postFix;
-                fileDiv[0].childNodes[0].textContent = newDispName;
-                fileDiv.show();
-                renameDiv.hide();
-                hintText.hide();
-            }
-        });
-
-        /*$(jqS + ' .btn-success').on('click', function () {
+    });
+    //回车键确认重命名
+    $(jqS).find('input:eq(0)').keypress(function (e) {
+        if(e.keyCode === 13){
+            let orgName = $(jqS + ' div:eq(0)')[0].childNodes[0].textContent;
             let attrId = $(jqS).attr('id');
             let attrId = $(jqS).attr('id');
             let id = attrId.slice(5, attrId.length);
             let id = attrId.slice(5, attrId.length);
             let newName = $(jqS + ' input').val().trim();
             let newName = $(jqS + ' input').val().trim();
             if(newName !== orgName){
             if(newName !== orgName){
                 if(hasThisFileName(fileObjs, newName)){
                 if(hasThisFileName(fileObjs, newName)){
-                    $(jqS).find('span:eq(2)').show();
-                    //$(jqS + ' input').val(orgName);
+                    hintText.show();
                     return;
                     return;
                 }
                 }
                 if(newName.trim().length === 0){
                 if(newName.trim().length === 0){
@@ -3218,7 +3173,6 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
                 updateObj.updateData = Object.create(null);
                 updateObj.updateData = Object.create(null);
                 if(type === fileType.unitPriceFile){
                 if(type === fileType.unitPriceFile){
                     updateObj.updateData.id = parseInt(id);
                     updateObj.updateData.id = parseInt(id);
-                    //updateObj.updateData.id = id;
                 }
                 }
                 else if(type === fileType.feeRateFile){
                 else if(type === fileType.feeRateFile){
                     updateObj.updateData.ID = id;
                     updateObj.updateData.ID = id;
@@ -3226,24 +3180,19 @@ function bindEvents_file_table(jqS, usedObj, targetBody, type){
                 updateObj.updateData.name = newName;
                 updateObj.updateData.name = newName;
                 a_updateFiles([updateObj], function () {
                 a_updateFiles([updateObj], function () {
                     let newDispName = newName + postFix;
                     let newDispName = newName + postFix;
-                    $(jqS + ' div:eq(0)')[0].childNodes[0].textContent = newDispName;
-                    $(jqS + ' div:eq(0)').show();
-                    $(jqS + ' div:eq(1)').hide();
+                    fileDiv[0].childNodes[0].textContent = newDispName;
+                    fileDiv.show();
+                    renameDiv.hide();
                     //refresh tender
                     //refresh tender
                     refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
                     refreshTenderFile(getTendersByFile(type, id, projTreeObj.tree.selected), type, newName);
                 });
                 });
             }
             }
             let newDispName = newName + postFix;
             let newDispName = newName + postFix;
-            $(jqS + ' div:eq(0)')[0].childNodes[0].textContent = newDispName;
-            $(jqS + ' div:eq(0)').show();
-            $(jqS + ' div:eq(1)').hide();
-        });
-        //取消重命名
-        $(jqS + ' .btn-secondary').on('click', function () {
-            $(jqS + ' div:eq(0)').show();
-            $(jqS + ' div:eq(1)').hide();
-            $(jqS).find('span:eq(2)').hide();
-        });*/
+            fileDiv[0].childNodes[0].textContent = newDispName;
+            fileDiv.show();
+            renameDiv.hide();
+            hintText.hide();
+        }
     });
     });
     //悬浮框显示使用该文件的单位工程
     //悬浮框显示使用该文件的单位工程
     $($(jqS)[0].nextSibling).popover({
     $($(jqS)[0].nextSibling).popover({