Files
EdgeAdmin/web/views/@default/clusters/tasks/listPopup.js

88 lines
2.4 KiB
JavaScript
Raw Normal View History

Tea.context(function () {
2021-02-02 20:52:46 +08:00
let checkedAll = false
this.$delay(function () {
this.reload()
})
2021-02-02 20:52:46 +08:00
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) {
this.countTasks = resp.data.countTasks
this.clusters = resp.data.clusters
})
.done(function () {
this.$delay(function () {
2021-02-02 20:52:46 +08:00
// 没有选中任务的时候才重新刷新
if (this.countCheckedTasks() == 0) {
this.reload()
}
}, 3000)
})
}
this.deleteTask = function (taskId) {
let that = this
teaweb.confirm("确定要删除这个任务吗?", function () {
that.$post(".delete")
.params({
taskId: taskId
})
.success(function () {
teaweb.reload()
})
})
}
2021-02-02 20:52:46 +08:00
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()
})
})
}
})