Commit 9c542719 authored by zhouzihao's avatar zhouzihao

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

parent 05489e0c
<template> <template>
<div id="app"> <div id="app">
<router-view/> <router-view/>
</div> </div>
</template> </template>
......
...@@ -56,7 +56,12 @@ ...@@ -56,7 +56,12 @@
<FormItem label="配置内容"> <FormItem label="配置内容">
<Input v-if="showData.type==2" v-model="showData.content" type="textarea" :rows="20"></Input> <Input v-if="showData.type==2" v-model="showData.content" type="textarea" :rows="20"></Input>
</FormItem> </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> </Form>
</div> </div>
<div class="demo-drawer-footer"> <div class="demo-drawer-footer">
...@@ -161,12 +166,18 @@ export default { ...@@ -161,12 +166,18 @@ export default {
p_id: 1, p_id: 1,
envlist: [], envlist: [],
project_name: "", project_name: "",
json:null, json: null
}; };
}, },
methods: { methods: {
getList: function() { getList: function() {
// todo 添加选项 // 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 axios
.get( .get(
config.serve_url + config.serve_url +
...@@ -198,19 +209,20 @@ export default { ...@@ -198,19 +209,20 @@ export default {
}); });
}, },
addShow: function() { 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.isShow = true;
// 这里正好名字可以对上 // 这里正好名字可以对上
this.showData = { this.showData = {
p_id: this.p_id, p_id: this.p_id,
env_id: this.env_id env_id: this.env_id
}; };
this.json = null;
}, },
show: function(index) { 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.isShow = true;
this.showData = this.data1[index]; this.showData = this.data1[index];
if (this.showData.type == 1){ if (this.showData.type == 1) {
this.json = JSON.parse(this.showData.content); this.json = JSON.parse(this.showData.content);
} }
}, },
...@@ -235,6 +247,21 @@ export default { ...@@ -235,6 +247,21 @@ export default {
.catch(err => { .catch(err => {
this.$Message.error(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() { mounted: function() {
......
...@@ -267,6 +267,7 @@ export default { ...@@ -267,6 +267,7 @@ export default {
addShow: function() { addShow: function() {
this.isShow = true; this.isShow = true;
this.showData = {}; this.showData = {};
this.meta_data = null;
}, },
show: function(index) { show: function(index) {
this.isShow = true; 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