Commit dcd1fd2f by 吴云建

会话阶段提交

parent b1023188
<template>
<div class="chat-con" :class="{ userMode }">
<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">
<chat-room />
</div>
......@@ -30,6 +30,7 @@
</el-tab-pane>
<el-tab-pane class="h-100" label="备注" name="four">
<remarkList
:isInSmallPage="true"
:modelName="currentChat.business_data.model_name"
:associateId="currentChat.business_data.obj_id"
/>
......@@ -48,9 +49,7 @@
</template>
<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import remarkList from "../components/common/remarkList.vue";
import ChatMembers from "./components/chat-members.vue";
import ChatRoom from "./components/chat-room.vue";
import ChatTitle from "./components/chat-title.vue";
......@@ -84,6 +83,9 @@ export default class Chat extends Vue {
@chatStore.State(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)
private readonly hide!: ChatStore.MUTATION_HIDE_CHAT;
......@@ -112,6 +114,9 @@ export default class Chat extends Vue {
<style lang="less" scoped>
.chat-area-con {
height: calc(100% - 60px);
&.isSingle {
height: 70vh;
}
}
.chat-con {
height: 100%;
......
......@@ -31,8 +31,11 @@ export default class ChatMembers extends Vue {
@chatStore.Action(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]) {
await this.$confirm(`确定要移除${item.name}?`, "提示", {
await this.$confirm(`确定要移除${item.name}?`, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
......
......@@ -3,7 +3,7 @@
<div class="chat-panel">
<div class="chat-area h-100">
<template v-if="notOnlyCheck">
<div class="chat-messages pos-rel">
<div class="chat-messages pos-rel" :class="{'is-not-chat-member': !isChatMember}">
<div
v-if="getCurrentInputingPeople.length"
class="someone-inputing"
......@@ -12,7 +12,7 @@
</div>
<messages />
</div>
<div class="chat-input">
<div class="chat-input" v-if="isChatMember">
<message-input @error="onError" />
</div>
</template>
......@@ -60,6 +60,9 @@ export default class ChatRoom extends Vue {
@chatStore.State(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: [] };
@Prop({ type: Function })
......@@ -165,6 +168,10 @@ export default class ChatRoom extends Vue {
.chat-messages {
height: calc(100% - 130px + 1px);
border-bottom: 1px solid #e1e1e1;
&.is-not-chat-member {
height: 100%;
border-bottom: none;
}
}
.chat-input {
......
......@@ -17,13 +17,16 @@
<div class="title-buttons">
<!-- <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
>
<el-button class="button" @click="showAddMember" round
>添加成员</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>
<ChatCreator
v-if="visible"
......@@ -49,12 +52,21 @@ export default class ChatTitle extends Vue {
@chatStore.State(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)
private readonly _terminate!: ChatStore.ACTION_TERINATE_CHAT;
@chatStore.Action(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() {
return this.chatMembers.map((k) => +k.eid);
}
......@@ -91,6 +103,15 @@ export default class ChatTitle extends Vue {
done();
}
}
private async addMemberForMyself() {
try {
console.log("====>>>??")
await this._addMember([this.operatorUid.toString()]);
} catch (error) {
console.error(error);
}
}
}
</script>
<style lang="less" scoped>
......
......@@ -9,7 +9,7 @@
<el-scrollbar class="workflow-scrollbar adjust-el-scroll-right-bar">
<div
class="workflow pos-rel table"
v-for="item in mockData"
v-for="item in flowList"
:key="item.id"
>
<span class="cell workflow-name">
......@@ -105,172 +105,11 @@ export default class WorkFlow extends Vue {
return WorkFlowStatus[status];
}
private mockData = [
{
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,
},
];
private flowList = [];
public async created() {
// const workflow = await sdk().model(this.model_name).workflow2().queryProcessByAssociateId(+this.id);
// console.log("workflow", workflow);
this.flowList = await sdk().model(this.model_name).workflow2().queryProcessByAssociateId(+this.id);
console.log("=======>>>>workflow", this.flowList);
}
public start(workflow: any) {
......
......@@ -69,10 +69,14 @@ export default {
namespaced: true,
state: () => ({
[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_USER_UID]: null,
[ChatStore.STATE_CHAT_MSG_HISTORY]: null,
[ChatStore.STATE_CHAT_SENDING_MESSAGES]: [],
[ChatStore.STATE_MY_CHAT_ROOM_LIST]: null,
[ChatStore.STATE_SINGLE_CHAT]: null,
[ChatStore.STATE_CHAT_CURRENT_CHAT_VERSION]: null,
[ChatStore.STATE_CHAT_CURRENT_CHAT_ID]: null,
[ChatStore.STATE_CHAT_MY_ID]: null,
......@@ -85,8 +89,9 @@ export default {
[ChatStore.STATE_CURRENT_CHAT_INITING]: false,
}),
mutations: {
[ChatStore.MUTATION_SHOW_CHAT](state) {
[ChatStore.MUTATION_SHOW_CHAT](state, isSingle?: boolean) {
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) {
state[ChatStore.STATE_CHAT_DIALOG_VISIBLE] = false;
......@@ -184,6 +189,14 @@ export default {
[ChatStore.MUTATION_CLEAR_CHAT_TITLE](state) {
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) {
state[ChatStore.STATE_FUNC_SCROLL_TO_BOTTOM]();
},
......@@ -274,11 +287,21 @@ export default {
[ChatStore.MUTATION_INITING_CHAT_DONE]: (state) => {
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: {
async [ChatStore.ACTION_GET_MY_CHAT_LIST]({
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();
if (data == null) return;
const chatList = data.args[0];
......@@ -311,7 +334,7 @@ export default {
const chatId = state[ChatStore.STATE_CHAT_CURRENT_CHAT_ID];
if (chatId == null) return;
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);
await preCacheImgs(data);
commit(ChatStore.MUTATION_SCROLL_TO_BOTTOM);
......@@ -331,7 +354,8 @@ export default {
chatType,
chatId,
msgId,
10
10,
!this.state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]
);
commit(ChatStore.MUTATION_UNSHIFT_CHAT_MSG_HISTORY, data);
return data;
......@@ -346,7 +370,8 @@ export default {
chatType,
chatId,
msgId,
10
10,
!this.state[ChatStore.STATE_CHAT_CURRENT_IS_CHAT_MEMBER]
);
commit(ChatStore.MUTATION_PUSH_CHAT_MSG_HISTORY, data);
return data;
......@@ -407,7 +432,7 @@ export default {
const chatId = Number(ImChatId.value);
const v = uniplat_version.value;
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);
},
// async [ChatStore.ACTION_CREATE_NEW_CHAT_BY_CLIENT_SIDE](
......@@ -473,17 +498,32 @@ export default {
chatId: Parameters<ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION>[0]
) {
const chatList = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
if (chatList.length === 0) return;
const wantedChatRoom = chatList.find(
let wantedChatRoom = chatList.find(
(k) => k.chat_id === chatId
);
if (wantedChatRoom == null) return;
if (wantedChatRoom.business_data == null) {
return;
if (wantedChatRoom == null || wantedChatRoom.business_data == null) {
const data = await xim.fetchChat(chatId);
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(
wantedChatRoom.business_data.model_name,
wantedChatRoom.business_data.obj_id,
......@@ -518,7 +558,7 @@ export default {
const getChatMembersResult = await xim.fetchChatMembers(chatId);
if (getChatMembersResult == null) return;
const chatMembers = getChatMembersResult.args[0] as ChatMember[];
const newChatMembers = await Promise.all(
let newChatMembers = await Promise.all(
chatMembers.map(async (member) => {
let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number];
try {
......@@ -535,6 +575,12 @@ export default {
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(
ChatStore.MUTATION_SAVE_CURRENT_CHAT_MEMBERS,
unique(newChatMembers, function (item, all) {
......@@ -570,7 +616,9 @@ export default {
{ getters, dispatch },
uids: Parameters<ChatStore.ACTION_CHAT_ADD_MEMBERS>[0]
) {
console.log("====123")
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;
......@@ -622,6 +670,12 @@ export default {
},
[ChatStore.GETTER_CURRENT_CURRENT_CHAT](state) {
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 =
state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list ?? [];
return chatList.find((chat) => chat.chat_id === chatId);
......
......@@ -16,11 +16,15 @@ export namespace ChatStore {
/* state */
export const STATE_CHAT_DIALOG_VISIBLE = "会话模块弹窗显示状态";
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 type STATE_MY_CHAT_ROOM_LIST = {
list: ChatType[];
total: number;
} | null
export const STATE_SINGLE_CHAT = "单独的会话";
export type STATE_SINGLE_CHAT = ChatType | null
export const STATE_CHAT_MSG_HISTORY = "某个会话聊天记录";
export type STATE_CHAT_MSG_HISTORY = dto.MessageRequestResult | null
......@@ -32,6 +36,10 @@ export namespace ChatStore {
export type STATE_CHAT_CURRENT_CHAT_ID = number | null
export const STATE_CHAT_CURRENT_CHAT_VERSION = "当前chat的Uniplat version";
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 type STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID = string | null
......@@ -103,6 +111,12 @@ export namespace ChatStore {
export const MUTATION_CLEAR_CHAT_MSG_HISTORY = "清空聊天记录";
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 type MUTATION_SAVE_CURRENT_CHAT_ID = (
chatId: ChatStore.STATE_CHAT_CURRENT_CHAT_ID
......@@ -111,6 +125,9 @@ export namespace ChatStore {
export const MUTATION_CLEAR_CURRENT_CHAT_ID = "清空chat-id";
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 =
"保存当前chat uniplat version";
export type MUTATION_SAVE_CURRENT_CHAT_VERSION = (
......@@ -184,6 +201,9 @@ export namespace ChatStore {
) => void
export const MUTATION_CLEAR_CURRENT_CHAT_INPUTING = "清空正在输入";
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 */
export const ACTION_GET_MY_CHAT_LIST = "获取我的会话列表";
......
......@@ -6,6 +6,7 @@ import chatType from "../xim/chat-type";
import { TokenStringGetter } from "./../model";
import { ChatLoggerService } from "./logger";
import { Message, NotifyMessage } from "./models/chat";
import chat from "./index";
wampDebug(true);
......@@ -109,6 +110,11 @@ export class Xim {
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 {
public async queryLastPageMsg(
chatType: string,
chatId: number,
limit: number
limit: number,
notToRead?: boolean
) {
const data = await this.queryMsgs(chatType, chatId, 0, 0, limit, true);
this.setMessagesRead(chatId, data);
if (!notToRead) {
this.setMessagesRead(chatId, data);
}
return data;
}
......@@ -183,7 +192,8 @@ export class Xim {
chatType: string,
chatId: number,
msgId: number,
limit: number
limit: number,
notToRead?: boolean
) {
const data = await this.queryMsgs(
chatType,
......@@ -193,7 +203,9 @@ export class Xim {
limit,
true
);
this.setMessagesRead(chatId, data);
if (!notToRead) {
this.setMessagesRead(chatId, data);
}
return data;
}
......@@ -202,7 +214,8 @@ export class Xim {
chatType: string,
chatId: number,
msgId: number,
limit: number
limit: number,
notToRead?: boolean
) {
const data = await this.queryMsgs(
chatType,
......@@ -212,7 +225,9 @@ export class Xim {
limit,
false
);
this.setMessagesRead(chatId, data);
if (!notToRead) {
this.setMessagesRead(chatId, data);
}
return data;
}
......@@ -295,7 +310,7 @@ export class Xim {
private onConnected() {
if (this.client == null) return;
// 连接成功后,需要调用pubUserInfo, 否则服务端会认为此连接无效
this.client.pubUserInfo("");
this.client.pubUserInfo(JSON.stringify({org_id: chat.getOrgId()}));
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