Commit fab95a52 authored by leon's avatar leon

feat: datepicker config

parent c91b002e
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
:select-open="show" :select-open="show"
:border="true" :border="true"
:borderColor="elementInfo.option.dateTime.borderColor" :borderColor="elementInfo.option.dateTime.borderColor"
:custom-style="{ color: elementInfo.option.dateTime.color }" :custom-style="{ color: elementInfo.option.dateTime.color, fontSize: `${elementInfo.option.dateTime.fontSize}px` }"
@click="show = true" @click="show = true"
></u-input> ></u-input>
<u-icon <u-icon
...@@ -61,7 +61,22 @@ export default { ...@@ -61,7 +61,22 @@ export default {
} }
}, },
mounted() { mounted() {
let { date } = this.elementInfo.option.dateTime let { date, isDefault, defaultDate } = this.elementInfo.option.dateTime
if(isDefault) {
const today = new Date()
if(defaultDate === 'today') {
}
if(defaultDate === 'yesterday') {
const timestamp = today.getTime() - 1000 * 24 * 60 * 60
today.setTime(timestamp)
}
if(defaultDate === 'week') {
const timestamp = today.getTime() - 1000 * 24 * 60 * 60 * 6
today.setTime(timestamp)
}
this.pickerValue = this.dateTimeFormat(today)
return
}
if (date) this.pickerValue = this.dateTimeFormat(date) if (date) this.pickerValue = this.dateTimeFormat(date)
}, },
methods: { methods: {
......
...@@ -158,7 +158,6 @@ const install = (Vue, vm) => { ...@@ -158,7 +158,6 @@ const install = (Vue, vm) => {
const day = () => { const day = () => {
const date = new Date(); const date = new Date();
const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
return day return day
} }
...@@ -177,7 +176,6 @@ const install = (Vue, vm) => { ...@@ -177,7 +176,6 @@ const install = (Vue, vm) => {
const date = new Date() const date = new Date()
const timestamp = date.getTime() - 1000 * 24 * 60 * 60 const timestamp = date.getTime() - 1000 * 24 * 60 * 60
date.setTime(timestamp) date.setTime(timestamp)
console.log(date)
const year = date.getFullYear(); const year = date.getFullYear();
// 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05 // 在日期格式中,月份是从0开始的,因此要加0,使用三元表达式在小于10的前面加0,以达到格式统一 如 09:11:05
const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment