可以批量删除同步任务

This commit is contained in:
刘祥超
2021-02-02 20:52:46 +08:00
parent 8b7661d82d
commit b2feb452e0
5 changed files with 92 additions and 4 deletions

View File

@@ -1,8 +1,40 @@
Tea.context(function () {
let checkedAll = false
this.$delay(function () {
this.reload()
})
this.checkAll = function (b) {
checkedAll = b
let that = this
this.clusters.forEach(function (cluster, index) {
cluster.tasks.forEach(function (task) {
task.isChecked = checkedAll
})
Vue.set(that.clusters, index, cluster)
})
}
this.checkTask = function (b) {
this.clusters.forEach(function (cluster, index) {
Vue.set(that.clusters, index, cluster)
})
}
let that = this
this.countCheckedTasks = function () {
let count = 0
that.clusters.forEach(function (cluster) {
cluster.tasks.forEach(function (task) {
if (task.isChecked) {
count++
}
})
})
return count
}
this.reload = function () {
this.$post("$")
.success(function (resp) {
@@ -11,7 +43,10 @@ Tea.context(function () {
})
.done(function () {
this.$delay(function () {
this.reload()
// 没有选中任务的时候才重新刷新
if (this.countCheckedTasks() == 0) {
this.reload()
}
}, 3000)
})
}
@@ -28,4 +63,26 @@ Tea.context(function () {
})
})
}
this.deleteBatch = function () {
var taskIds = []
this.clusters.forEach(function (cluster) {
cluster.tasks.forEach(function (task) {
if (task.isChecked) {
taskIds.push(task.id)
}
})
})
let that = this
teaweb.confirm("确定要批量删除选中的任务吗?", function () {
that.$post(".deleteBatch")
.params({
taskIds: taskIds
})
.success(function () {
teaweb.reload()
})
})
}
})