diff --git a/cmdb-ui/src/modules/cmdb/lang/en.js b/cmdb-ui/src/modules/cmdb/lang/en.js
index 9ceb9fb8..97d47e2e 100644
--- a/cmdb-ui/src/modules/cmdb/lang/en.js
+++ b/cmdb-ui/src/modules/cmdb/lang/en.js
@@ -837,7 +837,13 @@ if __name__ == "__main__":
onlineRatio: 'Online Ratio',
scanEnable: 'Scan Enable',
lastScanTime: 'Last Scan Time',
- isSuccess: 'Is Success'
+ isSuccess: 'Is Success',
+ batchAssign: 'Batch Assign',
+ batchAssignInProgress: 'Assign in batches, {total} in total, {successNum} successful, {errorNum} failed',
+ batchAssignCompleted: 'Batch Assign Completed',
+ batchRecycle: 'Batch Recycle',
+ batchRecycleInProgress: 'Recycle in batches, {total} in total, {successNum} successful, {errorNum} failed',
+ batchRecycleCompleted: 'Batch Recycle Completed',
}
}
export default cmdb_en
diff --git a/cmdb-ui/src/modules/cmdb/lang/zh.js b/cmdb-ui/src/modules/cmdb/lang/zh.js
index 66aaba6a..8ddee976 100644
--- a/cmdb-ui/src/modules/cmdb/lang/zh.js
+++ b/cmdb-ui/src/modules/cmdb/lang/zh.js
@@ -836,7 +836,13 @@ if __name__ == "__main__":
onlineRatio: '在线率',
scanEnable: '是否扫描',
lastScanTime: '最后扫描时间',
- isSuccess: '是否成功'
+ isSuccess: '是否成功',
+ batchAssign: '批量分配',
+ batchAssignInProgress: '正在批量分配,共{total}个,成功{successNum}个,失败{errorNum}个',
+ batchAssignCompleted: '批量分配已完成',
+ batchRecycle: '批量回收',
+ batchRecycleInProgress: '正在批量回收,共{total}个,成功{successNum}个,失败{errorNum}个',
+ batchRecycleCompleted: '批量回收已完成',
}
}
export default cmdb_zh
diff --git a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/assignForm.vue b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/assignForm.vue
index 45ce2768..940e8d71 100644
--- a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/assignForm.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/assignForm.vue
@@ -3,6 +3,7 @@
:visible="visible"
:width="700"
:title="$t('cmdb.ipam.addressAssign')"
+ :confirmLoading="confirmLoading"
@ok="handleOk"
@cancel="handleCancel"
>
@@ -17,7 +18,7 @@
- {{ ipData.ip }}
+ {{ ipList.join(', ') }}
[]
- },
- subnetData: {
- type: Object,
- default: () => {}
}
},
data() {
return {
visible: false,
ipData: {},
+ ipList: [],
nodeId: -1,
formList: [],
form: {},
formRules: {},
- statusSelectOption: [
- {
- value: 0,
- label: 'cmdb.ipam.assigned'
- },
- {
- value: 2,
- label: 'cmdb.ipam.reserved'
- }
- ]
+ confirmLoading: false,
+ isBatch: false
}
},
methods: {
async open({
- ipData,
+ ipList = [],
+ ipData = null,
nodeId,
}) {
+ this.isBatch = ipList.length !== 0
+ this.ipList = ipList.length ? _.cloneDeep(ipList) : [ipData?.ip ?? '']
this.ipData = ipData || {}
this.nodeId = nodeId || -1
this.visible = true
@@ -237,7 +230,8 @@ export default {
this.form = {}
this.formRules = {}
this.formList = []
- this.visible = false
+ this.confirmLoading = false
+ this.isBatch = false
this.$refs.assignFormRef.clearValidate()
},
@@ -248,16 +242,35 @@ export default {
return
}
- await postIPAMAddress({
- ips: [this.ipData.ip],
- parent_id: this.nodeId,
- ...this.form,
- subnet_mask: this?.ipData?.subnet_mask ?? undefined,
- gateway: this?.ipData?.gateway ?? undefined
- })
+ this.confirmLoading = true
+
+ if (!this.isBatch) {
+ await postIPAMAddress({
+ ips: this.ipList,
+ parent_id: this.nodeId,
+ ...this.form,
+ subnet_mask: this?.ipData?.subnet_mask ?? undefined,
+ gateway: this?.ipData?.gateway ?? undefined
+ })
+
+ this.$emit('ok')
+ } else {
+ const ipChunk = _.chunk(this.ipList, 5)
+ const paramsList = ipChunk.map((ips) => ({
+ ips,
+ parent_id: this.nodeId,
+ ...this.form,
+ subnet_mask: this?.ipData?.subnet_mask ?? undefined,
+ gateway: this?.ipData?.gateway ?? undefined
+ }))
+ this.$emit('batchAssign', {
+ paramsList,
+ ipList: this.ipList
+ })
+ }
- this.$emit('ok')
this.handleCancel()
+ this.confirmLoading = false
})
},
@@ -280,5 +293,12 @@ export default {
max-height: 400px;
overflow-y: auto;
overflow-x: hidden;
+
+ &-ip {
+ max-height: 100px;
+ overflow-y: auto;
+ overflow-x: hidden;
+ display: block;
+ }
}
diff --git a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue
index 24135754..a726a5bf 100644
--- a/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue
+++ b/cmdb-ui/src/modules/cmdb/views/ipam/modules/address/index.vue
@@ -9,12 +9,11 @@
{{ $t(addressNullTip) }}
-
-
-
{{ $t('loading') }}
-
-
-
+