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