rt-sim-training-client/src/views/newMap/displayNew/demon/addQuest.vue

277 lines
9.9 KiB
Vue
Raw Normal View History

2019-12-30 09:00:16 +08:00
<template>
<div>
<el-dialog
v-dialogDrag
:title="$t('display.script.scriptList')"
:visible.sync="show"
top="50px"
width="70%"
:before-do-close="doClose"
:close-on-click-modal="false"
:z-index="2000"
>
<QueryListPage
ref="queryListPage"
:pager-config="pagerConfig"
:query-form="queryForm"
:query-list="queryList"
/>
</el-dialog>
<el-dialog
v-dialogDrag
:title="$t('display.script.roleSelect')"
:visible.sync="roleShow"
top="50px"
width="350px"
:before-do-close="roleDoClose"
:close-on-click-modal="false"
:z-index="5000"
>
<div>
<el-form ref="ruleForm" :model="form" label-width="50px">
<el-form-item :label="$t('display.script.role')" prop="role">
<el-select v-model="form.type" :placeholder="$t('display.script.pleaseSelect')">
2019-12-30 09:00:16 +08:00
<el-option
v-for="item in memberList"
:key="item.id"
:label="(roleConfig[item.type]?roleConfig[item.type]: '')+(item.name?item.name: '')"
2019-12-30 09:00:16 +08:00
:value="item.id"
2020-08-21 15:41:46 +08:00
:disabled="item.disabled"
2019-12-30 09:00:16 +08:00
/>
2020-08-21 15:41:46 +08:00
<!-- checkDisabled(item.type) -->
2019-12-30 09:00:16 +08:00
</el-select>
</el-form-item>
</el-form>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="roleDoClose">{{ $t('global.cancel') }}</el-button>
<el-button type="primary" @click="confirm">{{ $t('global.confirm') }}</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
2020-05-15 16:54:31 +08:00
import Cookies from 'js-cookie';
import ConstConfig from '@/scripts/ConstConfig';
2020-08-17 13:21:27 +08:00
import {getScriptPageListOnlineNew, getScriptByIdNew } from '@/api/script';
2020-08-28 11:30:55 +08:00
import { EventBus } from '@/scripts/event-bus';
2019-12-30 09:00:16 +08:00
// 剧本弹窗
export default {
name: 'AddQuest',
props: {
trainings: {
type: Array,
default() {
return [];
}
},
detail: {
type: Object,
default() {
return null;
}
}
},
data() {
return {
show: false,
roleShow: false,
pagerConfig: {
pageSize: 'pageSize',
pageIndex: 'pageNum'
},
row: {},
form: {
type: ''
2019-12-30 09:00:16 +08:00
},
memberList: [],
mapLocation:null,
queryForm: {
labelWidth: '80px',
reset: false,
show: false,
queryObject: {
}
},
queryList: {
query: this.listQuest,
selectCheckShow: false,
indexShow: true,
columns: [
{
title: this.$t('display.script.scriptName'),
prop: 'name'
},
{
title: this.$t('display.script.createTime'),
prop: 'createTime'
},
{
type: 'button',
title: this.$t('display.script.operate'),
width: '250',
buttons: [
{
name: this.$t('display.script.loadScript'),
type: 'primary',
handleClick: this.handleLoad
}
]
}
],
actions: [
]
},
currentModel: {},
roleConfig: {
'Admin': this.$t('display.script.admin'),
'Instructor': this.$t('display.script.instructor'),
'Dispatcher': this.$t('display.script.dispatcher'),
'Attendant': this.$t('display.script.attendant'),
'Audience': this.$t('display.script.audience'),
'Driver': this.$t('display.script.driver'),
'Repair':this.$t('display.script.repair'),
'no': ''
}
};
},
created() {
this.loadInitData();
},
methods: {
doShow() {
this.show = true;
this.reloadTable();
},
doClose() {
this.show = false;
},
listQuest(params) {
params['mapId'] = this.$route.query.mapId;
2020-05-14 17:24:47 +08:00
return getScriptPageListOnlineNew(params);
2019-12-30 09:00:16 +08:00
},
async loadInitData() {
2020-05-15 16:54:31 +08:00
},
covert(data, roleTypeList) {
let lastData = data;
roleTypeList.forEach(function(element) {
const rolename = element.value;
if (Cookies.get('user_lang') == 'en') {
lastData = lastData.replace(new RegExp(rolename, 'g'), element.enLabel);
} else {
lastData = lastData.replace(new RegExp(rolename, 'g'), element.label);
}
});
lastData = JSON.parse(lastData);
lastData.forEach(each=>{
const name = each.name == undefined ? '' : '-' + each.name;
const deviceName = each.deviceName == undefined ? '' : '-' + each.deviceName;
2020-07-10 16:40:42 +08:00
each.name = each.type + deviceName + name;
2020-08-21 15:41:46 +08:00
each.disabled = false;
const prdType = this.$store.state.training.prdType;
if ( prdType == '01') {
if (each.type !== '行值' && each.type !== 'no') { each.disabled = true; }
} else if (prdType == '02') {
if (each.type !== '行调' && each.type !== 'no') { each.disabled = true; }
} else if (prdType == '04') {
if (each.type !== '司机' && each.type !== 'no') { each.disabled = true; }
}
2020-05-15 16:54:31 +08:00
});
return lastData;
2019-12-30 09:00:16 +08:00
},
async handleLoad(index, row) {
this.row = row;
2020-08-17 13:21:27 +08:00
const res = await getScriptByIdNew(row.id);
2020-05-14 17:24:47 +08:00
let newMemberList = [];
if (res.code == 200) {
2020-08-28 11:30:55 +08:00
EventBus.$emit('clearRunSeries');
2020-06-17 09:56:51 +08:00
if (res.data.memberList && res.data.memberList.length > 0) {
2020-06-17 18:36:22 +08:00
// newMemberList
2020-07-10 14:46:18 +08:00
// const playerList = res.data.memberList.filter(item => item.hasPlay === true);
// playerList.map(each=>{
// if (!each.deviceName && each.deviceCode) {
// const device = this.$store.getters['map/getDeviceByCode'](each.deviceCode);
// if (device.name) {
// each.deviceName = device.name;
// } else {
// each.deviceName = each.deviceCode;
// }
// }
// });
2020-07-15 19:05:32 +08:00
this.form.type = '';
this.$store.dispatch('training/setMemberList', {memberList:res.data.memberList, userId:this.$store.state.user.id});
2020-07-10 14:46:18 +08:00
const activeMemberList = [];
res.data.actionList.forEach((activeMember)=>{
if (!(activeMemberList.length > 0 && activeMemberList.includes(activeMember.memberId))) {
activeMemberList.push(activeMember.memberId);
}
});
const playerList = res.data.memberList.filter(member=>{
return activeMemberList.includes(member.id);
});
playerList.map(member=>{
if (!member.deviceName && member.deviceCode) {
const device = this.$store.getters['map/getDeviceByCode'](member.deviceCode);
2020-06-18 09:20:42 +08:00
if (device.name) {
2020-07-10 14:46:18 +08:00
member.deviceName = device.name;
2020-06-18 09:20:42 +08:00
} else {
2020-07-10 14:46:18 +08:00
member.deviceName = member.deviceCode;
2020-06-18 09:20:42 +08:00
}
2020-06-17 18:36:22 +08:00
}
});
const lastData = JSON.stringify(playerList);
newMemberList = this.covert(lastData, ConstConfig.ConstSelect.roleTypeNew);
2019-12-30 09:00:16 +08:00
}
2020-05-14 17:24:47 +08:00
if (res.data.mapLocation) {
this.mapLocation = res.data.mapLocation;
2019-12-30 09:00:16 +08:00
}
2020-05-14 17:24:47 +08:00
this.memberList = newMemberList || [];
this.memberList.unshift({ id: '', name: this.$t('display.script.none'), role: 'no' });
2019-12-30 09:00:16 +08:00
}
this.roleShow = true;
},
reloadTable() {
if (this.queryList && this.queryList.reload) {
this.queryList.reload();
}
},
confirm() {
const roleName = this.memberList.find(elem=>{ return elem.id == this.form.type; });
this.$emit('selectQuest', this.row, this.form.type, this.mapLocation, roleName.type);
2019-12-30 09:00:16 +08:00
this.doClose();
this.roleDoClose();
},
roleDoClose() {
this.$refs['ruleForm'].resetFields();
this.roleShow = false;
},
2020-08-21 15:41:46 +08:00
// checkDisabled(role) {
// const prdType = this.$store.state.training.prdType;
// return this.judgeDisabled(prdType, role);
// },
// judgeDisabled(prdType, role) {
// if ( prdType == '01') {
// return role !== '行值' && role !== 'no';
// } else if (prdType == '02') {
// return role !== '行调' && role !== 'no';
// } else if (prdType == '04') {
// return role !== '司机' && role !== 'no';
// }
// },
2019-12-30 09:00:16 +08:00
handleName(item) {
return this.roleConfig[item.type] ? this.roleConfig[item.type] : '' + (item.name ? item.name : '');
2019-12-30 09:00:16 +08:00
}
}
};
</script>