feat:backup

This commit is contained in:
1708-huayu 2025-01-15 19:35:44 +08:00
parent 9c81ff199c
commit 0a1bf766bc
11 changed files with 294 additions and 211 deletions

View File

@ -4,31 +4,19 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="c22c6a78-950d-4bff-ac7a-ed800fcbb7de" name="Changes" comment="feat:左滑修改">
<list default="true" id="c22c6a78-950d-4bff-ac7a-ed800fcbb7de" name="Changes" comment="feat:backup">
<change afterPath="$PROJECT_DIR$/src/components/MyRootContext/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package-lock.json" beforeDir="false" afterPath="$PROJECT_DIR$/package-lock.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/package.json" beforeDir="false" afterPath="$PROJECT_DIR$/package.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/App.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/App.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/DetailForm/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/DetailForm/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/components/DetailSearchBar/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/components/DetailSearchBar/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Bottom/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/Bottom/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/CityList/index.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/CityList/index.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/CityList/index.module.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/PersonalCenter/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/DetailSearchContext/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/DetailSearchContext/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Home/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/Home/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Index/index.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Index/index.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Map/index.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Map/index.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/Map/index.module.css" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/News/index.js" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/TaskCount/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/TaskCount/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/ToDoList/index.css" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/ToDoList/index.css" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/ToDoList/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/ToDoList/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/pages/ToDoTree/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/pages/ToDoTree/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/router/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/router/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/utils/requestUtil.js" beforeDir="false" afterPath="$PROJECT_DIR$/src/utils/requestUtil.js" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -49,23 +37,23 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "master",
"last_opened_file_path": "D:/electron/assistant-todo-mobile",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"npm.build.executor": "Run",
"npm.start.executor": "Run",
"ts.external.directory.path": "C:\\Program Files\\JetBrains\\WebStorm 2024.1.5\\plugins\\javascript-plugin\\jsLanguageServicesImpl\\external",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;D:/electron/assistant-todo-mobile&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;npm.build.executor&quot;: &quot;Run&quot;,
&quot;npm.start.executor&quot;: &quot;Run&quot;,
&quot;ts.external.directory.path&quot;: &quot;C:\\Program Files\\JetBrains\\WebStorm 2024.1.5\\plugins\\javascript-plugin\\jsLanguageServicesImpl\\external&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="D:\electron\assistant-todo-mobile\src\components\DataPickerItem" />
@ -120,7 +108,9 @@
<workItem from="1735474579369" duration="4701000" />
<workItem from="1735522393453" duration="23975000" />
<workItem from="1736653373329" duration="943000" />
<workItem from="1736729514856" duration="22949000" />
<workItem from="1736729514856" duration="23191000" />
<workItem from="1736823301169" duration="14584000" />
<workItem from="1736902715797" duration="17177000" />
</task>
<task id="LOCAL-00001" summary="feat:backup">
<option name="closed" value="true" />
@ -154,7 +144,23 @@
<option name="project" value="LOCAL" />
<updated>1735478048560</updated>
</task>
<option name="localTasksCounter" value="5" />
<task id="LOCAL-00005" summary="feat:发版">
<option name="closed" value="true" />
<created>1736767997236</created>
<option name="number" value="00005" />
<option name="presentableId" value="LOCAL-00005" />
<option name="project" value="LOCAL" />
<updated>1736767997236</updated>
</task>
<task id="LOCAL-00006" summary="feat:backup">
<option name="closed" value="true" />
<created>1736855240006</created>
<option name="number" value="00006" />
<option name="presentableId" value="LOCAL-00006" />
<option name="project" value="LOCAL" />
<updated>1736855240006</updated>
</task>
<option name="localTasksCounter" value="7" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
@ -172,11 +178,12 @@
</option>
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="feat:backup" />
<MESSAGE value="feat:添加任务" />
<MESSAGE value="feat:上滑更多下拉更新" />
<MESSAGE value="feat:flex,左右对齐" />
<option name="LAST_COMMIT_MESSAGE" value="feat:flex,左右对齐" />
<MESSAGE value="feat:发版" />
<MESSAGE value="feat:backup" />
<option name="LAST_COMMIT_MESSAGE" value="feat:backup" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

View File

@ -1,6 +1,7 @@
{
"name": "assistant-todo-mobile",
"version": "0.1.0",
"homepage": "/mobile",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",

View File

@ -8,18 +8,21 @@ import DetailSearchContext from "./pages/DetailSearchContext";
import ToDoCal from "./pages/ToDoCal";
import ToDoTree from "./pages/ToDoTree";
import {PersonalCenter} from "./pages/PersonalCenter";
import {MyRootProvider} from "./components/MyRootContext";
function App() {
return (
<MyRootProvider>
<Router>
<div className='app'>
<Routes>
<Route path='/' element={<Navigate to="/mobile/listTask" />}>
<Route path='/' element={<Navigate to="/mobile/listTask"/>}>
</Route>
<Route path='/mobile' element={<Home/>}>
{/*<Route index element={<ToDoList />} />*/}
<Route path='treeTask' element={<ToDoTree/>}/>
<Route index path='listTask' element={<ToDoList/>}></Route>
<Route path='listTask' element={<ToDoList/>}></Route>
<Route path='calTask' element={<ToDoCal/>}/>
<Route path='me' element={<PersonalCenter/>}></Route>
</Route>
@ -32,6 +35,7 @@ function App() {
</Routes>
</div>
</Router>
</MyRootProvider>
);
}

View File

@ -1,18 +1,17 @@
import {Tag,} from "antd-mobile";
import React, {Fragment, useEffect, useState} from "react";
import React, {Fragment, useContext, useEffect, useState} from "react";
import {useLocation, useNavigate} from 'react-router-dom';
import {AddOutline, CloseOutline, SearchOutline} from "antd-mobile-icons";
import "./index.css"
import {getDictionary} from "../../utils/dictUtil";
import dayjs from "dayjs";
import {MyRootContext, UPDATE_SEARCH} from "../MyRootContext";
import {getTaskById} from "../../utils";
const DetailSearchBar = (props) => {
// 从搜索设置中传来的search
// const location = useLocation();
// const searchUpdate = location.state?.search;
// 父子传值从搜索框传来的search
const {search, updateSearch, pName} = props;
console.log("DetailSearchBar.search", search)
const { state, dispatch } = useContext(MyRootContext);
const search = state.search
const [tags, setTags] = useState([]);
const showCloseOutline = search && search.data &&
(search.data.andList?.length > 0 || search.data.orList?.length > 0)
@ -27,9 +26,11 @@ const DetailSearchBar = (props) => {
// 处理主要条件
const tagList = [];
console.log("search.data.orSearchModel",search.data.orSearchModel)
search.data.orSearchModel?.andList?.forEach((searchObj) => {
await search.data.orSearchModel?.andList?.forEach((searchObj) => {
if (searchObj.name === "pid") {
tagList.push(<Tag key={pName}>{pName}</Tag>)
getTaskById(searchObj.value).then(result=>{
tagList.push(<Tag key={result[0].name}>{result[0].name}</Tag>)
})
} else if (searchObj.name === "state") {
const items = searchObj.value.split(',');
items.forEach((item) => {
@ -84,29 +85,27 @@ const DetailSearchBar = (props) => {
<div className="detailSearchBar">
<div className={"onSearchItem " + (showCloseOutline ? "onSearchItemWidth" : "onSearchItemOnlyWidth")}
onClick={() => {
navigate("/detail/searchTask", {state: {"search": search}});
navigate("/detail/searchTask");
}}>
<SearchOutline/>
{/*根据search处理搜素框展示内容*/}
{tags}
</div>
{showCloseOutline && <div className="CloseOutline-CloseOutline" onClick={() => {
updateSearch({
dispatch({type:UPDATE_SEARCH,search:{
"pageSize": 20,
"pageNumber": 1,
"data": {
"andList": [],
"orList": []
}
});
}});
setTags([]);
}}>
<CloseOutline style={{float: "right"}}/>
</div>
}
{/*<SearchBar placeholder='请输入内容' onFocus={() => {*/}
{/*<SearchBar placeholder='请输入内容,无法放入标签' onFocus={() => {*/}
{/* navigate("/detail/searchTask")*/}
{/*}}*/}

View File

@ -0,0 +1,94 @@
import { createContext, useReducer } from 'react';
import {dayStartUtcFormat, nextDayStartUtcFormat} from "../../utils/timeFormatUtil";
import dayjs from "dayjs";
// 创建一个 context
export const MyRootContext = createContext();
export const UPDATE_SEARCH = "UPDATE_SEARCH";
// 定义初始状态和 reducer 函数
const initialState = {"search":{
"pageSize": 20,
"pageNumber": 1,
"data": {
"orSearchModel": {
"andList": [
{"name": "state", "value": "8,9", "operateType": "IN"},
],
"andSearchModel": {
"andList": [
{
"name": "expectedStartTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
}
],
"orSearchModel": {
"andList": [
{
"name": "expectedStartTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedStartTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": "NULL"
}
],
"orSearchModel": {
"andList": [
{
"name": "expectedEndTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
},
{
"name": "expectedStartTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": "NULL"
}
],
}
}
},
},
"andList": [
{"name": "state", "value": "10", "operateType": "="}
]
}
}};
function reducer(state, action) {
switch (action.type) {
case UPDATE_SEARCH:
return { ...state, search:action.search};
case 'decrement':
return { count: state.count - 1 };
default:
throw new Error();
}
}
// 创建一个 Provider 组件
export function MyRootProvider({ children }) {
const [state, dispatch] = useReducer(reducer, initialState);
return (
<MyRootContext.Provider value={{ state, dispatch }}>
{children}
</MyRootContext.Provider>
);
}

View File

@ -1,19 +1,18 @@
import {Button, Checkbox, DatePicker, Form, Input, Space, Switch, Tag} from "antd-mobile";
import ParentTask from "../../components/ParentTask";
import React, {useEffect} from "react";
import React, {useContext, useEffect} from "react";
import dayjs from "dayjs";
import {CloseCircleFill} from "antd-mobile-icons";
import {useLocation, useNavigate, useOutletContext} from "react-router-dom";
import {getDictionary} from "../../utils/dictUtil";
import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext";
const DetailSearchContext = () => {
const navigate = useNavigate();
const [form] = Form.useForm();
const [visible, setVisible] = React.useState(false);
const location = useLocation();
console.log("DetailSearchContext", location);
const {search} = location?.state || undefined;
console.log("DetailSearchContext.search", search)
const { state, dispatch } = useContext(MyRootContext);
const search = state.search
const [stateList, setStateList] = React.useState([]);
const [priorityList, setPriorityList] = React.useState([]);
// 使用Outlet,传值修改标题
@ -132,19 +131,15 @@ const DetailSearchContext = () => {
if (allOverdueTasks) {
andList.push({"name": "state", "value": "10", "operateType": "="})
}
navigate("/mobile/listTask", {
state: {
search: {
dispatch({type:UPDATE_SEARCH,search:{
"pageSize": 12,
"pageNumber": 1,
"data": {
andList,
orSearchModel
}
}
}
}
)
}})
navigate("/mobile/listTask")
}}
footer={
<Button block type='submit' color='primary' size='large'>

View File

@ -1,90 +1,13 @@
import React, {Fragment, useEffect} from 'react'
import React, {Fragment, useContext, useEffect} from 'react'
import Bottom from './../Bottom/index'
import './index.css'
import {Outlet, useLocation} from 'react-router-dom'
import DetailSearchBar from "../../components/DetailSearchBar";
import dayjs from "dayjs";
import {dayStartUtcFormat, nextDayStartUtcFormat} from "../../utils/timeFormatUtil";
const Home = () => {
const location = useLocation();
console.log("Home", location);
const searchUrl = location?.state?.search;
const [pName, setName] = React.useState("");
const [search, setSearch] = React.useState()
const updateSearch = (values) => {
setSearch(values);
};
useEffect(() => {
setSearch(searchUrl ? searchUrl : {
"pageSize": 20,
"pageNumber": 1,
"data": {
"orSearchModel": {
"andList": [
{"name": "state", "value": "8,9", "operateType": "IN"},
],
"andSearchModel": {
"andList": [
{
"name": "expectedStartTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
}
],
"orSearchModel": {
"andList": [
{
"name": "expectedStartTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedStartTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": "NULL"
}
],
"orSearchModel": {
"andList": [
{
"name": "expectedEndTime",
"value": nextDayStartUtcFormat(dayjs()),
"operateType": "<"
},
{
"name": "expectedEndTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": ">"
},
{
"name": "expectedStartTime",
"value": dayStartUtcFormat(dayjs()),
"operateType": "NULL"
}
],
}
}
},
},
"andList": [
{"name": "state", "value": "10", "operateType": "="}
]
}
})
},[searchUrl])
return (
<div className='body'>
@ -92,15 +15,13 @@ const Home = () => {
location.pathname.endsWith("/calTask") ? (
<Fragment>
<div style={{marginBottom: "49px", width: "100%"}}>
<Outlet context={{"search": search}}/>
<Outlet />
</div>
</Fragment>
) : (<Fragment>
<DetailSearchBar search={search}
updateSearch={updateSearch}
pName={pName}/>
<DetailSearchBar/>
<div style={{marginTop: "40px", marginBottom: "49px", width: "100%"}}>
<Outlet context={{"search": search}}/>
<Outlet/>
</div>
</Fragment>
)

View File

@ -1,4 +1,4 @@
import React, {Fragment, useEffect, useMemo} from "react";
import React, {Fragment, useContext, useEffect, useMemo} from "react";
import {getTaskCount} from "../../utils";
import dayjs from "dayjs";
import {DATE_FORMAT} from "../../utils/timeFormatUtil";
@ -6,6 +6,7 @@ import {getDictionary} from "../../utils/dictUtil";
import {Tag} from "antd-mobile";
import detailSearchBar from "../../components/DetailSearchBar";
import {useNavigate} from "react-router-dom";
import {MyRootContext, UPDATE_SEARCH} from "../../components/MyRootContext";
const TaskCount = (props) => {
@ -14,6 +15,7 @@ const TaskCount = (props) => {
const [taskCount, setTaskCount] = React.useState([]);
const [stateMap, setStateMap] = React.useState(new Map);
const [priorityMap, setPriorityMap] = React.useState(new Map);
const {dispatch } = useContext(MyRootContext);
useEffect(() => {
console.log("useEffect");
if (currentDay) {
@ -81,18 +83,14 @@ const TaskCount = (props) => {
}
}
console.log({orSearchModel})
navigate("/mobile/listTask", {
state: {
search: {
dispatch({type:UPDATE_SEARCH,search:{
"pageSize": 12,
"pageNumber": 1,
"data": {
orSearchModel
}
}
}
}
)
}})
navigate("/mobile/listTask")
}
return (

View File

@ -4,6 +4,6 @@
.adm-card-header-title{
width:100%;
}
.adm-pull-to-refresh{
touch-action:none;
}
/*.adm-pull-to-refresh{*/
/* touch-action:none;*/
/*}*/

View File

@ -1,11 +1,13 @@
import {Dialog, InfiniteScroll, List, PullToRefresh, SwipeAction} from 'antd-mobile'
import React, {Fragment, useEffect, useRef, useState} from 'react'
import React, {Fragment, useContext, useEffect, useRef, useState} from 'react'
import {deleteTaskById, getTaskList, updateTaskStateById} from "../../utils";
import "./index.css"
import {useLocation, useNavigate, useOutletContext} from "react-router-dom";
import dayjs from "dayjs";
import {DATE_TIME_FORMAT, DATE_TIME_FORMAT_SIMPLE} from "../../utils/timeFormatUtil";
import {getDictionary} from "../../utils/dictUtil";
import {List as VirtualizedList,AutoSizer} from "react-virtualized";
import {MyRootContext} from "../../components/MyRootContext";
const reorder = (
list,
@ -26,20 +28,21 @@ const ToDoList = () => {
const [priorityMap, setPriorityMap] = useState([]);
const [stateMap, setStateMap] = useState([])
const navigate = useNavigate();
let loading = true;
const location = useLocation();
const {search: outletSearch} = useOutletContext()
const search = location.state ? location.state.search : outletSearch;
console.log("ToDoList.search", location, outletSearch)
console.log("ToDoList测试下从添加任务过来条件都没有了",search,outletSearch)
let loading = false;
const { state } = useContext(MyRootContext);
const search = state.search
console.log("从全局取出的search" ,{search})
const loadMore = async () => {
console.log("loading:",pageNumber,loading)
if (loading) {
return
}
loading = true;
console.log("loadMore", loading)
const taskRes = await getTaskList({...search, "pageNumber": pageNumber + 1});
setTaskList(val => [...val, ...taskRes.connect])
const taskRes = await getTaskList({...search, "pageNumber": pageNumber});
console.log({taskRes})
setTaskList( [...taskList, ...taskRes.content])
if (taskRes.page.number < taskRes.page.totalPages){
setHasMore(true)
setPageNumber(pageNumber + 1)
@ -63,17 +66,17 @@ const ToDoList = () => {
getDictionary("1").then(res => {
setPriorityMap(res)
})
getTaskList({...search, "pageNumber": pageNumber}).then(result => {
setTaskList(result.content)
if (result.page.number < result.page.totalPages){
setHasMore(true)
setPageNumber(pageNumber + 1)
}else {
setHasMore(false)
setPageNumber(1)
}
loading = false;
})
// getTaskList({...search, "pageNumber": pageNumber}).then(result => {
// setTaskList(result.content)
// if (result.page.number < result.page.totalPages){
// setHasMore(true)
// setPageNumber(pageNumber + 1)
// }else {
// setHasMore(false)
// setPageNumber(1)
// }
// loading = false;
// })
}, [useOutletContext()])
const ref = useRef(null)
@ -83,6 +86,7 @@ const ToDoList = () => {
<PullToRefresh
onRefresh={() => {
console.log("refresh")
loading = true;
getTaskList({...search, "pageNumber": 1}).then(result => {
setTaskList(result.content)
if (result.page.number < result.page.totalPages){
@ -93,9 +97,20 @@ const ToDoList = () => {
setPageNumber(1)
}
})
loading= false;
}}
>
<List>
{/*<AutoSizer disableHeight>*/}
{/* <VirtualizedList*/}
{/* rowCount={rowCount}*/}
{/* rowRenderer={rowRenderer}*/}
{/* width={width}*/}
{/* height={480}*/}
{/* rowHeight={60}*/}
{/* overscanRowCount={10}*/}
{/* />*/}
{/*</AutoSizer>*/}
{taskList.map((item, index) => (
<SwipeAction
ref={ref}
@ -200,11 +215,11 @@ const ToDoList = () => {
style={{color: priorityMap.get(item.priority)?.jsonValue?.color}}>{item.name}</span>) : (
<span>{item.name}</span>)}
{item.expectedEndTime && (stateMap.get(item.state)?.jsonValue?.color ?
{item.expectedStartTime && (stateMap.get(item.state)?.jsonValue?.color ?
(<span style={{color: stateMap.get(item.state)?.jsonValue?.color}}>
{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT_SIMPLE)}</span>) :
{dayjs(item.expectedStartTime).format(DATE_TIME_FORMAT_SIMPLE)}</span>) :
(
<span>{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT_SIMPLE)}</span>))
<span>{dayjs(item.expectedStartTime).format(DATE_TIME_FORMAT_SIMPLE)}</span>))
}
</div>}
description={item.description}

View File

@ -1,8 +1,57 @@
import {Fragment} from "react";
import {Fragment, useEffect, useMemo, useState} from "react";
import {Card, Cascader, CascaderView} from "antd-mobile";
import {getTaskByPid} from "../../utils";
export default ()=>{
const [valueToOptions, setValueToOptions] = useState([])
const options = useMemo(() => {
function generate(v) {
const options = valueToOptions[v]
if (options === null) {
return undefined
}
if (options === undefined) {
return Cascader.optionSkeleton
}
return options.map(option => ({
...option,
children: generate(option.value),
}))
}
return generate('0') ?? []
}, [valueToOptions])
async function fetchOptionsForValue(v, level) {
if (v in valueToOptions) return
// if (level >= 3) {
// setValueToOptions(prev => ({
// ...prev,
// [v]: null,
// }))
// return
// }
const data = await getTaskByPid(v)
console.log("await getTaskByPid(v)",data.content)
const options =
data.content.length === 0
? null
: data.content.map(task => ({
value: task.id,
label: task.name,
}))
console.log("await getTaskByPid(v) options",options)
setValueToOptions(prev => ({
...prev,
[v]: options,
}))
}
useEffect(() => {
fetchOptionsForValue('0', 0)
}, [])
return <Fragment>
<p>文本</p>
<p>联动数</p>
<Card title='任务名称'>
任务详情
</Card>
<CascaderView options={options} />
</Fragment>
}