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

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

View File

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

View File

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

View File

@ -12,6 +12,7 @@
:offset-bottom="offsetBottom"
:group="group"
:quest-id="questId"
:user-role="userRole"
@tryTime="tryTime"
@hidepanel="hidepanel"
@quitQuest="quitQuest"
@ -151,6 +152,17 @@ export default {
// return this.$route.query.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() {
return this.mode === 'demon';
},

View File

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

View File

@ -11,7 +11,7 @@
<div class="userBubble" @click="playAudio(baseUrl+chatContent.src)">
<div class="userMessage">
<!-- 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="messageText">{{ chatContent.message }}</span>
</div>
@ -102,7 +102,7 @@ export default {
coversition.self = true;
}
coversition.src = coversition.isAudio ? `/jlcloud/audio/${coversition.audioPath}` : '';
coversition.targetName = coversition.targetMember ? coversition.targetMember : 'All';
coversition.targetUser = coversition.targetMember ? coversition.targetMember : 'All';
return coversition;
});
this.chatContentList = coversitionList;
@ -143,26 +143,37 @@ export default {
},
covertName(data) {
if (data != 'All') {
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {
const rolename = element.value;
if (Cookies.get('user_lang') == 'en') {
if (rolename == data.role) {
data.role = element.enLabel;
}
} else {
if (rolename == data.role) {
data.role = element.label;
}
}
});
const deviceName = data.deviceName ? '-' + data.deviceName : '';
const memberName = data.name ? '-' + data.name : '';
return data.role + deviceName + memberName;
if (data instanceof Array) {
let result = '';
data.forEach(each=>{
result += this.covertEachName(each);
});
return result;
} else {
return this.covertEachName(data);
}
} else {
return 'All';
return '@All';
}
},
covertEachName(data) {
const roleTypeList = ConstConfig.ConstSelect.roleTypeNew;
roleTypeList.forEach(function(element) {
const rolename = element.value;
if (Cookies.get('user_lang') == 'en') {
if (rolename == data.role) {
data.role = element.enLabel;
}
} else {
if (rolename == data.role) {
data.role = element.label;
}
}
});
const deviceName = data.deviceName ? '-' + data.deviceName : '';
const memberName = data.name ? '-' + data.name : '';
return '@' + data.role + deviceName + memberName;
},
playAudio(audioUrl) {
document.querySelector('#audioPlay').src = audioUrl;
document.querySelector('#audioPlay').play();

View File

@ -7,13 +7,11 @@
:key="coversition.id"
:class="coversition.id==currentCoversition.id?'coversition-active each-coversition':'each-coversition'"
@click="changeCoversition(coversition)"
>{{ coversition.coverName }}</div>
>{{ coversition.name }}</div>
</div>
</div>
</template>
<script>
// import ConstConfig from '@/scripts/ConstConfig';
// import Cookies from 'js-cookie';
import {getSimulationConversationListNew} from '@/api/chat';
export default {
name:'ChatCoversitionList',
@ -31,22 +29,17 @@ export default {
getSimulationConversationListNew(this.$route.query.group).then(resp=>{
if (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;
if (resp.data.length >= 2) {
this.$emit('hideAddCoversition');
}
if (resp.data && resp.data.length && resp.data.length > 0 && status) {
this.currentCoversition = 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) {
const index = this.coversitionList.findIndex(item=>{ return item.id == data.id; });
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.currentCoversition = data;
}
},
changeCoversition(coversition) {
this.$emit('setHeadTitle', coversition.coverName);
this.$emit('setHeadTitle', coversition.name);
this.currentCoversition = {id:coversition.id, all:coversition.all};
this.$emit('setCurrentCoversition', coversition);
// this.$refs.chatContent.reloadData(this.currentCoversition);
},
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; });
if (index < 0) {
this.coversitionList.push(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>

View File

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

View File

@ -17,19 +17,28 @@
<script>
import ConstConfig from '@/scripts/ConstConfig';
import Cookies from 'js-cookie';
import {acceptCoversitionInvite} from '@/api/chat';
export default {
name:'ChatTooltip',
props: {
group: {
type: String,
required: true
}
},
data() {
return {
userName:'',
dialogVisible:false,
loading:false
loading:false,
conversationId:''
};
},
watch:{
'$store.state.socket.inviteOtherIntoChat':function(val) {
this.userName = this.coverName(val);
this.dialogVisible = true;
this.conversationId = val.conversationId;
}
},
// {"conversationId":"22e10b17-7a6c-4b1b-8724-f87fb2053b76","from":{"id":"17","userId":"75","name":"",
@ -52,7 +61,14 @@ export default {
return data + deviceName + memberName;
},
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() {
this.dialogVisible = false;