Commit 9c542719 authored by zhouzihao's avatar zhouzihao

fix-修复配置切换时出现的错误

parent 05489e0c
......@@ -56,7 +56,12 @@
<FormItem label="配置内容">
<Input v-if="showData.type==2" v-model="showData.content" type="textarea" :rows="20"></Input>
</FormItem>
<vue-json-editor v-if="showData.type==1" v-model="json" exapndedOnStart="true" @json-change="onJsonChange"></vue-json-editor>
<vue-json-editor
v-if="showData.type==1"
v-model="json"
exapndedOnStart="true"
@json-change="onJsonChange"
></vue-json-editor>
</Form>
</div>
<div class="demo-drawer-footer">
......@@ -161,12 +166,18 @@ export default {
p_id: 1,
envlist: [],
project_name: "",
json:null,
json: null
};
},
methods: {
getList: function() {
// todo 添加选项
if (_.isEmpty(this.$route.query.p_id)) {
this.p_id = this.$route.query.p_id;
}
if (_.isEmpty(this.$route.query.name)) {
this.project_name = this.$route.query.name;
}
axios
.get(
config.serve_url +
......@@ -198,19 +209,20 @@ export default {
});
},
addShow: function() {
this.env_name = (_.find(this.envlist, { env_id: this.env_id })).name;
this.env_name = _.find(this.envlist, { env_id: this.env_id }).name;
this.isShow = true;
// 这里正好名字可以对上
this.showData = {
p_id: this.p_id,
env_id: this.env_id
};
this.json = null;
},
show: function(index) {
this.env_name = (_.find(this.envlist, { env_id: this.env_id })).name;
this.env_name = _.find(this.envlist, { env_id: this.env_id }).name;
this.isShow = true;
this.showData = this.data1[index];
if (this.showData.type == 1){
if (this.showData.type == 1) {
this.json = JSON.parse(this.showData.content);
}
},
......@@ -235,6 +247,21 @@ export default {
.catch(err => {
this.$Message.error(err);
});
},
init: function() {
this.getEnvList();
// console.log(JSON.stringify(this.$route.query.p_id));
this.p_id = this.$route.query.p_id;
this.project_name = this.$route.query.name;
this.getList();
}
},
watch: {
$route(to, from) {
//监听路由是否变化
if (to.query.p_id != from.query.p_id) {
this.init(); //重新加载数据
}
}
},
mounted: function() {
......
......@@ -267,6 +267,7 @@ export default {
addShow: function() {
this.isShow = true;
this.showData = {};
this.meta_data = null;
},
show: function(index) {
this.isShow = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment