1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-08-13 23:20:12 +08:00

Add support to conditional for event handler (#474)

This commit is contained in:
Yamel Senih 2020-04-30 00:44:03 -04:00 committed by GitHub
parent 86fd3a432a
commit 49e82232f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 27 deletions

View File

@ -49,34 +49,42 @@ export const fieldMixin = {
this.handleChange(value) this.handleChange(value)
}, },
focusGained(value) { focusGained(value) {
this.$store.dispatch('notifyFocusGained', { if (this.metadata.handleFocusGained) {
containerUuid: this.metadata.containerUuid, this.$store.dispatch('notifyFocusGained', {
columnName: this.metadata.columnName, containerUuid: this.metadata.containerUuid,
value: this.value columnName: this.metadata.columnName,
}) value: this.value
})
}
}, },
focusLost(value) { focusLost(value) {
this.$store.dispatch('notifyFocusLost', { if (this.metadata.handleFocusLost) {
containerUuid: this.metadata.containerUuid, this.$store.dispatch('notifyFocusLost', {
columnName: this.metadata.columnName, containerUuid: this.metadata.containerUuid,
value: this.value columnName: this.metadata.columnName,
}) value: this.value
})
}
}, },
keyPressed(value) { keyPressed(value) {
this.$store.dispatch('notifyKeyPressed', { if (this.metadata.handleKeyPressed) {
containerUuid: this.metadata.containerUuid, this.$store.dispatch('notifyKeyPressed', {
columnName: this.metadata.columnName, containerUuid: this.metadata.containerUuid,
value: value.key, columnName: this.metadata.columnName,
keyCode: value.keyCode value: value.key,
}) keyCode: value.keyCode
})
}
}, },
keyReleased(value) { keyReleased(value) {
this.$store.dispatch('notifyKeyReleased', { if (this.metadata.handleKeyReleased) {
containerUuid: this.metadata.containerUuid, this.$store.dispatch('notifyKeyReleased', {
columnName: this.metadata.columnName, containerUuid: this.metadata.containerUuid,
value: value.key, columnName: this.metadata.columnName,
keyCode: value.keyCode value: value.key,
}) keyCode: value.keyCode
})
}
}, },
/** /**
* @param {mixed} value, main value in component * @param {mixed} value, main value in component
@ -115,11 +123,13 @@ export const fieldMixin = {
isChangedOldValue isChangedOldValue
} }
// Global Action performed // Global Action performed
this.$store.dispatch('notifyActionPerformed', { if (this.metadata.handleActionPerformed) {
containerUuid: this.metadata.containerUuid, this.$store.dispatch('notifyActionPerformed', {
columnName: this.metadata.columnName, containerUuid: this.metadata.containerUuid,
value: newValue columnName: this.metadata.columnName,
}) value: newValue
})
}
if (this.metadata.inTable) { if (this.metadata.inTable) {
this.$store.dispatch('notifyCellTableChange', { this.$store.dispatch('notifyCellTableChange', {
...sendParameters, ...sendParameters,

View File

@ -309,6 +309,11 @@ export function getFieldTemplate(overwriteDefinition) {
mandatoryLogic: undefined, mandatoryLogic: undefined,
readOnlyLogic: undefined, readOnlyLogic: undefined,
parentFieldsList: undefined, parentFieldsList: undefined,
handleFocusGained: false,
handleFocusLost: false,
handleKeyPressed: false,
handleKeyReleased: false,
handleActionPerformed: true,
dependentFieldsList: [], dependentFieldsList: [],
reference: { reference: {
tableName: '', tableName: '',