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