no message

This commit is contained in:
kuaifan 2021-06-14 17:00:03 +08:00
parent 72970eab2d
commit 27308cdebc
6 changed files with 91 additions and 30 deletions

View File

@ -52,6 +52,7 @@ class WebSocketDialog extends AbstractModel
$dialog->people = $builder->count(); $dialog->people = $builder->count();
// 对方信息 // 对方信息
$dialog->dialog_user = null; $dialog->dialog_user = null;
$dialog->group_info = null;
switch ($dialog->type) { switch ($dialog->type) {
case "user": case "user":
$dialog_user = $builder->where('userid', '!=', $userid)->first(); $dialog_user = $builder->where('userid', '!=', $userid)->first();
@ -60,9 +61,11 @@ class WebSocketDialog extends AbstractModel
break; break;
case "group": case "group":
if ($dialog->group_type === 'project') { if ($dialog->group_type === 'project') {
$dialog->name = Project::whereDialogId($dialog->id)->value('name'); $dialog->group_info = Project::select(['id', 'name'])->whereDialogId($dialog->id)->first();
$dialog->name = $dialog->group_info ? $dialog->group_info->name : '';
} elseif ($dialog->group_type === 'task') { } elseif ($dialog->group_type === 'task') {
$dialog->name = ProjectTask::whereDialogId($dialog->id)->value('name'); $dialog->group_info = ProjectTask::select(['id', 'name'])->whereDialogId($dialog->id)->first();
$dialog->name = $dialog->group_info ? $dialog->group_info->name : '';
} }
break; break;
} }

View File

@ -6,9 +6,19 @@
@dragleave.prevent="chatDragOver(false, $event)"> @dragleave.prevent="chatDragOver(false, $event)">
<slot name="head"> <slot name="head">
<div class="dialog-title"> <div class="dialog-title">
<div class="main-title">
<h2>{{dialogDetail.name}}</h2> <h2>{{dialogDetail.name}}</h2>
<em v-if="peopleNum > 0">({{peopleNum}})</em> <em v-if="peopleNum > 0">({{peopleNum}})</em>
</div> </div>
<template v-if="dialogDetail.type === 'group'">
<div v-if="dialogDetail.group_type === 'project'" class="sub-title pointer" @click="openProject">
{{$L('项目聊天室')}} {{$L('打开项目管理')}}
</div>
<div v-else-if="dialogDetail.group_type === 'task'" class="sub-title pointer" @click="openTask">
{{$L('任务聊天室')}} {{$L('查看任务详情')}}
</div>
</template>
</div>
</slot> </slot>
<ScrollerY <ScrollerY
ref="scroller" ref="scroller"
@ -267,6 +277,23 @@ export default {
} }
return string || ''; return string || '';
}, },
openProject() {
if (!this.dialogDetail.group_info) {
return;
}
this.goForward({path: '/manage/project/' + this.dialogDetail.group_info.id});
},
openTask() {
if (!this.dialogDetail.group_info) {
return;
}
this.$store.dispatch("openTask", {
id: this.dialogDetail.group_info.id,
dialog_id: this.dialogDetail.id
});
},
} }
} }
</script> </script>

View File

