rt-sim-training-client/src/views/scriptManage/addScriptMember.vue

144 lines
4.9 KiB
Vue
Raw Normal View History

2020-08-17 18:47:38 +08:00
<template>
<el-dialog
v-dialogDrag
:title="title"
:visible.sync="dialogVisible"
append-to-body
2020-08-17 18:47:38 +08:00
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-item v-if="stationRoleList.includes(formModel.type)" label="值班车站:" prop="deviceCode">
2021-05-18 10:04:03 +08:00
<el-select v-model="formModel.deviceCode" placeholder="请选择" size="small">
<el-option
v-for="item in filterStationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
2020-08-21 14:16:44 +08:00
<el-form-item label="仿真成员名称:" prop="name">
<el-input v-model="formModel.name" placeholder="请输入成员名称" />
</el-form-item>
2020-08-17 18:47:38 +08:00
</el-form>
<span slot="footer" class="dialog-footer">
2020-08-21 14:16:44 +08:00
<el-button type="primary" :lodaing="lodaing" @click="doSave">{{ $t('global.confirm') }}</el-button>
2020-08-17 18:47:38 +08:00
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
import { addSimulationMember } from '@/api/jointSimulation';
export default {
name: 'AddMember',
2021-05-18 10:04:03 +08:00
props: {
stationList: {
type: Array,
required: true
}
},
2020-08-17 18:47:38 +08:00
data() {
return {
dialogVisible: false,
2020-08-21 14:16:44 +08:00
lodaing:false,
2020-08-17 18:47:38 +08:00
formModel: {
2020-08-21 14:16:44 +08:00
type: '',
2021-05-18 10:04:03 +08:00
name:'',
deviceCode: ''
2020-08-17 18:47:38 +08:00
},
stationRoleList:[
'STATION_SUPERVISOR',
'STATION_ASSISTANT',
'STATION_MASTER',
'STATION_SIGNALER',
'STATION_PASSENGER',
'STATION_SWITCH_MAN',
'STATION_FACILITATOR',
'STATION_WORKER',
2022-08-01 17:48:03 +08:00
'DEVICE_MANAGER',
'TRAIN_MASTER'
],
2021-05-18 10:04:03 +08:00
filterStationList: [],
2020-08-17 18:47:38 +08:00
rules: {
type: [
2020-08-21 14:16:44 +08:00
{ required: true, message: '请选择成员类型', trigger: 'change' }
2021-05-18 10:04:03 +08:00
],
deviceCode: [
{ required: true, message: '请选择值班车站', trigger: 'change' }
2020-08-17 18:47:38 +08:00
]
},
2021-05-18 10:04:03 +08:00
typeList: [
{label: '行调', value: 'DISPATCHER'},
{label: '通号', value: 'MAINTAINER'},
{label: '车站值班员', value: 'STATION_SUPERVISOR'},
{label: '车站助理', value: 'STATION_ASSISTANT'},
{label: '车站站长', value: 'STATION_MASTER'},
{label: '车站信号员', value: 'STATION_SIGNALER'},
{label: '车站客运员', value: 'STATION_PASSENGER'},
{label: '车站扳道员', value: 'STATION_SWITCH_MAN'},
{label: '车站引导员', value: 'STATION_FACILITATOR'},
2022-07-26 10:14:45 +08:00
{label: '车站工务工', value: 'STATION_WORKER'},
{label: '设备管理员', value: 'DEVICE_MANAGER'}
2021-05-18 10:04:03 +08:00
]
2020-08-17 18:47:38 +08:00
};
},
computed: {
title() {
return '添加仿真角色成员';
}
},
methods: {
doShow(row) {
2021-05-18 10:04:03 +08:00
this.filterStationList = [];
this.stationList.forEach(item => {
if (!item.depot) {
this.filterStationList.push(item);
}
});
2020-08-17 18:47:38 +08:00
this.dialogVisible = true;
},
doSave() {
2020-08-21 14:16:44 +08:00
this.$refs.form.validate((valid) => {
if (valid) {
this.lodaing = true;
2022-07-27 13:43:13 +08:00
// this.formModel.type !== 'STATION_SUPERVISOR'
if (!this.stationRoleList.includes(this.formModel.type)) { delete this.formModel.deviceCode; }
2020-08-21 14:16:44 +08:00
addSimulationMember(this.formModel, this.$route.query.group).then((res) => {
this.$message.success('添加仿真角色成员成功!');
this.$emit('addScriptMember', res.data);
2020-09-01 18:27:36 +08:00
this.lodaing = false;
2020-08-21 14:16:44 +08:00
this.handleClose();
}).catch(() => {
this.lodaing = false;
this.$message.error('添加仿真角色成员失败!');
});
}
2020-08-17 18:47:38 +08:00
});
},
handleClose() {
this.dialogVisible = false;
this.formModel = {
2020-08-21 14:16:44 +08:00
type: '',
2021-05-18 10:04:03 +08:00
name:'',
deviceCode: ''
2020-08-17 18:47:38 +08:00
};
this.$refs.form.resetFields();
}
}
};
</script>