perf: add check_all

This commit is contained in:
w940853815 2025-04-09 11:16:49 +08:00 committed by w940853815
parent 39c0ae8cf7
commit 292aad0d59
2 changed files with 50 additions and 19 deletions

View File

@ -14,7 +14,11 @@
:visible.sync="showSetVariableDialog"
@submit="onSubmitVariable"
/>
<ConfirmRunAssetsDialog :visible.sync="showConfirmRunAssetsDialog" :assets="classifiedAssets" />
<ConfirmRunAssetsDialog
:visible.sync="showConfirmRunAssetsDialog"
:assets="classifiedAssets"
@submit="onConfirmRunAsset"
/>
<AssetTreeTable ref="TreeTable" :tree-setting="treeSetting">
<template slot="table">
<div class="transition-box" style="width: calc(100% - 17px);">
@ -467,12 +471,29 @@ export default {
this.$message.error(this.$tc('RequiredRunas'))
return
}
const data = {
this.$axios.post('/api/v1/ops/inventory/classified-hosts/', {
assets: hosts,
nodes: nodes,
module: this.module,
args: this.command,
runas: this.runas,
runas_policy: this.runasPolicy
}).then(data => {
this.classifiedAssets = data
if (this.classifiedAssets.error.length === 0) {
this.onConfirmRunAsset(hosts, nodes)
} else {
this.showConfirmRunAssetsDialog = true
}
})
},
onConfirmRunAsset(assets, nodes) {
const data = {
assets: assets,
nodes: nodes,
module: this.module,
args: this.command,
runas: this.runas,
runas_policy: this.runasPolicy,
instant: true,
is_periodic: false,
@ -484,17 +505,6 @@ export default {
if (this.parameters) {
data.parameters = this.parameters
}
this.showConfirmRunAssetsDialog = true
this.$axios.post('/api/v1/ops/inventory/classified-hosts/', {
assets: hosts,
nodes: nodes,
module: this.module,
args: this.command,
runas: this.runas,
runas_policy: this.runasPolicy
}).then(data => {
this.classifiedAssets = data
})
createJob(data).then(res => {
this.executionInfo.timeCost = 0
this.executionInfo.status = { value: 'running', label: this.$t('Running') }

View File

@ -6,16 +6,26 @@
:show-confirm="true"
:show-cancel="true"
width="1000px"
@confirm="onConfirm"
@cancel="onCancel"
>
<div class="confirm-run-assets-dialog">
<div class="assets-list">
<div class="asset-group">
<div class="group-title">可运行资产</div>
<el-checkbox-group v-model="selectedAssets" class="group-assets">
<el-checkbox
v-model="checkAll"
:indeterminate="isIndeterminate"
style="margin-left: 10px"
@change="handleCheckAllChange"
>
{{ $t('All') }}
</el-checkbox>
<el-checkbox-group v-model="selectedAssets" class="group-assets" @change="handleCheckedAssetChange">
<el-checkbox
v-for="asset in runnableAssets"
:key="asset.id"
:label="asset.name"
:label="asset.id"
class="asset-item"
>
<div class="asset-item">
@ -72,8 +82,9 @@ export default {
},
data() {
return {
searchQuery: '',
selectedAssets: []
checkAll: false,
selectedAssets: [],
isIndeterminate: true
}
},
computed: {
@ -81,7 +92,7 @@ export default {
return this.assets.runnable
},
failedAssets() {
return [...this.assets.skipped, ...this.assets.error]
return this.assets.error
}
},
methods: {
@ -89,7 +100,17 @@ export default {
this.$emit('update:visible', false)
},
onConfirm() {
this.$emit('confirm', this.selectedAssets)
this.$emit('submit', this.selectedAssets, [])
this.$emit('update:visible', false)
},
handleCheckAllChange(value) {
this.selectedAssets = value ? this.runnableAssets.map((item) => item.id) : []
this.isIndeterminate = false
},
handleCheckedAssetChange(value) {
const checkedCount = value.length
this.checkAll = checkedCount === this.runnableAssets.length
this.isIndeterminate = checkedCount > 0 && checkedCount < this.runnableAssets.length
}
}
}