Commit dbb01e7d authored by 田翔's avatar 田翔

fix: 默认当前时间bug

parent de945359
{ {
"name": "panda-xform", "name": "panda-xform",
"version": "2.8.3", "version": "2.8.4",
"description": "2.8.3: 关联表单映射字段查询添加的字段", "description": "2.8.4: 默认当前时间bug",
"keywords": [ "keywords": [
"panda-xform" "panda-xform"
], ],
......
...@@ -22,10 +22,12 @@ const Time = (props) => { ...@@ -22,10 +22,12 @@ const Time = (props) => {
useEffect(() => { useEffect(() => {
if (addons) { if (addons) {
let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('HH:mm:ss') : null) let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : null)
console.log('value', options, value)
addons.setValue(addons.dataPath, value) addons.setValue(addons.dataPath, value)
} else { } else {
onChange(presetValue) let value = presetValue || (options === '默认为当前时间' ? moment().format('YYYY-MM-DD HH:mm:ss') : null)
onChange(value)
} }
}, [presetValue, options]) }, [presetValue, options])
......
import React, { useState, useEffect, useMemo } from 'react' import React, { useState, useEffect, useMemo } from 'react'
import { TimePicker } from 'antd' import { TimePicker } from 'antd'
import locale from 'antd/lib/date-picker/locale/zh_CN' import locale from 'antd/lib/date-picker/locale/zh_CN'
import moment from 'moment'
const TimeDefault = (props) => { const TimeDefault = (props) => {
const { onChange } = props const { value, onChange } = props
const { format } = props.addons.formData const { format } = props.addons.formData
const dateChange = (date, dateStr) => { const dateChange = (time, dateStr) => {
onChange(dateStr) onChange(moment(time).format('YYYY-MM-DD HH:mm:ss'))
} }
return ( return (
<TimePicker <TimePicker
value={value ? moment(value) : null}
picker={format} picker={format}
onChange={dateChange} onChange={dateChange}
showTime={format === 'dateTime'} showTime={format === 'dateTime'}
......
...@@ -71,8 +71,8 @@ const MappedField = (props) => { ...@@ -71,8 +71,8 @@ const MappedField = (props) => {
key={key} key={key}
style={{ style={{
display: 'flex', display: 'flex',
marginBottom: '5px ', marginBottom: '5px',
justifyContent: 'center' justifyContent: 'center',
}} }}
align="baseline" align="baseline"
> >
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment