feat(ui): optimize batch operations for auto-discovery pool

This commit is contained in:
LH_R
2025-09-18 16:04:01 +08:00
parent 6661eb846d
commit e9342f1101
3 changed files with 198 additions and 152 deletions

View File

@@ -603,6 +603,8 @@ const cmdb_en = {
acceptTime: 'Accept Time', acceptTime: 'Accept Time',
confirmAccept: 'Confirm Accept?', confirmAccept: 'Confirm Accept?',
acceptSuccess: 'Accept successfully', acceptSuccess: 'Accept successfully',
batchAccept: 'Currently being stored...',
batchAccept2: 'Currently being stored: {total} items, {successNum} successful, {errorNum} failed',
isAccept: 'Accept', isAccept: 'Accept',
deleteADC: 'Confirm to delete this data?', deleteADC: 'Confirm to delete this data?',
batchDelete: 'Confirm to delete this data?', batchDelete: 'Confirm to delete this data?',

View File

@@ -603,6 +603,8 @@ const cmdb_zh = {
acceptTime: '入库时间', acceptTime: '入库时间',
confirmAccept: '确认入库?', confirmAccept: '确认入库?',
acceptSuccess: '入库成功', acceptSuccess: '入库成功',
batchAccept: '正在入库...',
batchAccept2: '正在入库,共{total}个,成功{successNum}个,失败{errorNum}个',
isAccept: '入库', isAccept: '入库',
deleteADC: '确认删除该条数据?', deleteADC: '确认删除该条数据?',
batchDelete: '确认删除这些数据?', batchDelete: '确认删除这些数据?',

View File

@@ -33,6 +33,7 @@
<template #two> <template #two>
<div id="discovery-ci"> <div id="discovery-ci">
<AdcCounter :typeId="currentType" /> <AdcCounter :typeId="currentType" />
<a-spin :tip="loadTip" :spinning="loading">
<div class="discovery-ci-header"> <div class="discovery-ci-header">
<a-input-search <a-input-search
:placeholder="$t('cmdb.components.pleaseSearch')" :placeholder="$t('cmdb.components.pleaseSearch')"
@@ -77,12 +78,11 @@
:height="tableHeight" :height="tableHeight"
:scroll-y="{ enabled: true, gt: 50 }" :scroll-y="{ enabled: true, gt: 50 }"
:scroll-x="{ enabled: true, gt: 0 }" :scroll-x="{ enabled: true, gt: 0 }"
:loading="loading" :checkbox-config="{ reserve: true, highlight: true, range: true }"
:sort-config="{ remote: false, trigger: 'cell' }"
@checkbox-change="onSelectChange" @checkbox-change="onSelectChange"
@checkbox-all="onSelectChange" @checkbox-all="onSelectChange"
@checkbox-range-end="onSelectChange" @checkbox-range-end="onSelectChange"
:checkbox-config="{ reserve: true, highlight: true, range: true }"
:sort-config="{ remote: false, trigger: 'cell' }"
> >
<vxe-column <vxe-column
align="center" align="center"
@@ -168,6 +168,7 @@
</div> </div>
</template> </template>
</ops-table> </ops-table>
</a-spin>
<a-modal <a-modal
v-model="logModalVisible" v-model="logModalVisible"
@@ -232,7 +233,8 @@ export default {
logTextArray: [], logTextArray: [],
acceptByFilters: [], acceptByFilters: [],
selectedCount: 0, selectedCount: 0,
loading: false loading: false,
loadTip: ''
} }
}, },
computed: { computed: {
@@ -301,6 +303,8 @@ export default {
}, },
getAdc(isInit) { getAdc(isInit) {
this.loading = true this.loading = true
this.loadTip = this.$t('loading')
getAdc({ getAdc({
type_id: this.currentType, type_id: this.currentType,
page_size: 100000, page_size: 100000,
@@ -380,35 +384,73 @@ export default {
}, },
async batchAccept() { async batchAccept() {
let successNum = 0
let errorNum = 0
this.loading = true
this.loadTip = this.$t('cmdb.ad.batchAccept')
for (let i = 0; i < this.selectedRowKeys.length; i++) { for (let i = 0; i < this.selectedRowKeys.length; i++) {
await updateADCAccept(this.selectedRowKeys[i]) await updateADCAccept(this.selectedRowKeys[i]).then((res) => {
successNum += 1
}).catch(() => {
errorNum += 1
}).finally(() => {
this.loadTip = this.$t('cmdb.ad.batchAccept2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
})
} }
this.$message.success(this.$t('cmdb.ad.acceptSuccess'))
this.getAdc(false) this.loading = false
this.loadTip = ''
this.selectedRowKeys = [] this.selectedRowKeys = []
this.getAdc(false)
this.$refs.xTable.getVxetableRef().clearCheckboxRow() this.$refs.xTable.getVxetableRef().clearCheckboxRow()
this.$refs.xTable.getVxetableRef().clearCheckboxReserve() this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
this.$refs.xTable.getVxetableRef().clearSort() this.$refs.xTable.getVxetableRef().clearSort()
}, },
async batchDelete() { async batchDelete() {
const that = this
this.$confirm({ this.$confirm({
title: that.$t('warning'), title: this.$t('warning'),
content: that.$t('cmdb.ad.batchDelete'), content: this.$t('cmdb.ad.batchDelete'),
async onOk() { onOk: () => {
for (let i = 0; i < that.selectedRowKeys.length; i++) { this.batchDeleteAsync()
await deleteAdc(that.selectedRowKeys[i])
} }
that.$message.success(that.$t('deleteSuccess'))
that.getAdc(false)
that.selectedRowKeys = []
that.$refs.xTable.getVxetableRef().clearCheckboxRow()
that.$refs.xTable.getVxetableRef().clearCheckboxReserve()
that.$refs.xTable.getVxetableRef().clearSort()
},
onCancel() {},
}) })
}, },
async batchDeleteAsync() {
let successNum = 0
let errorNum = 0
this.loading = true
this.loadTip = this.$t('cmdb.ci.batchDeleting')
for (let i = 0; i < this.selectedRowKeys.length; i++) {
await deleteAdc(this.selectedRowKeys[i]).then((res) => {
successNum += 1
}).catch(() => {
errorNum += 1
}).finally(() => {
this.loadTip = this.$t('cmdb.ci.batchDeleting2', {
total: this.selectedRowKeys.length,
successNum: successNum,
errorNum: errorNum,
})
})
}
this.loading = false
this.loadTip = ''
this.selectedRowKeys = []
this.getAdc(false)
this.$refs.xTable.getVxetableRef().clearCheckboxRow()
this.$refs.xTable.getVxetableRef().clearCheckboxReserve()
this.$refs.xTable.getVxetableRef().clearSort()
},
onSelectChange({ records, checked }) { onSelectChange({ records, checked }) {
this.selectedRowKeys = records.map((item) => item.id) this.selectedRowKeys = records.map((item) => item.id)
}, },