Skip to content

Commit

Permalink
优化按分部显示部门时, 部门tree未排序
Browse files Browse the repository at this point in the history
  • Loading branch information
baozhoutao committed May 9, 2024
1 parent 92a3b29 commit 1819359
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,9 +430,11 @@ CFDataManager.getRoot = function (spaceId, options) {
}

var showLimitedCompanyOnly = options && options.showLimitedCompanyOnly;
var needSort = false;
if(showLimitedCompanyOnly){
user_company_ids = Steedos.getUserCompanyOrganizationIds();
if (user_company_ids && user_company_ids.length) {
needSort = true;
query._id = {
$in: user_company_ids
};
Expand All @@ -445,7 +447,7 @@ CFDataManager.getRoot = function (spaceId, options) {
}
}

return SteedosDataManager.organizationRemote.find(query, {
var result = SteedosDataManager.organizationRemote.find(query, {
fields: {
_id: 1,
name: 1,
Expand All @@ -457,6 +459,13 @@ CFDataManager.getRoot = function (spaceId, options) {
hidden: 1,
}
});

if(needSort){
var curSpaceUser = db.space_users.findOne({space: Creator.USER_CONTEXT.user.spaceId,'user': Creator.USER_CONTEXT.user.userId});
return Creator.getOrderlySetByIds(result, curSpaceUser.organizations);
}

return result
};

CFDataManager.getOrganizationsByIds = function(ids) {
Expand Down
6 changes: 5 additions & 1 deletion creator/packages/steedos-objects/coreSupport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,11 @@ Creator.getOrderlySetByIds = (docs, ids, id_key, hit_first)->
return ids.length + _.indexOf(values, doc[id_key])
else
return _.sortBy docs, (doc)->
return ids.indexOf(doc[id_key])
v = ids.indexOf(doc[id_key]);
if v < 0
return 99999
else
return v

###
按用户所属本地化语言进行排序,支持中文、数值、日期等字段排序
Expand Down

0 comments on commit 1819359

Please sign in to comment.