perf: 优化账号批量创建

This commit is contained in:
ibuler
2023-03-29 15:02:01 +08:00
parent 41bb35f7c6
commit dc09364348

View File

@@ -1,11 +1,11 @@
<template> <template>
<Dialog <Dialog
:title="title" :close-on-click-modal="false"
:visible.sync="iVisible"
:destroy-on-close="true" :destroy-on-close="true"
:show-cancel="false" :show-cancel="false"
:show-confirm="false" :show-confirm="false"
:close-on-click-modal="false" :title="title"
:visible.sync="iVisible"
v-bind="$attrs" v-bind="$attrs"
width="70%" width="70%"
v-on="$listeners" v-on="$listeners"
@@ -73,25 +73,23 @@ export default {
methods: { methods: {
addAccount(form) { addAccount(form) {
const formValue = Object.assign({}, form) const formValue = Object.assign({}, form)
let assets = [] let data = {}
let url = ''
if (this.asset) { if (this.asset) {
assets = [this.asset.id] data = {
} else {
assets = formValue.assets
}
delete formValue.assets
if (assets.length === 0) {
this.$message.error(this.$tc('assets.PleaseSelectAsset'))
return
}
const data = []
for (const asset of assets) {
data.push({
...formValue, ...formValue,
asset asset: this.asset.id
}) }
url = `/api/v1/accounts/accounts/`
} else {
data = formValue
url = `/api/v1/accounts/accounts/bulk/`
if (data.assets.length === 0) {
this.$message.error(this.$tc('assets.PleaseSelectAsset'))
return
}
} }
this.$axios.post(`/api/v1/accounts/accounts/`, data).then(() => { this.$axios.post(url, data).then(() => {
this.iVisible = false this.iVisible = false
this.$emit('add', true) this.$emit('add', true)
this.$message.success(this.$tc('common.createSuccessMsg')) this.$message.success(this.$tc('common.createSuccessMsg'))