日历精确度问题修改
This commit is contained in:
parent
4414d3f71f
commit
7faea925b4
@ -10,7 +10,7 @@
|
||||
</u-input>
|
||||
<view class="pos-abt-all">
|
||||
<view v-if="showTools" @click.stop="">
|
||||
<tpx-select :list="toolsRangesList" :value="value[0]" mode="drop" @onChange="handleToolsRangChange">
|
||||
<tpx-select :list="toolsRangesList" v-model:value="rangeVal" mode="drop" @onChange="handleToolsRangChange">
|
||||
<view :style="`height: 64rpx;`" ></view>
|
||||
</tpx-select>
|
||||
</view>
|
||||
@ -24,13 +24,23 @@
|
||||
<script>
|
||||
import { } from "@/common/untool"
|
||||
import dayjs from "dayjs"
|
||||
const formatStr = 'YYYY-MM-DD'
|
||||
|
||||
export default {
|
||||
computed: {
|
||||
inputValue() {
|
||||
const val = this.value
|
||||
let val = this.value
|
||||
if(Array.isArray(val)) {
|
||||
val = [].concat(val)
|
||||
if(val.length > 1) {
|
||||
val[0] = dayjs(val[0]).format(formatStr)
|
||||
}
|
||||
if(val.length > 1) {
|
||||
val[1] = dayjs(val[1]).format(formatStr)
|
||||
}
|
||||
}
|
||||
return val && (val.length > 1 ? val.join("~") : val[0])
|
||||
}
|
||||
},
|
||||
},
|
||||
props: {
|
||||
value: {
|
||||
@ -60,11 +70,14 @@
|
||||
},
|
||||
toolsRangesList: {
|
||||
default () {
|
||||
let today = dayjs().format(`${formatStr}`),
|
||||
yesterday = dayjs().subtract(1, 'days').format(`${formatStr}`),
|
||||
lastWeek = dayjs().subtract(7, 'days').format(`${formatStr}`)
|
||||
return [
|
||||
{ title: '今日', val: dayjs().format("YYYY-MM-DD") },
|
||||
{ title: '昨日', val: dayjs().subtract(1, 'days').format("YYYY-MM-DD") },
|
||||
{ title: '最近一周', val: dayjs().subtract(7, 'days').format("YYYY-MM-DD") },
|
||||
{ title: '自定义', val: -1 },
|
||||
{ title: '今日', val: '1', range: [ today, today ] },
|
||||
{ title: '昨日', val: '2', range: [yesterday, yesterday] },
|
||||
{ title: '最近一周', val: '3', range: [lastWeek, today] },
|
||||
{ title: '自定义', val: '-1', range: [] },
|
||||
]
|
||||
}
|
||||
},
|
||||
@ -76,7 +89,8 @@
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showCladar: false
|
||||
showCladar: false,
|
||||
rangeVal: ''
|
||||
}
|
||||
},
|
||||
created() {
|
||||
@ -92,6 +106,8 @@
|
||||
this.handleSwitchCladar()
|
||||
},
|
||||
handleChange(val){
|
||||
val[0] = dayjs(val[0]).format(`${formatStr} 00:00:00`)
|
||||
val[1] = dayjs(val[1]).format(`${formatStr} 23:59:59`)
|
||||
this.$emit('change', val)
|
||||
this.$emit('update:value', val)
|
||||
},
|
||||
@ -108,7 +124,8 @@
|
||||
if(val == -1) {
|
||||
this.handleSwitchCladar()
|
||||
} else {
|
||||
this.handleChange([val, dayjs().format("YYYY-MM-DD")])
|
||||
let sltRang = this.toolsRangesList.filter(t=> t.val == val)[0].range
|
||||
this.handleChange(sltRang)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user