rt-sim-training-client/src/views/scriptManage/scriptRecord/addRole.vue

164 lines
5.8 KiB
Vue
Raw Normal View History

2019-08-21 18:45:16 +08:00
<template>
2019-08-22 18:13:55 +08:00
<el-card class="scriptTop">
2019-08-21 20:40:02 +08:00
<el-transfer v-model="selectRoleData" :data="allRoleData" class="script-player-choose" :titles="['所有角色', '演员角色']" @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)">
<el-radio-button label="Male"></el-radio-button>
<el-radio-button label="Female"></el-radio-button>
</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:[],
sexGroup:"男",
}
},
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=>{
let last=response.data;
// 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=[];
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=>{
this.$message.success('选择剧本角色成功');
2019-08-22 18:13:55 +08:00
this.$emit("refresh");
2019-08-21 18:45:16 +08:00
})
.catch(error => {
this.$messageBox(`选择剧本角色失败: ${error.message}`);
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-08-21 18:45:16 +08:00
this.$message.success('取消剧本角色成功');
})
.catch(error => {
this.$messageBox(`取消剧本角色失败: ${error.message}`);
this.initData();
2019-08-21 18:45:16 +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=>{
this.$message.success('修改剧本成员性别成功');
})
.catch(error => {
this.$messageBox(`修改剧本成员性别失败: ${error.message}`);
});
}
}
}
</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>