Compare commits

...

3 Commits

Author SHA1 Message Date
nopy 385044da04 Merge branch 'master' of https://gitea.xn--7p0a.site/2312072104/dm 2024-07-01 21:51:58 +08:00
nopy 217197318a 1 2024-07-01 21:51:55 +08:00
nopy 1beb4fdb86 7.1 2024-07-01 21:48:29 +08:00
5 changed files with 35 additions and 42 deletions

View File

@ -202,9 +202,8 @@
.calendar-box span{ .calendar-box span{
position: absolute; position: absolute;
/* top: 20px; */ top: 400px;
top: 380px; right: 185px;
right: 160px;
} }
.calendar1{ .calendar1{
width: 100px; width: 100px;

View File

@ -3,7 +3,8 @@ import { Link } from 'react-router-dom';
import './SendTrain.css' import './SendTrain.css'
import axios from 'axios'; import axios from 'axios';
import DatePicker from 'react-datepicker'; import DatePicker from 'react-datepicker';
import 'react-datepicker/dist/react-datepicker.css'; import "react-datepicker/dist/react-datepicker.css";
function SendTrain(){ function SendTrain(){
const teacher_ID=localStorage.getItem('islogin') const teacher_ID=localStorage.getItem('islogin')
@ -134,31 +135,18 @@ function SendTrain(){
// //
const [StopTime,SetStopTime]=useState('') const [StopTime,SetStopTime]=useState('')
// //
const [startDate, setStartDate] = useState(new Date()); const [startDate, setStartDate] = useState(new Date());
const [endDate, setEndDate] = useState(new Date()); const [endDate, setEndDate] = useState(new Date());
// //
const formatDate = (date) => {
return date.toLocaleDateString();
};
//
const handleStartDateChange = (date) => { const handleStartDateChange = (date) => {
setStartDate(date); setStartDate(date);
}; };
//
const handleEndDateChange = (date) => { const handleEndDateChange = (date) => {
setEndDate(date); setEndDate(date);
}; };
//
const calculateTotalDays = () => {
const differenceInTime = endDate - startDate;
const differenceInDays = Math.floor(differenceInTime / (1000 * 60 * 60 * 24)+1);
return differenceInDays;
};
// const [starTime,setstartTime]=useState()
useEffect(() => {
SetStopTime(calculateTotalDays())
console.log(calculateTotalDays());
}, [startDate, endDate]);
return( return(
<div className='SendTrain_body'> <div className='SendTrain_body'>
@ -344,27 +332,32 @@ function SendTrain(){
{/* 日历 */} {/* 日历 */}
<p>请填写考试开始截止日期</p> <p>请填写考试开始截止日期</p>
<div className='calendar-box'> <div className='calendar-box'>
<DatePicker {/* 开始时间输入框 */}
selected={startDate} <div className='start-date-input'>
onChange={handleStartDateChange} {/* 日历组件 */}
dateFormat="yyyy/MM/dd" <div className='calendar-picker'>
placeholderText="选择开始日期" <DatePicker
popperPlacement="left-start" selected={startDate}
className='calendar1' onChange={handleStartDateChange}
/> dateFormat="yyyy-MM-dd HH:mm"
<span>-</span> showTimeSelect
<DatePicker timeIntervals={10} //
selected={endDate} timeCaption="time"
onChange={handleEndDateChange} minDate={new Date()} //
dateFormat="yyyy/MM/dd" />
placeholderText="选择结束日期" <DatePicker
minDate={startDate} // selected={endDate}
withFullScreenPortal={false} // onChange={handleEndDateChange}
popperPlacement="left-start" dateFormat="yyyy-MM-dd HH:mm"
className='calendar2' showTimeSelect
/> timeIntervals={10}
timeCaption="time"
minDate={startDate || new Date()} //
/>
</div>
</div>
</div> </div>
<p className='data-num'>总天数{calculateTotalDays()}</p>
</div> </div>
</div> </div>
</div> </div>

1
app-dm/src/router/index.jsx Normal file → Executable file
View File

@ -69,6 +69,7 @@ function App() {
<Route path="/classID/:key" element={<MainLayout headerNav={HeaderNavTeacher} />}> <Route path="/classID/:key" element={<MainLayout headerNav={HeaderNavTeacher} />}>
<Route index element={<ClassID/>} /> <Route index element={<ClassID/>} />
</Route> </Route>
<Route path="test" element={<Test />}/>
{/* 页面使用单独的布局不包含HeaderNav和HeaderNavTeacher */} {/* 页面使用单独的布局不包含HeaderNav和HeaderNavTeacher */}
<Route path="exam/:examId" element={<Exam />} />{/* 练习-考试页面 */} <Route path="exam/:examId" element={<Exam />} />{/* 练习-考试页面 */}