From 181935945933a7ce2142b41b7597f5eb402d7d21 Mon Sep 17 00:00:00 2001 From: baozhoutao Date: Thu, 9 May 2024 14:43:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8C=89=E5=88=86=E9=83=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=83=A8=E9=97=A8=E6=97=B6,=20=E9=83=A8?= =?UTF-8?q?=E9=97=A8tree=E6=9C=AA=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../inputTypes/coreform-user/lib/cf_data_manager.js | 11 ++++++++++- creator/packages/steedos-objects/coreSupport.coffee | 6 +++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/creator/packages/steedos-autoform/client/coreform/inputTypes/coreform-user/lib/cf_data_manager.js b/creator/packages/steedos-autoform/client/coreform/inputTypes/coreform-user/lib/cf_data_manager.js index 86c6203931..6790a2ff42 100644 --- a/creator/packages/steedos-autoform/client/coreform/inputTypes/coreform-user/lib/cf_data_manager.js +++ b/creator/packages/steedos-autoform/client/coreform/inputTypes/coreform-user/lib/cf_data_manager.js @@ -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 }; @@ -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, @@ -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) { diff --git a/creator/packages/steedos-objects/coreSupport.coffee b/creator/packages/steedos-objects/coreSupport.coffee index 29dd9e6e75..edb40521cd 100644 --- a/creator/packages/steedos-objects/coreSupport.coffee +++ b/creator/packages/steedos-objects/coreSupport.coffee @@ -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 ### 按用户所属本地化语言进行排序,支持中文、数值、日期等字段排序