mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-01 18:52:20 +08:00
Merge branch 'main' into next
This commit is contained in:
commit
90fe98b4e5
@ -24,6 +24,7 @@ export class DateFieldInterface extends CollectionFieldInterface {
|
||||
'x-component': 'DatePicker',
|
||||
'x-component-props': {
|
||||
dateOnly: true,
|
||||
showTime: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
@ -10,6 +10,7 @@
|
||||
import { getDefaultFormat, str2moment, toGmt, toLocal, getPickerFormat } from '@nocobase/utils/client';
|
||||
import type { Dayjs } from 'dayjs';
|
||||
import dayjs from 'dayjs';
|
||||
import { dayjsable, formatDayjsValue } from '@formily/antd-v5/esm/__builtins__';
|
||||
|
||||
const toStringByPicker = (value, picker = 'date', timezone: 'gmt' | 'local') => {
|
||||
if (!dayjs.isDayjs(value)) return value;
|
||||
@ -89,7 +90,7 @@ export const handleDateChangeOnForm = (value, dateOnly, utc, picker, showTime, g
|
||||
return value;
|
||||
}
|
||||
if (dateOnly) {
|
||||
return dayjs(value).startOf(picker).format('YYYY-MM-DD');
|
||||
return formatDayjsValue(value, 'YYYY-MM-DD');
|
||||
}
|
||||
if (utc) {
|
||||
if (gmt) {
|
||||
@ -114,6 +115,7 @@ export const mapDatePicker = function () {
|
||||
const { dateOnly, showTime, picker = 'date', utc, gmt, underFilter } = props;
|
||||
const format = getDefaultFormat(props);
|
||||
const onChange = props.onChange;
|
||||
|
||||
return {
|
||||
...props,
|
||||
inputReadOnly: isMobileMedia,
|
||||
|
@ -33,7 +33,7 @@ const toDate = (date, options: any = {}) => {
|
||||
}
|
||||
|
||||
if (field.constructor.name === 'DateOnlyField') {
|
||||
val = moment(val).format('YYYY-MM-DD HH:mm:ss');
|
||||
val = moment.utc(val).format('YYYY-MM-DD HH:mm:ss');
|
||||
}
|
||||
|
||||
const eventObj = {
|
||||
@ -69,7 +69,6 @@ export default {
|
||||
const r = parseDate(value, {
|
||||
timezone: parseDateTimezone(ctx),
|
||||
});
|
||||
|
||||
if (typeof r === 'string') {
|
||||
return {
|
||||
[Op.eq]: toDate(r, { ctx }),
|
||||
@ -77,6 +76,9 @@ export default {
|
||||
}
|
||||
|
||||
if (Array.isArray(r)) {
|
||||
console.log(11111111, {
|
||||
[Op.and]: [{ [Op.gte]: toDate(r[0], { ctx }) }, { [Op.lt]: toDate(r[1], { ctx }) }],
|
||||
});
|
||||
return {
|
||||
[Op.and]: [{ [Op.gte]: toDate(r[0], { ctx }) }, { [Op.lt]: toDate(r[1], { ctx }) }],
|
||||
};
|
||||
|
@ -15,6 +15,7 @@ export interface Str2momentOptions {
|
||||
picker?: 'year' | 'month' | 'week' | 'quarter';
|
||||
utcOffset?: number;
|
||||
utc?: boolean;
|
||||
dateOnly?: boolean;
|
||||
}
|
||||
|
||||
export type Str2momentValue = string | string[] | dayjs.Dayjs | dayjs.Dayjs[];
|
||||
@ -83,10 +84,14 @@ const toMoment = (val: any, options?: Str2momentOptions) => {
|
||||
return;
|
||||
}
|
||||
const offset = options.utcOffset;
|
||||
const { gmt, picker, utc = true } = options;
|
||||
const { gmt, picker, utc = true, dateOnly } = options;
|
||||
|
||||
if (dayjs(val).isValid()) {
|
||||
if (dateOnly) {
|
||||
return dayjs.utc(val, 'YYYY-MM-DD');
|
||||
}
|
||||
if (!utc) {
|
||||
return dayjs(val);
|
||||
return dayjs.utc(val);
|
||||
}
|
||||
|
||||
if (dayjs.isDayjs(val)) {
|
||||
|
@ -188,9 +188,11 @@ export const parseFilter = async (filter: any, opts: ParseFilterOptions = {}) =>
|
||||
const field = getField?.(path);
|
||||
|
||||
if (field?.constructor.name === 'DateOnlyField' || field?.constructor.name === 'DatetimeNoTzField') {
|
||||
if (value.type) {
|
||||
return getDayRangeByParams({ ...value, timezone: field?.timezone || timezone });
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
return dateValueWrapper(value, field?.timezone || timezone);
|
||||
}
|
||||
return value;
|
||||
|
Loading…
x
Reference in New Issue
Block a user