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">
|
|
|
|
|
<el-form v-show="data.type === 'IBP'" ref="formIbp" :model="formIbp" label-width="100px" :rules="rulesIbp">
|
|
|
|
|
<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>
|
|
|
|
|
</el-form>
|
|
|
|
|
<el-form v-show="data.type === 'LW'" ref="formLw" :model="formLw" label-width="100px" :rules="rulesLw">
|
|
|
|
|
<el-form-item label="下辖IBP:" prop="ibpCodeList">
|
|
|
|
|
<el-select v-model="formLw.ibpCodeList" placeholder="请选择" multiple size="small">
|
|
|
|
|
<el-option
|
|
|
|
|
v-for="item in ibpList"
|
|
|
|
|
:key="item.code"
|
|
|
|
|
:label="item.code"
|
|
|
|
|
:value="item.code"
|
|
|
|
|
/>
|
|
|
|
|
</el-select>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</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-06-19 18:02:50 +08:00
|
|
|
|
import { getDeviceDetail, setIbpConfig, setLwConfig, getDevicesByType } from '@/api/project';
|
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: {},
|
|
|
|
|
ibpList: [],
|
|
|
|
|
formIbp: {
|
|
|
|
|
part: ''
|
|
|
|
|
},
|
|
|
|
|
formLw: {
|
|
|
|
|
ibpCodeList: []
|
|
|
|
|
},
|
|
|
|
|
rulesIbp: {
|
|
|
|
|
part: [
|
|
|
|
|
{ required: true, message: '请选择显示位置', trigger: 'change' }
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
rulesLw: {
|
|
|
|
|
ibpCodeList: [
|
|
|
|
|
{ required: true, message: '请选择下辖ibp设备!', trigger: 'change'}
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
partList: [{label: '左', value: 'LEFT'}, {label: '右', value: 'RIGHT'}, {label: '全部', value: 'WHOLE'}]
|
2020-01-02 17:01:11 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
title() {
|
|
|
|
|
return '编辑设备配置';
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
initData(row) {
|
|
|
|
|
getDeviceDetail(row.id).then(resp => {
|
|
|
|
|
if (resp.data.config) {
|
|
|
|
|
this.formModel = resp.data.config;
|
|
|
|
|
}
|
|
|
|
|
}).catch(()=> {
|
|
|
|
|
this.$message.error('获取项目设备详情失败!');
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
doShow(row) {
|
|
|
|
|
this.initData(row);
|
|
|
|
|
this.dialogVisible = true;
|
|
|
|
|
this.data = row;
|
2020-06-19 18:02:50 +08:00
|
|
|
|
if (row.type === 'LW') {
|
|
|
|
|
getDevicesByType('IBP').then(res => {
|
|
|
|
|
if (res.data && res.data.length) {
|
|
|
|
|
this.ibpList = res.data;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-01-02 17:01:11 +08:00
|
|
|
|
},
|
|
|
|
|
doSave() {
|
|
|
|
|
const self = this;
|
2020-06-19 18:02:50 +08:00
|
|
|
|
console.log(this.data.type);
|
|
|
|
|
if (this.data.type === 'IBP') {
|
|
|
|
|
this.$refs.formIbp.validate(() => {
|
|
|
|
|
setIbpConfig(this.data.id, this.formIbp).then(response => {
|
|
|
|
|
self.$message.success('设置设备网关映射配置成功');
|
|
|
|
|
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 => {
|
|
|
|
|
self.$message.success('设置设备网关映射配置成功');
|
|
|
|
|
self.handleClose();
|
|
|
|
|
self.$emit('reloadTable');
|
|
|
|
|
}).catch(error => {
|
|
|
|
|
self.$message.error(this.$t('tip.modifyTheFailure') + error.message);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2020-01-02 17:01:11 +08:00
|
|
|
|
},
|
|
|
|
|
handleClose(done) {
|
|
|
|
|
this.dialogVisible = false;
|
2020-06-19 18:02:50 +08:00
|
|
|
|
this.data = {};
|
2020-01-02 17:01:11 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|