import React, { useState, useEffect, useRef } from "react"; import { connect } from "react-redux"; import { DatePicker, Toast, ToastFactory, Space } from '@douyinfe/semi-ui'; import './videoPlay.less'; import moment from "moment"; const timeFormat = 'YYYY-MM-DD HH:mm:ss' const VideoOperationHistroyTime = ({ close, histroyTime, setHistroyTime, setProcessDisX }) => { const [selectedTimeRange, setSelectedTimeRange] = useState(histroyTime) useEffect(() => { if (!selectedTimeRange.length) { setSelectedTimeRange([moment().subtract(72, 'hours').format(timeFormat), moment().format(timeFormat)]) } }, []) const ToastInCustomContainer = ToastFactory.create({ getPopupContainer: () => document.getElementById('vcmp_videoplay'), }); return (
{ setSelectedTimeRange(timeRange) }} style={{ width: '100%' }} // disabledDate={(date, options) => { // const { rangeStart, rangeEnd } = options; // // console.log(date, options); // if (!rangeStart && !rangeEnd) { // return false // } // if (rangeStart) { // return Math.abs(moment(date).diff(moment(rangeStart), 'days')) > 3 // } // if (rangeEnd) { // return Math.abs(moment(date).diff(moment(rangeEnd), 'days')) > 3 // } // }} // disabledTime={(date, type) => { // console.log(date, type); // }} />
最长时间跨度不超过72小时
{ close() }} style={{ cursor: 'pointer', height: 32, width: 56, lineHeight: '32px', borderRadius: 2, textAlign: 'center', background: '#fff', color: 'rgba(0, 0, 0, 0.65)' }} >取消
{ if (selectedTimeRange.length == 2 && selectedTimeRange.every(t => t)) { if (Math.abs(moment(selectedTimeRange[0]).diff(moment(selectedTimeRange[1]), 'hours')) > 72) { ToastInCustomContainer.destroyAll() return ToastInCustomContainer.error('所选时间超过 72 小时') } setHistroyTime(selectedTimeRange) setProcessDisX(0) close() } }} style={{ cursor: 'pointer', height: 32, width: 56, lineHeight: '32px', borderRadius: 2, textAlign: 'center', background: '#1859C1', color: '#fff' }} >播放
) } function mapStateToProps (state) { const { auth } = state; return { user: auth.user, }; } export default connect(mapStateToProps)(VideoOperationHistroyTime);