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

155 lines
5.2 KiB
Vue
Raw Normal View History

2020-07-16 13:31:05 +08:00
<template>
2020-07-17 13:05:18 +08:00
<el-dialog v-dialogDrag :title="title" :visible.sync="dialogVisible" top="10vh" width="60%" :before-close="handleClose" center :close-on-click-modal="false">
<!--<data-form ref="dataTop" :form="formTop" :inline="inline" :form-model="formModel" :rules="topRules" />-->
2020-07-17 16:35:24 +08:00
<el-form ref="formStation" :model="formModel" label-width="220px" :rules="rulesStation" :inline="inline">
<el-form-item label="关联地图:" prop="mapId">
<el-select v-model="mapId" placeholder="请选择" size="small" style="width: 180px" @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">
<el-select v-model="formModel.stationCode" placeholder="请选择" style="width: 180px" size="small">
<el-option
v-for="item in stationList"
:key="item.code"
:label="item.name"
:value="item.code"
/>
</el-select>
</el-form-item>
</el-form>
<el-input v-model="jsonConfig" autosize :readonly="true" type="textarea" />
2020-07-16 13:31:05 +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>
import { getDeviceDetail, setIbpConfig} from '@/api/project';
2020-07-16 19:11:20 +08:00
import { deepAssign } from '@/utils/index';
2020-07-17 16:35:24 +08:00
import { getAllMapOnline, getStationListNeedAttendant } from '@/api/jmap/map';
2020-07-16 13:31:05 +08:00
export default {
name: 'EditConfigIbp',
data() {
return {
title: '编辑IBP盘配置',
2020-07-17 16:35:24 +08:00
activeNames: [],
2020-07-16 19:11:20 +08:00
checkCount: 0,
data: null,
jsonConfig: '',
2020-07-16 19:11:20 +08:00
formModel: {
afczjConfig: {},
dftConfig: {},
hjsbjkConfig: {
pfConfig: {},
shfConfig: {}
},
mjConfig: {},
pbmConfig: {},
sdtfConfig: {},
xhConfig: {},
xhsbConfig: {}
},
topRules: {
addr: [
{ required: true, message: '请填写网关位地址', trigger: 'blur' }
],
quantity: [
{ required: true, message: '请填写位数量', trigger: 'blur'}
]
},
2020-07-17 16:35:24 +08:00
rulesStation: {
stationCode: [
{ required: true, message: '请选择关联设备', trigger: 'change' }
]
},
2020-07-16 13:31:05 +08:00
dialogVisible: false,
2020-07-16 19:11:20 +08:00
inline: true,
2020-07-17 16:35:24 +08:00
mapId: '',
mapList: [],
stationList: []
2020-07-16 13:31:05 +08:00
};
},
computed: {
2020-07-16 19:11:20 +08:00
},
watch: {
2020-07-16 13:31:05 +08:00
},
2020-07-17 13:05:18 +08:00
mounted() {
},
2020-07-16 13:31:05 +08:00
methods: {
2020-07-16 19:11:20 +08:00
doShow(row) {
this.initData(row);
this.data = row;
2020-07-17 16:35:24 +08:00
getAllMapOnline().then(res => {
if (res.data && res.data.length) {
this.mapList = res.data;
this.mapId = this.mapList[0].id;
this.mapIdChange(this.mapList[0].id);
}
}).catch(() => {
this.$message.error('获取地图列表失败!');
});
2020-07-16 13:31:05 +08:00
this.dialogVisible = true;
},
initData(row) {
getDeviceDetail(row.id).then(resp => {
if (resp.data.config) {
2020-07-16 19:11:20 +08:00
const model = JSON.parse(resp.data.config) || {};
this.jsonConfig = JSON.stringify(JSON.parse(resp.data.config), null, 4);
2020-07-16 19:11:20 +08:00
this.formModel = model;
2020-07-16 13:31:05 +08:00
}
}).catch(()=> {
this.$message.error('获取项目设备详情失败!');
});
},
doSave() {
2020-07-16 19:11:20 +08:00
this.checkCount = 0;
this.$refs.formStation.validate((valid) => {
2020-07-17 14:32:33 +08:00
const model = deepAssign({}, this.formModel);
setIbpConfig(this.data.id, model).then(resp => {
this.$message.success('设置IBP网关映射配置成功');
this.handleClose();
this.$emit('reloadTable');
}).catch(error => {
this.$message.error(this.$t('tip.modifyTheFailure') + error.message);
});
});
2020-07-16 13:31:05 +08:00
},
handleClose() {
this.formModel = {};
2020-07-17 16:35:24 +08:00
this.$refs.formStation.resetFields();
2020-07-16 19:11:20 +08:00
this.data = null;
2020-07-17 17:20:32 +08:00
this.activeNames = [];
2020-07-16 13:31:05 +08:00
this.dialogVisible = false;
2020-07-17 16:35:24 +08:00
},
mapIdChange(mapId) {
this.stationList = [];
if (mapId) {
getStationListNeedAttendant(mapId).then(resp => {
if (resp.data && resp.data.length) {
this.stationList = resp.data;
}
}).catch(() => {
this.$message.error('获取车站列表失败');
});
}
2020-07-16 13:31:05 +08:00
}
}
};
</script>
<style scoped>
2020-07-17 13:05:18 +08:00
/deep/
.el-dialog--center .el-dialog__body {
padding: 25px 25px 10px;
}
2020-07-16 13:31:05 +08:00
</style>