mirror of
https://github.com/PanJiaChen/vue-element-admin.git
synced 2025-08-11 05:11:59 +08:00
feat: Add autofocus and showControl attributes. (#478)
This commit is contained in:
parent
8e00a50b14
commit
098de4d8f3
@ -38,7 +38,9 @@ export const fieldMixin = {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
activeFocus() {
|
activeFocus() {
|
||||||
this.$refs[this.metadata.columnName].focus()
|
if (this.$refs[this.metadata.columnName]) {
|
||||||
|
this.$refs[this.metadata.columnName].focus()
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Overwrite component method if necessary
|
* Overwrite component method if necessary
|
||||||
@ -49,6 +51,14 @@ export const fieldMixin = {
|
|||||||
this.handleChange(value)
|
this.handleChange(value)
|
||||||
},
|
},
|
||||||
focusGained(value) {
|
focusGained(value) {
|
||||||
|
if (this.metadata.isAutoSelection) {
|
||||||
|
// select all the content inside the text box
|
||||||
|
if (!this.isEmptyValue(value.target.selectionStart) &&
|
||||||
|
!this.isEmptyValue(value.target.selectionStart)) {
|
||||||
|
value.target.selectionStart = 0
|
||||||
|
value.target.selectionEnd = value.target.value.length
|
||||||
|
}
|
||||||
|
}
|
||||||
if (this.metadata.handleFocusGained) {
|
if (this.metadata.handleFocusGained) {
|
||||||
this.$store.dispatch('notifyFocusGained', {
|
this.$store.dispatch('notifyFocusGained', {
|
||||||
containerUuid: this.metadata.containerUuid,
|
containerUuid: this.metadata.containerUuid,
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
:placeholder="metadata.help"
|
:placeholder="metadata.help"
|
||||||
:disabled="isDisabled"
|
:disabled="isDisabled"
|
||||||
:precision="precision"
|
:precision="precision"
|
||||||
controls-position="right"
|
:controls="isShowControls"
|
||||||
|
:controls-position="controlsPosition"
|
||||||
:class="'display-type-amount ' + metadata.cssClassName"
|
:class="'display-type-amount ' + metadata.cssClassName"
|
||||||
@change="preHandleChange"
|
@change="preHandleChange"
|
||||||
@blur="focusLost"
|
@blur="focusLost"
|
||||||
@ -62,6 +63,24 @@ export default {
|
|||||||
return 2
|
return 2
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
|
},
|
||||||
|
isShowControls() {
|
||||||
|
if (!this.isEmptyValue(this.metadata.showControl)) {
|
||||||
|
if (this.metadata.showControl === 0) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
},
|
||||||
|
controlsPosition() {
|
||||||
|
if (!this.isEmptyValue(this.metadata.showControl)) {
|
||||||
|
// show side controls
|
||||||
|
if (this.metadata.showControl === 1) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// show right controls
|
||||||
|
return 'right'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
@ -89,6 +89,6 @@ export default {
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.custom-field-yes-no {
|
.custom-field-yes-no {
|
||||||
min-height: 34px;
|
max-height: 34px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -6,6 +6,7 @@ export default [
|
|||||||
columnName: 'URL',
|
columnName: 'URL',
|
||||||
definition: {
|
definition: {
|
||||||
name: 'Web',
|
name: 'Web',
|
||||||
|
isAutoSelection: true,
|
||||||
displayType: URL.id
|
displayType: URL.id
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -69,7 +70,8 @@ export default [
|
|||||||
definition: {
|
definition: {
|
||||||
name: 'Sequence for record',
|
name: 'Sequence for record',
|
||||||
displayType: INTEGER.id,
|
displayType: INTEGER.id,
|
||||||
mandatoryLogic: '@URL@!""'
|
mandatoryLogic: '@URL@!""',
|
||||||
|
showControl: 1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// Text Long
|
// Text Long
|
||||||
|
Loading…
x
Reference in New Issue
Block a user