Commit ef633167 by zhousil

withdraw controll

parent 830cf5ea
Showing with 74 additions and 48 deletions
...@@ -16,32 +16,58 @@ ...@@ -16,32 +16,58 @@
> >
{{ isQuestionAnswerMessage ? "" : userName }} {{ isQuestionAnswerMessage ? "" : userName }}
</div> </div>
<div <div class="d-flex">
class="content-avatar d-flex align-items-start" <template
:class="{ v-if="backend && showReadSummary && !isWithdrawMessage"
'justify-content-end': isMyMessage, >
'cs-flex-direction': !isMyMessage, <div v-if="isMyMessage" class="msg-read pos-rel">
}" <span
> @click="openReaderList"
<component class="pointer"
:is="messageComponent" :class="{ all: isAllRead }"
:user-name="userName" >
<template v-if="isAllRead">全部已读</template>
<template v-else-if="data.read_count > 0"
>{{ data.read_count }}人已读</template
>
<template v-else>未读</template>
</span>
<who-read-list
v-if="readListVisibility"
@blur="readListVisibility = false"
:msgId="data.id"
:class="{ offset: readerListOffset }"
/>
</div>
</template>
<div
class="content-avatar d-flex align-items-start"
:class="{ :class="{
'my-message': isMyMessage, 'justify-content-end': isMyMessage,
'cs-flex-direction': !isMyMessage,
}" }"
v-if="messageComponent" >
v-model="data" <component
@open="openFile" :is="messageComponent"
/> :user-name="userName"
<avatar :class="{
v-if="!isQuestionAnswerMessage && !isWithdrawMessage" 'my-message': isMyMessage,
:src=" }"
chatRole === 'admin' || chatRole === 'customer-service' v-if="messageComponent"
? defaultAvatar v-model="data"
: avatar @open="openFile"
" />
shape="circle" <avatar
/> v-if="!isQuestionAnswerMessage && !isWithdrawMessage"
:src="
chatRole === 'admin' ||
chatRole === 'customer-service'
? defaultAvatar
: avatar
"
shape="circle"
/>
</div>
</div> </div>
</div> </div>
...@@ -52,36 +78,17 @@ ...@@ -52,36 +78,17 @@
></i> ></i>
<i class="el-icon-loading" v-else-if="isSendingMessage"></i> <i class="el-icon-loading" v-else-if="isSendingMessage"></i>
<template v-if="backend && showReadSummary && !isWithdrawMessage">
<div v-if="isMyMessage" class="msg-read pos-rel">
<span
@click="openReaderList"
class="pointer"
:class="{ all: isAllRead }"
>
<template v-if="isAllRead">全部已读</template>
<template v-else-if="data.read_count > 0"
>{{ data.read_count }}人已读</template
>
<template v-else>未读</template>
</span>
<who-read-list
v-if="readListVisibility"
@blur="readListVisibility = false"
:msgId="data.id"
:class="{ offset: readerListOffset }"
/>
</div>
</template>
<span <span
class="withdraw" class="withdraw"
v-if=" v-if="
isMyMessage && isMyMessage &&
canWithdraw && canWithdraw &&
isWithdraw &&
!isWithdrawMessage && !isWithdrawMessage &&
!isQuestionAnswerMessage !isQuestionAnswerMessage &&
!isChatMember
" "
@mouseenter="hoverWithdraw"
@click="withdraw" @click="withdraw"
>撤回此消息</span >撤回此消息</span
> >
...@@ -147,6 +154,7 @@ ...@@ -147,6 +154,7 @@
import xim from "./../xim"; import xim from "./../xim";
import { ChatRole } from "@/customer-service/model"; import { ChatRole } from "@/customer-service/model";
import { getUserMapping } from "../utils/user-info"; import { getUserMapping } from "../utils/user-info";
import Xim from "@/customer-service/xim";
const twoMinutes = 2 * 60 * 1000; const twoMinutes = 2 * 60 * 1000;
...@@ -202,6 +210,9 @@ ...@@ -202,6 +210,9 @@
@chatStore.Getter(ChatStore.GETTER_CURRENT_CURRENT_CHAT) @chatStore.Getter(ChatStore.GETTER_CURRENT_CURRENT_CHAT)
private readonly currentChat!: ChatStore.GETTER_CURRENT_CURRENT_CHAT; private readonly currentChat!: ChatStore.GETTER_CURRENT_CURRENT_CHAT;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER)
private readonly isChatMember!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER;
@Prop({ type: Object, default: () => Object.create(null) }) @Prop({ type: Object, default: () => Object.create(null) })
private readonly data!: dto.Message; private readonly data!: dto.Message;
...@@ -227,6 +238,11 @@ ...@@ -227,6 +238,11 @@
private readerListOffset = false; private readerListOffset = false;
private defaultMessageHandledStatus = dto.MessageHandled.Default; private defaultMessageHandledStatus = dto.MessageHandled.Default;
private isWithdraw = true;
private overTwoMinutes =
new Date().valueOf() - this.data.ts * 1000 < twoMinutes;
private get canWithdraw() { private get canWithdraw() {
if (this.backend && this.data) { if (this.backend && this.data) {
return new Date().valueOf() - this.data.ts * 1000 < twoMinutes; return new Date().valueOf() - this.data.ts * 1000 < twoMinutes;
...@@ -297,7 +313,8 @@ ...@@ -297,7 +313,8 @@
private getFilterUsername(name: string) { private getFilterUsername(name: string) {
if ( if (
this.currentChat && this.currentChat.catalog === "福利宝" && this.currentChat &&
this.currentChat.catalog === "福利宝" &&
this.chatRole === "customer-service" this.chatRole === "customer-service"
) { ) {
return `采购顾问 ${name}`; return `采购顾问 ${name}`;
...@@ -398,6 +415,10 @@ ...@@ -398,6 +415,10 @@
} }
private withdraw() { private withdraw() {
if (new Date().valueOf() - this.data.ts * 1000 > twoMinutes) {
Xim.error("超过两分钟的消息不能撤回");
return;
}
ximInstance.withdraw(this.chatId!, this.data.id).finally(() => { ximInstance.withdraw(this.chatId!, this.data.id).finally(() => {
dbController dbController
.removeMessage(this.chatId!, this.data.id) .removeMessage(this.chatId!, this.data.id)
...@@ -408,6 +429,11 @@ ...@@ -408,6 +429,11 @@
}); });
} }
private hoverWithdraw() {
this.isWithdraw =
new Date().valueOf() - this.data.ts * 1000 < twoMinutes;
}
private openReaderList(e: MouseEvent) { private openReaderList(e: MouseEvent) {
this.readerListOffset = e.x < 450; this.readerListOffset = e.x < 450;
this.readListVisibility = true; this.readListVisibility = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment