|
@@ -3,6 +3,7 @@
|
|
|
<TimeSelectorContent
|
|
|
ref="content"
|
|
|
:options="options"
|
|
|
+ :beforeChange="beforeChange"
|
|
|
:selectorTime="type"
|
|
|
selectorType="line"
|
|
|
:defaultSelectedKey="value"
|
|
@@ -23,12 +24,17 @@ export default {
|
|
|
event: 'input'
|
|
|
},
|
|
|
props: {
|
|
|
+ beforeChange: Function,
|
|
|
options: {
|
|
|
type: Array,
|
|
|
default() {
|
|
|
return []
|
|
|
}
|
|
|
},
|
|
|
+ splitter: {
|
|
|
+ type: String,
|
|
|
+ default: '_'
|
|
|
+ },
|
|
|
value: {
|
|
|
type: String,
|
|
|
default: 'thisyear'
|
|
@@ -61,15 +67,16 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
syncState(val) {
|
|
|
+ const splitter = this.splitter // 默认_
|
|
|
const time = this.transformTimeBefore(val)
|
|
|
- if (time.indexOf('_') === -1) {
|
|
|
+ if (time.indexOf(splitter) === -1) {
|
|
|
this.selectTime = {
|
|
|
start: 0,
|
|
|
end: 0,
|
|
|
exact: time
|
|
|
}
|
|
|
} else {
|
|
|
- const times = time.split('_')
|
|
|
+ const times = time.split(splitter)
|
|
|
this.selectTime = {
|
|
|
start: times[0] * 1000,
|
|
|
end: times[1] * 1000,
|
|
@@ -109,8 +116,9 @@ export default {
|
|
|
return timeMap[time] || time
|
|
|
},
|
|
|
onChange(state) {
|
|
|
+ const split = this.splitter
|
|
|
if (state.exact === 'exact') {
|
|
|
- this.$emit('input', `${state.start / 1000}_${state.end / 1000}`)
|
|
|
+ this.$emit('input', `${state.start / 1000}${split}${state.end / 1000}`)
|
|
|
} else {
|
|
|
this.$emit('input', this.transformTimeAfter(state.exact))
|
|
|
}
|