2020-02-16 18:30:00 +00:00
|
|
|
import Vue from 'vue'
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
|
|
name: 'FtInput',
|
|
|
|
props: {
|
|
|
|
placeholder: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
2020-06-02 02:42:29 +00:00
|
|
|
value: {
|
|
|
|
type: String,
|
|
|
|
default: ''
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
showArrow: {
|
|
|
|
type: Boolean,
|
|
|
|
default: true
|
2020-03-01 03:37:02 +00:00
|
|
|
},
|
2020-06-02 02:42:29 +00:00
|
|
|
showLabel: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
|
|
|
},
|
2020-03-01 03:37:02 +00:00
|
|
|
isSearch: {
|
|
|
|
type: Boolean,
|
|
|
|
default: false
|
2020-06-02 02:42:29 +00:00
|
|
|
},
|
|
|
|
dataList: {
|
|
|
|
type: Array,
|
|
|
|
default: () => { return [] }
|
|
|
|
},
|
2020-02-16 18:30:00 +00:00
|
|
|
},
|
|
|
|
data: function () {
|
|
|
|
return {
|
|
|
|
id: '',
|
2020-03-01 03:37:02 +00:00
|
|
|
inputData: ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
barColor: function () {
|
|
|
|
return this.$store.getters.getBarColor
|
|
|
|
},
|
|
|
|
|
|
|
|
forceTextColor: function () {
|
|
|
|
return this.isSearch && this.barColor
|
2020-06-02 02:42:29 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
idDataList: function () {
|
|
|
|
return `${this.id}_datalist`
|
2020-02-16 18:30:00 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted: function () {
|
|
|
|
this.id = this._uid
|
2020-06-19 19:58:59 +00:00
|
|
|
this.inputData = this.value
|
2020-02-16 18:30:00 +00:00
|
|
|
|
|
|
|
setTimeout(this.addListener, 200)
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
handleClick: function () {
|
|
|
|
this.$emit('click', this.inputData)
|
|
|
|
},
|
|
|
|
|
2020-06-19 19:58:59 +00:00
|
|
|
handleInput: function () {
|
|
|
|
this.$emit('input', this.inputData)
|
2020-06-02 02:42:29 +00:00
|
|
|
},
|
|
|
|
|
2020-02-16 18:30:00 +00:00
|
|
|
addListener: function () {
|
|
|
|
const inputElement = document.getElementById(this.id)
|
|
|
|
|
|
|
|
if (inputElement !== null) {
|
|
|
|
inputElement.addEventListener('keydown', (event) => {
|
|
|
|
if (event.keyCode === 13) {
|
|
|
|
this.handleClick()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|