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

238 lines
8.9 KiB
Vue
Raw Normal View History

2020-07-07 17:37:45 +08:00
<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="formData" label-width="100px" :rules="rules">
<el-form-item label="教员机:" prop="deviceCode">
<el-select v-model="formData.deviceCode" placeholder="请选择" size="small">
<el-option
v-for="item in deviceList"
:key="item.code"
:label="item.code"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item v-show="data.type === 'LSW'" label="屏目配置:" prop="quadrant" size="small">
<el-select v-model="formData.quadrant" placeholder="请选择" size="small">
<el-option
v-for="item in screenList"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
2020-07-08 15:40:55 +08:00
<el-form-item v-show="data.type === 'VR_PSD'" label="关联地图:" prop="mapId">
<el-select v-model="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 v-show="data.type === 'VR_PSD'" label="关联车站:" prop="stationCode">
2020-07-08 16:29:40 +08:00
<el-select v-model="stationCode" placeholder="请选择" size="small" @change="stationCodeChange">
2020-07-08 15:40:55 +08:00
<el-option
v-for="item in stationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
2020-07-08 16:29:40 +08:00
<el-form-item v-show="data.type === 'VR_PSD'" label="关联站台:" prop="standCode">
<el-select v-model="standCode" placeholder="请选择" size="small" @change="standCodeChange">
<el-option
v-for="item in standList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
<el-form-item v-show="data.type === 'VR_PSD'" label="关联屏蔽门:" prop="psdCode">
<el-select v-model="formData.psdCode" placeholder="请选择" size="small">
<el-option
v-for="item in psdList"
:key="item.code"
:label="item.code"
:value="item.code"
/>
</el-select>
</el-form-item>
2020-07-07 17:37:45 +08:00
</el-form>
<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-07 18:25:05 +08:00
import { getDevicesByType, getDeviceDetail, setLswConfig, setCctvConfig, setVrPsdConfig } from '@/api/project';
2020-07-08 16:29:40 +08:00
import { getAllMapOnline, getStationListNeedAttendant, getPsdListByStandCode, getStandListByStationCode } from '@/api/jmap/map';
2020-07-07 17:37:45 +08:00
export default {
2020-07-15 16:11:58 +08:00
name: 'EditConfigScreen',
2020-07-07 17:37:45 +08:00
data() {
return {
dialogVisible: false,
data: {},
screenList: [
{ label: '第一屏', value: 1 },
{ label: '第二屏', value: 2 },
{ label: '第三屏', value: 3 },
{ label: '第四屏', value: 4 }
],
deviceList: [],
formData: {
quadrant: '',
2020-07-08 15:40:55 +08:00
deviceCode: '',
psdCode: ''
2020-07-07 17:37:45 +08:00
},
rules: {
quadrant: [
{ required: true, message: '请选择显示屏幕', trigger: 'change' }
],
deviceCode: [
{ required: true, message: '请选择教员机', trigger: 'change'}
2020-07-08 16:29:40 +08:00
],
psdCode: [
{ required: true, message: '请选择关联屏蔽门', trigger: 'change'}
2020-07-07 17:37:45 +08:00
]
2020-07-08 15:40:55 +08:00
},
mapId: '',
mapList: [],
stationCode: '',
2020-07-08 16:29:40 +08:00
stationList: [],
standList: [],
standCode: '',
psdList: []
2020-07-07 17:37:45 +08:00
};
},
computed: {
title() {
return '编辑设备配置';
}
},
methods: {
initData(row) {
getDevicesByType('IM').then(resp => {
this.deviceList = resp.data;
}).catch(()=> {
this.$message.error('获取项目设备详情失败!');
});
},
doShow(row) {
this.initData(row);
this.dialogVisible = true;
this.data = row;
getDeviceDetail(this.data.id).then(res => {
const data = res.data.config ? JSON.parse(res.data.config) : {};
this.formData = {
quadrant: data.quadrant,
2020-07-09 11:07:04 +08:00
deviceCode: data.deviceCode,
psdCode: data.psdCode
2020-07-07 17:37:45 +08:00
};
});
2020-07-08 15:40:55 +08:00
getAllMapOnline().then(resp => {
if (resp.data && resp.data.length) {
this.mapList = resp.data;
this.mapId = this.mapList[0].id;
this.mapIdChange(this.mapList[0].id);
}
}).catch(() => {
this.$message.error('获取地图列表失败');
});
},
mapIdChange(mapId) {
2020-07-08 16:29:40 +08:00
this.stationList = [];
2020-07-08 15:40:55 +08:00
if (mapId) {
getStationListNeedAttendant(mapId).then(resp => {
if (resp.data && resp.data.length) {
this.stationList = resp.data;
}
}).catch(() => {
this.$message.error('获取车站列表失败');
});
2020-07-08 16:29:40 +08:00
}
},
stationCodeChange(stationCode) {
this.standList = [];
if (stationCode) {
getStandListByStationCode(this.mapId, stationCode).then(resp => {
if (resp.data && resp.data.length) {
this.standList = resp.data;
}
}).catch(() => {
this.$message.error('获取站台列表失败');
});
}
},
standCodeChange(standCode) {
this.psdList = [];
if (standCode) {
getPsdListByStandCode(this.mapId, standCode).then(resp => {
if (resp.data && resp.data.length) {
this.psdList = resp.data;
}
}).catch(() => {
this.$message.error('获取屏蔽门列表失败');
});
2020-07-08 15:40:55 +08:00
}
2020-07-07 17:37:45 +08:00
},
doSave() {
const self = this;
if (this.data.type == 'LSW') {
this.$refs.form.validate(() => {
const param = {
deviceCode: this.formData.deviceCode,
quadrant: this.formData.quadrant
};
setLswConfig(this.data.id, param).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 == 'CCTV') {
this.$refs.form.validate(() => {
const param = {
deviceCode: this.formData.deviceCode
};
setCctvConfig(this.data.id, param).then(response => {
self.$message.success('设置CCTV工作站配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-07-07 18:25:05 +08:00
} else if (this.data.type == 'VR_PSD') {
this.$refs.form.validate(() => {
const param = {
2020-07-08 16:29:40 +08:00
deviceCode: this.formData.deviceCode,
psdCode: this.formData.psdCode
2020-07-07 18:25:05 +08:00
};
setVrPsdConfig(this.data.id, param).then(response => {
self.$message.success('设置虚拟屏蔽门工作站配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-07-07 17:37:45 +08:00
}
},
handleClose() {
this.dialogVisible = false;
this.data = {};
this.$refs.form.resetFields();
}
}
};
</script>