Sfoglia il codice sorgente

日期范围组件

lighter 1 anno fa
parent
commit
54c30d588c

+ 0 - 0
src/components/inpatient/frontsheet-printpage/ExportDclExcel.vue


+ 8 - 2
src/utils/cy-use/useDateRange.tsx

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