综合演练 仿真聊天 代码调整

This commit is contained in:
joylink_cuiweidong 2020-05-29 16:56:02 +08:00
parent 6fe1a0c22b
commit 933db5fb50
10 changed files with 137 additions and 129 deletions

View File

@ -345,3 +345,19 @@ export function getSimulationChatMemberNew(group, conversationId) {
}); });
} }
// 接受其他人的会话邀请 (新版地图)
export function acceptCoversitionInvite(group, conversationId) {
return request({
url: `/simulation/${group}/${conversationId}/accept`,
method: 'put'
});
}
// 退出该群聊 (新版地图)
export function quitCoversition(group, conversationId) {
return request({
url: `/simulation/${group}/${conversationId}/exist`,
method: 'delete'
});
}

View File

@ -32,6 +32,9 @@ function handle(state, data) {
case 'Simulation_Start_Conversation': // 综合演练仿真-聊天界面用户邀请其他人加入群聊 case 'Simulation_Start_Conversation': // 综合演练仿真-聊天界面用户邀请其他人加入群聊
state.inviteOtherIntoChat = msg; state.inviteOtherIntoChat = msg;
break; break;
case 'Simulation_Accept_Conversation': // 综合演练仿真-聊天界面用户接受被邀请
state.acceptInviteChat = msg;
break;
case 'Competition_Practical': // 竞赛裁判系统裁判员开始考试推送消息 case 'Competition_Practical': // 竞赛裁判系统裁判员开始考试推送消息
state.competitionStart++; // 竞赛裁判系统裁判员开始考试推送消息 state.competitionStart++; // 竞赛裁判系统裁判员开始考试推送消息
break; break;
@ -163,9 +166,7 @@ function handleSimulationInfo(state, data) {
member:data.member, member:data.member,
memberOnline:data.member.online, memberOnline:data.member.online,
chatTime: data.chatTime, chatTime: data.chatTime,
targetOnline:data.targetMember ? data.targetMember.online : null, targetUser:data.targetMember ? data.targetMember : 'All',
targetName:data.targetMember ? data.targetMember : 'All',
targetRole:data.targetMember ? data.targetMember.role : null,
all: data.all, all: data.all,
date: +new Date(`${myDate1} ${chatTime}`) date: +new Date(`${myDate1} ${chatTime}`)
}; };
@ -218,6 +219,7 @@ const socket = {
simulationReset: '', // 仿真-异常消息 simulationReset: '', // 仿真-异常消息
simulationText: {}, // 仿真-用户交互消息(聊天/命令), simulationText: {}, // 仿真-用户交互消息(聊天/命令),
inviteOtherIntoChat:{}, // 综合演练仿真-聊天界面用户邀请其他人加入群聊推送信息 inviteOtherIntoChat:{}, // 综合演练仿真-聊天界面用户邀请其他人加入群聊推送信息
acceptInviteChat:{}, // 综合演练仿真-聊天界面用户接受聊天邀请
// coversitionList:{}, // 历史仿真-用户消息列表 // coversitionList:{}, // 历史仿真-用户消息列表
message: {}, // 仿真聊天 message: {}, // 仿真聊天

View File

@ -10,7 +10,7 @@
<div class="userBubble" @click="playAudio('audio'+index)"> <div class="userBubble" @click="playAudio('audio'+index)">
<div class="userMessage"> <div class="userMessage">
<!-- &&!(chatContent.self) --> <!-- &&!(chatContent.self) -->
<span v-if="chatContent.all">@{{ covertName(chatContent.targetName) }}</span> <span v-if="chatContent.all">@{{ covertName(chatContent.targetUser) }}</span>
<span class="el-icon-video-play playicon" /> <span class="el-icon-video-play playicon" />
<span class="messageText">{{ chatContent.message }}</span> <span class="messageText">{{ chatContent.message }}</span>
<audio :id="'audio'+index" :src="baseUrl+chatContent.src" style="display:none" /> <audio :id="'audio'+index" :src="baseUrl+chatContent.src" style="display:none" />
@ -78,7 +78,7 @@ export default {
coversition.self = true; coversition.self = true;
} }
coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : ''; coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : '';
coversition.targetName = coversition.targetMember ? coversition.targetMember : 'All'; coversition.targetUser = coversition.targetMember ? coversition.targetMember : 'All';
return coversition; return coversition;
}); });
this.chatContentList = coversitionList; this.chatContentList = coversitionList;
@ -103,6 +103,20 @@ export default {
}, },
covertName(data) { covertName(data) {
if (data != 'All') { if (data != 'All') {
if (data instanceof Array) {
let result = '';
data.forEach(each=>{
result += this.covertEachName(each);
});
return result;
} else {
return this.covertEachName(data);
}
} else {
return '@All';
}
},
covertEachName(data) {
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew; const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) { roleTypeList.forEach(function(element) {
const rolename = element.value; const rolename = element.value;
@ -118,10 +132,7 @@ export default {
}); });
const deviceName = data.deviceName ? '-' + data.deviceName : ''; const deviceName = data.deviceName ? '-' + data.deviceName : '';
const memberName = data.name ? '-' + data.name : ''; const memberName = data.name ? '-' + data.name : '';
return data.role + deviceName + memberName; return '@' + data.role + deviceName + memberName;
} else {
return 'All';
}
}, },
playAudio(id) { playAudio(id) {
document.querySelector('#' + id).play(); document.querySelector('#' + id).play();

View File

@ -102,7 +102,7 @@ export default {
this.checkList = []; this.checkList = [];
} }
}).catch(error=>{ }).catch(error=>{
this.$messageBox('创建会话失败: ' + error.messagfe); this.$messageBox('创建会话失败: ' + error.message);
this.loading = false; this.loading = false;
this.dialogVisible = false; this.dialogVisible = false;
this.checkList = []; this.checkList = [];

View File

@ -12,6 +12,7 @@
:offset-bottom="offsetBottom" :offset-bottom="offsetBottom"
:group="group" :group="group"
:quest-id="questId" :quest-id="questId"
:user-role="userRole"
@tryTime="tryTime" @tryTime="tryTime"
@hidepanel="hidepanel" @hidepanel="hidepanel"
@quitQuest="quitQuest" @quitQuest="quitQuest"
@ -151,6 +152,17 @@ export default {
// return this.$route.query.prdType; // return this.$route.query.prdType;
return this.$store.state.training.prdType; return this.$store.state.training.prdType;
}, },
userRole() {
if (this.prdType == '02') {
return 'DISPATCHER';
} else if (this.prdType == '01') {
return 'STATION_SUPERVISOR';
} else if (this.prdType == '04') {
return 'DRIVER';
} else {
return 'AUDIENCE';
}
},
isDemon() { isDemon() {
return this.mode === 'demon'; return this.mode === 'demon';
}, },

View File

@ -2,9 +2,9 @@
<!-- v-quickMenuDrag --> <!-- v-quickMenuDrag -->
<div class="chatBox"> <div class="chatBox">
<div v-show="!minimize" class="chat-box"> <div v-show="!minimize" class="chat-box">
<chat-member-list ref="chatMemberList" :group="group" :current-coversition="currentCoversition" @addCoversition="addCoversition" /> <chat-member-list ref="chatMemberList" :group="group" :current-coversition="currentCoversition" />
<div class="chat-box-main"> <div class="chat-box-main">
<chat-coversition-list ref="chatCoversitionList" @setCurrentCoversition="setCurrentCoversition" @setHeadTitle="setHeadTitle" /> <chat-coversition-list ref="chatCoversitionList" @hideAddCoversition="hideAddCoversition" @setCurrentCoversition="setCurrentCoversition" @setHeadTitle="setHeadTitle" />
<div class="chat-window"> <div class="chat-window">
<div class="chat-box-header"> <div class="chat-box-header">
<div class="chat-box-header-title">{{ headerTitle }}</div> <div class="chat-box-header-title">{{ headerTitle }}</div>
@ -43,7 +43,7 @@
</div> </div>
<chat-setting ref="chatSetting" :form="form" @setSetting="setSetting" /> <chat-setting ref="chatSetting" :form="form" @setSetting="setSetting" />
<chat-create-group ref="createGroup" :group="group" @addCoversition="addCoversition" /> <chat-create-group ref="createGroup" :group="group" @addCoversition="addCoversition" />
<chat-tooltip /> <chat-tooltip :group="group" @getCoversitionList="getCoversitionList" />
</div> </div>
</template> </template>
<script> <script>
@ -84,6 +84,7 @@ export default {
inter:null, inter:null,
recorders: null, recorders: null,
microphone:null, microphone:null,
isHasCoversition:false,
form:{ form:{
language:'zh', language:'zh',
sex:'1' sex:'1'
@ -93,7 +94,7 @@ export default {
}, },
computed:{ computed:{
isShow() { isShow() {
return this.userRole != 'ADMIN' && this.userRole != 'AUDIENCE'; return this.userRole != 'ADMIN' && this.userRole != 'AUDIENCE' && !this.isHasCoversition;
} }
}, },
mounted() { mounted() {
@ -113,11 +114,12 @@ export default {
setSetting(data) { setSetting(data) {
this.form = data; this.form = data;
}, },
getCoversitionList() {
this.$refs.chatCoversitionList.initPage(false);
},
setCurrentCoversition(coversition) { setCurrentCoversition(coversition) {
this.currentCoversition = coversition; this.currentCoversition = coversition;
if (coversition.all) {
this.headerTitle = coversition.name; this.headerTitle = coversition.name;
}
if (this.recordSending) { if (this.recordSending) {
this.cancleRecording(); this.cancleRecording();
} }
@ -126,8 +128,12 @@ export default {
setHeadTitle(headerTitle) { setHeadTitle(headerTitle) {
this.headerTitle = headerTitle; this.headerTitle = headerTitle;
}, },
hideAddCoversition() {
this.isHasCoversition = true;
},
addCoversition({data, headerTitle}) { addCoversition({data, headerTitle}) {
this.$refs.chatCoversitionList.addCoversition(data); this.$refs.chatCoversitionList.addCoversition(data);
this.isHasCoversition = true;
this.currentCoversition = {id:data.id, all:data.all}; this.currentCoversition = {id:data.id, all:data.all};
this.headerTitle = headerTitle; this.headerTitle = headerTitle;
}, },

View File

@ -11,7 +11,7 @@
<div class="userBubble" @click="playAudio(baseUrl+chatContent.src)"> <div class="userBubble" @click="playAudio(baseUrl+chatContent.src)">
<div class="userMessage"> <div class="userMessage">
<!-- chatContent.all&& --> <!-- chatContent.all&& -->
<span v-if="!chatContent.member.robot">@{{ covertName(chatContent.targetName) }}</span> <span v-if="!chatContent.member.robot">{{ covertName(chatContent.targetUser) }}</span>
<span class="el-icon-video-play playicon" /> <span class="el-icon-video-play playicon" />
<span class="messageText">{{ chatContent.message }}</span> <span class="messageText">{{ chatContent.message }}</span>
</div> </div>
@ -102,7 +102,7 @@ export default {
coversition.self = true; coversition.self = true;
} }
coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : ''; coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : '';
coversition.targetName = coversition.targetMember ? coversition.targetMember : 'All'; coversition.targetUser = coversition.targetMember ? coversition.targetMember : 'All';
return coversition; return coversition;
}); });
this.chatContentList = coversitionList; this.chatContentList = coversitionList;
@ -143,6 +143,20 @@ export default {
}, },
covertName(data) { covertName(data) {
if (data != 'All') { if (data != 'All') {
if (data instanceof Array) {
let result = '';
data.forEach(each=>{
result += this.covertEachName(each);
});
return result;
} else {
return this.covertEachName(data);
}
} else {
return '@All';
}
},
covertEachName(data) {
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew; const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) { roleTypeList.forEach(function(element) {
const rolename = element.value; const rolename = element.value;
@ -158,10 +172,7 @@ export default {
}); });
const deviceName = data.deviceName ? '-' + data.deviceName : ''; const deviceName = data.deviceName ? '-' + data.deviceName : '';
const memberName = data.name ? '-' + data.name : ''; const memberName = data.name ? '-' + data.name : '';
return data.role + deviceName + memberName; return '@' + data.role + deviceName + memberName;
} else {
return 'All';
}
}, },
playAudio(audioUrl) { playAudio(audioUrl) {
document.querySelector('#audioPlay').src = audioUrl; document.querySelector('#audioPlay').src = audioUrl;

View File

@ -7,13 +7,11 @@
:key="coversition.id" :key="coversition.id"
:class="coversition.id==currentCoversition.id?'coversition-active each-coversition':'each-coversition'" :class="coversition.id==currentCoversition.id?'coversition-active each-coversition':'each-coversition'"
@click="changeCoversition(coversition)" @click="changeCoversition(coversition)"
>{{ coversition.coverName }}</div> >{{ coversition.name }}</div>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
// import ConstConfig from '@/scripts/ConstConfig';
// import Cookies from 'js-cookie';
import {getSimulationConversationListNew} from '@/api/chat'; import {getSimulationConversationListNew} from '@/api/chat';
export default { export default {
name:'ChatCoversitionList', name:'ChatCoversitionList',
@ -31,22 +29,17 @@ export default {
getSimulationConversationListNew(this.$route.query.group).then(resp=>{ getSimulationConversationListNew(this.$route.query.group).then(resp=>{
if (resp.data) { if (resp.data) {
const data = resp.data; const data = resp.data;
data.map(coversition=>{
// if (coversition.name) {
coversition.coverName = coversition.name;
coversition.isOnline = true;
// }
// else {
// const objectCover = this.handleMemberName(coversition);
// coversition.coverName = objectCover.coversitionName;
// coversition.isOnline = objectCover.isOnline;
// }
return coversition;
});
this.coversitionList = data; this.coversitionList = data;
if (resp.data.length >= 2) {
this.$emit('hideAddCoversition');
}
if (resp.data && resp.data.length && resp.data.length > 0 && status) { if (resp.data && resp.data.length && resp.data.length > 0 && status) {
this.currentCoversition = data[0]; this.currentCoversition = data[0];
this.$emit('setCurrentCoversition', resp.data[0]); this.$emit('setCurrentCoversition', resp.data[0]);
} else if (resp.data && resp.data.length && resp.data.length > 0 && !status) {
const coversition = data.filter(coversition=>{ return coversition.all == false; });
this.currentCoversition = coversition[0];
this.$emit('setCurrentCoversition', coversition[0]);
} }
} }
}); });
@ -54,85 +47,23 @@ export default {
addCoversition(data) { addCoversition(data) {
const index = this.coversitionList.findIndex(item=>{ return item.id == data.id; }); const index = this.coversitionList.findIndex(item=>{ return item.id == data.id; });
if (index < 0) { if (index < 0) {
// const objectCover = this.handleMemberName(data);
// if (data.name) {
data.coverName = data.name;
data.isOnline = true;
// }
// else {
// data.coverName = objectCover.coversitionName;
// data.isOnline = objectCover.isOnline;
// }
this.coversitionList.push(data); this.coversitionList.push(data);
this.currentCoversition = data; this.currentCoversition = data;
} }
}, },
changeCoversition(coversition) { changeCoversition(coversition) {
this.$emit('setHeadTitle', coversition.coverName); this.$emit('setHeadTitle', coversition.name);
this.currentCoversition = {id:coversition.id, all:coversition.all}; this.currentCoversition = {id:coversition.id, all:coversition.all};
this.$emit('setCurrentCoversition', coversition); this.$emit('setCurrentCoversition', coversition);
// this.$refs.chatContent.reloadData(this.currentCoversition); // this.$refs.chatContent.reloadData(this.currentCoversition);
}, },
changeCoversitionOther(coversition) { changeCoversitionOther(coversition) {
// const objectCover = this.handleMemberName(coversition);
// coversition.coverName = objectCover.coversitionName;
// coversition.isOnline = objectCover.isOnline;
coversition.coverName = coversition.name;
coversition.isOnline = true;
const index = this.coversitionList.findIndex(item=>{ return item.id == coversition.id; }); const index = this.coversitionList.findIndex(item=>{ return item.id == coversition.id; });
if (index < 0) { if (index < 0) {
this.coversitionList.push(coversition); this.coversitionList.push(coversition);
} }
this.changeCoversition(coversition); this.changeCoversition(coversition);
} }
// handleMemberName(conversition) {
// if (conversition.all) {
// return {coversitionName:conversition.name, isOnline:true};
// } else {
// let coversitionName = '';
// let isOnline = true;
// if (conversition.memberList) {
// conversition.memberList.forEach(member=>{
// if (member.userId != this.$store.state.user.id) {
// const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
// let data = member.role;
// roleTypeList.forEach(function(element) {
// const rolename = element.value;
// if (Cookies.get('user_lang') == 'en') {
// data = data.replace(rolename, element.enLabel);
// } else {
// data = data.replace(rolename, element.label);
// }
// });
// const deviceName = member.deviceName ? '-' + member.deviceName : '';
// const memberName = member.name ? '-' + member.name : '';
// isOnline = member.online;
// coversitionName = data + deviceName + memberName;
// }
// });
// } else if (conversition.member) {
// const member = conversition.member;
// let data = member.role;
// const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
// roleTypeList.forEach(function(element) {
// const rolename = element.value;
// if (Cookies.get('user_lang') == 'en') {
// data = data.replace(rolename, element.enLabel);
// } else {
// data = data.replace(rolename, element.label);
// }
// });
// const deviceName = member.deviceName ? '-' + member.deviceName : '';
// const memberName = member.name ? '-' + member.name : '';
// isOnline = member.online;
// coversitionName = data + deviceName + memberName;
// } else {
// coversitionName = conversition.name;
// }
// return {coversitionName:coversitionName, isOnline:isOnline};
// }
// }
} }
}; };
</script> </script>

View File

@ -46,6 +46,9 @@ export default {
if (val) { if (val) {
this.getSimulationMembers(); this.getSimulationMembers();
} }
},
'$store.state.socket.acceptInviteChat':function(val) {
this.getSimulationMembers();
} }
}, },
mounted() { mounted() {

View File

@ -17,19 +17,28 @@
<script> <script>
import ConstConfig from '@/scripts/ConstConfig'; import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import {acceptCoversitionInvite} from '@/api/chat';
export default { export default {
name:'ChatTooltip', name:'ChatTooltip',
props: {
group: {
type: String,
required: true
}
},
data() { data() {
return { return {
userName:'', userName:'',
dialogVisible:false, dialogVisible:false,
loading:false loading:false,
conversationId:''
}; };
}, },
watch:{ watch:{
'$store.state.socket.inviteOtherIntoChat':function(val) { '$store.state.socket.inviteOtherIntoChat':function(val) {
this.userName = this.coverName(val); this.userName = this.coverName(val);
this.dialogVisible = true; this.dialogVisible = true;
this.conversationId = val.conversationId;
} }
}, },
// {"conversationId":"22e10b17-7a6c-4b1b-8724-f87fb2053b76","from":{"id":"17","userId":"75","name":"", // {"conversationId":"22e10b17-7a6c-4b1b-8724-f87fb2053b76","from":{"id":"17","userId":"75","name":"",
@ -52,7 +61,14 @@ export default {
return data + deviceName + memberName; return data + deviceName + memberName;
}, },
doCreate() { doCreate() {
this.loading = true;
acceptCoversitionInvite(this.group, this.conversationId).then(res=>{
this.loading = false;
this.dialogVisible = false;
this.$emit('getCoversitionList');
}).catch(error=>{
this.$messageBox('接受邀请失败: ' + error.message);
});
}, },
doClose() { doClose() {
this.dialogVisible = false; this.dialogVisible = false;