diff --git a/spug_web/src/components/schedule/Job.vue b/spug_web/src/components/schedule/Job.vue
index 3908bb9..b5d2f65 100644
--- a/spug_web/src/components/schedule/Job.vue
+++ b/spug_web/src/components/schedule/Job.vue
@@ -78,14 +78,21 @@
-
+
+
如果修改任务详情、执行用户或执行对象,则需要重启任务后才会生效!
@@ -93,7 +100,6 @@
取消
- 添加执行对象
保存
@@ -166,7 +172,6 @@
{label: '本地', value: 'local'},
{label: '主机', value: 'host', children: []},
{label: '容器', value: 'container', children: []},
- {label: '删除', value: 'delete', disabled: true}
]
}
},
@@ -226,7 +231,7 @@
return x.slice(1, 3).join('_')
}
});
- this.form['targets'] = tmp.join(',');
+ this.form['targets'] = tmp.filter(x => x).join(',');
let request;
if (this.form.id) {
request = this.$http.put(`/api/schedule/jobs/${this.form.id}`, this.form)
@@ -240,34 +245,30 @@
this.get_job_group();
}, res => this.$layer_message(res.result)).finally(() => this.btnSaveLoading = false)
},
- loadContainer (val) {
- if (val.length > 1) {
- let item = this.options[2].children.find((x) => x.value === val[1]);
- if (item.hasOwnProperty('is_load')) return;
- this.$http.get(`/api/deploy/containers/${val[1]}/`).then(res => {
- item['is_load'] = true;
- let apps = res.result['apps'];
- let envs = res.result['envs'];
- item.children = res.result['relationships'].map(x => Object({
- label: `${apps[x.app_id]['name']} - ${envs[x.env_id]['name']}`,
- value: `${x.app_id}_${x.env_id}`
- }));
- if (item.children.length === 0) item.disabled = true;
- }, res => this.$layer_message(res.result))
- }
+ _loadContainer (item) {
+ return this.$http.get(`/api/deploy/containers/${item.value}/`).then(res => {
+ item['is_load'] = true;
+ let apps = res.result['apps'];
+ let envs = res.result['envs'];
+ item.children = res.result['relationships'].map(x => Object({
+ label: `${apps[x.app_id]['name']} - ${envs[x.env_id]['name']}`,
+ value: `${x.app_id}_${x.env_id}`
+ }));
+ if (item.children.length === 0) item.disabled = true;
+ }, res => this.$layer_message(res.result))
},
- loadNode (val) {
+ _loadNode () {
if (this.hosts === undefined) {
this.$http.get('/api/assets/hosts/').then(res => {
this.hosts = res.result.data.map(x => Object({label: x.name, value: x.id + ''}));
this.options[1].children = this.hosts;
this.options[2].children = this.$deepCopy(this.hosts).map(x => Object.assign(x, {children: []}));
- this.loadContainer(val)
+ Promise.all(this.options[2].children.map(item => this._loadContainer(item)))
+ .then(this.handleChange)
}, res => this.$layer_message(res.result))
} else {
- this.loadContainer(val)
+ this.handleChange()
}
-
},
clear_disabled (data) {
for (let item of data) {
@@ -277,7 +278,6 @@
item['disabled'] = false
}
}
- this.options[3]['disabled'] = this.targets.length <= 1;
},
handleChange () {
this.clear_disabled(this.options);
@@ -289,8 +289,6 @@
} else if (val[0] === 'container') {
let sub = this.options[2].children.find(x => x.value === val[1])['children'];
sub.find(x => x.value === val[2])['disabled'] = true
- } else if (val[0] === 'delete') {
- this.targets.splice(this.targets.indexOf(val), 1)
}
}
},
@@ -308,8 +306,7 @@
return ['host', x]
}
});
- this.options[3]['disabled'] = this.targets.length <= 1;
- this.targets.map(x => this.loadNode(x));
+ this._loadNode();
this.dialogAddVisible = true
} else if (action === 'del') {
this.$confirm(`此操作将永久删除 ${this.form.name},是否继续?`, '删除确认', {type: 'warning'}).then(() => {
@@ -369,4 +366,24 @@
this.get_job_group()
}
}
-
\ No newline at end of file
+
+
+
\ No newline at end of file