Browse Source

项目管理直接清除分享,没触发相关推送的问题

vian 5 years ago
parent
commit
a2f736e419
2 changed files with 54 additions and 12 deletions
  1. 46 11
      web/building_saas/pm/js/pm_share.js
  2. 8 1
      web/common/components/share/index.js

+ 46 - 11
web/building_saas/pm/js/pm_share.js

@@ -520,14 +520,15 @@ const pmShare = (function () {
         const col = headers.findIndex(item => item.dataCode === 'shareDate');
         const sheet = spreadObj.workBook.getActiveSheet();
         const style = new GC.Spread.Sheets.Style();
-        //style.foreColor = foreColor;
-        markReadProjectIDs.forEach(projectID => {
-            SHARE_TO.removeUnread(projectID, unreadList);
-            tree.items.forEach(node => {
-                if (node.data && node.data.actualTreeInfo && node.data.actualTreeInfo.ID === projectID) {
-                    const row = node.serialNo();
-                    sheet.setStyle(row, col, style);
-                }
+        projTreeObj.renderSheetFuc(sheet, function () {
+            markReadProjectIDs.forEach(projectID => {
+                SHARE_TO.removeUnread(projectID, unreadList);
+                tree.items.forEach(node => {
+                    if (node.data && node.data.actualTreeInfo && node.data.actualTreeInfo.ID === projectID) {
+                        const row = node.serialNo();
+                        sheet.setStyle(row, col, style);
+                    }
+                });
             });
         });
     }
@@ -985,7 +986,7 @@ const pmShare = (function () {
         showTreeData(tree.items, headers);
     }
     // 处理清除
-    function handleCancelShare(cancelProjID, callback) {
+    /* function handleCancelShare(cancelProjID, callback) {
         $.bootstrapLoading.start();
         CommonAjax.post('/pm/api/share', {user_id: userID, type: oprType.cancel,  projectID: cancelProjID, shareData:[{userID: userID}]}, function (rstData) {
             const node = tree.items.find(item => item.data.actualTreeInfo && item.data.actualTreeInfo.ID === cancelProjID);
@@ -1019,6 +1020,32 @@ const pmShare = (function () {
         }, function () {
             $.bootstrapLoading.end();
         });
+    } */
+    function handleCancelShare(cancelProjID) {
+        const node = tree.items.find(item => item.data.actualTreeInfo && item.data.actualTreeInfo.ID === cancelProjID);
+        if (node) {
+            tree.removeNode(node);
+        }
+        //更新与清除节点数据相同,且未被清除缓存分享信息
+        updateAfterCancel(userID, cancelProjID);
+        //重新设置actualIDShareInfo,以正确更新权限(清除了分享信息后,可能会导致权限变化 eg:清除了新的分享,则存留的分享项目采用旧的)
+        actualIDShareInfo = {};
+        let treeDatas = [];
+        for (let item of tree.items) {
+            treeDatas.push(item.data);
+            let actualTreeInfo = item.data.actualTreeInfo;
+            if (actualTreeInfo && !actualIDShareInfo[actualTreeInfo.ID]) {
+                actualIDShareInfo[actualTreeInfo.ID] = {
+                    ID: actualTreeInfo.ID,
+                    ParentID: actualTreeInfo.ParentID,
+                    NextSiblingID: actualTreeInfo.NextSiblingID,
+                    shareInfo: item.data.shareInfo
+                };
+            }
+        }
+        //重新设置权限
+        setPermissionsInfo(treeDatas);
+        showTreeData(tree.items, headers);
     }
     //事件监听器
     //@return void
@@ -1095,12 +1122,20 @@ const pmShare = (function () {
         });
         //清除分享
         $('#cancelShareConfirm').click(function (data) {
+            $.bootstrapLoading.start();
             const cancelProjID = tree.selected.data.actualTreeInfo.ID;
-            handleCancelShare(cancelProjID, () => {
+            const permissionType = commonConstants.SharePermissionChangeType.CANCEL;
+            CommonAjax.post('/pm/api/share', { user_id: userID, type: oprType.cancel, permissionType, projectID: cancelProjID, shareData: [{ userID: userID }] }, function (rstData) {
+                handleCancelShare(cancelProjID);
+
                 // 推送已打开的项目,通知已取消分享
-                SHARE_TO.emitPermissionChange(commonConstants.SharePermissionChangeType.CANCEL, userID, cancelProjID, data.emitTenders);
+                SHARE_TO.emitPermissionChange(permissionType, userID, cancelProjID, rstData.emitTenders);
                 // 清除已读
                 SHARE_TO.removeUnread(cancelProjID, unreadShareList);
+
+                $.bootstrapLoading.end();
+            }, function () {
+                $.bootstrapLoading.end();
             });
         });
     }

+ 8 - 1
web/common/components/share/index.js

@@ -353,7 +353,14 @@ const SHARE_TO = (() => {
 
     // 已读分享项目
     function handleShareItemRead({ markReadProjectIDs }) {
-        pmShare.handleMarkRead(unreadShareList, markReadProjectIDs);
+        const isActive = $('#tab_pm_share').hasClass('active');
+        if (isActive) {
+            pmShare.handleMarkRead(unreadShareList, markReadProjectIDs);
+        } else {
+            markReadProjectIDs.forEach(projectID => {
+                removeUnread(projectID, unreadShareList);
+            });
+        }
     }
     // 分享条数属性变更(是否可拷贝、是否可编辑)
     // @param {Object} prop - 属性变更对象 eg: { allowCopy: false }