剧本录制代码调整

This commit is contained in:
joylink_cuiweidong 2020-08-17 18:47:38 +08:00
parent e60fe128ab
commit c7bd321446
7 changed files with 440 additions and 107 deletions

View File

@ -119,3 +119,11 @@ export function changeScriptRole(group, memberId) {
});
}
/** 获取所有选取过的成员 接口(剧本录制) */
export function getAllSelectedScriptRole(group) {
return request({
url: `/api/scriptSimulation/${group}/allSelectedMembers`,
method: 'get'
});
}

View File

@ -238,17 +238,21 @@ const training = {
}
}
},
updateMemberListInScript:(state, {oldMemberId, newMemberId, userId, name}) => {
updateMemberListInScript:(state, {oldMemberId, newMember, userId, name}) => {
if (oldMemberId) {
// 重置旧数据
delete state.memberData[oldMemberId].userId;
delete state.memberData[oldMemberId].name;
state.memberData[oldMemberId].disabled = false;
}
if (!state.memberData[newMember.id]) {
state.memberData[newMember.id] = newMember;
}
// 更新新数据
state.memberData[newMemberId].userId = userId;
state.memberData[newMemberId].name = name;
state.memberData[newMemberId].disabled = true;
state.memberData[newMember.id].userId = userId;
state.memberData[newMember.id].name = name;
state.memberData[newMember.id].disabled = true;
},
updateMemberAndUser: (state, {simulationUserList, userId}) => {

View File

@ -23,6 +23,9 @@
<el-button v-if="!isScheduling" size="small" :type="faultMode ? '':'primary' " @click="changeOperateMode()">{{ faultMode?'切换到普通模式':'切换到故障模式' }}</el-button>
</template>
</div>
<!-- 菜单按钮 -->
<menu-system-time ref="menuSystemTime" :offset="offset" :group="group" />
</div>
<!-- <Jl3d-Simulation v-show="simulationShow" ref="Jl3dSimulation" :panel-show="simulationShow" @showpanel="showpanel" /> -->
@ -227,16 +230,16 @@ export default {
}
});
let prdType;
if (this.userRole == '行值') {
if (role.type == '行值') {
prdType = '01';
this.$store.dispatch('training/setRoles', 'STATION_SUPERVISOR');
this.$store.dispatch('training/setRoleDeviceCode', role.deviceCode);
} else if (this.userRole == '行调') {
} else if (role.type == '行调') {
prdType = '02';
this.$store.dispatch('training/setRoles', 'DISPATCHER');
} else if (this.userRole == '司机') {
} else if (role.type == '司机') {
prdType = '04';
} else if (this.userRole == '通号') {
} else if (role.type == '通号') {
prdType = '';
const routeData = this.$router.resolve({
path:'/jlmap3d/maintainer',
@ -248,7 +251,7 @@ export default {
noPreLogout: true
}
});
this.openWindow = window.open(routeData.href);
window.open(routeData.href);
} else {
prdType = '';
}

View File

@ -70,7 +70,7 @@ export default {
watch:{
//
'$store.state.socket.createConversition':function(val) {
debugger;
// debugger;
if (this.memberData.length > 0) {
const member = this.memberData.find(member=>{ return member.id == val.creatorId; });
if (member && member.userId == this.$store.state.user.id) {
@ -183,6 +183,7 @@ export default {
clearAllData() {
this.resetCoversition();
this.createCoversition = false;
this.$refs.scriptTip.resetScriptTip();
},
resetCoversition() {
this.conversitionId = '';
@ -196,6 +197,9 @@ export default {
},
allowCreatCoversition() {
this.createCoversition = true;
},
resetScriptTip() {
this.$refs.scriptTip.resetScriptTip();
}
}

View File

@ -0,0 +1,81 @@
<template>
<el-dialog
v-dialogDrag
:title="title"
:visible.sync="dialogVisible"
width="500px"
:before-close="handleClose"
center
:close-on-click-modal="false"
>
<el-form ref="form" :model="formModel" label-width="120px" :rules="rules">
<el-form-item label="添加仿真成员:" prop="type">
<el-select v-model="formModel.type" placeholder="请选择" size="small">
<el-option
v-for="item in typeList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { addSimulationMember } from '@/api/jointSimulation';
export default {
name: 'AddMember',
data() {
return {
dialogVisible: false,
formModel: {
type: ''
},
rules: {
type: [
{ required: true, message: '请选择显示位置', trigger: 'change' }
]
},
typeList: [{label: '行调', value: 'DISPATCHER'}, {label: '通号', value: 'MAINTAINER'}]
};
},
computed: {
title() {
return '添加仿真角色成员';
}
},
methods: {
initData(row) {
},
doShow(row) {
this.initData(row);
this.dialogVisible = true;
},
doSave() {
this.$refs.form.validate(() => {
addSimulationMember(this.formModel, this.$route.query.group).then((res) => {
this.$message.success('添加仿真角色成员成功!');
this.$emit('addScriptMember', res.data);
this.handleClose();
}).catch(() => {
this.$message.error('添加仿真角色成员失败!');
});
});
},
handleClose() {
this.dialogVisible = false;
this.formModel = {
type: ''
};
this.$refs.form.resetFields();
}
}
};
</script>

View File

@ -0,0 +1,236 @@
<template>
<div style="width:95%;height:100%">
<div>
<el-input v-model="queryMember" placeholder="请输入搜索人员" style="width:300px">
<el-button slot="append" icon="el-icon-search" />
</el-input>
<el-button @click="addMember">添加仿真成员</el-button>
</div>
<el-tree
ref="tree"
:data="covertMemberList"
:props="defaultProps"
node-key="id"
default-expand-all
:filter-node-method="filterNode"
style="margin: 10px;overflow-y:auto;height:255px;margin-right: 0;"
>
<span :id="data.id" slot-scope="{ node, data }" style="width:100%">
<span style="font-size: 14px">{{ data.label }}</span>
<span v-if="data.type!='role'" class="setGroup">
<span v-if="data.id!=memberId" class="settingBtn" @click="changeRole(data)">设置</span>
<span v-else class="hasSetted">已设置</span>
</span>
</span>
</el-tree>
</div>
</template>
<script>
import { getToken } from '@/utils/auth';
import ConstConfig from '@/scripts/ConstConfig';
import {changeScriptRole} from '@/api/script';
export default {
name:'AllScriptRole',
props:{
memberList:{
type: Array,
default() {
return [];
}
},
memberId:{
type: String,
default() {
return '';
}
},
group: {
type: String,
required: true
}
},
data() {
return {
covertMemberList:[],
driverList:[],
queryMember:'',
oldMemberId:'',
defaultProps: {
children: 'children',
label: 'label'
}
};
},
watch:{
'memberList':function(val) {
if (val && val.length > 0) {
this.covertMember();
}
},
queryMember(val) {
if (this.$refs.tree) {
this.$refs.tree.filter(val);
}
}
},
methods:{
filterNode(value, data) {
return data.label.indexOf(value) !== -1;
},
covertMember() {
// if (this.covertMemberList.length > 0) {
// this.setMemmberList(this.driverList, this.memberList[0].children, this.memberList[1].children, this.memberList[3].children);
// } else {
const dispatcherList = [];
// const electricDispatcherList = [];
// const depotDispatcherList = [];
const stationSupervisorList = [];
const driverList = [];
const maintainerList = [];
this.memberList.forEach((member, index)=>{
if (member.type != '观众') {
if (member.deviceCode) {
const device = this.$store.getters['map/getDeviceByCode'](member.deviceCode);
if (device) {
if (device._type == 'Train') {
member.label = member.name;
driverList.push(member);
} else {
member.label = member.name;
if (device._type == 'Station') {
stationSupervisorList.push(member);
}
}
} else {
member.label = member.name;
}
} else {
member.label = member.name;
if (member.type == '行调') {
dispatcherList.push(member);
} else if (member.type == '通号') {
maintainerList.push(member);
}
}
}
});
this.driverList = driverList;
this.setMemmberList(driverList, dispatcherList, stationSupervisorList, maintainerList);
// }
},
setMemmberList(driverList, dispatcherList, stationSupervisorList, maintainerList) {
this.oldMemberId = this.memberId;
// if (this.$store.state.training.started) {
// const activeList = this.$store.state.map.activeTrainList;
// driverList = driverList.filter(driver=>{
// return activeList.length > 0 && activeList.includes(driver.deviceCode);
// });
// } else {
// driverList = [];
// }
this.covertMemberList = [{
label: '行调',
id: 'dispatcher',
type: 'role',
children: dispatcherList
}, {
label: '车站值班员',
id: 'stationSupervisor',
type: 'role',
children: stationSupervisorList
}, {
label: '司机',
id: 'driver',
type: 'role',
children: driverList
}, {
label: '通号',
id: 'maintainer',
type: 'role',
children: maintainerList
}];
},
changeRole(member) {
if (member) {
// this.$store.dispatch('scriptRecord/updateIsScriptCommand', true);
this.switchMode(member);
}
},
addMember() {
this.$emit('addMember');
},
switchMode(role) {
changeScriptRole(this.group, role.id).then(res=>{
let prdType = '';
if (this.openWindow) {
this.openWindow.close();
}
if (role.type == '行值') {
prdType = '01';
this.$store.dispatch('training/setRoles', 'STATION_SUPERVISOR');
this.$store.dispatch('training/setRoleDeviceCode', role.deviceCode);
} else if (role.type == '行调') {
prdType = '02';
this.$store.dispatch('training/setRoles', 'DISPATCHER');
} else if (role.type == '司机') {
prdType = '04';
} else if (role.type == '通号') {
prdType = '';
const routeData = this.$router.resolve({
path:'/jlmap3d/maintainer',
query:{
mapid:this.$route.query.mapId,
group:this.group,
token:getToken(),
project: this.project,
noPreLogout: true
}
});
this.openWindow = window.open(routeData.href);
} else {
prdType = '';
}
this.$store.dispatch('training/updateMemberListInScript',
{
oldMemberId:this.oldMemberId,
newMember:role,
userId:this.$store.state.user.id,
name:this.$store.state.user.nickname
}
);
// this.oldMemberId = role.id;
this.$store.dispatch('training/setPrdType', prdType);
ConstConfig.ConstSelect.roleTypeNew.forEach(each=>{
if (each.label == role.type) {
this.$store.dispatch('scriptRecord/updateRole', each.value + ':' + role.id);
}
});
this.$emit('setMemberId', role.id);
this.$message('切换角色成功');
// this.$refs.changeScriptRole.blur();
}).catch(()=>{
this.$messageBox('切换角色失败');
// this.$refs.changeScriptRole.blur();
});
}
}
};
</script>
<style scoped>
.setGroup{
font-size: 14px;
float: right;
margin-right: 15px;
}
.settingBtn{
color: #409eff;
cursor: pointer;
padding: 5px 10px;
border-radius: 4px;
}
.hasSetted{
}
</style>

View File

@ -1,4 +1,5 @@
<template>
<div>
<div class="scriptRecordNew" :style="{bottom:(offsetBottom-15)+'px'}">
<div v-show="isShow" class="scriptRecordNewIn">
<el-tabs type="card">
@ -7,10 +8,30 @@
<div class="scriptPanelLeft">
<div class="panelLeftSelect">
<span style="font-size:13px;">当前剧本角色:</span>
<span style="font-size:13px;">{{ getRoleName(memberId) }}</span>
<!-- <el-tree
ref="tree"
:data="quickChangeMember"
:props="defaultProps"
node-key="id"
default-expand-all
style="margin: 10px;overflow-y:auto;height:255px;margin-right: 0;"
>
<span :id="data.id" slot-scope="{ node, data }" style="width:100%">
<span style="font-size: 14px">{{ data.label }}</span>
<span v-if="data.type!='role'" class="setGroup">
<span v-if="data.id!=memberId" class="settingBtn" @click="changeRole(data)">设置</span>
<span v-else class="hasSetted">已设置</span>
</span>
</span>
</el-tree> -->
<!-- :disabled="!backDisabled||isPause" -->
<el-select ref="changeScriptRole" v-model="memberId" filterable placeholder="请选择" @change="changeRole">
<!-- <el-select ref="changeScriptRole" v-model="memberId" filterable placeholder="请选择" @change="changeRole">
<el-option v-for="member in memberList" :key="member.id" :label="member.name" :value="member.id" />
</el-select>
</el-select> -->
</div>
<el-button-group class="button-group">
<el-button v-if="isPause" size="small" type="primary" :disabled="executeDisabled" @click="pauseScript">{{ $t('scriptRecord.drivingPause') }}</el-button>
@ -25,26 +46,36 @@
</div>
</div>
</el-tab-pane>
<el-tab-pane label="所有成员">
<div class="eachScriptPanel">
<all-script-role ref="allScriptRole" :member-list="memberList" :member-id="memberId" :group="group" @setMemberId="setMemberId" @addMember="addMember" />
</div>
</el-tab-pane>
</el-tabs>
</div>
<div class="scriptRecordNewTitle" @click="minisize">
<span class="titleStyle">{{ $t('scriptRecord.scriptRecordTitle') }}</span>
</div>
</div>
<add-script-member ref="addScriptMember" @addScriptMember="addScriptMember" />
</div>
</template>
<script>
import Vue from 'vue';
import GetActionNew from './getAction';
import { getToken } from '@/utils/auth';
import {getSimulationMemberList, executeScriptNew, dumpScriptDataNew, saveScriptDataNew, saveScriptScenesNew, updateMapLocationNew, simulationPause} from '@/api/simulation';
import ConstConfig from '@/scripts/ConstConfig';
import {getDraftScriptByGroupNew, changeScriptRole} from '@/api/script';
import {getDraftScriptByGroupNew, getAllSelectedScriptRole } from '@/api/script';
import AddScriptMember from './addScriptMember';
import Cookies from 'js-cookie';
import AllScriptRole from './allScriptRole';
export default {
name:'TipScriptRecord',
components: {
GetActionNew
GetActionNew,
AllScriptRole,
AddScriptMember
},
props: {
group: {
@ -64,16 +95,20 @@ export default {
return {
isShow:true,
language:'',
oldMemberId:'',
memberId:'',
isPause:false,
executeDisabled: false,
backDisabled: false,
autoSaveScript: null,
isSavingScript: false,
mapLocation:null,
memberId:'',
allMemberList:[],
memberList:[],
// defaultProps: {
// children: 'children',
// label: 'label'
// },
// quickChangeMember:[],
size: {
width: 300,
height: 300
@ -134,10 +169,26 @@ export default {
}
this.$store.dispatch('training/setPrdType', '02');
this.$store.dispatch('training/setRoles', 'DISPATCHER');
getAllSelectedScriptRole(this.group).then(res=>{
this.quickChangeMember = res.data;
});
}).catch(error => {
this.$message(error.message);
});
},
addScriptMember(member) {
const lastData = JSON.stringify([member]);
const covertmember = this.covert(lastData, ConstConfig.ConstSelect.roleTypeNew);
covertmember.forEach(each=>{
this.memberList.push(each);
});
},
setMemberId(memberId) {
this.memberId = memberId;
},
addMember() {
this.$refs.addScriptMember.doShow();
},
changeRunPlanStatus() {
this.memberList = [];
if (this.$store.state.training.started) {
@ -157,6 +208,15 @@ export default {
});
}
},
getRoleName(memberId) {
const currentMember = this.memberList.find(member=>{
return member.id == memberId;
});
if (currentMember) {
return currentMember.name;
}
return '';
},
minisize() {
if (this.isShow) {
this.isShow = false;
@ -164,70 +224,6 @@ export default {
this.isShow = true;
}
},
changeRole(member) {
if (member) {
// this.$store.dispatch('scriptRecord/updateIsScriptCommand', true);
this.switchMode(member);
}
},
switchMode(role) {
changeScriptRole(this.group, role).then(res=>{
let prdType = '';
const memberInfo = this.memberList.find(member=>{
return member.id == role;
});
if (memberInfo) {
if (this.openWindow) {
this.openWindow.close();
}
if (memberInfo.type == '行值') {
prdType = '01';
this.$store.dispatch('training/setRoles', 'STATION_SUPERVISOR');
this.$store.dispatch('training/setRoleDeviceCode', memberInfo.deviceCode);
} else if (memberInfo.type == '行调') {
prdType = '02';
this.$store.dispatch('training/setRoles', 'DISPATCHER');
} else if (memberInfo.type == '司机') {
prdType = '04';
} else if (memberInfo.type == '通号') {
prdType = '';
const routeData = this.$router.resolve({
path:'/jlmap3d/maintainer',
query:{
mapid:this.$route.query.mapId,
group:this.group,
token:getToken(),
project: this.project,
noPreLogout: true
}
});
this.openWindow = window.open(routeData.href);
} else {
prdType = '';
}
}
this.$store.dispatch('training/updateMemberListInScript',
{
oldMemberId:this.oldMemberId,
newMemberId:role,
userId:this.$store.state.user.id,
name:this.$store.state.user.nickname
}
);
this.oldMemberId = role;
this.$store.dispatch('training/setPrdType', prdType);
ConstConfig.ConstSelect.roleTypeNew.forEach(each=>{
if (each.label == memberInfo.type) {
this.$store.dispatch('scriptRecord/updateRole', each.value + ':' + role);
}
});
this.$refs.changeScriptRole.blur();
}).catch(()=>{
this.$messageBox('切换角色失败');
this.$refs.changeScriptRole.blur();
});
},
covert(data, roleTypeList) {
let lastData = data;
roleTypeList.forEach(function(element) {
@ -240,7 +236,7 @@ export default {
});
lastData = JSON.parse(lastData);
lastData.forEach(each=>{
const name = each.name == undefined ? '' : '-' + each.name;
// const name = each.name == undefined ? '' : '-' + each.name;
let deviceName = '';
if (each.deviceCode) {
const device = this.$store.getters['map/getDeviceByCode'](each.deviceCode);
@ -254,7 +250,7 @@ export default {
deviceName = each.deviceCode;
}
}
each.name = each.type + deviceName + name;
each.name = each.type + deviceName;
});
return lastData;
},
@ -342,7 +338,8 @@ export default {
this.$parent.resetBeginTime();
this.$refs['getAction'].loadInitData();
this.changeRunPlanStatus();
this.memberId = '';
//
// this.memberId = '';
this.$store.dispatch('training/setPrdType', '02');
this.$store.dispatch('map/resetActiveTrainList');
// this.initAutoSaveScript();