Commit 456f72e4 by panjiangyi

梳理添加成员逻辑

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