A date transfer day option

This commit is contained in:
张臻 2020-09-11 15:59:49 +08:00
parent 26b6fe4ee5
commit bc87efcd15
4 changed files with 34 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@ -42,6 +42,10 @@ export default {
notice: 'Notice',
task: 'Task',
date: 'Date',
now: 'Now',
today: 'Today',
m1d: 'M1D',
p1d: 'P1D',
time: 'Time',
insertTime: 'Insert time',
updateTime: 'Update time',

View File

@ -42,7 +42,10 @@ export default {
notice: '通知',
task: '任务',
date: '日期',
time: '时间',
now: '当前',
today: '今天',
m1d: '减一天',
p1d: '加一天',
insertTime: '创建时间',
updateTime: '更新时间',
creator: '创建人',

View File

@ -28,7 +28,11 @@
>
<el-row class="transform-content">
<el-row v-show="transformType === 'time'">
<el-row>
<el-button style="margin-left:80px;" type="primary" @click="timestamp('now')">{{ $t('now') }}</el-button>
<el-button type="primary" @click="timestamp('today')">{{ $t('today') }}</el-button>
<el-button type="primary" @click="timestamp('m1d')">{{ $t('m1d') }}</el-button>
<el-button type="primary" @click="timestamp('p1d')">{{ $t('p1d') }}</el-button>
<el-row style="margin-top: 10px;">
<span style="display:inline-block;width:70px;font-size:14px;margin-right:10px">Timestamp</span>
<el-input v-model="timeExchange.timestamp" style="width: 200px" :placeholder="timeExchange.placeholder" clearable />
<el-button type="primary" @click="timestampToDate">>></el-button>
@ -255,6 +259,26 @@ export default {
this.transformVisible = true
this.transformType = type
},
timestamp(value) {
switch (value) {
case 'now':
this.timeExchange.timestamp = Date.parse(new Date()) / 1000
break
case 'today':
this.timeExchange.timestamp = new Date(new Date().setHours(0, 0, 0, 0)) / 1000
break
case 'm1d':
this.timeExchange.timestamp = this.timeExchange.timestamp > 0 ? this.timeExchange.timestamp - 86400 : Date.parse(new Date()) / 1000 - 86400
break
case 'p1d':
this.timeExchange.timestamp = this.timeExchange.timestamp > 0 ? this.timeExchange.timestamp + 86400 : Date.parse(new Date()) / 1000 + 86400
break
default:
this.timeExchange.timestamp = Date.parse(new Date()) / 1000
}
this.timeExchange.date = parseTime(this.timeExchange.timestamp)
},
timestampToDate() {
this.timeExchange.date = parseTime(this.timeExchange.timestamp)
},