forked from github/dataease
Merge pull request #1483 from dataease/pr@dev@feat_时间组件增加时间格式
feat: 时间组件增加时间格式'无'
This commit is contained in:
commit
342b797871
@ -97,7 +97,8 @@ export default {
|
|||||||
timeOptions: [
|
timeOptions: [
|
||||||
|
|
||||||
{ value: 'hh:mm:ss', label: 'hh:mm:ss' },
|
{ value: 'hh:mm:ss', label: 'hh:mm:ss' },
|
||||||
{ value: 'hh时mm分ss秒', label: 'hh时mm分ss秒' }
|
{ value: 'hh时mm分ss秒', label: 'hh时mm分ss秒' },
|
||||||
|
{ value: '', label: '无' }
|
||||||
],
|
],
|
||||||
dateOptions: [
|
dateOptions: [
|
||||||
{ value: 'yyyy-MM-dd', label: 'yyyy-MM-dd' },
|
{ value: 'yyyy-MM-dd', label: 'yyyy-MM-dd' },
|
||||||
|
@ -44,7 +44,7 @@ export default {
|
|||||||
},
|
},
|
||||||
formatDate() {
|
formatDate() {
|
||||||
const weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
|
const weekArr = ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
|
||||||
let timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss'
|
let timeFormat = this.element.formatInfo.timeFormat
|
||||||
const showWeek = this.element.formatInfo.showWeek
|
const showWeek = this.element.formatInfo.showWeek
|
||||||
const showDate = this.element.formatInfo.showDate
|
const showDate = this.element.formatInfo.showDate
|
||||||
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="clock" :style="{'--varBg': varBg}">
|
<div id="clock" :style="{'--varBg': varBg}">
|
||||||
<p class="date">{{ date }}</p>
|
<p class="date">{{ date }}</p>
|
||||||
<p class="time" :style="{'fontSize': (parseInt(element.style.fontSize) * 3) + 'px'}">{{ time }}</p>
|
<p v-if="time" class="time" :style="{'fontSize': (parseInt(element.style.fontSize) * 3) + 'px'}">{{ time }}</p>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ export default {
|
|||||||
},
|
},
|
||||||
updateTime() {
|
updateTime() {
|
||||||
var cd = new Date()
|
var cd = new Date()
|
||||||
const timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss'
|
const timeFormat = this.element.formatInfo.timeFormat
|
||||||
const showWeek = this.element.formatInfo.showWeek
|
const showWeek = this.element.formatInfo.showWeek
|
||||||
const showDate = this.element.formatInfo.showDate
|
const showDate = this.element.formatInfo.showDate
|
||||||
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
||||||
@ -75,8 +75,12 @@ export default {
|
|||||||
nowDate = cd.format(dateFormat)
|
nowDate = cd.format(dateFormat)
|
||||||
}
|
}
|
||||||
const nowWeek = this.week[cd.getDay()]
|
const nowWeek = this.week[cd.getDay()]
|
||||||
|
if (timeFormat) {
|
||||||
this.time = cd.format(timeFormat)
|
this.time = cd.format(timeFormat)
|
||||||
|
} else {
|
||||||
|
this.time = null
|
||||||
|
}
|
||||||
|
|
||||||
this.date = showWeek ? (nowDate + ' ' + nowWeek) : nowDate
|
this.date = showWeek ? (nowDate + ' ' + nowWeek) : nowDate
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ export default {
|
|||||||
this.timer = setInterval(this.canvass, 500)
|
this.timer = setInterval(this.canvass, 500)
|
||||||
},
|
},
|
||||||
canvass() {
|
canvass() {
|
||||||
const timeFormat = this.element.formatInfo.timeFormat || 'hh:mm:ss'
|
const timeFormat = this.element.formatInfo.timeFormat
|
||||||
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
const dateFormat = this.element.formatInfo.dateFormat || 'yyyy-MM-dd'
|
||||||
const showWeek = this.element.formatInfo.showWeek
|
const showWeek = this.element.formatInfo.showWeek
|
||||||
const showDate = this.element.formatInfo.showDate
|
const showDate = this.element.formatInfo.showDate
|
||||||
@ -110,8 +110,10 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
englishWeek = 'Saturday'
|
englishWeek = 'Saturday'
|
||||||
}
|
}
|
||||||
|
let simpleTime = ''
|
||||||
const simpleTime = time.format(timeFormat)
|
if (timeFormat) {
|
||||||
|
simpleTime = time.format(timeFormat)
|
||||||
|
}
|
||||||
let nowDate = ''
|
let nowDate = ''
|
||||||
if (showDate && dateFormat) {
|
if (showDate && dateFormat) {
|
||||||
nowDate = time.format(dateFormat)
|
nowDate = time.format(dateFormat)
|
||||||
|
Loading…
Reference in New Issue
Block a user