fix: 设置移动端时间组件默认值生效 (#1388)

Co-authored-by: sealday <zhanglin@daoyoucloud.com>
Reviewed-on: daoyoucloud/tachybase#1388
Reviewed-by: sealday <zhanglin@daoyoucloud.com>
Co-authored-by: wjh <wwwjh0710@163.com>
Co-committed-by: wjh <wwwjh0710@163.com>
This commit is contained in:
wjh 2024-07-25 17:41:18 +08:00 committed by sealday
parent d16fd867c5
commit 69dcf1add2

View File

@ -7,7 +7,10 @@ import { Button, DatePicker, Input, Space } from 'antd-mobile';
export const MDatePicker = connect(
(props) => {
const [visible, setVisible] = useState(false);
const nowDate = props.value || new Date();
const nowDate = props?.value || new Date();
if (!props?.value) {
props.onChange(nowDate);
}
return (
<>
<Button
@ -23,6 +26,7 @@ export const MDatePicker = connect(
onClose={() => {
setVisible(false);
}}
value={nowDate}
onConfirm={(value) => {
props.onChange(value);
setVisible(false);