diff --git a/src/components/DetailSearchBar/index.js b/src/components/DetailSearchBar/index.js index 28c1bfd..23a18e8 100644 --- a/src/components/DetailSearchBar/index.js +++ b/src/components/DetailSearchBar/index.js @@ -28,9 +28,9 @@ const DetailSearchBar = (props) => { console.log("search.data.orSearchModel", search.data.orSearchModel) search.data.orSearchModel?.andList?.forEach((searchObj) => { if (searchObj.name === "pid") { - getTaskById(searchObj.value).then(result=>{ + getTaskById(searchObj.value).then(result => { setTags([{result.content[0].name} - ,...tagList]) + , ...tagList]) }) } else if (searchObj.name === "state") { const items = searchObj.value.split(','); @@ -94,16 +94,32 @@ const DetailSearchBar = (props) => { {tags} {showCloseOutline &&
{ - dispatch({ - type: UPDATE_SEARCH, search: { - "pageSize": 12, - "pageNumber": 1, - "data": { - "andList": [], - "orList": [] + // 查看排序 + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting && JSON.parse(setting).columnSort) { + dispatch({ + type: UPDATE_SEARCH, search: { + "pageSize": 12, + "pageNumber": 1, + "sortList":[{"property":"expectedStartTime","direction":"ASC"}], + "data": { + "andList": [], + "orList": [] + } } - } - }); + }); + }else { + dispatch({ + type: UPDATE_SEARCH, search: { + "pageSize": 12, + "pageNumber": 1, + "data": { + "andList": [], + "orList": [] + } + } + }); + } setTags([]); }}> diff --git a/src/components/MyRootContext/index.js b/src/components/MyRootContext/index.js index 8f99ad0..4f0f7bc 100644 --- a/src/components/MyRootContext/index.js +++ b/src/components/MyRootContext/index.js @@ -17,6 +17,7 @@ function getInitialState(){ const initialState = {"search":{ "pageSize": 20, "pageNumber": 1, + "sortList":[{"property":"expectedStartTime","direction":"ASC"}], "data": { "orSearchModel": { "andList": [ diff --git a/src/pages/DetailSearchContext/index.js b/src/pages/DetailSearchContext/index.js index 84ce951..247e219 100644 --- a/src/pages/DetailSearchContext/index.js +++ b/src/pages/DetailSearchContext/index.js @@ -13,7 +13,7 @@ const DetailSearchContext = () => { const navigate = useNavigate(); const [form] = Form.useForm(); const [visible, setVisible] = React.useState(false); - const { state, dispatch } = useContext(MyRootContext); + const {state, dispatch} = useContext(MyRootContext); const search = state.search const [stateList, setStateList] = React.useState([]); const [priorityList, setPriorityList] = React.useState([]); @@ -34,7 +34,7 @@ const DetailSearchContext = () => { console.log({res, parentMessageVOList}); setPName(parentMessageVOList[parentMessageVOList.length - 1].name); setPidArray(parentMessageVOList.map(parent => parent.id)) - form.setFieldValue("pidArray",parentMessageVOList.map(parent => parent.id)) + form.setFieldValue("pidArray", parentMessageVOList.map(parent => parent.id)) }) } @@ -145,14 +145,31 @@ const DetailSearchContext = () => { if (allOverdueTasks) { andList.push({"name": "state", "value": "10", "operateType": "="}) } - dispatch({type:UPDATE_SEARCH,search:{ - "pageSize": 12, - "pageNumber": 1, - "data": { - andList, - orSearchModel + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting && JSON.parse(setting).columnSort) { + dispatch({ + type: UPDATE_SEARCH, search: { + "pageSize": 12, + "pageNumber": 1, + "sortList": [{"property": "expectedStartTime", "direction": "ASC"}], + "data": { + andList, + orSearchModel + } } - }}) + }) + } else { + dispatch({ + type: UPDATE_SEARCH, search: { + "pageSize": 12, + "pageNumber": 1, + "data": { + andList, + orSearchModel + } + } + }) + } navigate("/home/listTask") }} footer={ @@ -161,7 +178,7 @@ const DetailSearchContext = () => { } > - + { { setVisible(false) }} - onConfirm={(val)=>setFieldsValue({todoDay:val})} + onConfirm={(val) => setFieldsValue({todoDay: val})} /> { getFieldValue('todoDay') ? dayjs(getFieldValue('todoDay')).format('YYYY-MM-DD') : '请选择日期' diff --git a/src/pages/PersonalCenter/columnSortConstant.js b/src/pages/PersonalCenter/columnSortConstant.js index e592c63..5c6b219 100644 --- a/src/pages/PersonalCenter/columnSortConstant.js +++ b/src/pages/PersonalCenter/columnSortConstant.js @@ -7,7 +7,7 @@ export const columnSortConstant = [ { label: '任务优先级', value: 'priority' }, ], [ - { label: '升序', value: 'am' }, - { label: '降序', value: 'pm' }, + { label: '升序', value: 'ASC' }, + { label: '降序', value: 'DESC' }, ], ] \ No newline at end of file diff --git a/src/pages/PersonalCenter/index.js b/src/pages/PersonalCenter/index.js index 4fa7872..3e4610b 100644 --- a/src/pages/PersonalCenter/index.js +++ b/src/pages/PersonalCenter/index.js @@ -1,59 +1,99 @@ -import React, {useState} from "react"; +import React, {Fragment, useContext, useEffect, useState} from "react"; import {Button, Form, List, Picker, Space, Switch} from "antd-mobile"; import Cookies from "js-cookie"; import {columnSortConstant} from "./columnSortConstant"; +import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext"; export function PersonalCenter() { - const [columnSort, setColumnSort] = useState() - return
- - }>新建任务时父任务只展示未完成任务 + const [columnSort, setColumnSort] = useState(['expectedStartTime', 'ASC']) + const [parentCheck, setParentCheck] = useState(true) + const webUrl = 网站:http://www.hauruyu.com; + const {state, dispatch} = useContext(MyRootContext); + useEffect(() => { + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting) { + setColumnSort(JSON.parse(setting).columnSort); + setParentCheck(JSON.parse(setting).parentCheck); + dispatch({ + type: UPDATE_SEARCH, search: { + ...state.search, + sortList: [{ + "property": JSON.parse(setting).columnSort[0], + "direction": JSON.parse(setting).columnSort[1] + }], + } + }); + } else { + localStorage.setItem('huayu-todo-setting', JSON.stringify({ + columnSort: columnSort, + parentCheck: parentCheck, + })); + dispatch({ + type: UPDATE_SEARCH, search: { + ...state.search, + sortList: [{ + "property": columnSort[0], + "direction": columnSort[1] + }], + } + }); + } + + }, []) + return
+ + { + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting) { + let parseObj = JSON.parse(setting); + parseObj.parentCheck = checked + setting = JSON.stringify(parseObj) + setParentCheck(checked); + } else { + setting = JSON.stringify({parentCheck: checked}) + } + localStorage.setItem('huayu-todo-setting', setting); + } + }/>}>新建任务时父任务只展示未完成任务 { - console.log('onSelect', val, extend.items) + onConfirm={(val, extend) => { + console.log({val}) + let setting = localStorage.getItem('huayu-todo-setting'); + if (setting) { + let parseObj = JSON.parse(setting); + parseObj.columnSort = val + setting = JSON.stringify(parseObj) + setColumnSort(val); + } else { + setting = JSON.stringify({columnSort: val}) + } + console.log({setting}) + dispatch({ + type: UPDATE_SEARCH, search: { + ...state.search, + sortList: [{"property": val[0], "direction": val[1]}], + } + }); + localStorage.setItem('huayu-todo-setting', setting); }}> {(items, {open}) => { return ( // - item === null) - ? '未选择' - : items.map(item => item?.label ?? '未选择').join(' - ')}> - 任务排序方式: - + item === null) + ? '未选择' + : items.map(item => item?.label ?? '未选择').join(' - ')}> + 任务排序方式: + // ) }} - - - 授权管理 - - - 这里是主信息 - - {/**/} - {/* 提交*/} - {/* */} - {/* }*/} - {/*>*/} - {/* 网站:http://www.hauruyu.com*/} - {/* */} - {/* */} - {/* */} - {/**/} -