1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-10 20:39:48 +08:00

Validate mandatory fields when creating a business partner (#725)

* Fixes: #724

* bugfix: Delete duplicated code.

* minimal changes

* remove computed

Co-authored-by: Edwin Betancourt <EdwinBetanc0urt@outlook.com>
This commit is contained in:
Elsio Sanchez 2021-04-08 17:06:36 -04:00 committed by GitHub
parent 54dce3ff69
commit 0860a69b22
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 25 deletions

View File

@ -29,7 +29,8 @@ export default [
defaultValue: '@#C_Country_ID@',
size: 24,
sequenceFields: 'CO',
index: 2
index: 2,
isMandatory: true
}
},
{
@ -40,7 +41,8 @@ export default [
isCustomField: true,
size: 24,
sequenceFields: 'R',
index: 3
index: 3,
isMandatory: true
}
},
{
@ -51,7 +53,8 @@ export default [
isCustomField: true,
size: 24,
sequenceFields: 'C',
index: 4
index: 4,
isMandatory: true
}
},
{

View File

@ -237,15 +237,15 @@ export default {
// })
},
sendValuesToServer() {
const fieldsNotReady = this.$store.getters.getFieldsListEmptyMandatory({
const emptyMandatoryFields = this.$store.getters.getFieldsListEmptyMandatory({
containerUuid: this.containerUuid,
isValidate: true
formatReturn: 'name'
})
if (!this.isEmptyValue(fieldsNotReady)) {
if (!this.isEmptyValue(emptyMandatoryFields)) {
showNotification({
type: 'warning',
title: this.$t('notifications.emptyValues'),
name: '<b>' + fieldsNotReady + '.</b> ',
name: '<b>' + emptyMandatoryFields + '.</b> ',
message: this.$t('notifications.fieldMandatory'),
isRedirect: false
})

View File

@ -22,7 +22,6 @@
type="primary"
class="custom-button-create-bp"
icon="el-icon-check"
:loading="isLoadingRecord"
@click="createBusinessParter"
/>
<el-button
@ -75,14 +74,6 @@ export default {
unsubscribe: () => {}
}
},
computed: {
emptyMandatoryFields() {
const field = this.$store.getters.getFieldsListEmptyMandatory({
containerUuid: this.containerUuid
})
return field
}
},
watch: {
showField(value) {
if (value) {
@ -105,16 +96,17 @@ export default {
containerUuid: this.containerUuid,
format: 'object'
})
if (this.isEmptyValue(values)) {
return
}
const name2 = this.$store.getters.getValueOfField({
containerUuid: this.containerUuid,
columnName: 'Name2'
})
values = this.convertValuesToSend(values)
values.name2 = name2
if (this.isEmptyValue(this.emptyMandatoryFields)) {
const emptyMandatoryFields = this.$store.getters.getFieldsListEmptyMandatory({
containerUuid: this.containerUuid,
formatReturn: 'name'
})
if (this.isEmptyValue(emptyMandatoryFields)) {
this.isLoadingRecord = true
requestCreateBusinessPartner(values)
.then(responseBPartner => {
@ -132,7 +124,7 @@ export default {
this.showsPopovers.isShowCreate = true
this.$message({
type: 'warning',
message: error.message,
message: error.message + 'Name',
duration: 1500,
showClose: true
})
@ -144,7 +136,7 @@ export default {
} else {
this.$message({
type: 'warn',
message: this.$t('notifications.mandatoryFieldMissing') + this.emptyMandatoryFields,
message: this.$t('notifications.mandatoryFieldMissing') + emptyMandatoryFields,
duration: 1500,
showClose: true
})

View File

@ -8,7 +8,8 @@ export default [
tabindex: '0',
overwriteDefinition: {
isCustomField: true,
size: 24
size: 24,
isMandatory: true
}
},
{
@ -19,7 +20,8 @@ export default [
isFromDictionary: true,
overwriteDefinition: {
isCustomField: true,
size: 24
size: 24,
isMandatory: true
}
},
{
@ -66,7 +68,8 @@ export default [
componentPath: 'FieldLocation',
handleActionPerformed: false,
isSendParentValues: true,
popoverPlacement: 'top'
popoverPlacement: 'top',
isMandatory: true
}
}
]