|
@@ -500,8 +500,37 @@ const pmShare = (function () {
|
|
|
};
|
|
|
return new InteractionCell();
|
|
|
}
|
|
|
+
|
|
|
+ function isUnread(unreadList, node) {
|
|
|
+ if (!unreadList) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const actualID = node && node.data && node.data.actualTreeInfo && node.data.actualTreeInfo.ID || null;
|
|
|
+ if (!actualID) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return !!unreadList.find(ID => ID === actualID);
|
|
|
+ }
|
|
|
const foreColor = '#007bff';
|
|
|
- const cancelForeColor = 'red';
|
|
|
+ const dangerColor = '#dc3545';
|
|
|
+ // 标记已读
|
|
|
+ // 打开任意的单位工程,都会将其父分享条目标记和自身为已读
|
|
|
+ // eg:被分享了一个建设项目,和其下一个单位工程,打开该一个单位工程,建设项目标记为已读、该单位工程也标记为已读
|
|
|
+ function handleMarkRead(unreadList, markReadProjectIDs) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
//显示树结构数据
|
|
|
//@param {Array}nodes {Array}headers @return {void}
|
|
|
function showTreeData(nodes, headers){
|
|
@@ -520,6 +549,12 @@ const pmShare = (function () {
|
|
|
style.foreColor = foreColor;
|
|
|
sheet.setStyle(i, j, style);
|
|
|
sheet.getCell(i, j).cellType(getInteractionCell());
|
|
|
+ } else if (dataCode === 'shareDate') {
|
|
|
+ let style = new GC.Spread.Sheets.Style();
|
|
|
+ if (isUnread(unreadShareList, nodes[i])) {
|
|
|
+ style.foreColor = dangerColor;
|
|
|
+ }
|
|
|
+ sheet.setStyle(i, j, style);
|
|
|
}
|
|
|
sheet.setValue(i, j, nodes[i].data[dataCode] !== null && typeof nodes[i].data[dataCode] !== 'undefined' ? nodes[i].data[dataCode] : '');
|
|
|
}
|
|
@@ -527,6 +562,30 @@ const pmShare = (function () {
|
|
|
};
|
|
|
renderSheetFunc(sheet, fuc);
|
|
|
}
|
|
|
+ // 获取实际树ID为某值的所有节点
|
|
|
+ function getNodesByActualID(ID, items) {
|
|
|
+ return items.filter(node => node.data && node.data.actualTreeInfo && node.data.actualTreeInfo.ID === ID);
|
|
|
+ }
|
|
|
+ // 刷新显示某些节点
|
|
|
+ function refreshNodes(nodes, headers) {
|
|
|
+ const sheet = spreadObj.workBook.getActiveSheet();
|
|
|
+ const fuc = function(){
|
|
|
+ for (let i = 0; i < nodes.length; i++) {
|
|
|
+ const row = nodes[i].serialNo();
|
|
|
+ for (let j = 0; j < headers.length; j++) {
|
|
|
+ const dataCode = headers[j].dataCode;
|
|
|
+ if (dataCode === 'from') {
|
|
|
+ const style = new GC.Spread.Sheets.Style();
|
|
|
+ style.foreColor = foreColor;
|
|
|
+ sheet.setStyle(row, j, style);
|
|
|
+ sheet.getCell(row, j).cellType(getInteractionCell());
|
|
|
+ }
|
|
|
+ sheet.setValue(row, j, nodes[i].data[dataCode] !== null && typeof nodes[i].data[dataCode] !== 'undefined' ? nodes[i].data[dataCode] : '');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ renderSheetFunc(sheet, fuc);
|
|
|
+ }
|
|
|
//同一棵树,可能存在相同数据显示多条的问题(传入的datas中不存在相同数据)
|
|
|
//将真实树结构数据存在actualTreeInfo中,外部树结构数据用uuid重置。
|
|
|
//@param {Array}datas
|
|
@@ -698,6 +757,7 @@ const pmShare = (function () {
|
|
|
$.bootstrapLoading.start();
|
|
|
//获取分享数据
|
|
|
CommonAjax.post('/pm/api/receiveProjects', {user_id: userID}, function (rstData) {
|
|
|
+ actualIDShareInfo = {};
|
|
|
// 排序 --分享的文件按照时间先后顺序排序,分享文件下的子文件,按照原本树结构显示,不需要排序
|
|
|
sortByDate(rstData.grouped);
|
|
|
sortByDate(rstData.ungrouped);
|
|
@@ -904,6 +964,26 @@ const pmShare = (function () {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // 处理节点操作属性变更(是否可拷贝、是否可编辑)
|
|
|
+ function handlePropChange(projectID, prop) {
|
|
|
+ const actualShareData = actualIDShareInfo[projectID];
|
|
|
+ if (actualShareData) {
|
|
|
+ const shareItem = actualShareData.shareInfo.find(s => s.userID === userID);
|
|
|
+ if(shareItem) {
|
|
|
+ Object.assign(shareItem, prop);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const nodes = getNodesByActualID(projectID, tree.items);
|
|
|
+ nodes.forEach(node => {
|
|
|
+ const shareItem = node.data.shareInfo.find(s => s.userID === userID);
|
|
|
+ if(shareItem) {
|
|
|
+ Object.assign(shareItem, prop);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ const treeData = tree.items.map(item => item.data);
|
|
|
+ setPermissionsInfo(treeData);
|
|
|
+ showTreeData(tree.items, headers);
|
|
|
+ }
|
|
|
// 处理清除
|
|
|
function handleCancelShare(cancelProjID, callback) {
|
|
|
$.bootstrapLoading.start();
|
|
@@ -934,7 +1014,7 @@ const pmShare = (function () {
|
|
|
showTreeData(tree.items, headers);
|
|
|
$.bootstrapLoading.end();
|
|
|
if (callback) {
|
|
|
- callback();
|
|
|
+ callback(rstData);
|
|
|
}
|
|
|
}, function () {
|
|
|
$.bootstrapLoading.end();
|
|
@@ -1014,11 +1094,11 @@ const pmShare = (function () {
|
|
|
copyShareProject(tree.selected, parseInt(selProj), parseInt(selEng));
|
|
|
});
|
|
|
//清除分享
|
|
|
- $('#cancelShareConfirm').click(function () {
|
|
|
+ $('#cancelShareConfirm').click(function (data) {
|
|
|
const cancelProjID = tree.selected.data.actualTreeInfo.ID;
|
|
|
handleCancelShare(cancelProjID, () => {
|
|
|
// 推送已打开的项目,通知已取消分享
|
|
|
- SHARE_TO.emitPermissionChange(commonConstants.SharePermissionChangeType.CANCEL, userID, cancelProjID);
|
|
|
+ SHARE_TO.emitPermissionChange(commonConstants.SharePermissionChangeType.CANCEL, userID, cancelProjID, data.emitTenders);
|
|
|
// 清除已读
|
|
|
SHARE_TO.removeUnread(cancelProjID, unreadShareList);
|
|
|
});
|
|
@@ -1031,7 +1111,9 @@ const pmShare = (function () {
|
|
|
initView,
|
|
|
eventListener,
|
|
|
initShareTree,
|
|
|
- handleCancelShare
|
|
|
+ handlePropChange,
|
|
|
+ handleCancelShare,
|
|
|
+ handleMarkRead
|
|
|
}
|
|
|
})();
|
|
|
|