rt-sim-training-client/src/views/scriptManage/addScriptMember.vue
2020-09-01 18:27:36 +08:00

92 lines
2.9 KiB
Vue

<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-item label="仿真成员名称:" prop="name">
<el-input v-model="formModel.name" placeholder="请输入成员名称" />
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" :lodaing="lodaing" @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,
lodaing:false,
formModel: {
type: '',
name:''
},
rules: {
type: [
{ required: true, message: '请选择成员类型', trigger: 'change' }
]
// name:[
// { required: true, message: '请输入成员名称', trigger: 'blur' }
// ]
},
typeList: [{label: '行调', value: 'DISPATCHER'}, {label: '通号', value: 'MAINTAINER'}]
};
},
computed: {
title() {
return '添加仿真角色成员';
}
},
methods: {
doShow(row) {
this.dialogVisible = true;
},
doSave() {
this.$refs.form.validate((valid) => {
if (valid) {
this.lodaing = true;
addSimulationMember(this.formModel, this.$route.query.group).then((res) => {
this.$message.success('添加仿真角色成员成功!');
this.$emit('addScriptMember', res.data);
this.lodaing = false;
this.handleClose();
}).catch(() => {
this.lodaing = false;
this.$message.error('添加仿真角色成员失败!');
});
}
});
},
handleClose() {
this.dialogVisible = false;
this.formModel = {
type: '',
name:''
};
this.$refs.form.resetFields();
}
}
};
</script>