Commit dcd1fd2f by 吴云建

会话阶段提交

parent b1023188
<template> <template>
<div class="chat-con" :class="{ userMode }"> <div class="chat-con" :class="{ userMode }">
<ChatTitle :close="hide" class="chat-title" /> <ChatTitle :close="hide" class="chat-title" />
<div class="chat-area-con"> <div class="chat-area-con" :class="{isSingle: isSingleChat}">
<div v-if="chatId != null" class="h-100 chat-area"> <div v-if="chatId != null" class="h-100 chat-area">
<chat-room /> <chat-room />
</div> </div>
...@@ -30,6 +30,7 @@ ...@@ -30,6 +30,7 @@
</el-tab-pane> </el-tab-pane>
<el-tab-pane class="h-100" label="备注" name="four"> <el-tab-pane class="h-100" label="备注" name="four">
<remarkList <remarkList
:isInSmallPage="true"
:modelName="currentChat.business_data.model_name" :modelName="currentChat.business_data.model_name"
:associateId="currentChat.business_data.obj_id" :associateId="currentChat.business_data.obj_id"
/> />
...@@ -48,9 +49,7 @@ ...@@ -48,9 +49,7 @@
</template> </template>
<script lang="ts"> <script lang="ts">
import { Component, Vue } from "vue-property-decorator"; import { Component, Vue } from "vue-property-decorator";
import remarkList from "../components/common/remarkList.vue"; import remarkList from "../components/common/remarkList.vue";
import ChatMembers from "./components/chat-members.vue"; import ChatMembers from "./components/chat-members.vue";
import ChatRoom from "./components/chat-room.vue"; import ChatRoom from "./components/chat-room.vue";
import ChatTitle from "./components/chat-title.vue"; import ChatTitle from "./components/chat-title.vue";
...@@ -84,6 +83,9 @@ export default class Chat extends Vue { ...@@ -84,6 +83,9 @@ export default class Chat extends Vue {
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_CHAT_ID) @chatStore.State(ChatStore.STATE_CHAT_CURRENT_CHAT_ID)
private readonly chatId!: ChatStore.STATE_CHAT_CURRENT_CHAT_ID; private readonly chatId!: ChatStore.STATE_CHAT_CURRENT_CHAT_ID;
@chatStore.State(ChatStore.STATE_CHAT_DIALOG_IS_SINGLE)
private readonly isSingleChat: ChatStore.STATE_CHAT_DIALOG_IS_SINGLE;
@chatStore.Mutation(ChatStore.MUTATION_HIDE_CHAT) @chatStore.Mutation(ChatStore.MUTATION_HIDE_CHAT)
private readonly hide!: ChatStore.MUTATION_HIDE_CHAT; private readonly hide!: ChatStore.MUTATION_HIDE_CHAT;
...@@ -112,6 +114,9 @@ export default class Chat extends Vue { ...@@ -112,6 +114,9 @@ export default class Chat extends Vue {
<style lang="less" scoped> <style lang="less" scoped>
.chat-area-con { .chat-area-con {
height: calc(100% - 60px); height: calc(100% - 60px);
&.isSingle {
height: 70vh;
}
} }
.chat-con { .chat-con {
height: 100%; height: 100%;
......
...@@ -31,6 +31,9 @@ export default class ChatMembers extends Vue { ...@@ -31,6 +31,9 @@ export default class ChatMembers extends Vue {
@chatStore.Action(ChatStore.ACTION_CHAT_REMOVE_MEMBER) @chatStore.Action(ChatStore.ACTION_CHAT_REMOVE_MEMBER)
private readonly _getout!: ChatStore.ACTION_CHAT_REMOVE_MEMBER; private readonly _getout!: ChatStore.ACTION_CHAT_REMOVE_MEMBER;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER)
private readonly isChatMember!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER;
private async getout(item: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS[number]) { private async getout(item: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS[number]) {
await this.$confirm(`确定要移除${item.name}?`, "提示", { await this.$confirm(`确定要移除${item.name}?`, "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<div class="chat-panel"> <div class="chat-panel">
<div class="chat-area h-100"> <div class="chat-area h-100">
<template v-if="notOnlyCheck"> <template v-if="notOnlyCheck">
<div class="chat-messages pos-rel"> <div class="chat-messages pos-rel" :class="{'is-not-chat-member': !isChatMember}">
<div <div
v-if="getCurrentInputingPeople.length" v-if="getCurrentInputingPeople.length"
class="someone-inputing" class="someone-inputing"
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
</div> </div>
<messages /> <messages />
</div> </div>
<div class="chat-input"> <div class="chat-input" v-if="isChatMember">
<message-input @error="onError" /> <message-input @error="onError" />
</div> </div>
</template> </template>
...@@ -60,6 +60,9 @@ export default class ChatRoom extends Vue { ...@@ -60,6 +60,9 @@ export default class ChatRoom extends Vue {
@chatStore.State(ChatStore.STATE_MY_CHAT_ROOM_LIST) @chatStore.State(ChatStore.STATE_MY_CHAT_ROOM_LIST)
private readonly myChatList!: ChatStore.STATE_MY_CHAT_ROOM_LIST; private readonly myChatList!: ChatStore.STATE_MY_CHAT_ROOM_LIST;
@chatStore.State(ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER)
private readonly isChatMember!: ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER;
private allChatList = { list: [] }; private allChatList = { list: [] };
@Prop({ type: Function }) @Prop({ type: Function })
...@@ -165,6 +168,10 @@ export default class ChatRoom extends Vue { ...@@ -165,6 +168,10 @@ export default class ChatRoom extends Vue {
.chat-messages { .chat-messages {
height: calc(100% - 130px + 1px); height: calc(100% - 130px + 1px);
border-bottom: 1px solid #e1e1e1; border-bottom: 1px solid #e1e1e1;
&.is-not-chat-member {
height: 100%;
border-bottom: none;
}
} }
.chat-input { .chat-input {
......
...@@ -17,13 +17,16 @@ ...@@ -17,13 +17,16 @@
<div class="title-buttons"> <div class="title-buttons">
<!-- <el-button class="button" round>开始接待</el-button> <!-- <el-button class="button" round>开始接待</el-button>
<el-button class="button" round>结束接待</el-button> --> <el-button class="button" round>结束接待</el-button> -->
<el-button class="button" @click="addMemberForMyself" round v-if="!isChatMember"
>加入会话</el-button
>
<el-button class="button" @click="terminate" round <el-button class="button" @click="terminate" round
>结束会话</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" @click="close" class="title-close el-icon-close" /> --> <i v-if="close && isSingleChat" @click="close" class="title-close el-icon-close" />
</div> </div>
<ChatCreator <ChatCreator
v-if="visible" v-if="visible"
...@@ -49,12 +52,21 @@ export default class ChatTitle extends Vue { ...@@ -49,12 +52,21 @@ export default class ChatTitle extends Vue {
@chatStore.State(ChatStore.STATE_CURRENT_CHAT_TITLE) @chatStore.State(ChatStore.STATE_CURRENT_CHAT_TITLE)
private readonly chatTitle!: ChatStore.STATE_CURRENT_CHAT_TITLE; private readonly chatTitle!: ChatStore.STATE_CURRENT_CHAT_TITLE;
@chatStore.State(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_TERINATE_CHAT)
private readonly _terminate!: ChatStore.ACTION_TERINATE_CHAT; private readonly _terminate!: ChatStore.ACTION_TERINATE_CHAT;
@chatStore.Action(ChatStore.ACTION_CHAT_ADD_MEMBERS) @chatStore.Action(ChatStore.ACTION_CHAT_ADD_MEMBERS)
private readonly _addMember!: ChatStore.ACTION_CHAT_ADD_MEMBERS; private readonly _addMember!: ChatStore.ACTION_CHAT_ADD_MEMBERS;
@chatStore.State(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)
private readonly operatorUid!: ChatStore.STATE_CHAT_CURRENT_USER_UID;
private get chatMembersId() { private get chatMembersId() {
return this.chatMembers.map((k) => +k.eid); return this.chatMembers.map((k) => +k.eid);
} }
...@@ -91,6 +103,15 @@ export default class ChatTitle extends Vue { ...@@ -91,6 +103,15 @@ export default class ChatTitle extends Vue {
done(); done();
} }
} }
private async addMemberForMyself() {
try {
console.log("====>>>??")
await this._addMember([this.operatorUid.toString()]);
} catch (error) {
console.error(error);
}
}
} }
</script> </script>
<style lang="less" scoped> <style lang="less" scoped>
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<el-scrollbar class="workflow-scrollbar adjust-el-scroll-right-bar"> <el-scrollbar class="workflow-scrollbar adjust-el-scroll-right-bar">
<div <div
class="workflow pos-rel table" class="workflow pos-rel table"
v-for="item in mockData" v-for="item in flowList"
:key="item.id" :key="item.id"
> >
<span class="cell workflow-name"> <span class="cell workflow-name">
...@@ -105,172 +105,11 @@ export default class WorkFlow extends Vue { ...@@ -105,172 +105,11 @@ export default class WorkFlow extends Vue {
return WorkFlowStatus[status]; return WorkFlowStatus[status];
} }
private mockData = [ private flowList = [];
{
id: null,
associateId: 27,
processName: "333",
state: "无",
status: 0,
isComplete: null,
},
{
id: 51,
associateId: 27,
processName: "bug流程测试",
state: "4",
status: 1,
isComplete: 0,
},
{
id: 153,
associateId: 27,
processName: "工作流演示流程",
state: "待联系",
status: 1,
isComplete: 0,
},
{
id: 55,
associateId: 27,
processName: "工作流演示流程",
state: "已支付111",
status: 2,
isComplete: 1,
},
{
id: 56,
associateId: 27,
processName: "最新工作流程定义",
state: "商议阶段",
status: 1,
isComplete: 0,
},
{
id: 147,
associateId: 27,
processName: "测试流程2",
state: "状态1",
status: 1,
isComplete: 0,
},
{
id: 144,
associateId: 27,
processName: "测试流程2",
state: "终结状态",
status: 2,
isComplete: 1,
},
{
id: 146,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 145,
associateId: 27,
processName: "计划任务",
state: "处理中",
status: 1,
isComplete: 0,
},
{
id: 143,
associateId: 27,
processName: "计划任务",
state: "已取消",
status: 2,
isComplete: 1,
},
{
id: 142,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 131,
associateId: 27,
processName: "计划任务",
state: "处理中",
status: 1,
isComplete: 0,
},
{
id: 130,
associateId: 27,
processName: "计划任务",
state: "处理中",
status: 1,
isComplete: 0,
},
{
id: 129,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 128,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 126,
associateId: 27,
processName: "计划任务",
state: "已取消",
status: 2,
isComplete: 1,
},
{
id: 125,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 124,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 123,
associateId: 27,
processName: "计划任务",
state: "已完成",
status: 2,
isComplete: 1,
},
{
id: 155,
associateId: 27,
processName: "超管演示",
state: "状态1",
status: 1,
isComplete: 0,
},
];
public async created() { public async created() {
// const workflow = await sdk().model(this.model_name).workflow2().queryProcessByAssociateId(+this.id); this.flowList = await sdk().model(this.model_name).workflow2().queryProcessByAssociateId(+this.id);
// console.log("workflow", workflow); console.log("=======>>>>workflow", this.flowList);
} }
public start(workflow: any) { public start(workflow: any) {
......
...@@ -69,10 +69,14 @@ export default { ...@@ -69,10 +69,14 @@ export default {
namespaced: true, namespaced: true,
state: () => ({ state: () => ({
[ChatStore.STATE_CHAT_DIALOG_VISIBLE]: false, [ChatStore.STATE_CHAT_DIALOG_VISIBLE]: false,
[ChatStore.STATE_CHAT_DIALOG_IS_SINGLE]: false,
[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]: false,
[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]: null, [ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]: null,
[ChatStore.STATE_CHAT_CURRENT_USER_UID]: null,
[ChatStore.STATE_CHAT_MSG_HISTORY]: null, [ChatStore.STATE_CHAT_MSG_HISTORY]: null,
[ChatStore.STATE_CHAT_SENDING_MESSAGES]: [], [ChatStore.STATE_CHAT_SENDING_MESSAGES]: [],
[ChatStore.STATE_MY_CHAT_ROOM_LIST]: null, [ChatStore.STATE_MY_CHAT_ROOM_LIST]: null,
[ChatStore.STATE_SINGLE_CHAT]: null,
[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION]: null, [ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION]: null,
[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]: null, [ChatStore.STATE_CHAT_CURRENT_CHAT_ID]: null,
[ChatStore.STATE_CHAT_MY_ID]: null, [ChatStore.STATE_CHAT_MY_ID]: null,
...@@ -85,8 +89,9 @@ export default { ...@@ -85,8 +89,9 @@ export default {
[ChatStore.STATE_CURRENT_CHAT_INITING]: false, [ChatStore.STATE_CURRENT_CHAT_INITING]: false,
}), }),
mutations: { mutations: {
[ChatStore.MUTATION_SHOW_CHAT](state) { [ChatStore.MUTATION_SHOW_CHAT](state, isSingle?: boolean) {
state[ChatStore.STATE_CHAT_DIALOG_VISIBLE] = true; state[ChatStore.STATE_CHAT_DIALOG_VISIBLE] = true;
isSingle ? state[ChatStore.STATE_CHAT_DIALOG_IS_SINGLE] = true : state[ChatStore.STATE_CHAT_DIALOG_IS_SINGLE] = false;
}, },
[ChatStore.MUTATION_HIDE_CHAT](state) { [ChatStore.MUTATION_HIDE_CHAT](state) {
state[ChatStore.STATE_CHAT_DIALOG_VISIBLE] = false; state[ChatStore.STATE_CHAT_DIALOG_VISIBLE] = false;
...@@ -184,6 +189,14 @@ export default { ...@@ -184,6 +189,14 @@ export default {
[ChatStore.MUTATION_CLEAR_CHAT_TITLE](state) { [ChatStore.MUTATION_CLEAR_CHAT_TITLE](state) {
state[ChatStore.STATE_CURRENT_CHAT_TITLE] = ""; state[ChatStore.STATE_CURRENT_CHAT_TITLE] = "";
}, },
[ChatStore.MUTATION_SAVE_SINGLE_CHAT](state, v: ChatType) {
state[ChatStore.STATE_SINGLE_CHAT] = v;
},
[ChatStore.MUTATION_CLEAR_SINGLE_CHAT](state) {
state[ChatStore.STATE_SINGLE_CHAT] = null;
},
[ChatStore.MUTATION_SCROLL_TO_BOTTOM](state) { [ChatStore.MUTATION_SCROLL_TO_BOTTOM](state) {
state[ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM](); state[ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]();
}, },
...@@ -274,11 +287,21 @@ export default { ...@@ -274,11 +287,21 @@ export default {
[ChatStore.MUTATION_INITING_CHAT_DONE]: (state) => { [ChatStore.MUTATION_INITING_CHAT_DONE]: (state) => {
state[ChatStore.STATE_CURRENT_CHAT_INITING] = false; state[ChatStore.STATE_CURRENT_CHAT_INITING] = false;
}, },
[ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER]: (state, v: boolean) => {
state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER] = v;
},
[ChatStore.MUTATION_SET_CURRENT_USER_UID]: (state, v: number) => {
state[ChatStore.STATE_CHAT_CURRENT_USER_UID] = v;
},
}, },
actions: { actions: {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({ async [ChatStore.ACTION_GET_MY_CHAT_LIST]({
commit, commit,
}) /* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */ { }) /* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */ {
if (!this.state[ChatStore.STATE_CHAT_CURRENT_USER_UID]) {
const userInfo = await sdk().getUserInfo();
commit(ChatStore.MUTATION_SET_CURRENT_USER_UID, userInfo.id);
}
const data = await xim.fetchChatList(); const data = await xim.fetchChatList();
if (data == null) return; if (data == null) return;
const chatList = data.args[0]; const chatList = data.args[0];
...@@ -311,7 +334,7 @@ export default { ...@@ -311,7 +334,7 @@ export default {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return; if (chatId == null) return;
try { try {
const data = await xim.queryLastPageMsg(chatType, chatId, 20); const data = await xim.queryLastPageMsg(chatType, chatId, 20, !this.state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]);
commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data); commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data);
await preCacheImgs(data); await preCacheImgs(data);
commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM); commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM);
...@@ -331,7 +354,8 @@ export default { ...@@ -331,7 +354,8 @@ export default {
chatType, chatType,
chatId, chatId,
msgId, msgId,
10 10,
!this.state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]
); );
commit(ChatStore.MUTATION_UNSHIFT_CHAT_MSG_HISTORY, data); commit(ChatStore.MUTATION_UNSHIFT_CHAT_MSG_HISTORY, data);
return data; return data;
...@@ -346,7 +370,8 @@ export default { ...@@ -346,7 +370,8 @@ export default {
chatType, chatType,
chatId, chatId,
msgId, msgId,
10 10,
!this.state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]
); );
commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data); commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data);
return data; return data;
...@@ -407,7 +432,7 @@ export default { ...@@ -407,7 +432,7 @@ export default {
const chatId = Number(ImChatId.value); const chatId = Number(ImChatId.value);
const v = uniplat_version.value; const v = uniplat_version.value;
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
commit(ChatStore.MUTATION_SHOW_CHAT); commit(ChatStore.MUTATION_SHOW_CHAT, true);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, chatId); await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, chatId);
}, },
// async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE]( // async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE](
...@@ -473,16 +498,31 @@ export default { ...@@ -473,16 +498,31 @@ export default {
chatId: Parameters<ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION>[0] chatId: Parameters<ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION>[0]
) { ) {
const chatList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? []; const chatList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
if (chatList.length === 0) return; let wantedChatRoom = chatList.find(
const wantedChatRoom = chatList.find(
(k) => k.chat_id === chatId (k) => k.chat_id === chatId
); );
if (wantedChatRoom == null) return; if (wantedChatRoom == null || wantedChatRoom.business_data == null) {
if (wantedChatRoom.business_data == null) { const data = await xim.fetchChat(chatId);
return; let chat = data.args[0];
let business_data;
if (chat.business_data) {
business_data = JSON.parse(chat.business_data);
} }
if (business_data?.model_name == null) {
business_data = null;
}
wantedChatRoom = {
...chat,
chat_id: chat.id,
business_data,
} as ChatType;
commit(ChatStore.MUTATION_SAVE_SINGLE_CHAT, wantedChatRoom);
} else {
commit(ChatStore.MUTATION_CLEAR_SINGLE_CHAT);
}
console.log("============>>>", wantedChatRoom);
const info = await getChatModelInfo( const info = await getChatModelInfo(
wantedChatRoom.business_data.model_name, wantedChatRoom.business_data.model_name,
...@@ -518,7 +558,7 @@ export default { ...@@ -518,7 +558,7 @@ export default {
const getChatMembersResult = await xim.fetchChatMembers(chatId); const getChatMembersResult = await xim.fetchChatMembers(chatId);
if (getChatMembersResult == null) return; if (getChatMembersResult == null) return;
const chatMembers = getChatMembersResult.args[0] as ChatMember[]; const chatMembers = getChatMembersResult.args[0] as ChatMember[];
const newChatMembers = await Promise.all( let newChatMembers = await Promise.all(
chatMembers.map(async (member) => { chatMembers.map(async (member) => {
let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number]; let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number];
try { try {
...@@ -535,6 +575,12 @@ export default { ...@@ -535,6 +575,12 @@ export default {
return result; return result;
}) })
); );
newChatMembers = newChatMembers.filter(it => !it.is_exited)
if (newChatMembers.findIndex(it => it.eid == state[ChatStore.STATE_CHAT_CURRENT_USER_UID]) > -1) {
commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, true);
} else {
commit(ChatStore.MUTATION_CHAT_UPDATE_IS_MEMBER, false);
}
commit( commit(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS, ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) { unique(newChatMembers, function (item, all) {
...@@ -570,7 +616,9 @@ export default { ...@@ -570,7 +616,9 @@ export default {
{ getters, dispatch }, { getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0] uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
) { ) {
console.log("====123")
const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT]; const currentChat = getters[ChatStore.GETTER_CURRENT_CURRENT_CHAT];
console.log(currentChat)
if (currentChat == null) return; if (currentChat == null) return;
const { model_name, obj_id } = currentChat.business_data; const { model_name, obj_id } = currentChat.business_data;
if (model_name == null) return; if (model_name == null) return;
...@@ -622,6 +670,12 @@ export default { ...@@ -622,6 +670,12 @@ export default {
}, },
[ChatStore.GETTER_CURRENT_CURRENT_CHAT](state) { [ChatStore.GETTER_CURRENT_CURRENT_CHAT](state) {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]; const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
const singleChat = state[ChatStore.STATE_SINGLE_CHAT];
console.log("singleChat:", singleChat)
console.log("chatId", chatId)
if (singleChat && singleChat.chat_id == chatId) {
return singleChat;
}
const chatList = const chatList =
state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? []; state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
return chatList.find((chat) => chat.chat_id === chatId); return chatList.find((chat) => chat.chat_id === chatId);
......
...@@ -16,11 +16,15 @@ export namespace ChatStore { ...@@ -16,11 +16,15 @@ export namespace ChatStore {
/* state */ /* state */
export const STATE_CHAT_DIALOG_VISIBLE = "会话模块弹窗显示状态"; export const STATE_CHAT_DIALOG_VISIBLE = "会话模块弹窗显示状态";
export type STATE_CHAT_DIALOG_VISIBLE = boolean export type STATE_CHAT_DIALOG_VISIBLE = boolean
export const STATE_CHAT_DIALOG_IS_SINGLE = "会话模块是否是单个弹窗";
export type STATE_CHAT_DIALOG_IS_SINGLE = boolean
export const STATE_MY_CHAT_ROOM_LIST = "我的会话列表"; export const STATE_MY_CHAT_ROOM_LIST = "我的会话列表";
export type STATE_MY_CHAT_ROOM_LIST = { export type STATE_MY_CHAT_ROOM_LIST = {
list: ChatType[]; list: ChatType[];
total: number; total: number;
} | null } | null
export const STATE_SINGLE_CHAT = "单独的会话";
export type STATE_SINGLE_CHAT = ChatType | null
export const STATE_CHAT_MSG_HISTORY = "某个会话聊天记录"; export const STATE_CHAT_MSG_HISTORY = "某个会话聊天记录";
export type STATE_CHAT_MSG_HISTORY = dto.MessageRequestResult | null export type STATE_CHAT_MSG_HISTORY = dto.MessageRequestResult | null
...@@ -32,6 +36,10 @@ export namespace ChatStore { ...@@ -32,6 +36,10 @@ export namespace ChatStore {
export type STATE_CHAT_CURRENT_CHAT_ID = number | null export type STATE_CHAT_CURRENT_CHAT_ID = number | null
export const STATE_CHAT_CURRENT_CHAT_VERSION = "当前chat的Uniplat version"; export const STATE_CHAT_CURRENT_CHAT_VERSION = "当前chat的Uniplat version";
export type STATE_CHAT_CURRENT_CHAT_VERSION = number | null export type STATE_CHAT_CURRENT_CHAT_VERSION = number | null
export const STATE_CHAT_CURRENT_IS_CHAT_MEMBER = "是否是当前chat的成员";
export type STATE_CHAT_CURRENT_IS_CHAT_MEMBER = boolean
export const STATE_CHAT_CURRENT_USER_UID = "用户的UiplatId";
export type STATE_CHAT_CURRENT_USER_UID = number | 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
...@@ -103,6 +111,12 @@ export namespace ChatStore { ...@@ -103,6 +111,12 @@ export namespace ChatStore {
export const MUTATION_CLEAR_CHAT_MSG_HISTORY = "清空聊天记录"; export const MUTATION_CLEAR_CHAT_MSG_HISTORY = "清空聊天记录";
export type MUTATION_CLEAR_CHAT_MSG_HISTORY = () => void export type MUTATION_CLEAR_CHAT_MSG_HISTORY = () => void
export const MUTATION_SAVE_SINGLE_CHAT = "设置单独的会话";
export type MUTATION_SAVE_SINGLE_CHAT = (v: ChatType) => void
export const MUTATION_CLEAR_SINGLE_CHAT = "清空单独的会话";
export type MUTATION_CLEAR_SINGLE_CHAT = () => void
export const MUTATION_SAVE_CURRENT_CHAT_ID = "保存当前chat-id"; export const MUTATION_SAVE_CURRENT_CHAT_ID = "保存当前chat-id";
export type MUTATION_SAVE_CURRENT_CHAT_ID = ( export type MUTATION_SAVE_CURRENT_CHAT_ID = (
chatId: ChatStore.STATE_CHAT_CURRENT_CHAT_ID chatId: ChatStore.STATE_CHAT_CURRENT_CHAT_ID
...@@ -111,6 +125,9 @@ export namespace ChatStore { ...@@ -111,6 +125,9 @@ export namespace ChatStore {
export const MUTATION_CLEAR_CURRENT_CHAT_ID = "清空chat-id"; export const MUTATION_CLEAR_CURRENT_CHAT_ID = "清空chat-id";
export type MUTATION_CLEAR_CURRENT_CHAT_ID = () => void export type MUTATION_CLEAR_CURRENT_CHAT_ID = () => void
export const MUTATION_SET_CURRENT_USER_UID = "设置当前用户UniplatId";
export type MUTATION_SET_CURRENT_USER_UID = (v: number) => void
export const MUTATION_SAVE_CURRENT_CHAT_VERSION = export const MUTATION_SAVE_CURRENT_CHAT_VERSION =
"保存当前chat uniplat version"; "保存当前chat uniplat version";
export type MUTATION_SAVE_CURRENT_CHAT_VERSION = ( export type MUTATION_SAVE_CURRENT_CHAT_VERSION = (
...@@ -185,6 +202,9 @@ export namespace ChatStore { ...@@ -185,6 +202,9 @@ export namespace ChatStore {
export const MUTATION_CLEAR_CURRENT_CHAT_INPUTING = "清空正在输入"; export const MUTATION_CLEAR_CURRENT_CHAT_INPUTING = "清空正在输入";
export type MUTATION_CLEAR_CURRENT_CHAT_INPUTING = () => void export type MUTATION_CLEAR_CURRENT_CHAT_INPUTING = () => void
export const MUTATION_CHAT_UPDATE_IS_MEMBER = "更新是否是当前成员";
export type MUTATION_CHAT_UPDATE_IS_MEMBER = (v: boolean) => 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
......
...@@ -6,6 +6,7 @@ import chatType from "../xim/chat-type"; ...@@ -6,6 +6,7 @@ import chatType from "../xim/chat-type";
import { TokenStringGetter } from "./../model"; import { TokenStringGetter } from "./../model";
import { ChatLoggerService } from "./logger"; import { ChatLoggerService } from "./logger";
import { Message, NotifyMessage } from "./models/chat"; import { Message, NotifyMessage } from "./models/chat";
import chat from "./index";
wampDebug(true); wampDebug(true);
...@@ -109,6 +110,11 @@ export class Xim { ...@@ -109,6 +110,11 @@ export class Xim {
return this.client.fetchChatList({}); return this.client.fetchChatList({});
} }
public fetchChat(chat_id: number) {
if (this.client == null) return;
return this.client.fetchChat(chat_id);
}
/** /**
* 发送消息 * 发送消息
*/ */
...@@ -171,10 +177,13 @@ export class Xim { ...@@ -171,10 +177,13 @@ export class Xim {
public async queryLastPageMsg( public async queryLastPageMsg(
chatType: string, chatType: string,
chatId: number, chatId: number,
limit: number limit: number,
notToRead?: boolean
) { ) {
const data = await this.queryMsgs(chatType, chatId, 0, 0, limit, true); const data = await this.queryMsgs(chatType, chatId, 0, 0, limit, true);
if (!notToRead) {
this.setMessagesRead(chatId, data); this.setMessagesRead(chatId, data);
}
return data; return data;
} }
...@@ -183,7 +192,8 @@ export class Xim { ...@@ -183,7 +192,8 @@ export class Xim {
chatType: string, chatType: string,
chatId: number, chatId: number,
msgId: number, msgId: number,
limit: number limit: number,
notToRead?: boolean
) { ) {
const data = await this.queryMsgs( const data = await this.queryMsgs(
chatType, chatType,
...@@ -193,7 +203,9 @@ export class Xim { ...@@ -193,7 +203,9 @@ export class Xim {
limit, limit,
true true
); );
if (!notToRead) {
this.setMessagesRead(chatId, data); this.setMessagesRead(chatId, data);
}
return data; return data;
} }
...@@ -202,7 +214,8 @@ export class Xim { ...@@ -202,7 +214,8 @@ export class Xim {
chatType: string, chatType: string,
chatId: number, chatId: number,
msgId: number, msgId: number,
limit: number limit: number,
notToRead?: boolean
) { ) {
const data = await this.queryMsgs( const data = await this.queryMsgs(
chatType, chatType,
...@@ -212,7 +225,9 @@ export class Xim { ...@@ -212,7 +225,9 @@ export class Xim {
limit, limit,
false false
); );
if (!notToRead) {
this.setMessagesRead(chatId, data); this.setMessagesRead(chatId, data);
}
return data; return data;
} }
...@@ -295,7 +310,7 @@ export class Xim { ...@@ -295,7 +310,7 @@ export class Xim {
private onConnected() { private onConnected() {
if (this.client == null) return; if (this.client == null) return;
// 连接成功后,需要调用pubUserInfo, 否则服务端会认为此连接无效 // 连接成功后,需要调用pubUserInfo, 否则服务端会认为此连接无效
this.client.pubUserInfo(""); this.client.pubUserInfo(JSON.stringify({org_id: chat.getOrgId()}));
this.debug("xim connected"); this.debug("xim connected");
} }
......
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