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

273 lines
12 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">
<data-form ref="dataForm" :form="formItem" :form-model="formData" :rules="rules" />
2020-07-07 17:37:45 +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-08-04 10:42:04 +08:00
import { getDevicesByType, getDeviceDetail, setLswConfig, setCctvConfig, setVrPsdConfig, setPlcConfig, setSandboxConfig } 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 },
2020-07-22 14:59:00 +08:00
{ label: '第四屏', value: 4 },
{ label: '第五屏', value: 5 },
{ label: '第六屏', value: 6 },
{ label: '全部', value: 99 }
2020-07-07 17:37:45 +08:00
],
deviceList: [],
formData: {
addr: '',
quantity: '',
2020-07-07 17:37:45 +08:00
quadrant: '',
2020-07-08 15:40:55 +08:00
deviceCode: '',
psdCode: '',
mapId: '',
stationCode: '',
standCode: ''
2020-07-07 17:37:45 +08:00
},
rules: {
addr: [
{ required: true, message: '请填写读取开始位地址', trigger: 'blur'}
],
quantity: [
{ required: true, message: '请填写数量', trigger: 'blur'}
],
2020-07-07 17:37:45 +08:00
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
},
mapList: [],
2020-07-08 16:29:40 +08:00
stationList: [],
standList: [],
psdList: []
2020-07-07 17:37:45 +08:00
};
},
computed: {
title() {
return '编辑设备配置';
},
formItem() {
let form = {labelWidth: '150px', item: []};
if (this.data.type === 'PLC_GATEWAY') {
form = {
labelWidth: '150px',
items: [
{ prop:'addr', label: '读取开始位地址:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, noControls: true},
{ prop: 'quantity', label: '位数量:', type: 'number', min: 0, max: 20000, step: 1, precisionFlag: true, precision: 0, noControls: true }
]
};
} else if (this.data.type === 'VR_PSD') {
form = {
labelWidth: '150px',
items: [
{ prop: 'deviceCode', label: '教研机:', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code' },
{ prop: 'mapId', label: '关联地图:', type: 'select', options: this.mapList, optionLabel: 'name', optionValue: 'id', deviceChange: this.mapIdChange},
{ prop: 'stationCode', label: '关联车站:', type: 'select', options: this.stationList, optionLabel: 'name', optionValue: 'code', deviceChange: this.stationCodeChange},
{ prop: 'standCode', label: '关联站台:', type: 'select', options: this.standList, optionLabel: 'name', optionValue: 'code', deviceChange: this.standCodeChange},
2020-08-04 14:47:47 +08:00
{ prop: 'psdCode', label: '关联屏蔽门:', type: 'select', options: this.psdList, optionLabel: 'code', optionValue: 'code' }
]
};
} else if (this.data.type === 'LSW') {
form = {
labelWidth: '150px',
items: [
{ prop: 'deviceCode', label: '教研机:', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code' },
{ prop: 'quadrant', label: '屏幕配置:', type: 'select', options: this.screenList, optionLabel: 'label', optionValue: 'value'}
]
};
} else if (this.data.type === 'CCTV') {
form = {
labelWidth: '150px',
items: [
{ prop: 'deviceCode', label: '教研机:', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code' }
]
};
2020-08-04 10:42:04 +08:00
} else if ( this.data.type === 'SANDBOX') {
form = {
labelWidth: '150px',
items: [
{ prop: 'deviceCode', label: '教研机', type: 'select', options: this.deviceList, optionLabel: 'code', optionValue: 'code'}
]
};
}
return form;
2020-07-07 17:37:45 +08:00
}
},
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,
addr: data.addr,
quantity: data.quantity
2020-07-07 17:37:45 +08:00
};
});
2020-07-22 14:59:00 +08:00
if (row.type === 'VR_PSD') {
getAllMapOnline().then(resp => {
if (resp.data && resp.data.length) {
this.mapList = resp.data;
this.formData.mapId = this.mapList[0].id;
2020-07-22 14:59:00 +08:00
this.mapIdChange(this.mapList[0].id);
}
}).catch(() => {
this.$message.error('获取地图列表失败');
});
}
2020-07-08 15:40:55 +08:00
},
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.formData.mapId, stationCode).then(resp => {
2020-07-08 16:29:40 +08:00
if (resp.data && resp.data.length) {
this.standList = resp.data;
}
}).catch(() => {
this.$message.error('获取站台列表失败');
});
}
},
standCodeChange(standCode) {
this.psdList = [];
if (standCode) {
getPsdListByStandCode(this.formData.mapId, standCode).then(resp => {
2020-07-08 16:29:40 +08:00
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.dataForm.validateForm(() => {
2020-07-07 17:37:45 +08:00
const param = {
deviceCode: this.formData.deviceCode,
quadrant: this.formData.quadrant
};
setLswConfig(this.data.id, param).then(() => {
2020-07-07 17:37:45 +08:00
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.dataForm.validateForm(() => {
2020-07-07 17:37:45 +08:00
const param = {
deviceCode: this.formData.deviceCode
};
setCctvConfig(this.data.id, param).then(() => {
2020-07-07 17:37:45 +08:00
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.dataForm.validateForm(() => {
2020-07-07 18:25:05 +08:00
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(() => {
2020-07-07 18:25:05 +08:00
self.$message.success('设置虚拟屏蔽门工作站配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
} else if (this.data.type == 'PLC_GATEWAY') {
this.$refs.dataForm.validateForm(() => {
const param = {
addr: this.formData.addr,
quantity: this.formData.quantity
};
setPlcConfig(this.data.id, param).then(() => {
self.$message.success('设置PLC配置成功');
self.handleClose();
self.$emit('reloadTable');
}).catch(error => {
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-08-04 10:42:04 +08:00
} else if (this.data.type === 'SANDBOX') {
this.$refs.dataForm.validateForm(() => {
const param = {
deviceCode: this.formData.deviceCode
};
setSandboxConfig(this.data.id, param).then(() => {
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.mapList = [];
this.stationList = [];
this.standList = [];
this.psdList = [];
this.mapId = '';
this.stationCode = '';
this.standCode = '';
this.deviceList = [];
this.$refs.dataForm.resetForm();
2020-07-07 17:37:45 +08:00
}
}
};
</script>