|
@@ -1,7 +1,9 @@
|
|
import {ElDatePicker} from "element-plus";
|
|
import {ElDatePicker} from "element-plus";
|
|
import {ref, Ref, watch} from 'vue'
|
|
import {ref, Ref, watch} from 'vue'
|
|
|
|
+// @ts-ignore
|
|
import {currentAndAFewDaysAgo, elDateRangeAddTime} from "@/utils/moment-utils";
|
|
import {currentAndAFewDaysAgo, elDateRangeAddTime} from "@/utils/moment-utils";
|
|
import moment from 'moment'
|
|
import moment from 'moment'
|
|
|
|
+// @ts-ignore
|
|
import {tsxVModel} from "@/utils/cy-use/useTsxUtils";
|
|
import {tsxVModel} from "@/utils/cy-use/useTsxUtils";
|
|
|
|
|
|
const shortcuts = [
|
|
const shortcuts = [
|
|
@@ -44,6 +46,7 @@ interface ElDatePickerType {
|
|
defaultValue?: object,
|
|
defaultValue?: object,
|
|
teleported?: boolean,
|
|
teleported?: boolean,
|
|
aFewDaysAgo?: number,
|
|
aFewDaysAgo?: number,
|
|
|
|
+ shortcutsIndex?: number
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -53,17 +56,20 @@ export default function useDateRange(props?: ElDatePickerType) {
|
|
defaultValue: null,
|
|
defaultValue: null,
|
|
teleported: false,
|
|
teleported: false,
|
|
aFewDaysAgo: null,
|
|
aFewDaysAgo: null,
|
|
|
|
+ shortcutsIndex: null,
|
|
...props
|
|
...props
|
|
}
|
|
}
|
|
|
|
|
|
const modelValue: Ref<any[]> = ref([])
|
|
const modelValue: Ref<any[]> = ref([])
|
|
- const dateRange = ref({})
|
|
|
|
|
|
+ const dateRange: Ref<{start: string, end: string}> = ref({ start: '', end: ''})
|
|
|
|
|
|
watch(() => modelValue.value, () => {
|
|
watch(() => modelValue.value, () => {
|
|
dateRange.value = elDateRangeAddTime(modelValue.value)
|
|
dateRange.value = elDateRangeAddTime(modelValue.value)
|
|
})
|
|
})
|
|
|
|
|
|
- if (props.aFewDaysAgo !== null) {
|
|
|
|
|
|
+ if (props.shortcutsIndex !== null) {
|
|
|
|
+ modelValue.value = shortcuts[props.shortcutsIndex].value
|
|
|
|
+ } else if (props.aFewDaysAgo !== null) {
|
|
currentAndAFewDaysAgo(props?.aFewDaysAgo).then(res => {
|
|
currentAndAFewDaysAgo(props?.aFewDaysAgo).then(res => {
|
|
modelValue.value = res
|
|
modelValue.value = res
|
|
})
|
|
})
|