feat(sj_1.1.0_beta1): 新增时间范围查询组件
This commit is contained in:
parent
4510c251cf
commit
a07016214f
60
src/components/common/datetime-range.vue
Normal file
60
src/components/common/datetime-range.vue
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
|
|
||||||
|
defineOptions({
|
||||||
|
name: 'DatetimeRange'
|
||||||
|
});
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
beginDate?: number | null;
|
||||||
|
endDate?: number | null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<Props>();
|
||||||
|
|
||||||
|
interface Emits {
|
||||||
|
(e: 'update:beginDate', beginDate: number): void;
|
||||||
|
(e: 'update:endDate', endDate: number): void;
|
||||||
|
}
|
||||||
|
const emit = defineEmits<Emits>();
|
||||||
|
|
||||||
|
const dateRange = ref<[number, number]>(getDefaultDate());
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.beginDate,
|
||||||
|
beginDate => {
|
||||||
|
if (typeof beginDate === 'number' && beginDate) {
|
||||||
|
dateRange.value[0] = beginDate;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => props.endDate,
|
||||||
|
endDate => {
|
||||||
|
if (typeof endDate === 'number' && endDate) {
|
||||||
|
dateRange.value[1] = endDate;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
|
|
||||||
|
function getDefaultDate(): [number, number] {
|
||||||
|
const currentDate = new Date();
|
||||||
|
const currentTime = currentDate.getTime();
|
||||||
|
currentDate.setMonth(currentDate.getMonth() - 1);
|
||||||
|
return [currentDate.getTime(), currentTime];
|
||||||
|
}
|
||||||
|
|
||||||
|
function onChange(value: [number, number]) {
|
||||||
|
emit('update:beginDate', value[0]);
|
||||||
|
emit('update:endDate', value[1]);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<NDatePicker v-model:value="dateRange" class="w-full" type="datetimerange" clearable @update:value="onChange" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss"></style>
|
@ -10,6 +10,7 @@ defineOptions({
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
model: Record<string, any>;
|
model: Record<string, any>;
|
||||||
|
btnSpan?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<Props>();
|
const props = defineProps<Props>();
|
||||||
@ -41,14 +42,14 @@ async function search() {
|
|||||||
|
|
||||||
const btnSpan = computed(() => {
|
const btnSpan = computed(() => {
|
||||||
const keyNum = Object.keys(props.model).length - 2;
|
const keyNum = Object.keys(props.model).length - 2;
|
||||||
return `24 m:12 m:${(4 - (keyNum % 4)) * 6}`;
|
return props.btnSpan || `24 m:12 m:${(4 - (keyNum % 4)) * 6}`;
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<NCard :title="title" :bordered="false" size="small" class="card-wrapper">
|
<NCard :title="title" :bordered="false" size="small" class="card-wrapper">
|
||||||
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
<NForm ref="formRef" :model="model" label-placement="left" :label-width="80" :show-feedback="appStore.isMobile">
|
||||||
<NGrid responsive="screen" item-responsive :y-gap="5">
|
<NGrid responsive="screen" item-responsive :y-gap="8">
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
<NFormItemGi :y-gap="8" :span="btnSpan" class="pr-24px lg:p-t-0 md:p-t-16px">
|
<NFormItemGi :y-gap="8" :span="btnSpan" class="pr-24px lg:p-t-0 md:p-t-16px">
|
||||||
<NSpace class="min-w-172px w-full" justify="end">
|
<NSpace class="min-w-172px w-full" justify="end">
|
||||||
|
3
src/typings/api.d.ts
vendored
3
src/typings/api.d.ts
vendored
@ -1079,7 +1079,8 @@ declare namespace Api {
|
|||||||
|
|
||||||
/** JobBatch search params */
|
/** JobBatch search params */
|
||||||
type JobBatchSearchParams = CommonType.RecordNullable<
|
type JobBatchSearchParams = CommonType.RecordNullable<
|
||||||
Pick<Api.JobBatch.JobBatch, 'groupName' | 'jobName' | 'taskBatchStatus'> & CommonSearchParams
|
Pick<Api.JobBatch.JobBatch, 'groupName' | 'jobName' | 'taskBatchStatus'> &
|
||||||
|
CommonSearchParams & { beginDate: number; endDate: number }
|
||||||
>;
|
>;
|
||||||
|
|
||||||
/** JobBatch list */
|
/** JobBatch list */
|
||||||
|
@ -26,7 +26,9 @@ const { columnChecks, columns, data, getData, loading, mobilePagination, searchP
|
|||||||
size: 10,
|
size: 10,
|
||||||
groupName: null,
|
groupName: null,
|
||||||
jobName: null,
|
jobName: null,
|
||||||
taskBatchStatus: null
|
taskBatchStatus: null,
|
||||||
|
beginDate: null,
|
||||||
|
endDate: null
|
||||||
},
|
},
|
||||||
searchParams: {
|
searchParams: {
|
||||||
jobName,
|
jobName,
|
||||||
|
@ -26,7 +26,7 @@ function search() {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<SearchForm :model="model" @search="search" @reset="reset">
|
<SearchForm btn-span="24 s:24 m:9 l:12 xl:15" :model="model" @search="search" @reset="reset">
|
||||||
<NFormItemGi span="24 s:12 m:6" :label="$t('page.jobBatch.groupName')" path="groupName" class="pr-24px">
|
<NFormItemGi span="24 s:12 m:6" :label="$t('page.jobBatch.groupName')" path="groupName" class="pr-24px">
|
||||||
<SelectGroup v-model:value="model.groupName" />
|
<SelectGroup v-model:value="model.groupName" />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
@ -36,6 +36,9 @@ function search() {
|
|||||||
<NFormItemGi span="24 s:12 m:6" :label="$t('page.jobBatch.taskBatchStatus')" path="taskBatchStatus" class="pr-24px">
|
<NFormItemGi span="24 s:12 m:6" :label="$t('page.jobBatch.taskBatchStatus')" path="taskBatchStatus" class="pr-24px">
|
||||||
<TaskBatchStatus v-model:value="model.taskBatchStatus" />
|
<TaskBatchStatus v-model:value="model.taskBatchStatus" />
|
||||||
</NFormItemGi>
|
</NFormItemGi>
|
||||||
|
<NFormItemGi span="24 s:24 m:15 l:12 xl:9" :label="$t('page.common.createTime')" path="createTime" class="pr-24px">
|
||||||
|
<DatetimeRange v-model:begin-date="model.beginDate" v-model:end-date="model.endDate" />
|
||||||
|
</NFormItemGi>
|
||||||
</SearchForm>
|
</SearchForm>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user