待办任务
diff --git a/src/views/home/today-task/index.tsx b/src/views/home/today-task/index.tsx
index c085d19..aa0efa1 100755
--- a/src/views/home/today-task/index.tsx
+++ b/src/views/home/today-task/index.tsx
@@ -9,7 +9,7 @@ import NoData from '@/components/no-data/index';
import TaskItem from './components/task-item';
import CreateTask from './components/create-task';
import moment from 'moment';
-import { DatePicker, Button, Tag, Row, Col } from 'antd';
+import { DatePicker, Button, Tag, Row, Col, Form } from 'antd';
import { getStartTimestampByDate, getEndTimestampByDate } from '@/utils';
import { serviceGetTask } from '@/services';
@@ -23,7 +23,6 @@ const TASK_TYPE: any = {
};
interface State {
- startDate: moment.Moment;
data: {
wait: any[];
process: any[];
@@ -34,16 +33,22 @@ interface State {
}
const initialState: State = {
- startDate: datePickerValue,
- data: { wait: [], process: [], finished: [], unfinished: [] },
+ data: {
+ wait: [],
+ process: [],
+ finished: [],
+ unfinished: []
+ },
showCreateTaskModal: false
};
const TodayTask = () => {
+ const [form] = Form.useForm();
const [state, setState] = useKeepState(initialState);
function getTask() {
- const date = state.startDate.valueOf();
+ const values = form.getFieldsValue();
+ const date = values.startDate.valueOf();
serviceGetTask({
startDate: getStartTimestampByDate(date),
endDate: getEndTimestampByDate(date)
@@ -56,7 +61,9 @@ const TodayTask = () => {
}
function initParams() {
- setState({ startDate: datePickerValue });
+ form.setFieldsValue({
+ startDate: datePickerValue
+ });
getTask();
}
@@ -70,23 +77,29 @@ const TodayTask = () => {
}
useEffect(() => {
- getTask();
+ initParams();
}, []);
return (
- 查询日期:
- setState({ startDate: date })}
- />
-
-
-
+
+
+
+
+
+
+
+
+
+
+
{(
state.data.wait.length > 0 ||
@@ -113,6 +126,7 @@ const TodayTask = () => {
/>
)}
+
{
+ const [form] = Form.useForm();
const [state, setState] = useKeepState(initialState);
const tableRef = useRef();
const tableColumns = [
@@ -60,9 +59,13 @@ const TodoList = () => {
tableRef.current.getTableData();
}
- const getTodoList = useCallback((params?: any) => {
- params.startDate = state.date[0].valueOf();
- params.endDate = state.date[1].valueOf() + ONE_DAY_TIMESTAMP;
+ function getTodoList(params: any) {
+ const values = form.getFieldsValue();
+
+ if (values.date && values.date.length === 2) {
+ params.startDate = values.date[0].valueOf();
+ params.endDate = values.date[1].valueOf() + ONE_DAY_TIMESTAMP;
+ }
return serviceGetTodoList(params).then(res => {
res.data.data.rows.map((item: any) => {
@@ -71,12 +74,15 @@ const TodoList = () => {
});
return res;
});
- }, [state.date]);
+ }
function initParams() {
const startDate = moment(getThisYearFirstDay(), dateFormat);
const endDate = moment(getCurMonthLastDay(dateFormat), dateFormat);
- setState({ date: [startDate, endDate] });
+ form.setFieldsValue({
+ date: [startDate, endDate]
+ });
+ tableRef?.current?.getTableData();
}
function toggleCreateTodoModal() {
@@ -123,24 +129,25 @@ const TodoList = () => {
initParams();
}, []);
- useEffect(() => {
- if (state.date.length <= 0) return;
- tableRef?.current?.getTableData();
- }, [state.date]);
-
return (
- 查询日期:
- setState({ date })}
- />
-
-
+
+
+
+
+
+
+
+
+
+