Commit 29523d40 authored by 田翔's avatar 田翔

fix: 日期选择器优化

parent d13f0dc4
{
"name": "panda-xform",
"version": "6.0.23",
"description": "6.0.23 文件上传全部不做限制",
"version": "6.0.24",
"description": "6.0.24 日期选择器优化",
"keywords": [
"panda-xform"
],
......
......@@ -620,7 +620,7 @@ const Account = (props, ref) => {
{detailShow ? (
<div className={styles.tableDetail}>
<div className={styles.formBox}>
<FormRender ref={formRenderRef} schemaValues={schemaValues} />
<FormRender ref={formRenderRef} schemaValues={schemaValues} disabled={operation.type === '详情'} />
</div>
<div className={styles.formBtns}>
<Button onClick={back}>返回</Button>
......
// 自定义时间组件
import React, { useEffect, useMemo, useState } from 'react'
import { DatePicker, Select } from 'antd'
import moment, { months } from 'moment'
import moment from 'moment'
import locale from 'antd/lib/date-picker/locale/zh_CN'
const DateTime = (props) => {
const { value, onChange, schema, addons } = props
const { disabled, format, presetValue, placeholder, options, currentDate, defaultCurrent } = schema
const {
disabled,
format,
presetValue,
placeholder,
options,
currentDate,
defaultCurrent,
formDisabled,
} = schema
const period = useMemo(() => {
let hour = moment().hour()
......@@ -19,12 +28,21 @@ const DateTime = (props) => {
useEffect(() => {
if (addons) {
let value = presetValue || (options === '默认为当前时间' ? moment(new Date()).format('YYYY-MM-DD HH:mm:ss') : '')
let value = presetValue
if (!formDisabled && options === '默认为当前时间') {
if (disabled) {
if (!presetValue) {
value = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
}
} else {
value = moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
}
}
addons.setValue(addons.dataPath, value)
} else {
onChange(presetValue)
}
}, [presetValue, options])
}, [presetValue, options, formDisabled, disabled])
const disabledDate = (current) => {
if (options === '不超过当前时间') {
......
......@@ -67,6 +67,7 @@ const SearchLocation = (props) => {
options={(options || []).map(v => ({ label: v.name, value: v.name }))}
onSelect={onSelect}
onSearch={handleSearch}
disabled={disabled}
>
<Input.Search
value={value}
......
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