提交 54158e26 authored 作者: 钟是志's avatar 钟是志

RangePickerDiy 修改

上级 97109d8b
...@@ -771,7 +771,6 @@ export default class ZdyTable extends Component { ...@@ -771,7 +771,6 @@ export default class ZdyTable extends Component {
} }
if (this.props.currentFormKey === 'a05771be-44c9-4fd6-b579-f8d7b2133206') { if (this.props.currentFormKey === 'a05771be-44c9-4fd6-b579-f8d7b2133206') {
debugger;
console.log(this); console.log(this);
} }
......
import moment from 'moment'; import moment from 'moment';
import { DatePicker } from 'antd'; import { DatePicker } from 'antd';
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
export function getMomentArr({ export function getMomentArr({
begin, begin,
end, end,
initValue, initValue,
init, init,
obj, obj,
}){ }) {
let ivs = []; let ivs = [];
if (initValue != null && init != null) { if (initValue != null && init != null) {
ivs.push(moment(parseInt(initValue))); ivs.push(moment(parseInt(initValue)));
...@@ -25,11 +26,11 @@ export function getMomentArr({ ...@@ -25,11 +26,11 @@ export function getMomentArr({
} }
} }
if(!ivs || !Array.isArray(ivs) || ivs.length !==2){ if (!ivs || !Array.isArray(ivs) || ivs.length !== 2) {
ivs = [undefined, undefined]; ivs = [];
}else{ } else {
for(let i = 0; i < ivs.length; i++){ for (let i = 0; i < ivs.length; i++) {
if(!moment.isMoment(ivs[i])){ if (!moment.isMoment(ivs[i])) {
ivs[i] = moment(); ivs[i] = moment();
} }
} }
...@@ -37,28 +38,28 @@ export function getMomentArr({ ...@@ -37,28 +38,28 @@ export function getMomentArr({
return ivs; return ivs;
} }
export default function RangePickerDiy(props){ export default function RangePickerDiy(props) {
const { const {
onChange, onChange,
value, value,
json, json,
disabled, disabled,
} = props; } = props;
const [bindValue, setBindValue] = useState([undefined, undefined]); const [bindValue, setBindValue] = useState([]);
useEffect(() => { useEffect(() => {
// console.log('RangePickerDiy组件Value', value); // console.log('RangePickerDiy组件Value', value);
if(!value || !Array.isArray(value) || value.length !==2){ if (!value || !Array.isArray(value) || value.length !== 2) {
setBindValue([undefined, undefined]); setBindValue([]);
}else{ } else {
for(let i = 0; i < value.length; i++){ for (let i = 0; i < value.length; i++) {
if(typeof value[i] === 'number' && value[i] > 10000){ if (typeof value[i] === 'number' && value[i] > 10000) {
bindValue[i] = moment(value[i]); bindValue[i] = moment(value[i]);
}else if(!moment.isMoment(value[i])){ } else if (!moment.isMoment(value[i])) {
bindValue[i] = undefined; // bindValue[i] = undefined;
// console.log('RangePickerDiy组件没有获取到正确的值', value); // console.log('RangePickerDiy组件没有获取到正确的值', value);
}else{ } else {
bindValue[i] = value[i]; bindValue[i] = value[i];
} }
} }
...@@ -76,6 +77,6 @@ export default function RangePickerDiy(props){ ...@@ -76,6 +77,6 @@ export default function RangePickerDiy(props){
return document.body; return document.body;
}} }}
/> />
) );
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论