@ -49,14 +49,13 @@
</div> </div>
</div> </div>
<div class="messenger-msg"> <div class="messenger-msg" @click="scrollIntoActive">
<DialogWrapper v-if="dialogId > 0" @on-focus="scrollIntoActive"/> <DialogWrapper v-if="dialogId > 0"/>
<div v-else class="dialog-no"> <div v-else class="dialog-no">
<div class="dialog-no-icon"><Icon type="ios-chatbubbles" /></div> <div class="dialog-no-icon"><Icon type="ios-chatbubbles" /></div>
<div class="dialog-no-text">{{$L('选择一个会话开始聊天')}}</div> <div class="dialog-no-text">{{$L('选择一个会话开始聊天')}}</div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</template> </template>
@ -140,6 +139,7 @@ export default {
openContacts(user) { openContacts(user) {
this.$store.dispatch("openDialogUserid", user.userid); this.$store.dispatch("openDialogUserid", user.userid);
this.tabActive = 'dialog'; this.tabActive = 'dialog';
this.scrollIntoActive();
}, },
getContactsList() { getContactsList() {
@ -219,7 +219,7 @@ export default {
let active = this.$refs.list.querySelector(".active") let active = this.$refs.list.querySelector(".active")
if (active) { if (active) {
scrollIntoView(active, { scrollIntoView(active, {
behavior: 'smooth', behavior: 'instant',
scrollMode: 'if-needed', scrollMode: 'if-needed',
}); });
} }

View File

@ -510,26 +510,25 @@ export default {
if (state.projectChatShow) { if (state.projectChatShow) {
dispatch("toggleBoolean", "projectChatShow"); dispatch("toggleBoolean", "projectChatShow");
} }
state.dialogId = 0;
// //
let data = {id: task_id}; let data = state.method.isJson(task_id) ? task_id : {id: task_id};
state.projectDetail.project_column.some(({project_task}) => { state.projectDetail.project_column.some(({project_task}) => {
const task = project_task.find(({id}) => id === task_id); const task = project_task.find(({id}) => id === data.id);
if (task) { if (task) {
data = Object.assign(data, task); data = Object.assign(data, task);
return true return true
} }
}); });
// //
data.content = state.projectTaskContent[task_id] || "" data.content = state.projectTaskContent[data.id] || ""
data.files = state.projectTaskFiles[task_id] || [] data.files = state.projectTaskFiles[data.id] || []
data.sub_task = state.projectSubTask[task_id] || [] data.sub_task = state.projectSubTask[data.id] || []
// //
state.projectOpenTask = Object.assign({}, data, {_show: true}); state.projectOpenTask = Object.assign({}, data, {_show: true});
dispatch("getTaskOne", task_id); dispatch("getTaskOne", data.id);
dispatch("getTaskContent", task_id); dispatch("getTaskContent", data.id);
dispatch("getTaskFiles", task_id); dispatch("getTaskFiles", data.id);
dispatch("getSubTask", task_id); dispatch("getSubTask", data.id);
}, },
/** /**

View File

@ -9,10 +9,25 @@
background-color: #ffffff; background-color: #ffffff;
z-index: 1; z-index: 1;
.dialog-title { .dialog-title {
display: flex;
flex-direction: column;
justify-content: center;
padding: 0 30px;
height: 68px;
position: relative;
&:after {
content: "";
position: absolute;
left: 0;
bottom: 0;
width: 100%;
height: 1px;
background-color: #f2f2f2;
}
.main-title {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 32px; line-height: 22px;
margin-top: 20px;
> h2 { > h2 {
font-size: 18px; font-size: 18px;
font-weight: 600; font-weight: 600;
@ -24,11 +39,24 @@
padding-left: 6px; padding-left: 6px;
} }
} }
.sub-title {
flex-shrink: 0;
font-size: 12px;
line-height: 20px;
margin-top: 2px;
color: #aaaaaa;
&.pointer {
cursor: pointer;
&:hover {
color: #888888;
}
}
}
}
.dialog-scroller { .dialog-scroller {
position: relative; position: relative;
flex: 1; flex: 1;
padding: 0 32px; padding: 0 32px;
margin-top: 18px;
overflow: auto; overflow: auto;
.dialog-list { .dialog-list {
> ul { > ul {
@ -38,6 +66,9 @@
align-items: flex-end; align-items: flex-end;
list-style: none; list-style: none;
margin-bottom: 16px; margin-bottom: 16px;
&:first-child {
margin-top: 16px;
}
.dialog-avatar { .dialog-avatar {
position: relative; position: relative;
margin-bottom: 20px; margin-bottom: 20px;

View File

@ -94,6 +94,7 @@
} }
.dialog-box { .dialog-box {
flex: 1; flex: 1;
width: 0;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
padding-left: 12px; padding-left: 12px;