rt-sim-training-client/src/views/newMap/displayNew/demonChat.vue

168 lines
6.3 KiB
Vue
Raw Normal View History

2020-07-23 17:51:37 +08:00
<template>
2020-08-20 20:27:19 +08:00
<div>
<chat-box
ref="chatbox"
:group="group"
2020-09-11 09:26:51 +08:00
:user-role="userRole"
2020-08-20 20:27:19 +08:00
/>
2020-09-11 09:26:51 +08:00
<script-tip ref="scriptTip" :offset="offset" @allowCreatCoversition="allowCreatCoversition" />
2020-08-20 20:27:19 +08:00
</div>
2020-07-23 17:51:37 +08:00
</template>
<script>
2020-09-11 17:10:11 +08:00
import ChatBox from '../chatView/chatBox.vue';
2020-08-20 20:27:19 +08:00
import ScriptTip from '@/views/newMap/displayNew/scriptDisplay/component/scriptTip';
2020-09-11 09:26:51 +08:00
// import {getAllConversition} from '@/api/chat';
2020-07-23 17:51:37 +08:00
export default {
name:'DemonChat',
components:{
2020-08-20 20:27:19 +08:00
ChatBox,
ScriptTip
2020-07-23 17:51:37 +08:00
},
props: {
group: {
type: String,
required: true
},
userRole: {
type: String,
required: true
2020-08-20 20:27:19 +08:00
},
offset: {
type: Number,
required: true
2020-07-23 17:51:37 +08:00
}
},
data() {
return {
isHasCoversition:false,
conversitionId:'',
currentMemberList:[],
chatContentList:[],
activeTrainList:[],
2020-07-23 17:51:37 +08:00
isStartRecord:false,
inviteUserName:'',
createCoversition:true,
inviteUser:{},
isQuitShow:false,
treeData:[],
driverList:[],
simulationUsers:{}
2020-07-23 17:51:37 +08:00
};
},
computed:{
isShow() {
return this.userRole != '' &&
this.userRole != 'ADMIN' && this.userRole != 'AUDIENCE' &&
!this.isHasCoversition && this.createCoversition;
}
},
watch:{
// 剧本执行完成消息
'$store.state.socket.scriptFinish':function(val, old) {
2020-08-26 15:28:32 +08:00
this.$message('剧本演出完毕');
2020-08-20 20:27:19 +08:00
this.$refs.scriptTip.resetScriptTip();
2020-07-23 17:51:37 +08:00
}
},
mounted() {
},
methods:{
addContent(simulationText) {
const text = {};
const member = this.currentMemberList.find(member=>{
return member.id == simulationText.memberId;
});
if (member) {
text.self = (this.$store.state.user.id == member.userId);
text.member = member;
text.chatTime = simulationText.time;
text.src = simulationText.audioPath;
text.message = simulationText.content;
}
return text;
},
coverName(inviteUser) {
const member = this.memberData.find(member=>{ return member.id == inviteUser.creatorId; });
return member.label;
},
2020-07-23 17:51:37 +08:00
clearAllData() {
this.resetCoversition();
2020-08-21 14:55:28 +08:00
this.createCoversition = true;
2020-08-20 20:27:19 +08:00
this.$refs.scriptTip.resetScriptTip();
},
setMembers(roleId) {
this.memberData.map(member=>{
if (member.id == roleId) {
member.userId = this.$store.state.user.id;
2020-08-21 14:55:28 +08:00
member.userName = this.$store.state.user.nickname;
2020-08-20 20:27:19 +08:00
member.disabled = true;
2020-08-21 14:55:28 +08:00
} else {
member.userId = '';
member.userName = '';
member.disabled = false;
2020-08-20 20:27:19 +08:00
}
2020-08-21 14:55:28 +08:00
const userName = member.userName ? '-' + member.userName : '';
const name = member.name == undefined ? '' : '-' + member.name;
member.label = member.type + member.deviceName + name + userName;
2020-08-20 20:27:19 +08:00
});
2020-07-23 17:51:37 +08:00
},
resetCoversition() {
this.conversitionId = '';
this.isHasCoversition = false;
this.currentMemberList = [];
this.chatContentList = [];
this.isStartRecord = false;
this.inviteUserName = '';
this.inviteUser = {};
this.isQuitShow = false;
2020-08-20 20:27:19 +08:00
},
allowCreatCoversition() {
this.createCoversition = true;
},
resetScriptTip() {
this.$refs.scriptTip.resetScriptTip();
2020-07-23 17:51:37 +08:00
}
// isAudienceInitData() {
// getAllConversition(this.group).then(resp => {
// const messages = [];
// if (resp.data && resp.data.length) {
// debugger;
// resp.data.forEach(conversation => {
// (conversation.messageList || []).forEach(message => {
// const member = this.memberData[message.memberId];
// message.src = `/audio/${message.audioPath}`;
// message.members = conversation.memberList;
// if (member) {
// message.self = this.$store.state.userId == member.userId;
// }
// messages.push(message);
// });
// if (this.userRole !== 'AUDIENCE') {
// const user = this.simulationUsers[this.$store.state.user.id];
// this.isConversitionCreator = conversation.creatorId == user.memberId;
// !conversation.over && conversation.memberList.forEach(member =>{
// if (member.memberId == user.memberId && member.connect) {
// this.conversitionMemberList = conversation.memberList;
// this.conversitionId = conversation.id;
// this.messageList = [];
// conversation.messageList.forEach(message => {
// const member = this.memberData[message.memberId];
// message.src = `/audio/${message.audioPath}`;
// if (member) {
// message.self = this.$store.state.userId == member.userId;
// }
// this.privateMessageList.push(message);
// this.messageList.push(message);
// });
// }
// });
// }
// });
// }
// this.commonMessageList = messages.sort(this.sortByMessageTime);
// // this.initCommonMemberList();
// });
// }
2020-07-23 17:51:37 +08:00
}
};
</script>