mirror of
https://github.com/continew-org/continew-admin.git
synced 2025-11-03 12:57:11 +08:00
优化:聚合日志相关 API,封装 date-range-picker 组件并优化部分细节
This commit is contained in:
79
continew-admin-ui/src/components/date-range-picker/index.vue
Normal file
79
continew-admin-ui/src/components/date-range-picker/index.vue
Normal file
@@ -0,0 +1,79 @@
|
||||
<template>
|
||||
<a-range-picker
|
||||
style="width: 100%"
|
||||
:shortcuts="shortcuts"
|
||||
shortcuts-position="left"
|
||||
:format="format"
|
||||
:show-time="showTime"
|
||||
:placeholder="placeholder"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, PropType } from 'vue';
|
||||
import { ShortcutType } from '@arco-design/web-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
defineProps({
|
||||
format: {
|
||||
type: String,
|
||||
default: 'YYYY-MM-DD HH:mm:ss',
|
||||
},
|
||||
showTime: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
placeholder: {
|
||||
type: Array as PropType<string[]>,
|
||||
default: (): string[] => ['开始时间', '结束时间'],
|
||||
},
|
||||
});
|
||||
|
||||
const shortcuts = computed<ShortcutType[]>(() => {
|
||||
return [
|
||||
{
|
||||
label: '今天',
|
||||
value: (): Date[] => [
|
||||
dayjs().startOf('day').toDate(),
|
||||
dayjs().toDate()
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '昨天',
|
||||
value: (): Date[] => [
|
||||
dayjs().subtract(1, 'day').startOf('day').toDate(),
|
||||
dayjs().subtract(1, 'day').endOf('day').toDate()
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '本周',
|
||||
value: (): Date[] => [
|
||||
dayjs().startOf('week').add(1, 'day').toDate(),
|
||||
dayjs().toDate()
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '本月',
|
||||
value: (): Date[] => [
|
||||
dayjs().startOf('month').toDate(),
|
||||
dayjs().toDate()
|
||||
]
|
||||
},
|
||||
{
|
||||
label: '本年',
|
||||
value: (): Date[] => [
|
||||
dayjs().startOf('year').toDate(),
|
||||
dayjs().toDate()
|
||||
]
|
||||
}
|
||||
];
|
||||
});
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: 'DateRangePicker',
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="less"></style>
|
||||
@@ -11,6 +11,7 @@ import {
|
||||
} from 'echarts/components';
|
||||
import Chart from './chart/index.vue';
|
||||
import Breadcrumb from './breadcrumb/index.vue';
|
||||
import DateRangePicker from './date-range-picker/index.vue';
|
||||
|
||||
// Manually introduce ECharts modules to reduce packing size
|
||||
|
||||
@@ -31,5 +32,6 @@ export default {
|
||||
install(Vue: App) {
|
||||
Vue.component('Chart', Chart);
|
||||
Vue.component('Breadcrumb', Breadcrumb);
|
||||
Vue.component('DateRangePicker', DateRangePicker);
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user