【类 型】:refactor
【主 题】:重构了日期组件 【描 述】: [原因]:初始化值 并vuex实时记录其 日期 [过程]:初始化为今天 同步到vuex [影响]: 【结 束】 # 类型 包含: # feat:新功能(feature) # fix:修补bug # docs:文档(documentation) # style: 格式(不影响代码运行的变动) # refactor:重构(即不是新增功能,也不是修改bug的代码变动) # test:增加测试 # chore:构建过程或辅助工具的变动
This commit is contained in:
parent
81c9229993
commit
b92d305678
@ -6,14 +6,6 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export default {
|
export default {
|
||||||
props: {
|
|
||||||
startDate: {
|
|
||||||
type: Number
|
|
||||||
},
|
|
||||||
endDate: {
|
|
||||||
type: Number
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
pickerOptions: {
|
pickerOptions: {
|
||||||
@ -87,22 +79,36 @@ export default {
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
value: [new Date(this.startDate * 1000), new Date(this.endDate * 1000)]
|
value: []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created () {
|
||||||
|
const startTime = this.$store.getters['app/getOrderSerch'].start_time
|
||||||
|
const endTime = this.$store.getters['app/getOrderSerch'].end_time
|
||||||
|
|
||||||
|
if (startTime === '' && endTime === '') {
|
||||||
|
this.value = [
|
||||||
|
new Date(new Date().setHours(0, 0, 0, 0)).getTime(),
|
||||||
|
new Date(new Date().setHours(23, 59, 59, 999)).getTime()
|
||||||
|
]
|
||||||
|
} else {
|
||||||
|
this.value = [
|
||||||
|
new Date(startTime * 1000),
|
||||||
|
new Date(endTime * 1000)
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
value (newVal) {
|
value (newVal) {
|
||||||
if (newVal && newVal.length === 2) {
|
if (newVal && newVal.length === 2) {
|
||||||
const end = newVal[1]
|
const start = new Date(newVal[0])
|
||||||
|
const end = new Date(newVal[1])
|
||||||
end.setHours(23, 59, 59, 999) // 设置结束日期为当天的23:59:59
|
end.setHours(23, 59, 59, 999) // 设置结束日期为当天的23:59:59
|
||||||
const startTimestamp = Math.floor(newVal[0].getTime() / 1000) // 转换毫秒为秒
|
const startTimestamp = Math.floor(start.getTime() / 1000) // 转换毫秒为秒
|
||||||
const endTimestamp = Math.floor(end.getTime() / 1000) // 转换毫秒为秒
|
const endTimestamp = Math.floor(end.getTime() / 1000) // 转换毫秒为秒
|
||||||
this.$store.commit('app/setOrderSerch', { start_time: startTimestamp })
|
this.$store.commit('app/setOrderSerch', { start_time: startTimestamp, end_time: endTimestamp })
|
||||||
this.$store.commit('app/setOrderSerch', { end_time: endTimestamp })
|
} else if (newVal === null) {
|
||||||
}
|
this.$store.commit('app/setOrderSerch', { start_time: '', end_time: '' })
|
||||||
if (newVal === null) {
|
|
||||||
this.$store.commit('app/setOrderSerch', { start_time: '' })
|
|
||||||
this.$store.commit('app/setOrderSerch', { end_time: '' })
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user