mirror of
https://github.com/jumpserver/lina.git
synced 2025-08-12 20:05:57 +00:00
perf: Optimize cloud account update error reporting to prompt on the corresponding field
This commit is contained in:
parent
b4ba209a8b
commit
56f05e09ca
@ -244,6 +244,7 @@ export default {
|
|||||||
this.$refs.form.setFieldError(key, err)
|
this.$refs.form.setFieldError(key, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.$emit('performError', data)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
hasSaveContinue: {
|
hasSaveContinue: {
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
ref="form"
|
ref="form"
|
||||||
class="form"
|
class="form"
|
||||||
v-bind="settings"
|
v-bind="settings"
|
||||||
|
@performError="handlePerformError"
|
||||||
@performFinished="handlePerformFinished"
|
@performFinished="handlePerformFinished"
|
||||||
@submitSuccess="handleSubmitSuccess"
|
@submitSuccess="handleSubmitSuccess"
|
||||||
/>
|
/>
|
||||||
@ -54,6 +55,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
priSubmitForm: null,
|
||||||
submitType: 'auto',
|
submitType: 'auto',
|
||||||
settings: {
|
settings: {
|
||||||
url: `/api/v1/xpack/cloud/accounts/`,
|
url: `/api/v1/xpack/cloud/accounts/`,
|
||||||
@ -106,6 +108,9 @@ export default {
|
|||||||
},
|
},
|
||||||
project: {
|
project: {
|
||||||
label: this.$t('Project')
|
label: this.$t('Project')
|
||||||
|
},
|
||||||
|
hostname_prefix: {
|
||||||
|
required: false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -172,16 +177,11 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
submitForm(form, btn, submitType) {
|
submitForm(form, btn, submitType) {
|
||||||
|
this.priSubmitForm = form
|
||||||
form.validate((valid) => {
|
form.validate((valid) => {
|
||||||
if (valid) {
|
if (valid) {
|
||||||
btn.loading = true
|
btn.loading = true
|
||||||
this.$refs.form.$refs.form.dataForm.submitForm('form', false)
|
this.$refs.form.$refs.form.dataForm.submitForm('form', false)
|
||||||
if (this.origin === 'update') {
|
|
||||||
setTimeout(() => {
|
|
||||||
this.$emit('submitSuccess')
|
|
||||||
this.$emit('update:visible', false)
|
|
||||||
}, 500)
|
|
||||||
}
|
|
||||||
this.submitType = submitType
|
this.submitType = submitType
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -190,12 +190,40 @@ export default {
|
|||||||
if (this.submitType === 'manual') {
|
if (this.submitType === 'manual') {
|
||||||
this.$emit('update:object', res)
|
this.$emit('update:object', res)
|
||||||
this.$emit('update:active', 2)
|
this.$emit('update:active', 2)
|
||||||
|
} else if (this.submitType === 'update') {
|
||||||
|
setTimeout(() => {
|
||||||
|
this.$emit('submitSuccess')
|
||||||
|
this.$emit('update:visible', false)
|
||||||
|
}, 500)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
handlePerformFinished() {
|
handlePerformFinished() {
|
||||||
for (const btn of this.settings.moreButtons) {
|
for (const btn of this.settings.moreButtons) {
|
||||||
btn.loading = false
|
btn.loading = false
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handlePerformError(errorData) {
|
||||||
|
if (errorData.hasOwnProperty('attrs')) {
|
||||||
|
for (const f in errorData['attrs']) {
|
||||||
|
this.setAttrsFieldError(f, errorData['attrs'][f])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
setAttrsFieldError(name, errors) {
|
||||||
|
for (const item of this.priSubmitForm.content) {
|
||||||
|
if (item.id === 'attrs') {
|
||||||
|
errors = Array.isArray(errors) ? errors.join(',') : errors
|
||||||
|
const totalFields = item.el.fields
|
||||||
|
const field = totalFields.find((v) => v.prop === name)
|
||||||
|
if (!field) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (typeof errors === 'string') {
|
||||||
|
field.el.errors = errors
|
||||||
|
field.attrs.error = errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user