|
|
@@ -1,6 +1,6 @@
|
|
|
<script setup lang="ts">
|
|
|
-import {ElDatePicker} from "element-plus";
|
|
|
-import {listNotBlank} from "@/utils/blank-utils";
|
|
|
+import { ElDatePicker } from "element-plus";
|
|
|
+import { listNotBlank } from "@/utils/blank-utils";
|
|
|
import {
|
|
|
DATEFORMAT,
|
|
|
elDateRangeAddTime,
|
|
|
@@ -8,60 +8,66 @@ import {
|
|
|
} from "@/utils/moment-utils";
|
|
|
import moment from "moment/moment";
|
|
|
import XEUtils from "xe-utils";
|
|
|
-import {WritableComputedRef} from "vue";
|
|
|
-import {useVModel} from "@vueuse/core";
|
|
|
+import { WritableComputedRef } from "vue";
|
|
|
+import { useVModel } from "@vueuse/core";
|
|
|
|
|
|
const shortcuts = [
|
|
|
{
|
|
|
- text: '今天',
|
|
|
- value: [moment(), moment()]
|
|
|
+ text: "今天",
|
|
|
+ value: [moment(), moment()],
|
|
|
},
|
|
|
{
|
|
|
- text: '最近一周',
|
|
|
- value: [moment().subtract(7, 'days'), moment()]
|
|
|
+ text: "最近一周",
|
|
|
+ value: [moment().subtract(7, "days"), moment()],
|
|
|
},
|
|
|
{
|
|
|
- text: '最近一个月',
|
|
|
- value: [moment().subtract(1, 'months'), moment()]
|
|
|
+ text: "最近一个月",
|
|
|
+ value: [moment().subtract(1, "months"), moment()],
|
|
|
},
|
|
|
{
|
|
|
- text: '最近三个月',
|
|
|
- value: [moment().subtract(3, 'months'), moment()]
|
|
|
+ text: "最近三个月",
|
|
|
+ value: [moment().subtract(3, "months"), moment()],
|
|
|
},
|
|
|
{
|
|
|
- text: '本月',
|
|
|
- value: [moment().startOf('month'), moment().endOf('month')]
|
|
|
+ text: "本月",
|
|
|
+ value: [moment().startOf("month"), moment().endOf("month")],
|
|
|
},
|
|
|
{
|
|
|
- text: '上个月',
|
|
|
- value: [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
|
|
|
+ text: "上个月",
|
|
|
+ value: [
|
|
|
+ moment().subtract(1, "month").startOf("month"),
|
|
|
+ moment().subtract(1, "month").endOf("month"),
|
|
|
+ ],
|
|
|
},
|
|
|
{
|
|
|
- text: '今年',
|
|
|
- value: [moment().startOf('year'), moment()]
|
|
|
+ text: "今年",
|
|
|
+ value: [moment().startOf("year"), moment()],
|
|
|
},
|
|
|
{
|
|
|
- text: '去年',
|
|
|
- value: [moment().subtract(1, 'year').startOf('year'), moment().subtract(1, 'year').endOf('year')]
|
|
|
- }
|
|
|
+ text: "去年",
|
|
|
+ value: [
|
|
|
+ moment().subtract(1, "year").startOf("year"),
|
|
|
+ moment().subtract(1, "year").endOf("year"),
|
|
|
+ ],
|
|
|
+ },
|
|
|
];
|
|
|
|
|
|
const props = withDefaults(
|
|
|
- defineProps<{
|
|
|
- modelValue?: any;
|
|
|
- start?: string;
|
|
|
- end?: string;
|
|
|
- clearable?: boolean;
|
|
|
- unlinkPanels?: boolean;
|
|
|
- shortcutsIndex?: number | string | null;
|
|
|
- }>(),
|
|
|
- {
|
|
|
- start: "startTime",
|
|
|
- end: "endTime",
|
|
|
- clearable: true,
|
|
|
- unlinkPanels: true,
|
|
|
- shortcutsIndex: null,
|
|
|
- }
|
|
|
+ defineProps<{
|
|
|
+ modelValue?: any;
|
|
|
+ start?: string;
|
|
|
+ end?: string;
|
|
|
+ clearable?: boolean;
|
|
|
+ unlinkPanels?: boolean;
|
|
|
+ shortcutsIndex?: number | string | null;
|
|
|
+ }>(),
|
|
|
+ {
|
|
|
+ start: "startTime",
|
|
|
+ end: "endTime",
|
|
|
+ clearable: true,
|
|
|
+ unlinkPanels: true,
|
|
|
+ shortcutsIndex: null,
|
|
|
+ }
|
|
|
);
|
|
|
|
|
|
const emits = defineEmits(["update:modelValue"]);
|
|
|
@@ -87,7 +93,7 @@ const dateRange: WritableComputedRef<string[]> = computed({
|
|
|
}
|
|
|
},
|
|
|
set(value: string[]) {
|
|
|
- const {start, end} = elDateRangeAddTime(value);
|
|
|
+ const { start, end } = elDateRangeAddTime(value);
|
|
|
if (isArr) {
|
|
|
model.value = value === null ? null : [start, end];
|
|
|
} else {
|
|
|
@@ -109,12 +115,12 @@ onMounted(() => {
|
|
|
|
|
|
<template>
|
|
|
<el-date-picker
|
|
|
- v-model="dateRange"
|
|
|
- :unlinkPanels
|
|
|
- :shortcuts
|
|
|
- :clearable
|
|
|
- type="daterange"
|
|
|
- style="display: inline-flex; vertical-align: middle; width: 220px"
|
|
|
+ v-model="dateRange"
|
|
|
+ :unlinkPanels
|
|
|
+ :shortcuts
|
|
|
+ :clearable
|
|
|
+ type="daterange"
|
|
|
+ style="display: inline-flex; vertical-align: middle; width: 220px"
|
|
|
/>
|
|
|
</template>
|
|
|
|