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

Rename event handler for fields, add some commits: (#480)

- addActionPerformed
- addKeyPressed
- addKeyReleased
- addFocusGained
- addFocusLost
- addRunAction
This commit is contained in:
Yamel Senih 2020-05-04 21:38:53 -04:00 committed by GitHub
parent 46abc1f316
commit 0079502942
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 22 deletions

View File

@ -8,7 +8,8 @@ export default [
overwriteDefinition: {
size: 24,
sequence: 10,
cssClassName: 'price-inquiry'
cssClassName: 'price-inquiry',
handleActionPerformed: true
}
},
// Product Name

View File

@ -49,7 +49,7 @@ export default {
methods: {
subscribeChanges() {
return this.$store.subscribe((mutation, state) => {
if (mutation.type === 'changeFieldValue' && mutation.payload.field.columnName === 'ProductValue') {
if (mutation.type === 'addActionPerformed' && mutation.payload.columnName === 'ProductValue') {
// cleans all values except column name 'ProductValue'
this.setValues({ withOutColumnNames: ['ProductValue'] })
getProductPrice({

View File

@ -10,6 +10,15 @@
// value: new value for event,
// keyCode: optional for key events
// }
// How subsribe for it?
// Just create a method and call it
// subscribeChanges() {
// this.$store.subscribe((mutation, state) => {
// if (mutation.type === 'addActionPerformed' && mutation.payload.columnName === 'ProductValue') {
// // here is your code
// }
// }
// }
// Generic Action
export const ACTION_PERFORMED = 1
export const FOCUS_GAINED = 2
@ -23,10 +32,37 @@ const event = {
actionEvents: []
},
mutations: {
addChange(state, change) {
state.fieldEvents.push(change)
addActionPerformed(state, change) {
state.fieldEvents.push({
...change,
eventType: ACTION_PERFORMED
})
},
addAction(state, action) {
addKeyPressed(state, change) {
state.fieldEvents.push({
...change,
eventType: KEY_PRESSED
})
},
addKeyReleased(state, change) {
state.fieldEvents.push({
...change,
eventType: KEY_RELEASED
})
},
addFocusGained(state, change) {
state.fieldEvents.push({
...change,
eventType: FOCUS_GAINED
})
},
addFocusLost(state, change) {
state.fieldEvents.push({
...change,
eventType: FOCUS_LOST
})
},
addRunAction(state, action) {
state.actionEvents.push(action)
},
resetStateLookup(state) {
@ -38,49 +74,44 @@ const event = {
},
actions: {
notifyActionPerformed({ commit }, event) {
commit('addChange', {
commit('addActionPerformed', {
containerUuid: event.containerUuid,
columnName: event.columnName,
value: event.value,
eventType: ACTION_PERFORMED
value: event.value
})
},
notifyKeyPressed({ commit }, event) {
commit('addChange', {
commit('addKeyPressed', {
containerUuid: event.containerUuid,
columnName: event.columnName,
value: event.value,
keyCode: event.keyCode,
eventType: KEY_PRESSED
keyCode: event.keyCode
})
},
notifyKeyReleased({ commit }, event) {
commit('addChange', {
commit('addKeyReleased', {
containerUuid: event.containerUuid,
columnName: event.columnName,
value: event.value,
keyCode: event.keyCode,
eventType: KEY_RELEASED
keyCode: event.keyCode
})
},
notifyFocusGained({ commit }, event) {
commit('addChange', {
commit('addFocusGained', {
containerUuid: event.containerUuid,
columnName: event.columnName,
value: event.value,
eventType: FOCUS_GAINED
value: event.value
})
},
notifyFocusLost({ commit }, event) {
commit('addChange', {
commit('addFocusLost', {
containerUuid: event.containerUuid,
columnName: event.columnName,
value: event.value,
eventType: FOCUS_LOST
value: event.value
})
},
notifyRunAction({ commit }, action) {
commit('addAction', {
runAction({ commit }, action) {
commit('addRunAction', {
containerUuid: action.containerUuid,
action: action.action,
paremeters: action.parameters