Commit 76c7b004 by 杨铁龙
parents 38e7a3b5 7d6bb058
...@@ -15,17 +15,18 @@ ...@@ -15,17 +15,18 @@
</template> </template>
</div> </div>
<div class="title-buttons"> <div class="title-buttons">
<el-button class="button" @click="startReception" round v-if="!isChatMember" <el-button class="button" @click="startReception" round v-if="!isChatMember"
>开始接待</el-button >开始接待</el-button
> >
<el-button class="button" @click="finishReception" round v-if="isChatMember" <el-button class="button" @click="exitChat" round v-if="isChatMember"
>结束接待</el-button >退出会话</el-button
> >
<el-button class="button" @click="terminate" round <el-button class="button" @click="finishReception" round v-if="isChatMember && operatorType > 25"
>结束会话</el-button >结束接待</el-button
> >
<el-button class="button" @click="showAddMember" round <el-button class="button" @click="showAddMember" round
>添加成员</el-button >添加客服</el-button
> >
<i v-if="close && isSingleChat" @click="close" class="title-close el-icon-close" /> <i v-if="close && isSingleChat" @click="close" class="title-close el-icon-close" />
</div> </div>
...@@ -56,11 +57,8 @@ export default class ChatTitle extends Vue { ...@@ -56,11 +57,8 @@ export default class ChatTitle extends Vue {
@chatStore.State(ChatStore.STATE_CHAT_DIALOG_IS_SINGLE) @chatStore.State(ChatStore.STATE_CHAT_DIALOG_IS_SINGLE)
private readonly isSingleChat: ChatStore.STATE_CHAT_DIALOG_IS_SINGLE; private readonly isSingleChat: ChatStore.STATE_CHAT_DIALOG_IS_SINGLE;
@chatStore.Action(ChatStore.ACTION_TERINATE_CHAT) @chatStore.Action(ChatStore.ACTION_CHAT_ADD_CS)
private readonly _terminate!: ChatStore.ACTION_TERINATE_CHAT; private readonly _addCS!: ChatStore.ACTION_CHAT_ADD_CS;
@chatStore.Action(ChatStore.ACTION_CHAT_ADD_MEMBERS)
private readonly _addMember!: ChatStore.ACTION_CHAT_ADD_MEMBERS;
@chatStore.Action(ChatStore.ACTION_CHAT_START_RECEPTION) @chatStore.Action(ChatStore.ACTION_CHAT_START_RECEPTION)
private readonly _startReception!: ChatStore.ACTION_CHAT_START_RECEPTION; private readonly _startReception!: ChatStore.ACTION_CHAT_START_RECEPTION;
...@@ -68,12 +66,21 @@ export default class ChatTitle extends Vue { ...@@ -68,12 +66,21 @@ export default class ChatTitle extends Vue {
@chatStore.Action(ChatStore.ACTION_CHAT_FINISH_RECEPTION) @chatStore.Action(ChatStore.ACTION_CHAT_FINISH_RECEPTION)
private readonly _finishReception!: ChatStore.ACTION_CHAT_FINISH_RECEPTION; private readonly _finishReception!: ChatStore.ACTION_CHAT_FINISH_RECEPTION;
@chatStore.Action(ChatStore.ACTION_CHAT_USER_EXIT)
private readonly _userExitChat!: ChatStore.ACTION_CHAT_USER_EXIT;
@chatStore.Action(ChatStore.ACTION_CHAT_CS_EXIT)
private readonly _csExitChat!: ChatStore.ACTION_CHAT_CS_EXIT;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER)
private readonly isChatMember!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER; private readonly isChatMember!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_USER_UID) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_USER_UID)
private readonly operatorUid!: ChatStore.STATE_CHAT_CURRENT_USER_UID; private readonly operatorUid!: ChatStore.STATE_CHAT_CURRENT_USER_UID;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_USER_TYPE)
private readonly operatorType!: ChatStore.STATE_CHAT_CURRENT_USER_TYPE;
private get chatMembersId() { private get chatMembersId() {
return this.chatMembers.map((k) => +k.eid); return this.chatMembers.map((k) => +k.eid);
} }
...@@ -87,11 +94,6 @@ export default class ChatTitle extends Vue { ...@@ -87,11 +94,6 @@ export default class ChatTitle extends Vue {
@Prop({ type: Function }) @Prop({ type: Function })
private close?: () => void; private close?: () => void;
@buttonThrottle()
private terminate() {
this._terminate();
}
private showAddMember() { private showAddMember() {
this.visible = true; this.visible = true;
} }
...@@ -102,7 +104,7 @@ export default class ChatTitle extends Vue { ...@@ -102,7 +104,7 @@ export default class ChatTitle extends Vue {
private async addMember(users: string[], done: () => void) { private async addMember(users: string[], done: () => void) {
try { try {
await this._addMember(users); await this._addCS(users);
this.hideAddMember(); this.hideAddMember();
} catch (error) { } catch (error) {
console.error(error); console.error(error);
...@@ -111,21 +113,34 @@ export default class ChatTitle extends Vue { ...@@ -111,21 +113,34 @@ export default class ChatTitle extends Vue {
} }
} }
private async startReception() { private async exitChat() {
try { try {
await this._startReception(); if (this.operatorType == '25') {
await this._userExitChat();
} else if (+this.operatorType > 25){
await this._csExitChat();
}
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
} }
private async finishReception() { private async startReception() {
try { try {
await this._finishReception(); await this._startReception();
} catch (error) { } catch (error) {
console.error(error); console.error(error);
} }
} }
private async finishReception() {
await this.$confirm("确定要结束接待吗?结束接待将会终止客服会话", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
})
await this._finishReception();
}
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -63,9 +63,6 @@ type User = { ...@@ -63,9 +63,6 @@ type User = {
type ThenArg<T> = T extends PromiseLike<infer U> ? U : T; type ThenArg<T> = T extends PromiseLike<infer U> ? U : T;
@Component({ components: { avatar } }) @Component({ components: { avatar } })
export default class ChatCreator extends Vue { export default class ChatCreator extends Vue {
@chatStore.Action(ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN)
private readonly _createChat!: ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN;
@Prop({ @Prop({
type: Array, type: Array,
default: () => [], default: () => [],
......
...@@ -87,6 +87,7 @@ export default { ...@@ -87,6 +87,7 @@ export default {
[ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]: () => true, [ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]: () => true,
[ChatStore.STATE_CURRENT_CHAT_INPUTING]: [], [ChatStore.STATE_CURRENT_CHAT_INPUTING]: [],
[ChatStore.STATE_CURRENT_CHAT_INITING]: false, [ChatStore.STATE_CURRENT_CHAT_INITING]: false,
[ChatStore.STATE_CHAT_CURRENT_USER_TYPE]: ChatStore.STATE_CHAT_CURRENT_USER_TYPE,
}), }),
mutations: { mutations: {
[ChatStore.MUTATION_SHOW_CHAT](state, isSingle?: boolean) { [ChatStore.MUTATION_SHOW_CHAT](state, isSingle?: boolean) {
...@@ -293,6 +294,9 @@ export default { ...@@ -293,6 +294,9 @@ export default {
[ChatStore.MUTATION_SET_CURRENT_USER_UID]: (state, v: number) => { [ChatStore.MUTATION_SET_CURRENT_USER_UID]: (state, v: number) => {
state[ChatStore.STATE_CHAT_CURRENT_USER_UID] = v; state[ChatStore.STATE_CHAT_CURRENT_USER_UID] = v;
}, },
[ChatStore.MUTATION_CHAT_UPDATE_USER_TYPE]: (state, v: string) => {
state[ChatStore.STATE_CHAT_CURRENT_USER_TYPE] = v;
},
}, },
actions: { actions: {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ async [ChatStore.ACTION_GET_MY_CHAT_LIST]({
...@@ -436,7 +440,7 @@ export default { ...@@ -436,7 +440,7 @@ export default {
const { id, ImChatId, uniplat_version } = await sdk() const { id, ImChatId, uniplat_version } = await sdk()
.model(params.modelName) .model(params.modelName)
.chat(+params.selectedListId, orgId()) .chat(+params.selectedListId, orgId())
.createChat(); .createChat(true);
const uniplatId = id.value; const uniplatId = id.value;
const chatId = Number(ImChatId.value); const chatId = Number(ImChatId.value);
const v = uniplat_version.value; const v = uniplat_version.value;
...@@ -593,10 +597,13 @@ export default { ...@@ -593,10 +597,13 @@ export default {
}) })
); );
newChatMembers = newChatMembers.filter(it => !it.is_exited) newChatMembers = newChatMembers.filter(it => !it.is_exited)
if (newChatMembers.findIndex(it => it.eid === String(state[ChatStore.STATE_CHAT_CURRENT_USER_UID])) > -1) { const member = newChatMembers.find(it => it.eid === String(state[ChatStore.STATE_CHAT_CURRENT_USER_UID]))
if (member) {
commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, true); commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, true);
commit(ChatStore.MUTATION_CHAT_UPDATE_USER_TYPE, member.type)
} else { } else {
commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, false); commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, false);
commit(ChatStore.MUTATION_CHAT_UPDATE_USER_TYPE, "0")
} }
commit( commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS, ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
...@@ -661,6 +668,38 @@ export default { ...@@ -661,6 +668,38 @@ export default {
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS); await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}, },
async [ChatStore.ACTION_CHAT_USER_EXIT](
{ getters, dispatch }
) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return;
if (obj_id == null) return;
await sdk()
.model(model_name)
.chat(obj_id, orgId())
.userExitChat();
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
async [ChatStore.ACTION_CHAT_CS_EXIT](
{ getters, dispatch }
) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return;
if (obj_id == null) return;
await sdk()
.model(model_name)
.chat(obj_id, orgId())
.csExitChat();
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
async [ChatStore.ACTION_CHAT_ADD_MEMBERS]( async [ChatStore.ACTION_CHAT_ADD_MEMBERS](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
...@@ -694,6 +733,24 @@ export default { ...@@ -694,6 +733,24 @@ export default {
await new Promise((resolve) => setTimeout(resolve, 500)); await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS); await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
}, },
async [ChatStore.ACTION_CHAT_ADD_CS](
{ getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_CS>[0]
) {
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
console.log(currentChat)
if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return;
if (obj_id == null) return;
await sdk()
.model(model_name)
.chat(obj_id, orgId())
.addCs(uids.map((id) => Number(id)));
await new Promise((resolve) => setTimeout(resolve, 500));
await dispatch(ChatStore.ACTION_GET_CHAT_MEMBERS);
},
async [ChatStore.ACTION_CHAT_REMOVE_CS]( async [ChatStore.ACTION_CHAT_REMOVE_CS](
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0] uids: Parameters<ChatStore.ACTION_CHAT_REMOVE_CS>[0]
......
...@@ -40,6 +40,8 @@ export namespace ChatStore { ...@@ -40,6 +40,8 @@ export namespace ChatStore {
export type STATE_CHAT_CURRENT_IS_CHAT_MEMBER = boolean export type STATE_CHAT_CURRENT_IS_CHAT_MEMBER = boolean
export const STATE_CHAT_CURRENT_USER_UID = "用户的UiplatId"; export const STATE_CHAT_CURRENT_USER_UID = "用户的UiplatId";
export type STATE_CHAT_CURRENT_USER_UID = number | null export type STATE_CHAT_CURRENT_USER_UID = number | null
export const STATE_CHAT_CURRENT_USER_TYPE = "当前用户类型状态,25-普通用户,92-客服";
export type STATE_CHAT_CURRENT_USER_TYPE = string | null
export const STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID = "当前chat的Uniplat id"; export const STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID = "当前chat的Uniplat id";
export type STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID = string | null export type STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID = string | null
...@@ -205,6 +207,9 @@ export namespace ChatStore { ...@@ -205,6 +207,9 @@ export namespace ChatStore {
export const MUTATION_CHAT_UPDATE_IS_MEMBER = "更新是否是当前成员"; export const MUTATION_CHAT_UPDATE_IS_MEMBER = "更新是否是当前成员";
export type MUTATION_CHAT_UPDATE_IS_MEMBER = (v: boolean) => Promise<void> export type MUTATION_CHAT_UPDATE_IS_MEMBER = (v: boolean) => Promise<void>
export const MUTATION_CHAT_UPDATE_USER_TYPE = "更新当前用户的类型";
export type MUTATION_CHAT_UPDATE_USER_TYPE = (v: string) => Promise<void>
/* action */ /* action */
export const ACTION_GET_MY_CHAT_LIST = "获取我的会话列表"; export const ACTION_GET_MY_CHAT_LIST = "获取我的会话列表";
export type ACTION_GET_MY_CHAT_LIST = (keyword?: string) => void export type ACTION_GET_MY_CHAT_LIST = (keyword?: string) => void
...@@ -276,6 +281,8 @@ export namespace ChatStore { ...@@ -276,6 +281,8 @@ export namespace ChatStore {
export type ACTION_CHAT_ADD_MEMBERS = (uids: string[]) => Promise<void> export type ACTION_CHAT_ADD_MEMBERS = (uids: string[]) => Promise<void>
export const ACTION_CHAT_REMOVE_MEMBER = "移除成员"; export const ACTION_CHAT_REMOVE_MEMBER = "移除成员";
export type ACTION_CHAT_REMOVE_MEMBER = (uids: string[]) => Promise<void> export type ACTION_CHAT_REMOVE_MEMBER = (uids: string[]) => Promise<void>
export const ACTION_CHAT_ADD_CS = "添加客服";
export type ACTION_CHAT_ADD_CS = (uids: string[]) => Promise<void>
export const ACTION_CHAT_START_RECEPTION = "开始接待"; export const ACTION_CHAT_START_RECEPTION = "开始接待";
export type ACTION_CHAT_START_RECEPTION = () => Promise<void> export type ACTION_CHAT_START_RECEPTION = () => Promise<void>
...@@ -285,6 +292,12 @@ export namespace ChatStore { ...@@ -285,6 +292,12 @@ export namespace ChatStore {
export const ACTION_CHAT_REMOVE_CS = "移除客服"; export const ACTION_CHAT_REMOVE_CS = "移除客服";
export type ACTION_CHAT_REMOVE_CS = (uids: string[]) => Promise<void> export type ACTION_CHAT_REMOVE_CS = (uids: string[]) => Promise<void>
export const ACTION_CHAT_USER_EXIT = "普通用户退出";
export type ACTION_CHAT_USER_EXIT = () => Promise<void>
export const ACTION_CHAT_CS_EXIT = "客服退出";
export type ACTION_CHAT_CS_EXIT = () => Promise<void>
} }
export interface ChatStoreState { export interface ChatStoreState {
...@@ -307,6 +320,7 @@ export interface ChatStoreState { ...@@ -307,6 +320,7 @@ export interface ChatStoreState {
[ChatStore.STATE_SINGLE_CHAT]: ChatStore.STATE_SINGLE_CHAT [ChatStore.STATE_SINGLE_CHAT]: ChatStore.STATE_SINGLE_CHAT
[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER [ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER
[ChatStore.STATE_CHAT_CURRENT_USER_UID]: ChatStore.STATE_CHAT_CURRENT_USER_UID [ChatStore.STATE_CHAT_CURRENT_USER_UID]: ChatStore.STATE_CHAT_CURRENT_USER_UID
[ChatStore.STATE_CHAT_CURRENT_USER_TYPE]: ChatStore.STATE_CHAT_CURRENT_USER_TYPE
} }
export const chatStore = namespace(ChatStore.ns); export const chatStore = namespace(ChatStore.ns);
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