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:
Katherine 2025-04-18 17:29:52 +08:00 committed by GitHub
parent deb85d30bd
commit aa6a46924a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 10 additions and 10 deletions

View File

@ -268,8 +268,9 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
const value = Array.isArray(props.value) ? props.value[0] : props.value;
const compile = useCompile();
const fieldSchema = useFieldSchema();
const targetPicker = value ? inferPickerType(value, picker) : picker;
const targetDateFormat = getPickerFormat(targetPicker) || format;
const initPicker = value ? inferPickerType(value, picker) : picker;
const [targetPicker, setTargetPicker] = useState(initPicker);
const targetDateFormat = getPickerFormat(initPicker) || format;
const newProps = {
utc,
inputReadOnly: isMobileMedia,
@ -287,12 +288,6 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
};
const field: any = useField();
const [stateProps, setStateProps] = useState(newProps);
useEffect(() => {
newProps.picker = targetPicker;
const dateTimeFormat = getDateTimeFormat(targetPicker, targetDateFormat, showTime, timeFormat);
newProps.format = dateTimeFormat;
setStateProps(newProps);
}, [targetPicker]);
return (
<Space.Compact style={{ width: '100%' }}>
<Select
@ -322,6 +317,7 @@ DatePicker.FilterWithPicker = function FilterWithPicker(props: any) {
},
])}
onChange={(value) => {
setTargetPicker(value);
const format = getPickerFormat(value);
const dateTimeFormat = getDateTimeFormat(value, format, showTime, timeFormat);
field.setComponentProps({

View File

@ -97,6 +97,9 @@ export const ValueDynamicComponent = (props: ValueDynamicComponentProps) => {
.ant-input-affix-wrapper {
border-radius: 0px;
}
.ant-checkbox-wrapper {
margin-left: 50%;
}
`}
>
{React.createElement(DynamicComponent, {

View File

@ -69,12 +69,13 @@ export const toLocal = (value: dayjs.Dayjs) => {
};
const convertQuarterToFirstDay = (quarterStr) => {
if (dayjs(quarterStr).isValid()) {
try {
const year = parseInt(quarterStr.slice(0, 4)); // 提取年份
const quarter = parseInt(quarterStr.slice(-1)); // 提取季度数字
return dayjs().quarter(quarter).year(year);
} catch (error) {
return null;
}
return null;
};
const toMoment = (val: any, options?: Str2momentOptions) => {