mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-13 23:20:12 +08:00
Add support to ActionKeyPerformance event for implement enter event (#488)
This commit is contained in:
parent
e424b84768
commit
50bac60614
@ -86,6 +86,16 @@ export const fieldMixin = {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
actionKeyPerformed(value) {
|
||||||
|
if (this.metadata.handleActionKeyPerformed) {
|
||||||
|
this.$store.dispatch('notifyActionKeyPerformed', {
|
||||||
|
containerUuid: this.metadata.containerUuid,
|
||||||
|
columnName: this.metadata.columnName,
|
||||||
|
value: value.target.value,
|
||||||
|
keyCode: value.keyCode
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
keyReleased(value) {
|
keyReleased(value) {
|
||||||
if (this.metadata.handleKeyReleased) {
|
if (this.metadata.handleKeyReleased) {
|
||||||
this.$store.dispatch('notifyKeyReleased', {
|
this.$store.dispatch('notifyKeyReleased', {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
@focus="focusGained"
|
@focus="focusGained"
|
||||||
@keydown.native="keyPressed"
|
@keydown.native="keyPressed"
|
||||||
@keyup.native="keyReleased"
|
@keyup.native="keyReleased"
|
||||||
|
@keyup.native.enter="actionKeyPerformed"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ export default [
|
|||||||
size: 24,
|
size: 24,
|
||||||
sequence: 10,
|
sequence: 10,
|
||||||
cssClassName: 'price-inquiry',
|
cssClassName: 'price-inquiry',
|
||||||
handleActionPerformed: true
|
handleActionKeyPerformed: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Product Name
|
// Product Name
|
||||||
|
@ -49,11 +49,11 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
subscribeChanges() {
|
subscribeChanges() {
|
||||||
return this.$store.subscribe((mutation, state) => {
|
return this.$store.subscribe((mutation, state) => {
|
||||||
if (mutation.type === 'addActionPerformed' && mutation.payload.columnName === 'ProductValue') {
|
if (mutation.type === 'addActionKeyPerformed' && 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({
|
||||||
searchValue: mutation.payload.newValue
|
searchValue: mutation.payload.value
|
||||||
})
|
})
|
||||||
.then(productPrice => {
|
.then(productPrice => {
|
||||||
const { product, taxRate } = productPrice
|
const { product, taxRate } = productPrice
|
||||||
|
@ -50,6 +50,9 @@ const event = {
|
|||||||
eventType: KEY_RELEASED
|
eventType: KEY_RELEASED
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
addActionKeyPerformed(state, change) {
|
||||||
|
state.fieldEvents.push(change)
|
||||||
|
},
|
||||||
addFocusGained(state, change) {
|
addFocusGained(state, change) {
|
||||||
state.fieldEvents.push({
|
state.fieldEvents.push({
|
||||||
...change,
|
...change,
|
||||||
@ -96,6 +99,14 @@ const event = {
|
|||||||
keyCode: event.keyCode
|
keyCode: event.keyCode
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
notifyActionKeyPerformed({ commit }, event) {
|
||||||
|
commit('addActionKeyPerformed', {
|
||||||
|
containerUuid: event.containerUuid,
|
||||||
|
columnName: event.columnName,
|
||||||
|
value: event.value,
|
||||||
|
keyCode: event.keyCode
|
||||||
|
})
|
||||||
|
},
|
||||||
notifyFocusGained({ commit }, event) {
|
notifyFocusGained({ commit }, event) {
|
||||||
commit('addFocusGained', {
|
commit('addFocusGained', {
|
||||||
containerUuid: event.containerUuid,
|
containerUuid: event.containerUuid,
|
||||||
|
@ -313,7 +313,8 @@ export function getFieldTemplate(overwriteDefinition) {
|
|||||||
handleFocusLost: false,
|
handleFocusLost: false,
|
||||||
handleKeyPressed: false,
|
handleKeyPressed: false,
|
||||||
handleKeyReleased: false,
|
handleKeyReleased: false,
|
||||||
handleActionPerformed: true,
|
handleActionKeyPerformed: false,
|
||||||
|
handleActionPerformed: false,
|
||||||
dependentFieldsList: [],
|
dependentFieldsList: [],
|
||||||
reference: {
|
reference: {
|
||||||
tableName: '',
|
tableName: '',
|
||||||
@ -328,7 +329,6 @@ export function getFieldTemplate(overwriteDefinition) {
|
|||||||
isFixedTableColumn: false,
|
isFixedTableColumn: false,
|
||||||
...overwriteDefinition
|
...overwriteDefinition
|
||||||
}
|
}
|
||||||
|
|
||||||
// get parsed parent fields list
|
// get parsed parent fields list
|
||||||
fieldTemplateMetadata.parentFieldsList = getParentFields(fieldTemplateMetadata)
|
fieldTemplateMetadata.parentFieldsList = getParentFields(fieldTemplateMetadata)
|
||||||
|
|
||||||
|
@ -52,7 +52,8 @@ export default [
|
|||||||
definition: {
|
definition: {
|
||||||
name: 'Only Name',
|
name: 'Only Name',
|
||||||
displayType: TEXT.id,
|
displayType: TEXT.id,
|
||||||
displayLogic: '@URL@!""'
|
displayLogic: '@URL@!""',
|
||||||
|
handleActionKeyPerformed: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Amount
|
// Amount
|
||||||
@ -61,7 +62,8 @@ export default [
|
|||||||
definition: {
|
definition: {
|
||||||
name: 'Amount for it',
|
name: 'Amount for it',
|
||||||
displayType: NUMBER.id,
|
displayType: NUMBER.id,
|
||||||
readOnlyLogic: '@C_Currency_ID@<>""'
|
readOnlyLogic: '@C_Currency_ID@<>""',
|
||||||
|
handleActionKeyPerformed: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Integer
|
// Integer
|
||||||
|
@ -103,6 +103,21 @@ export default {
|
|||||||
formTitle() {
|
formTitle() {
|
||||||
return this.metadata.name || this.$route.meta.title
|
return this.metadata.name || this.$route.meta.title
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.unsubscribe = this.subscribeChanges()
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
this.unsubscribe()
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
subscribeChanges() {
|
||||||
|
return this.$store.subscribe((mutation, state) => {
|
||||||
|
if (mutation.type === 'addActionKeyPerformed') {
|
||||||
|
console.log(mutation)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user