mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +08:00
fix(date-picker): picker switching issue in date field of filter button (#6695)
* fix: picker switching issue in date field of filter button * fix: bug * fix: bug
This commit is contained in:
parent
deb85d30bd
commit
aa6a46924a
@ -268,8 +268,9 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
|
|||||||
const value = Array.isArray(props.value) ? props.value[0] : props.value;
|
const value = Array.isArray(props.value) ? props.value[0] : props.value;
|
||||||
const compile = useCompile();
|
const compile = useCompile();
|
||||||
const fieldSchema = useFieldSchema();
|
const fieldSchema = useFieldSchema();
|
||||||
const targetPicker = value ? inferPickerType(value, picker) : picker;
|
const initPicker = value ? inferPickerType(value, picker) : picker;
|
||||||
const targetDateFormat = getPickerFormat(targetPicker) || format;
|
const [targetPicker, setTargetPicker] = useState(initPicker);
|
||||||
|
const targetDateFormat = getPickerFormat(initPicker) || format;
|
||||||
const newProps = {
|
const newProps = {
|
||||||
utc,
|
utc,
|
||||||
inputReadOnly: isMobileMedia,
|
inputReadOnly: isMobileMedia,
|
||||||
@ -287,12 +288,6 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
|
|||||||
};
|
};
|
||||||
const field: any = useField();
|
const field: any = useField();
|
||||||
const [stateProps, setStateProps] = useState(newProps);
|
const [stateProps, setStateProps] = useState(newProps);
|
||||||
useEffect(() => {
|
|
||||||
newProps.picker = targetPicker;
|
|
||||||
const dateTimeFormat = getDateTimeFormat(targetPicker, targetDateFormat, showTime, timeFormat);
|
|
||||||
newProps.format = dateTimeFormat;
|
|
||||||
setStateProps(newProps);
|
|
||||||
}, [targetPicker]);
|
|
||||||
return (
|
return (
|
||||||
<Space.Compact style={{ width: '100%' }}>
|
<Space.Compact style={{ width: '100%' }}>
|
||||||
<Select
|
<Select
|
||||||
@ -322,6 +317,7 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
|
|||||||
},
|
},
|
||||||
])}
|
])}
|
||||||
onChange={(value) => {
|
onChange={(value) => {
|
||||||
|
setTargetPicker(value);
|
||||||
const format = getPickerFormat(value);
|
const format = getPickerFormat(value);
|
||||||
const dateTimeFormat = getDateTimeFormat(value, format, showTime, timeFormat);
|
const dateTimeFormat = getDateTimeFormat(value, format, showTime, timeFormat);
|
||||||
field.setComponentProps({
|
field.setComponentProps({
|
||||||
|
@ -97,6 +97,9 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => {
|
|||||||
.ant-input-affix-wrapper {
|
.ant-input-affix-wrapper {
|
||||||
border-radius: 0px;
|
border-radius: 0px;
|
||||||
}
|
}
|
||||||
|
.ant-checkbox-wrapper {
|
||||||
|
margin-left: 50%;
|
||||||
|
}
|
||||||
`}
|
`}
|
||||||
>
|
>
|
||||||
{React.createElement(DynamicComponent, {
|
{React.createElement(DynamicComponent, {
|
||||||
|
@ -69,12 +69,13 @@ export const toLocal = (value: dayjs.Dayjs) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const convertQuarterToFirstDay = (quarterStr) => {
|
const convertQuarterToFirstDay = (quarterStr) => {
|
||||||
if (dayjs(quarterStr).isValid()) {
|
try {
|
||||||
const year = parseInt(quarterStr.slice(0, 4)); // 提取年份
|
const year = parseInt(quarterStr.slice(0, 4)); // 提取年份
|
||||||
const quarter = parseInt(quarterStr.slice(-1)); // 提取季度数字
|
const quarter = parseInt(quarterStr.slice(-1)); // 提取季度数字
|
||||||
return dayjs().quarter(quarter).year(year);
|
return dayjs().quarter(quarter).year(year);
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const toMoment = (val: any, options?: Str2momentOptions) => {
|
const toMoment = (val: any, options?: Str2momentOptions) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user