mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 07:04:21 +08:00
Rename event handler for fields, add some commits: (#480)
- addActionPerformed - addKeyPressed - addKeyReleased - addFocusGained - addFocusLost - addRunAction
This commit is contained in:
parent
46abc1f316
commit
0079502942
@ -8,7 +8,8 @@ export default [
|
|||||||
overwriteDefinition: {
|
overwriteDefinition: {
|
||||||
size: 24,
|
size: 24,
|
||||||
sequence: 10,
|
sequence: 10,
|
||||||
cssClassName: 'price-inquiry'
|
cssClassName: 'price-inquiry',
|
||||||
|
handleActionPerformed: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Product Name
|
// Product Name
|
||||||
|
@ -49,7 +49,7 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
subscribeChanges() {
|
subscribeChanges() {
|
||||||
return this.$store.subscribe((mutation, state) => {
|
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'
|
// cleans all values except column name 'ProductValue'
|
||||||
this.setValues({ withOutColumnNames: ['ProductValue'] })
|
this.setValues({ withOutColumnNames: ['ProductValue'] })
|
||||||
getProductPrice({
|
getProductPrice({
|
||||||
|
@ -10,6 +10,15 @@
|
|||||||
// value: new value for event,
|
// value: new value for event,
|
||||||
// keyCode: optional for key events
|
// 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
|
// Generic Action
|
||||||
export const ACTION_PERFORMED = 1
|
export const ACTION_PERFORMED = 1
|
||||||
export const FOCUS_GAINED = 2
|
export const FOCUS_GAINED = 2
|
||||||
@ -23,10 +32,37 @@ const event = {
|
|||||||
actionEvents: []
|
actionEvents: []
|
||||||
},
|
},
|
||||||
mutations: {
|
mutations: {
|
||||||
addChange(state, change) {
|
addActionPerformed(state, change) {
|
||||||
state.fieldEvents.push(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)
|
state.actionEvents.push(action)
|
||||||
},
|
},
|
||||||
resetStateLookup(state) {
|
resetStateLookup(state) {
|
||||||
@ -38,49 +74,44 @@ const event = {
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
notifyActionPerformed({ commit }, event) {
|
notifyActionPerformed({ commit }, event) {
|
||||||
commit('addChange', {
|
commit('addActionPerformed', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
columnName: event.columnName,
|
columnName: event.columnName,
|
||||||
value: event.value,
|
value: event.value
|
||||||
eventType: ACTION_PERFORMED
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notifyKeyPressed({ commit }, event) {
|
notifyKeyPressed({ commit }, event) {
|
||||||
commit('addChange', {
|
commit('addKeyPressed', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
columnName: event.columnName,
|
columnName: event.columnName,
|
||||||
value: event.value,
|
value: event.value,
|
||||||
keyCode: event.keyCode,
|
keyCode: event.keyCode
|
||||||
eventType: KEY_PRESSED
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notifyKeyReleased({ commit }, event) {
|
notifyKeyReleased({ commit }, event) {
|
||||||
commit('addChange', {
|
commit('addKeyReleased', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
columnName: event.columnName,
|
columnName: event.columnName,
|
||||||
value: event.value,
|
value: event.value,
|
||||||
keyCode: event.keyCode,
|
keyCode: event.keyCode
|
||||||
eventType: KEY_RELEASED
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notifyFocusGained({ commit }, event) {
|
notifyFocusGained({ commit }, event) {
|
||||||
commit('addChange', {
|
commit('addFocusGained', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
columnName: event.columnName,
|
columnName: event.columnName,
|
||||||
value: event.value,
|
value: event.value
|
||||||
eventType: FOCUS_GAINED
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notifyFocusLost({ commit }, event) {
|
notifyFocusLost({ commit }, event) {
|
||||||
commit('addChange', {
|
commit('addFocusLost', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
columnName: event.columnName,
|
columnName: event.columnName,
|
||||||
value: event.value,
|
value: event.value
|
||||||
eventType: FOCUS_LOST
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
notifyRunAction({ commit }, action) {
|
runAction({ commit }, action) {
|
||||||
commit('addAction', {
|
commit('addRunAction', {
|
||||||
containerUuid: action.containerUuid,
|
containerUuid: action.containerUuid,
|
||||||
action: action.action,
|
action: action.action,
|
||||||
paremeters: action.parameters
|
paremeters: action.parameters
|
||||||
|
Loading…
x
Reference in New Issue
Block a user