diff --git a/src/App.js b/src/App.js
index 3f5f77f..43d4b10 100644
--- a/src/App.js
+++ b/src/App.js
@@ -4,12 +4,13 @@ import Map from './pages/Map';
import Index from './pages/Index'
import './pages/Bottom/index.css'
import CityList from './pages/CityList';
-import { PersonalCenter} from './pages/Bottom'
+import {PersonalCenter} from './pages/Bottom'
import ToDoList from "./pages/ToDoList";
import DetailForm from "./components/DetailForm";
import {NavBar} from "antd-mobile";
import DetailNavBar from "./components/DetailNavBar";
import DetailSearchContext from "./pages/DetailSearchContext";
+import ToDoCal from "./pages/ToDoCal";
function App() {
return (
@@ -20,12 +21,14 @@ function App() {
*/}
{/*
*/}
- {/* }>
- */}
- }>
- }/>
- }>
- }>
+ }>
+
+
+ }>
+ }/>
+ }>
+ }/>
+ }>
}>
}>
diff --git a/src/components/DetailSearchBar/index.js b/src/components/DetailSearchBar/index.js
index 14982e0..9f0ba80 100644
--- a/src/components/DetailSearchBar/index.js
+++ b/src/components/DetailSearchBar/index.js
@@ -10,14 +10,17 @@ const DetailSearchBar = (props) => {
// const location = useLocation();
// const searchUpdate = location.state?.search;
// 父子传值从搜索框传来的search
- const {search,updateSearch} = props;
- console.log("DetailSearchBar.search", search)
+ const {search,updateSearch,pName} = props;
+ console.log("DetailSearchBar.search", search.data)
const [tags, setTags] = useState([]);
useEffect(() => {
if (search && search.data) {
Promise.all(
search.data.map(async (searchObj) => {
- if (searchObj.name === "state") {
+ console.log("DetailSearchContext.search", searchObj)
+ if (searchObj.name === "pid") {
+ return {pName}
+ }else if (searchObj.name === "state") {
const dictionary = await getDictionary("2");
const items = searchObj.value.split(',');
const itemPromises = items.map((item) => {
@@ -25,6 +28,16 @@ const DetailSearchBar = (props) => {
return dict ? {dict.itemName} : null;
});
return Promise.all(itemPromises);
+ }else if (searchObj.name === "priority"){
+ const dictionary = await getDictionary("1");
+ const items = searchObj.value.split(',');
+ const itemPromises = items.map((item) => {
+ const dict = dictionary.get(item);
+ return dict ? {dict.itemName} : null;
+ });
+ return Promise.all(itemPromises);
+ }else if (searchObj.name === "todoDay"){
+ return {searchObj.value};
}
})
).then((results) => {
diff --git a/src/pages/Bottom/index.js b/src/pages/Bottom/index.js
index 714e4c4..547c400 100644
--- a/src/pages/Bottom/index.js
+++ b/src/pages/Bottom/index.js
@@ -9,23 +9,22 @@ import {
AddOutline,
} from 'antd-mobile-icons'
import "./index.css"
-import DetailForm from "../../components/DetailForm";
const tabs = [
{
- key: '/home',
+ key: '/home/treeTask',
title: '树状任务',
icon: ,
badge: '1',
},
{
- key: '/home/todo',
+ key: '/home/listTask',
title: '列表任务',
icon: ,
badge: '2',
},
{
- key: '/home/message',
+ key: '/home/calTask',
title: '日历任务',
icon: ,
badge: '3',
diff --git a/src/pages/DetailSearchContext/index.js b/src/pages/DetailSearchContext/index.js
index 846aa6d..db93a71 100644
--- a/src/pages/DetailSearchContext/index.js
+++ b/src/pages/DetailSearchContext/index.js
@@ -1,30 +1,78 @@
import {Button, Checkbox, DatePicker, Form, Input, Space, Switch, Tag} from "antd-mobile";
import ParentTask from "../../components/ParentTask";
-import React from "react";
+import React, {useEffect} from "react";
import dayjs from "dayjs";
import {CloseCircleFill} from "antd-mobile-icons";
import {useLocation, useNavigate, useOutletContext} from "react-router-dom";
-const now = new Date()
+import {getDictionary} from "../../utils/dictUtil";
+import {getTaskById} from "../../utils";
+
const DetailSearchContext = () => {
- // 使用Outlet,传值修改标题
- const {setTitle} = useOutletContext();
- setTitle("搜索查询")
const navigate = useNavigate();
const [form] = Form.useForm();
const [visible, setVisible] = React.useState(false);
const location = useLocation();
- console.log("DetailSearchContext",location);
- const {search,updateSearch} = location.state;
- console.log("DetailSearchContext.search",search)
+ console.log("DetailSearchContext", location);
+ const {search} = location?.state || undefined;
+ console.log("DetailSearchContext.search", search)
+ const [stateList, setStateList] = React.useState([]);
+ const [priorityList, setPriorityList] = React.useState([]);
+ // 使用Outlet,传值修改标题
+ const {setTitle} = useOutletContext();
+ useEffect(() => {
+ // 使用Outlet,传值修改标题
+ setTitle("搜索查询")
+ initDate()
+ }, [])
+
+ async function initDate() {
+ let stateDictionary = await getDictionary("2");
+ let priorityDictionary = await getDictionary("1");
+ setStateList(Array.from(stateDictionary.values()));
+ setPriorityList(Array.from(priorityDictionary.values()));
+ if (!search) {
+ return
+ }
+ let searchMap = new Map(search.data.map(searchObj => [searchObj.name, searchObj]));
+ if (searchMap.has("pid")) {
+ let task = await getTaskById(searchMap.get("pid"));
+ // form.setFieldValue(task.name);
+ }
+ if (searchMap.has("state")) {
+ form.setFieldValue("state", searchMap.get("state").value.split(','))
+ }
+ if (searchMap.has("priority")) {
+ form.setFieldValue("priority", searchMap.get("priority").value.split(','))
+ }
+ if (searchMap.has("todoDay")) {
+ form.setFieldValue("todoDay", searchMap.get("todoDay").value)
+ }
+ }
+
return (
)
}
export default DetailSearchContext;
\ No newline at end of file
diff --git a/src/pages/Home/index.js b/src/pages/Home/index.js
index a061cc3..72dc9e9 100644
--- a/src/pages/Home/index.js
+++ b/src/pages/Home/index.js
@@ -1,35 +1,39 @@
import React from 'react'
import Bottom from './../Bottom/index'
import './index.css'
-import {Outlet} from 'react-router-dom'
+import {Outlet, useLocation} from 'react-router-dom'
import DetailSearchBar from "../../components/DetailSearchBar";
-export default class Home extends React.Component {
- constructor(props) {
- super(props);
- this.state = {
- search:{
- "pageSize":10,
- "pageNumber":1,
- "data":[
- {"name":"state","value":"8,9","operateType":"IN"},
- {"name":"expectedStartTime","value":"2024-12-29T16:00:00.000Z","operateType":">="},
- {"name":"expectedStartTime","value":"2024-12-29T16:00:00.000Z","operateType":"<="}]}
- };
- }
- updateSearch = (values) => {
- this.setState({search:values});
+const Home = () => {
+
+ const location = useLocation();
+ console.log("Home", location);
+ const searchUrl = location?.state?.search;
+ const [pName, setName] = React.useState("");
+ const [search, setSearch] = React.useState({
+ "pageSize": 12,
+ "pageNumber": 1,
+ "data": searchUrl ? JSON.parse(searchUrl) : [
+ {"name": "state", "value": "8,9", "operateType": "IN"},
+ {"name": "expectedStartTime", "value": "2024-12-29T16:00:00.000Z", "operateType": ">="},
+ {"name": "expectedStartTime", "value": "2024-12-29T16:00:00.000Z", "operateType": "<="}
+ ]
+ })
+ const updateSearch = (values) => {
+ this.setState({search: values});
};
- render() {
- return (
-
-
-
-
-
-
+ return (
+
+ )
}
+
+export default Home;
\ No newline at end of file
diff --git a/src/pages/ToDoCal/index.jsx b/src/pages/ToDoCal/index.jsx
new file mode 100644
index 0000000..05777ac
--- /dev/null
+++ b/src/pages/ToDoCal/index.jsx
@@ -0,0 +1,23 @@
+import {Calendar} from "antd-mobile";
+import dayjs from "dayjs";
+
+const ToDoCal = (props) => {
+ const defaultSingle = new Date()
+ const today = dayjs()
+ return (
+
{
+ if (dayjs(date).isSame(today, 'day')) return '今天'
+ if (date.getDay() === 0 || date.getDay() === 6) {
+ return '周末'
+ }
+ }}
+ defaultValue={defaultSingle}
+ onChange={val => {
+ console.log(val)
+ }}
+ />
+ )
+}
+export default ToDoCal;
\ No newline at end of file
diff --git a/src/pages/WidthUseNavigate/index.js b/src/pages/WidthUseNavigate/index.js
index 7ed8553..582c1c9 100644
--- a/src/pages/WidthUseNavigate/index.js
+++ b/src/pages/WidthUseNavigate/index.js
@@ -1,4 +1,4 @@
-import { useNavigate } from 'react-router-dom'
+import {useLocation, useNavigate} from 'react-router-dom'
// 高阶组件包装useNavigate()功能
// 原因:类组件中无法使用useNavigate(),会报错
// React Hook "useNavigate" cannot be called in a class component.
@@ -7,8 +7,9 @@ function WidthUseNavigate(WrapComponent) {
WrapComponent.displayName = `widthUseNavigate${getDisplayName(WrapComponent)}`
return function NavigateComponent() {
const navigate = useNavigate()
+ const location = useLocation()
// 给传入的组件新增一个to方法,传给原始组件的props,在原始组件中通过this.props.to(参数)使用
- return
+ return
}
}
diff --git a/src/utils/dictUtil.js b/src/utils/dictUtil.js
index 5a3b6b1..dd84cd2 100644
--- a/src/utils/dictUtil.js
+++ b/src/utils/dictUtil.js
@@ -1,17 +1,20 @@
import {requestUtil} from "./requestUtil";
const dict = new Map();
-export const getDictionary= async (typeId) => {
+export const getDictionary = async (typeId) => {
if (dict.has(typeId)) {
return dict.get(typeId);
}
- let search = encodeURI(`{"data":[{"code":"type_id","value":"${typeId}","operateType":"="}]}`)
+ let search = encodeURI(`{"data":[
+ {"code":"type_id","value":"${typeId}","operateType":"="},
+ {"code":"enable_flag","value":"1","operateType":"="}
+ ]}`)
let todo = await requestUtil.get(`/todo-server/search/dict_items?search=${search}`);
- let context = todo.content;
- let result;
- if (context.length>0){
- result = new Map(context.map(item => [item.itemCode, item]))
- dict.set(typeId,result);
- }
+ let context = todo.content;
+ let result;
+ if (context.length > 0) {
+ result = new Map(context.map(item => [item.itemCode, item]))
+ dict.set(typeId, result);
+ }
return result;
}
\ No newline at end of file
diff --git a/src/utils/index.js b/src/utils/index.js
index 4345d6b..a3294b0 100644
--- a/src/utils/index.js
+++ b/src/utils/index.js
@@ -32,6 +32,11 @@ export const getTaskList= (pageNumber) => {
export const getTaskByPid = (pid) => {
return requestUtil.get('/todo-server/search/task_message_tree?search=%7B%22pageSize%22%3A1000%2C%22pageNumber%22%3A1%2C%22data%22%3A%5B%7B%22name%22%3A%22pid%22%2C%22value%22%3A%22'+pid+'%22%2C%22operateType%22%3A%22%3D%22%7D%5D%7D');
}
+
+export const getTaskById= (id) => {
+ let request = encodeURI(`{"data":[{"name":"id","value":"${id}","operateType":"="}]}`)
+ return requestUtil.get('/todo-server/search/task_message_tree?search='+request);
+}
export const addTask = async (entity) => {
// 使用 Axios 发送 POST 请求添加数据
return await requestUtil.post('/todo-server' + '/task', entity);