rt-sim-training-client/src/views/system/deviceManage/editConfig.vue

239 lines
9.2 KiB
Vue
Raw Normal View History

2020-01-02 17:01:11 +08:00
<template>
2020-06-19 18:02:50 +08:00
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" width="500px" :before-close="handleClose" center :close-on-click-modal="false">
2020-07-10 18:30:37 +08:00
<el-form v-show="data.type === 'VR_IBP'" ref="formIbp" :model="formIbp" label-width="100px" :rules="rulesIbp">
2020-06-19 18:02:50 +08:00
<el-form-item label="显示位置:" prop="part">
<el-select v-model="formIbp.part" placeholder="请选择" size="small">
<el-option
v-for="item in partList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
2020-07-07 16:09:14 +08:00
<el-form-item label="现地工作站:" prop="deviceCode" size="small">
<el-select v-model="formIbp.deviceCode" placeholder="请选择" size="small">
2020-06-30 14:27:32 +08:00
<el-option
2020-07-01 18:52:29 +08:00
v-for="item in lwList"
2020-06-30 14:27:32 +08:00
:key="item.code"
2020-07-01 18:52:29 +08:00
:label="item.code"
:value="item.code"
2020-06-30 14:27:32 +08:00
/>
</el-select>
</el-form-item>
2020-06-19 18:02:50 +08:00
</el-form>
<el-form v-show="data.type === 'LW'" ref="formLw" :model="formLw" label-width="100px" :rules="rulesLw">
2020-07-01 18:52:29 +08:00
<el-form-item label="关联地图:" prop="mapId">
<el-select v-model="formLw.mapId" placeholder="请选择" size="small" @change="mapIdChange">
<el-option
v-for="item in mapList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="关联车站:" prop="stationCode">
2020-06-30 14:27:32 +08:00
<el-select v-model="formLw.stationCode" placeholder="请选择" size="small">
2020-06-19 18:02:50 +08:00
<el-option
2020-06-30 14:27:32 +08:00
v-for="item in stationList"
2020-06-19 18:02:50 +08:00
:key="item.code"
2020-06-30 14:27:32 +08:00
:label="item.name"
2020-06-19 18:02:50 +08:00
:value="item.code"
/>
</el-select>
</el-form-item>
</el-form>
2020-07-07 18:22:54 +08:00
<el-form v-show="data.type === 'ISCS_LW' || data.type === 'ISCS_CW'" ref="formIscs" :model="formIscs" label-width="100px" :rules="rulesIscs">
<el-form-item :label="data.type === 'ISCS_LW'?'现地工作站:': '行调工作站'" prop="deviceCode">
<el-select v-model="formIscs.deviceCode" placeholder="请选择" size="small">
<el-option
v-for="item in lwList"
:key="item.code"
:label="item.code"
:value="item.code"
/>
</el-select>
</el-form-item>
2020-07-07 16:09:14 +08:00
</el-form>
2020-01-02 17:01:11 +08:00
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="doSave">{{ $t('global.confirm') }}</el-button>
<el-button @click="handleClose">{{ $t('global.cancel') }}</el-button>
</span>
</el-dialog>
</template>
<script>
2020-07-10 18:30:37 +08:00
import { getDeviceDetail, setVrIbpConfig, setLwConfig, getDevicesByType, setIscsLwConfig, setIscsCwConfig } from '@/api/project';
2020-07-01 18:52:29 +08:00
import { getAllMapOnline, getStationListNeedAttendant } from '@/api/jmap/map';
2020-01-02 17:01:11 +08:00
export default {
name: 'EditConfig',
props: {
2020-04-24 14:17:15 +08:00
// type: {
// type: String,
// required: true
// }
2020-01-02 17:01:11 +08:00
},
data() {
return {
dialogVisible: false,
2020-06-19 18:02:50 +08:00
data: {},
2020-07-01 18:52:29 +08:00
mapList: [],
lwList: [],
2020-06-19 18:02:50 +08:00
formIbp: {
2020-06-30 14:27:32 +08:00
part: '',
2020-07-07 16:09:14 +08:00
deviceCode: ''
2020-06-19 18:02:50 +08:00
},
formLw: {
2020-07-01 18:52:29 +08:00
mapId: '',
2020-06-30 14:27:32 +08:00
stationCode: ''
2020-06-19 18:02:50 +08:00
},
2020-07-07 18:22:54 +08:00
formIscs: {
deviceCode: ''
},
2020-06-19 18:02:50 +08:00
rulesIbp: {
part: [
{ required: true, message: '请选择显示位置', trigger: 'change' }
2020-06-30 14:27:32 +08:00
],
2020-07-07 16:09:14 +08:00
deviceCode: [
2020-06-30 14:27:32 +08:00
{ required: true, message: '请选择归属车站', trigger: 'change'}
2020-06-19 18:02:50 +08:00
]
},
rulesLw: {
2020-06-30 14:27:32 +08:00
stationCode: [
{ required: true, message: '请选择关联车站', trigger: 'change'}
2020-06-19 18:02:50 +08:00
]
},
2020-07-07 18:22:54 +08:00
rulesIscs: {
deviceCode: [
{ required: true, message: '请选择关联设备', trigger: 'change'}
]
},
2020-06-30 14:27:32 +08:00
partList: [{label: '左', value: 'LEFT'}, {label: '右', value: 'RIGHT'}, {label: '全部', value: 'WHOLE'}],
stationList: []
2020-01-02 17:01:11 +08:00
};
},
computed: {
title() {
return '编辑设备配置';
}
},
methods: {
initData(row) {
getDeviceDetail(row.id).then(resp => {
2020-07-10 18:30:37 +08:00
if (resp.data.config && resp.data.type === 'VR_IBP') {
2020-06-19 18:39:41 +08:00
this.formIbp = JSON.parse(resp.data.config);
} else if (resp.data.config && resp.data.type === 'LW') {
this.formLw = JSON.parse(resp.data.config);
2020-07-07 18:22:54 +08:00
} else if (resp.data.config && (resp.data.type === 'ISCS_LW' || resp.data.type === 'ISCS_CW')) {
this.formIscs = JSON.parse(resp.data.config);
2020-01-02 17:01:11 +08:00
}
}).catch(()=> {
this.$message.error('获取项目设备详情失败!');
});
},
doShow(row) {
this.initData(row);
this.dialogVisible = true;
this.data = row;
2020-07-01 18:52:29 +08:00
this.mapList = [];
this.stationList = [];
2020-07-10 18:30:37 +08:00
if (this.data.type === 'VR_IBP' || this.data.type === 'ISCS_LW') {
2020-07-01 18:52:29 +08:00
getDevicesByType('LW').then(res => {
2020-06-19 18:02:50 +08:00
if (res.data && res.data.length) {
2020-07-01 18:52:29 +08:00
this.lwList = res.data;
2020-06-19 18:02:50 +08:00
}
2020-07-01 18:52:29 +08:00
}).catch(() => {
this.$message.error('获取设备列表失败!');
});
2020-07-07 18:22:54 +08:00
} else if (this.data.type === 'ISCS_CW') {
getDevicesByType('CW').then(res => {
if (res.data && res.data.length) {
this.lwList = res.data;
}
}).catch(() => {
this.$message.error('获取设备列表失败!');
});
2020-07-01 18:52:29 +08:00
} else {
getAllMapOnline().then(res => {
if (res.data && res.data.length) {
this.mapList = res.data;
this.formLw.mapId = this.mapList[0].id;
this.mapIdChange(this.mapList[0].id);
}
}).catch(() => {
this.$message.error('获取地图列表失败!');
2020-06-19 18:02:50 +08:00
});
}
2020-07-01 18:52:29 +08:00
2020-01-02 17:01:11 +08:00
},
doSave() {
const self = this;
2020-07-10 18:30:37 +08:00
if (this.data.type === 'VR_IBP') {
2020-06-19 18:02:50 +08:00
this.$refs.formIbp.validate(() => {
2020-07-10 18:30:37 +08:00
setVrIbpConfig(this.data.id, this.formIbp).then(response => {
self.$message.success('设置虚拟IBP设备配置成功');
2020-06-19 18:02:50 +08:00
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
2020-01-02 17:01:11 +08:00
});
});
2020-06-19 18:02:50 +08:00
} else if (this.data.type === 'LW') {
this.$refs.formLw.validate(() => {
setLwConfig(this.data.id, this.formLw).then(response => {
2020-07-01 18:52:29 +08:00
self.$message.success('设置现地工作站配置成功');
2020-06-19 18:02:50 +08:00
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-07-07 18:22:54 +08:00
} else if (this.data.type === 'ISCS_LW') {
this.$refs.formIscs.validate(() => {
setIscsLwConfig(this.data.id, this.formIscs).then(response => {
self.$message.success('设置现地综合监控配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
} else if (this.data.type === 'ISCS_CW') {
this.$refs.formIscs.validate(() => {
setIscsCwConfig(this.data.id, this.formIscs).then(response => {
self.$message.success('设置中心综合监控配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-06-19 18:02:50 +08:00
}
2020-01-02 17:01:11 +08:00
},
2020-06-30 14:27:32 +08:00
handleClose() {
2020-01-02 17:01:11 +08:00
this.dialogVisible = false;
2020-06-19 18:02:50 +08:00
this.data = {};
2020-07-07 18:22:54 +08:00
this.lwList = [];
2020-06-30 14:27:32 +08:00
this.$refs.formIbp.resetFields();
this.$refs.formLw.resetFields();
2020-07-07 18:22:54 +08:00
this.$refs.formIscs.resetFields();
2020-07-01 18:52:29 +08:00
},
mapIdChange(mapId) {
if (mapId) {
getStationListNeedAttendant(mapId).then(resp => {
if (resp.data && resp.data.length) {
this.stationList = resp.data;
}
}).catch(() => {
this.$message.error('获取车站列表失败');
});
} else {
this.stationList = [];
}
2020-01-02 17:01:11 +08:00
}
}
};
</script>