Commit 456f72e4 by panjiangyi

梳理添加成员逻辑

parent ff7ed205
......@@ -39,12 +39,6 @@
</el-tabs>
</div>
</div>
<ChatCreator
v-if="visible"
:selected="chatMembersId"
@submit="addMember"
@hide="hideAddMember"
/>
</div>
</template>
<script lang="ts">
......@@ -60,7 +54,6 @@ import ModelDetail from "./components/model-detail.vue";
import MsgShortCut from "./components/msg-shortcut.vue";
import buttonThrottle from "./utils/button-throttle";
import ChatCreator from "@/customer-service/components/create-chat.vue";
import { ChatStore, chatStore } from "@/customer-service/store/model";
@Component({
......@@ -68,7 +61,6 @@ import { ChatStore, chatStore } from "@/customer-service/store/model";
MsgShortCut,
MessageList,
ChatRoom,
ChatCreator,
ChatMembers,
remarkList,
ChatTitle,
......@@ -104,24 +96,10 @@ export default class Chat extends Vue {
return this.chatMembers.map((k) => +k.eid);
}
private visible = false;
@buttonThrottle()
private terminate() {
this._terminate();
}
private showAddMember() {
this.visible = true;
}
private hideAddMember() {
this.visible = false;
}
private async addMember(users: string[], done: () => void) {
await this._addMember(users);
done();
}
}
</script>
<style lang="less" scoped>
......
......@@ -84,6 +84,7 @@ export default class ChatTitle extends Vue {
private async addMember(users: string[], done: () => void) {
await this._addMember(users);
done();
this.hideAddMember();
}
}
</script>
......
......@@ -22,11 +22,14 @@
:key="user.id"
class="user-con"
@click="onClickUser(user.id)"
:class="{ forbid: forbidden(user.id) }"
>
<avatar />
<span
class="user-name"
:class="{ isChoosed: isChoosed(user.id) }"
:class="{
isChoosed: isMember(user.id),
}"
>{{ user.name }}</span
>
</div>
......@@ -88,7 +91,6 @@ export default class ChatCreator extends Vue {
public async created() {
await this.getUserList();
this.selectedUsers = this.selected;
}
private async getUserList(searchText: string | null = null) {
......@@ -138,12 +140,20 @@ export default class ChatCreator extends Vue {
this.userList = this.exactUserList(data.rows);
}
private isChoosed(id: number) {
private forbidden(id: number) {
return this.selected.includes(id);
}
private isMember(id: number) {
return this.selectedUsers.includes(id) || this.selected.includes(id);
}
private isSelected(id: number) {
return this.selectedUsers.includes(id);
}
private onClickUser(id: number) {
if (this.isChoosed(id)) {
if (this.isSelected(id)) {
this.removeUser(id);
} else {
this.addUser(id);
......@@ -186,6 +196,9 @@ export default class ChatCreator extends Vue {
align-items: center;
margin-bottom: 40px;
cursor: pointer;
&.forbid {
cursor: not-allowed;
}
}
.user-name {
height: 15px;
......
import { RootStoreState } from "@/store/model";
import { Index } from "uniplat-sdk";
import { Module } from "vuex";
import { ChatMember } from "../model";
......@@ -288,7 +287,7 @@ export default {
commit,
}) /* ...params: Parameters<ChatStore.ACTION_GET_MY_CHAT_LIST> */ {
const data = await xim.fetchChatList();
if (data == null) return
if (data == null) return;
const chatList = data.args[0];
console.log("testing", chatList);
commit(ChatStore.MUTATION_SAVE_CHAT_LIST, {
......@@ -516,6 +515,7 @@ export default {
const getChatMembersResult = await xim.fetchChatMembers(chatId);
if (getChatMembersResult == null) return;
const chatMembers = getChatMembersResult.args[0] as ChatMember[];
console.log("fuck 1", chatMembers);
const newChatMembers = await Promise.all(
chatMembers.map(async (member) => {
let result: NonNullable<ChatStore.STATE_CURRENT_CHAT_MEMBERS>[number];
......@@ -558,7 +558,7 @@ export default {
.execute();
await dispatch(ChatStore.ACTION_GET_MY_CHAT_LIST);
const firstChat = state[ChatStore.STATE_MY_CHAT_ROOM_LIST]?.list[0];
if (firstChat == null) return
if (firstChat == null) return;
const chatInfo = await getChatModelInfo(firstChat.business_data.model_name, firstChat.business_data.obj_id);
await dispatch(ChatStore.ACTION_SAVE_CURRENT_CHAT_ID_VERSION, {
chatId: firstChat.chat_id,
......@@ -575,6 +575,7 @@ export default {
const id = Number(
state[ChatStore.STATE_CHAT_CURRENT_CHAT_UNIPLAT_ID]
);
console.log("fuck 0", uids, v, id);
const action = sdk().model(UniplatChatModelName).action("update");
action.updateInitialParams({
selected_list: [{ v, id }],
......@@ -589,6 +590,7 @@ export default {
type: ChatMemberType.member,
});
});
detailManager.uniqBy("Uid");
detailManager.done();
await action.execute();
await new Promise((resolve) => setTimeout(resolve, 500));
......
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