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

fix: 日期选择器优化

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