diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 44e5e6891..b38e0f18c 100755 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -350,6 +350,7 @@ class UsersController extends AbstractController * - keys.no_project_id 不在指定项目ID * @apiParam {Object} sorts 排序方式 * - sorts.az 按字母:asc|desc + * @apiParam {Number} updated_time 在这个时间戳之后更新的 * * @apiParam {Number} [take] 获取数量,10-100 * @apiParam {Number} [page] 当前页,默认:1(赋值分页模式,take参数无效) @@ -365,6 +366,7 @@ class UsersController extends AbstractController // $keys = Request::input('keys'); $sorts = Request::input('sorts'); + $updatedTime = intval(Request::input('updated_time')); $keys = is_array($keys) ? $keys : []; $sorts = is_array($sorts) ? $sorts : []; // @@ -379,6 +381,9 @@ class UsersController extends AbstractController } elseif (intval($keys['disable']) == 2) { $builder->whereNotNull("disable_at"); } + if ($updatedTime > 0) { + $builder->where("updated_at", ">=", Carbon::createFromTimestamp($updatedTime)); + } if (intval($keys['project_id']) > 0) { $builder->whereIn('userid', function ($query) use ($keys) { $query->select('userid')->from('project_users')->where('project_id', $keys['project_id']); diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index 07c48ad08..701d5feed 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -171,6 +171,7 @@ export default { contactsData: null, contactsCurrentPage: 1, contactsHasMorePages: false, + contactsLastTime: 0, operateItem: {}, operateStyles: {}, @@ -346,7 +347,14 @@ export default { tabActive: { handler(val) { if (val == 'contacts') { - this.contactsData === null && this.getContactsList(1); + if ($A.Time() - this.contactsLastTime > 24 * 3600) { + this.contactsData = null; // 24个小时重新加载列表 + } + if (this.contactsData === null) { + this.getContactsList(1); + } else { + this.updateContactsList(1000); + } } else { this.updateDialogs(1000); } @@ -477,9 +485,38 @@ export default { this.contactsHasMorePages = false; }).finally(_ => { this.contactsLoad--; + this.contactsLastTime = $A.Time() }); }, + updateContactsList(timeout) { + this.__updateContactsList && clearTimeout(this.__updateContactsList) + if (timeout > -1) { + this.__updateContactsList = setTimeout(_ => { + if (this.tabActive === 'contacts') { + this.$store.dispatch("call", { + url: 'users/search', + data: { + updated_time: this.contactsLastTime, + take: 100 + }, + }).then(({data}) => { + data.some((user) => { + const index = this.contactsData.findIndex(item => item.userid == user.userid); + if (index > -1) { + this.contactsData.splice(index, 1, user); + } else { + this.contactsData.push(user); + } + }); + }).finally(_ => { + this.contactsLastTime = $A.Time() + }); + } + }, timeout) + } + }, + formatLastMsg(data) { if ($A.isJson(data)) { switch (data.type) {