2019-08-21 18:45:16 +08:00
|
|
|
<template>
|
2019-08-22 18:13:55 +08:00
|
|
|
<el-card class="scriptTop">
|
2019-09-10 19:08:48 +08:00
|
|
|
<el-transfer v-model="selectRoleData" :data="allRoleData" class="script-player-choose" :titles="[$t('scriptRecord.allRoles'), $t('scriptRecord.actors')]" @change="handleChange">
|
2019-08-21 18:45:16 +08:00
|
|
|
<span slot-scope="{option}">
|
|
|
|
<span>{{option.role+(option.name==undefined?'':option.name)}}</span>
|
|
|
|
<el-radio-group v-model="option.gender" size="mini" class="sexGroup" @change="changeSex($event,option.key)">
|
2019-09-10 19:08:48 +08:00
|
|
|
<el-radio-button label="Male">{{$t('scriptRecord.roleSexMale')}}</el-radio-button>
|
|
|
|
<el-radio-button label="Female">{{$t('scriptRecord.roleSexFemale')}}</el-radio-button>
|
2019-08-21 18:45:16 +08:00
|
|
|
</el-radio-group>
|
|
|
|
</span>
|
|
|
|
</el-transfer>
|
2019-08-22 18:13:55 +08:00
|
|
|
</el-card>
|
2019-08-21 18:45:16 +08:00
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import Vue from 'vue';
|
|
|
|
import ConstConfig from '@/scripts/ConstConfig';
|
|
|
|
import {getScriptPlayMember,getScriptMemberData,cancleScriptMembers,selectScriptMembers,modifyScriptMemberSex} from '@/api/simulation';
|
|
|
|
export default {
|
|
|
|
name: 'addRole',
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
allRoleData:[],
|
|
|
|
selectRoleData:[],
|
2019-09-10 19:08:48 +08:00
|
|
|
sexGroup:this.$t('scriptRecord.roleSexMale'),
|
2019-08-21 18:45:16 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted(){
|
|
|
|
this.initData();
|
|
|
|
},
|
2019-08-22 18:13:55 +08:00
|
|
|
watch:{
|
|
|
|
'$store.state.socket.simulationStart': function (val) {
|
|
|
|
if(val)
|
|
|
|
{
|
|
|
|
this.initData();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
2019-08-21 18:45:16 +08:00
|
|
|
methods:{
|
|
|
|
initData(){
|
|
|
|
let group=this.$props.group;
|
|
|
|
getScriptMemberData(group).then(response=>{
|
|
|
|
let lastData=JSON.stringify(response.data);
|
|
|
|
this.allRoleData=this.coverData(lastData);
|
|
|
|
getScriptPlayMember(group).then(response=>{
|
2019-08-21 20:32:37 +08:00
|
|
|
let last=response.data;
|
2019-08-29 13:05:30 +08:00
|
|
|
// let userdata=JSON.stringify(response.data)
|
|
|
|
// let reg=new RegExp('\"id\":\"(.*?)\\\"','g');
|
|
|
|
// let datalist=userdata.match(reg);
|
2019-08-21 18:45:16 +08:00
|
|
|
let data=[];
|
2019-08-21 20:32:37 +08:00
|
|
|
last.forEach(function(element){data.push(element.id)});
|
2019-08-21 18:45:16 +08:00
|
|
|
this.selectRoleData=data;
|
|
|
|
})
|
|
|
|
})
|
|
|
|
},
|
|
|
|
coverData(data){
|
|
|
|
let roleTypeList=ConstConfig.ConstSelect.roleType;
|
|
|
|
let lastData=data.replace(new RegExp('id','g'),'key');
|
|
|
|
roleTypeList.forEach(function(element){
|
|
|
|
let rolename=element.value;
|
|
|
|
lastData=lastData.replace(new RegExp(rolename,'g'),element.label);
|
|
|
|
});
|
|
|
|
lastData=JSON.parse(lastData);
|
|
|
|
return lastData;
|
|
|
|
},
|
|
|
|
handleChange(value, direction, movedKeys) {
|
|
|
|
switch(direction)
|
|
|
|
{
|
|
|
|
case 'right':{
|
|
|
|
let group=this.$props.group;
|
|
|
|
let data=movedKeys;
|
|
|
|
selectScriptMembers(group,data).then(response=>{
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.selectScriptActorSuccess'));
|
2019-08-22 18:13:55 +08:00
|
|
|
this.$emit("refresh");
|
2019-08-21 18:45:16 +08:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$messageBox(`${this.$t('scriptRecord.selectScriptActorFail')}: ${error.message}`);
|
2019-08-21 20:32:37 +08:00
|
|
|
return false;
|
2019-08-21 18:45:16 +08:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 'left':{
|
|
|
|
let group=this.$props.group;
|
|
|
|
let data=movedKeys;
|
|
|
|
cancleScriptMembers(group,data).then(response=>{
|
2019-08-22 18:13:55 +08:00
|
|
|
this.$emit("refresh");
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.cancleScriptActorSuccess'));
|
2019-08-21 18:45:16 +08:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$messageBox(`${this.$t('scriptRecord.cancleScriptActorFail')}: ${error.message}`);
|
2019-08-21 20:32:37 +08:00
|
|
|
this.initData();
|
2019-08-21 18:45:16 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2019-08-29 13:05:30 +08:00
|
|
|
// resetData(data){
|
|
|
|
// debugger;
|
|
|
|
// let allRoleData=this.allRoleData;
|
|
|
|
// // debugger;
|
|
|
|
// data.forEach(function(element){
|
|
|
|
// allRoleData.forEach(function(select){
|
|
|
|
// if(select.key==element)
|
|
|
|
// {
|
|
|
|
// debugger;
|
|
|
|
// select.disabled="disabled";
|
|
|
|
// }
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
// },
|
2019-08-21 18:45:16 +08:00
|
|
|
changeSex(event,id)
|
|
|
|
{
|
|
|
|
let group=this.$props.group;
|
|
|
|
let data={"gender":event};
|
|
|
|
modifyScriptMemberSex(group,id,data).then(response=>{
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$message.success(this.$t('scriptRecord.modifyScriptActorSexSuccess'));
|
2019-08-21 18:45:16 +08:00
|
|
|
})
|
|
|
|
.catch(error => {
|
2019-09-10 19:08:48 +08:00
|
|
|
this.$messageBox(`${this.$t('scriptRecord.modifyScriptActorSexFail')}: ${error.message}`);
|
2019-08-21 18:45:16 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
|
|
|
.elTransfer{
|
|
|
|
margin-left:20px;
|
|
|
|
width:700px;
|
|
|
|
}
|
2019-08-22 18:13:55 +08:00
|
|
|
.scriptTop{
|
|
|
|
padding: 10px 10px;
|
|
|
|
width: 730px;
|
|
|
|
}
|
2019-08-21 20:40:02 +08:00
|
|
|
/deep/ {
|
|
|
|
.script-player-choose .el-transfer-panel__body{
|
|
|
|
height: 120px;
|
|
|
|
}
|
|
|
|
.script-player-choose .el-transfer-panel__list{
|
|
|
|
height: 120px;
|
|
|
|
}
|
|
|
|
.script-player-choose .el-transfer-panel{
|
2019-08-22 18:13:55 +08:00
|
|
|
width: 310px;
|
|
|
|
}
|
|
|
|
.el-transfer-panel__item{
|
|
|
|
margin-right:0px;
|
|
|
|
}
|
|
|
|
.el-transfer__buttons{
|
|
|
|
padding: 0 20px;
|
2019-08-21 20:40:02 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-21 18:45:16 +08:00
|
|
|
</style>
|
|
|
|
<style>
|
|
|
|
.sexGroup{
|
|
|
|
margin-left: 10px;
|
|
|
|
}
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|