提交 36fd0b78 authored 作者: 钟是志's avatar 钟是志

增加时间选择组件

上级 f6d6cded
import React, { useMemo } from 'react';
import moment from 'moment';
import { TimePicker } from 'antd';
export default function TimePickerDiy(props) {
const { value, onChange, json } = props;
const otherProps = useMemo(
() => {
if (json?.otherProps) {
let v = json?.otherProps;
try {
return new Function(v)();
} catch (e) {
return {};
}
}
return {};
},
[json],
);
const changeValue = useMemo(
() => {
if (value) {
return moment(value);
} else {
return null;
}
},
[value],
);
const handleChange = (v) => {
if (v) {
onChange(v.format('HH:mm:ss'));
} else {
onChange(null);
}
};
return <TimePicker value={changeValue} onChange={handleChange} {...otherProps} />;
}
......@@ -24,6 +24,7 @@ import {
Switch,
Table,
Tabs,
TimePicker
} from 'antd';
import UUID from 'react-native-uuid';
import QRCode from 'qrcode.react';
......@@ -97,6 +98,7 @@ import {
getOptionsApi,
} from '../Services/apiConfig';
import UploadComReadOnly from '@/webPublic/one_stop_public/libs/Split/UploadComReadOnly';
import TimePickerDiy from "@/webPublic/one_stop_public/tableCompon/Split_Index/TimePickerDiy";
/**
* 日期组件antd3.x有bug 详情见禅道 27152 毕业跟踪调查管理 毕业时间改为年级筛选
*/
......@@ -1745,18 +1747,6 @@ export default class TableCom extends Component {
)
}
// if([
// // 'Select',
// // 'Input',
// 'InputHidden',
// // 'DatePicker',
// // 'TextArea',
// // 'Radio',
// ].includes(json.comName)){
// return null;
// // Select Input InputHidden DatePicker DatePicker TextArea Radio
// }
if (json.comName === 'Excel') {
const value = getCellValue(i, j, currentFormTitle);
const xx = (
......@@ -1891,6 +1881,17 @@ export default class TableCom extends Component {
</span>
);
break;
case 'TimePicker':
cm = value ? (
<span>
{moment(parseInt(value)).format('HH:mm:ss')}
{get === 'mobile' ? <br /> : ''}
</span>
) : (
''
);
break;
case 'DatePicker':
cm = value ? (
......@@ -2421,6 +2422,21 @@ ${obj[dataColumn.base52]}
}
title = title ? title : '起止时间';
break;
case 'TimePicker':
const vTimePicker = obj[dataColumn.base52];
if (vTimePicker && typeof vTimePicker === 'string' ) {
cm = (
<span>
{vTimePicker}
</span>
);
} else {
cm = (
<span></span>
);
}
break;
case 'DatePicker':
const vTime = obj[dataColumn.base52];
if (vTime && typeof vTime === 'string' && vTime.indexOf('-') <= -1) {
......@@ -3436,7 +3452,6 @@ ${obj[dataColumn.base52]}
);
}
break;
case 'RangePicker':
if (json?.otherProps) {
otherProps = json?.otherProps;
......@@ -3540,18 +3555,36 @@ ${obj[dataColumn.base52]}
}
if (json.label == null) title = '起止时间';
break;
case 'TimePicker':
var iv = null;
if (initValue != null) {
iv = initValue;
}
cm = getFieldDecorator(dataColumn.base52, {
initialValue: iv,
rules:
json.vlds && json.vlds.length > 0
? json.vlds
: [
{
required: required,
message: '请选择时间',
},
],
})(
<TimePickerDiy json={json}/>
);
break;
case 'DatePicker':
if (json?.otherProps) {
otherProps = json?.otherProps;
try {
// mode = multiple 就支持下拉多选了
otherProps = new Function(otherProps)();
} catch (e) {
otherProps = {};
}
}
// cm = null;
// break;
var iv = null;
if (initValue != null) {
iv = moment(typeof initValue === 'string' ? +initValue : initValue);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论