Commit 38c4ddaf by panjiangyi

创建会话通过所属详情获取chatid

parent 15024190
...@@ -116,9 +116,6 @@ export default class ChatList extends Vue { ...@@ -116,9 +116,6 @@ export default class ChatList 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_CURRENT_CHAT_VERSION)
private readonly uniplatVersion!: ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION;
@chatStore.State(ChatStore.STATE_MY_CHAT_ROOM_LIST) @chatStore.State(ChatStore.STATE_MY_CHAT_ROOM_LIST)
private readonly chatList!: ChatStore.STATE_MY_CHAT_ROOM_LIST; private readonly chatList!: ChatStore.STATE_MY_CHAT_ROOM_LIST;
...@@ -221,17 +218,16 @@ export default class ChatList extends Vue { ...@@ -221,17 +218,16 @@ export default class ChatList extends Vue {
wantedChatRoom.business_data.model_name, wantedChatRoom.business_data.model_name,
wantedChatRoom.business_data.obj_id wantedChatRoom.business_data.obj_id
); );
console.log("testing getChatInfo", info);
this.saveChatId({ this.saveChatId({
chatId: wantedChatRoom.chat_id, chatId: wantedChatRoom.chat_id,
v: data.uniplat_version, v: info.uniplat_version,
uniplatId: data.uniplatId, uniplatId: info.uniplatId,
}).finally(this.raiseChatIdChanged); }).finally(this.raiseChatIdChanged);
this.showChat(); this.showChat();
this.$emit("close"); this.$emit("close");
this.saveChatTitle(data.uniplatId); this.saveChatTitle(info.uniplatId);
} }
private raiseChatIdChanged() { private raiseChatIdChanged() {
......
<template> <template>
<div class="chat-room-con h-100 pos-rel"> <div class="chat-room-con h-100 pos-rel">
{{ chatId }}-{{ uniplatId }} {{ chatId }}
<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">
...@@ -43,9 +43,6 @@ export default class ChatRoom extends Vue { ...@@ -43,9 +43,6 @@ export default class ChatRoom 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_CURRENT_CHAT_VERSION)
private readonly uniplatId!: ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION;
@chatStore.Getter(ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS) @chatStore.Getter(ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS)
private readonly chatMembers!: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS; private readonly chatMembers!: ChatStore.GETTER_CURRENT_CHAT_PRESENT_MEMBERS;
...@@ -86,11 +83,9 @@ export default class ChatRoom extends Vue { ...@@ -86,11 +83,9 @@ export default class ChatRoom extends Vue {
} }
private get currentChat() { private get currentChat() {
const chatId = this.currentChatUniplatId; const chatId = this.chatId;
if (this.myChatList == null) return; if (this.myChatList == null) return;
const result = this.myChatList.list.find((k) => k.uniplatId === chatId); const result = this.myChatList.list.find((k) => k.chat_id === chatId);
// if (result) return result;
// result = this.allChatList.list.find((k) => k.uniplatId === chatId);
return result ?? {}; return result ?? {};
} }
......
...@@ -4,6 +4,7 @@ import { Module } from "vuex"; ...@@ -4,6 +4,7 @@ import { Module } from "vuex";
import { ChatMember } from "../model"; import { ChatMember } from "../model";
import { isAccessibleUrl } from "../service/tools"; import { isAccessibleUrl } from "../service/tools";
import { unique } from "../utils"; import { unique } from "../utils";
import { getChatModelInfo } from "../utils/chat-info";
import { decode } from "../utils/jwt"; import { decode } from "../utils/jwt";
import { getUserInfo } from "../utils/user-info"; import { getUserInfo } from "../utils/user-info";
import Chat from "../xim"; import Chat from "../xim";
...@@ -362,14 +363,13 @@ export default { ...@@ -362,14 +363,13 @@ export default {
) { ) {
const uniplatId = const uniplatId =
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]; state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID];
const version = state[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION];
if (uniplatId == null) return; if (uniplatId == null) return;
try { try {
const data = await model() const data = await model()
.action("sendMsg") .action("sendMsg")
.updateInitialParams({ .updateInitialParams({
selected_list: [ selected_list: [
{ v: Number(version), id: Number(uniplatId) }, { v: 0, id: Number(uniplatId) },
], ],
}) })
.addInputs_parameter({ .addInputs_parameter({
...@@ -408,49 +408,23 @@ export default { ...@@ -408,49 +408,23 @@ export default {
params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0] params: Parameters<ChatStore.ACTION_CREATE_NEW_CHAT_BY_SERVICE_MAN>[0]
) { ) {
const myId = (await getMyinfo()).id; const myId = (await getMyinfo()).id;
const action = sdk().model(UniplatChatModelName).action("insert"); const { id } = await sdk().model(params.modelName).createChat({
action.addInputs_parameter({ orgId: orgId(),
OrgId: orgId(), uid: myId,
ModelName: params.modelName, detailId: +params.selectedListId
ObjId: +params.selectedListId,
Creator: myId,
Status: ChatStatus.opening,
}); });
const detailManager = await action.getDetailParametersManagerByName( await new Promise(resolve => setTimeout(resolve, 500));
"UniplatChatMember"
);
detailManager.add({
OrgId: orgId(),
Uid: myId,
type: ChatMemberType.member,
});
params.uids.forEach((id) => {
detailManager.add({
OrgId: orgId(),
Uid: id,
type: ChatMemberType.member,
});
});
detailManager.done();
const { id } = await action.dryExecute();
// 无法得到chat id
await sdk()
.model(UniplatChatModelName)
.action("createXimChat")
.updateInitialParams({
selected_list: [{ v: 0, id }],
})
.dryExecute();
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const newChatInfo = await getChatModelInfo(params.modelName, params.selectedListId);
const roomList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]; const roomList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST];
if (roomList == null) return; if (roomList == null) return;
const newChat = roomList.list.find((k) => k.uniplatId === id); const newChat = roomList.list.find((k) => k.chat_id === newChatInfo.chat_id);
if (newChat == null) return; if (newChat == null) return;
commit(ChatStore.MUTATION_SHOW_CHAT); commit(ChatStore.MUTATION_SHOW_CHAT);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, { await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
chatId: newChat.chat_id, chatId: newChat.chat_id,
v: newChat.uniplat_version, v: newChatInfo.uniplat_version,
uniplatId: newChat.uniplatId, uniplatId: id,
}); });
}, },
// async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE]( // async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE](
...@@ -584,10 +558,11 @@ export default { ...@@ -584,10 +558,11 @@ export default {
.execute(); .execute();
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST); await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0]; const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0];
const chatInfo = await getChatModelInfo(firstChat.business_data.model_name, firstChat.business_data.obj_id);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, { await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
chatId: firstChat.chat_id, chatId: firstChat.chat_id,
v: firstChat.uniplat_version, v: chatInfo.uniplat_version,
uniplatId: firstChat.uniplatId, uniplatId: chatInfo.uniplatId,
}); });
}, },
async [ChatStore.ACTION_CHAT_ADD_MEMBERS]( async [ChatStore.ACTION_CHAT_ADD_MEMBERS](
......
...@@ -12,5 +12,9 @@ export async function getChatModelInfo(modelName: string, id: string) { ...@@ -12,5 +12,9 @@ export async function getChatModelInfo(modelName: string, id: string) {
const info = await Chat.getSdk().model(modelName).detail(id).query(); const info = await Chat.getSdk().model(modelName).detail(id).query();
const data = info; const data = info;
chatInfo[id] = data; chatInfo[id] = data;
return data; return {
uniplatId: info.row.UniplatChatId.value,
chat_id: info.row.UniplatImBizId.value,
uniplat_version: 0
};
} }
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