Skip to content

Commit

Permalink
chore: 调整AntdDateRangePicker参数pickerValue格式及底层逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
CNFeffery committed Sep 13, 2024
1 parent e16cb65 commit 2d4a099
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion feffery_antd_components/AntdDateRangePicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class AntdDateRangePicker(Component):
- defaultValue (list of strings; optional):
初始化已选值,与`format`格式对应.
- pickerValue (list of strings; optional):
- pickerValue (string; optional):
监听或设置面板展开对应日期,与`format`格式对应.
- disabledDatesStrategy (list of dicts; optional):
Expand Down
2 changes: 1 addition & 1 deletion src/lib/components/dataEntry/AntdDateRangePicker.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ AntdDateRangePicker.propTypes = {
/**
* 监听或设置面板展开对应日期,与`format`格式对应
*/
pickerValue: PropTypes.arrayOf(PropTypes.string),
pickerValue: PropTypes.string,

/**
* 配置日期禁用项策略数组,满足策略中至少一项规则的日期将会被禁止选中
Expand Down
9 changes: 3 additions & 6 deletions src/lib/fragments/dataEntry/AntdDateRangePicker.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,7 @@ const AntdDateRangePicker = (props) => {
// 处理pickerValue缺省赋值
if (!pickerValue) {
setProps({
pickerValue: [
dayjs(new Date()).format(format || (showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD')),
dayjs(new Date()).format(format || (showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'))
]
pickerValue: dayjs(new Date()).format(format || (showTime ? 'YYYY-MM-DD HH:mm:ss' : 'YYYY-MM-DD'))
})
}
}, [])
Expand Down Expand Up @@ -498,7 +495,7 @@ const AntdDateRangePicker = (props) => {
onChange={onChange}
onPanelChange={(v, m) => {
setProps({
pickerValue: [(v[0] || v[1]).format(format), (v[0] || v[1]).format(format)]
pickerValue: (v[0] || v[1]).format(format)
})
}}
variant={(
Expand All @@ -507,7 +504,7 @@ const AntdDateRangePicker = (props) => {
variant
)}
disabledDate={disabledDatesStrategy ? checkDisabledDate : undefined}
pickerValue={pickerValue && [dayjs(pickerValue[0], format), dayjs(pickerValue[0], format)]}
pickerValue={pickerValue && [dayjs(pickerValue, format), dayjs(pickerValue, format)]}
value={
formId && (name || id) ?
(
Expand Down

0 comments on commit 2d4a099

Please sign in to comment.