Files
EdgeAdmin/web/public/js/components/common/datepicker.js
2022-10-03 19:25:20 +08:00

52 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Vue.component("datepicker", {
props: ["value", "v-name", "name", "v-value", "v-bottom-left", "placeholder"],
mounted: function () {
let that = this
teaweb.datepicker(this.$refs.dayInput, function (v) {
that.day = v
that.change()
}, !!this.vBottomLeft)
},
data: function () {
let name = this.vName
if (name == null) {
name = this.name
}
if (name == null) {
name = "day"
}
let day = this.vValue
if (day == null) {
day = this.value
if (day == null) {
day = ""
}
}
let placeholder = "YYYY-MM-DD"
if (this.placeholder != null) {
placeholder = this.placeholder
}
return {
realName: name,
realPlaceholder: placeholder,
day: day
}
},
watch: {
value: function (v) {
this.day = v
}
},
methods: {
change: function () {
this.$emit("input", this.day) // support v-model事件触发需要在 change 之前
this.$emit("change", this.day)
}
},
template: `<div style="display: inline-block">
<input type="text" :name="realName" v-model="day" :placeholder="realPlaceholder" style="width:8.6em" maxlength="10" @input="change" ref="dayInput" autocomplete="off"/>
</div>`
})