diff --git a/app/Models/AbstractModel.php b/app/Models/AbstractModel.php index 1a5e8f01..41d77e5d 100644 --- a/app/Models/AbstractModel.php +++ b/app/Models/AbstractModel.php @@ -18,6 +18,7 @@ use Illuminate\Support\Facades\DB; * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel saveOrIgnore() * @method static \Illuminate\Database\Eloquent\Builder|AbstractModel getKeyValue() * @method static \Illuminate\Database\Eloquent\Model|object|static|null cancelAppend() + * @method static \Illuminate\Database\Eloquent\Model|object|static|null cancelHidden() * @method static \Illuminate\Database\Eloquent\Builder|static with($relations) * @method static \Illuminate\Database\Query\Builder|static select($columns = []) * @method static \Illuminate\Database\Query\Builder|static whereNotIn($column, $values, $boolean = 'and') @@ -72,6 +73,15 @@ class AbstractModel extends Model return $this->setAppends([]); } + /** + * 取消隐藏值 + * @return static + */ + protected function scopeCancelHidden() + { + return $this->setHidden([]); + } + /** * 为数组 / JSON 序列化准备日期。 * @param DateTimeInterface $date diff --git a/app/Models/WebSocketDialog.php b/app/Models/WebSocketDialog.php index feddefa9..7bd1e98d 100644 --- a/app/Models/WebSocketDialog.php +++ b/app/Models/WebSocketDialog.php @@ -120,10 +120,10 @@ class WebSocketDialog extends AbstractModel break; case "group": if ($dialog->group_type === 'project') { - $dialog->group_info = Project::withTrashed()->select(['id', 'name'])->whereDialogId($dialog->id)->first(); + $dialog->group_info = Project::withTrashed()->select(['id', 'name', 'archived_at', 'deleted_at'])->whereDialogId($dialog->id)->first()?->cancelAppend()->cancelHidden(); $dialog->name = $dialog->group_info ? $dialog->group_info->name : ''; } elseif ($dialog->group_type === 'task') { - $dialog->group_info = ProjectTask::withTrashed()->select(['id', 'name'])->whereDialogId($dialog->id)->first(); + $dialog->group_info = ProjectTask::withTrashed()->select(['id', 'name', 'complete_at', 'archived_at', 'deleted_at'])->whereDialogId($dialog->id)->first()?->cancelAppend()->cancelHidden(); $dialog->name = $dialog->group_info ? $dialog->group_info->name : ''; } break; diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 764c9a38..fd40bfda 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -315,6 +315,37 @@ return [new Date(), lastSecond(e.getTime())]; } }]; + }, + + /** + * 对话标签 + * @param dialog + * @returns {*[]} + */ + dialogTags(dialog) { + let tags = []; + if (dialog.type == 'group') { + if (['project', 'task'].includes(dialog.group_type) && $A.isJson(dialog.group_info)) { + if (dialog.group_type == 'task' && dialog.group_info.complete_at) { + tags.push({ + color: 'success', + text: '已完成' + }) + } + if (dialog.group_info.deleted_at) { + tags.push({ + color: 'error', + text: '已删除' + }) + } else if (dialog.group_info.archived_at) { + tags.push({ + color: 'default', + text: '已归档' + }) + } + } + } + return tags; } }); diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index 2e653b03..8d529aa7 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -8,6 +8,7 @@
+ {{$L(tag.text)}}

{{dialogData.name}}

({{peopleNum}})
@@ -413,7 +414,7 @@ export default { } }) } - } + }, } } diff --git a/resources/assets/js/pages/manage/messenger.vue b/resources/assets/js/pages/manage/messenger.vue index 6f01fd85..83d503a6 100644 --- a/resources/assets/js/pages/manage/messenger.vue +++ b/resources/assets/js/pages/manage/messenger.vue @@ -40,6 +40,7 @@
+ {{$L(tag.text)}} {{dialog.name}} {{$A.formatTime(dialog.last_at)}} @@ -124,32 +125,24 @@ export default { dialogList() { const {dialogActive, dialogKey} = this; if (dialogActive == '' && dialogKey == '') { - return this.cacheDialogs.filter(({name, last_at}) => { - if (name === undefined) { - return false; - } - return last_at; - }).sort((a, b) => { + return this.cacheDialogs.filter(dialog => this.filterDialog(dialog)).sort((a, b) => { return $A.Date(b.last_at) - $A.Date(a.last_at); }); } - return this.cacheDialogs.filter(({name, type, group_type, last_msg, last_at}) => { - if (name === undefined) { - return false; - } - if (!last_at) { + return this.cacheDialogs.filter(dialog => { + if (!this.filterDialog(dialog)) { return false; } if (dialogActive) { switch (dialogActive) { case 'project': case 'task': - if (group_type != dialogActive) { + if (dialog.group_type != dialogActive) { return false; } break; case 'user': - if (type != 'user') { + if (dialog.type != 'user') { return false; } break; @@ -158,8 +151,8 @@ export default { } } if (dialogKey) { - let existName = $A.strExists(name, dialogKey); - let existMsg = last_msg && last_msg.type === 'text' && $A.strExists(last_msg.msg.text, dialogKey); + let existName = $A.strExists(dialog.name, dialogKey); + let existMsg = dialog.last_msg && dialog.last_msg.type === 'text' && $A.strExists(dialog.last_msg.msg.text, dialogKey); if (!existName && !existMsg) { return false; } @@ -276,6 +269,44 @@ export default { }); }, + filterDialog(dialog) { + if (dialog.unread > 0 || dialog.id == this.dialogId) { + return true + } + if (dialog.name === undefined) { + return false; + } + if (!dialog.last_at) { + return false; + } + if (dialog.type == 'group') { + if (['project', 'task'].includes(dialog.group_type) && $A.isJson(dialog.group_info)) { + if (dialog.group_type == 'task' && dialog.group_info.complete_at) { + // 已完成5天后隐藏对话 + let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.complete_at, true)) + if (5 * 86400 + time < $A.Time()) { + return false + } + } + if (dialog.group_info.deleted_at) { + // 已删除3天后隐藏对话 + let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.deleted_at, true)) + if (3 * 86400 + time < $A.Time()) { + return false + } + } + if (dialog.group_info.archived_at) { + // 已删除7天后隐藏对话 + let time = Math.max($A.Date(dialog.last_at, true), $A.Date(dialog.group_info.archived_at, true)) + if (7 * 86400 + time < $A.Time()) { + return false + } + } + } + } + return true; + }, + getContactsList(page) { if (this.contactsData === null) { this.contactsData = {}; diff --git a/resources/assets/sass/pages/page-messenger.scss b/resources/assets/sass/pages/page-messenger.scss index 629694bf..e1ab86b1 100644 --- a/resources/assets/sass/pages/page-messenger.scss +++ b/resources/assets/sass/pages/page-messenger.scss @@ -124,6 +124,15 @@ align-items: center; justify-content: space-between; line-height: 24px; + .ivu-tag { + padding: 0 5px; + &.ivu-tag-error, + &.ivu-tag-primary, + &.ivu-tag-success, + &.ivu-tag-warning { + padding: 0 6px; + } + } > span { flex: 1; color: #333333;