feat:左滑修改
This commit is contained in:
parent
8f20efb98e
commit
da867a47f7
|
@ -33,6 +33,8 @@ function App() {
|
||||||
<Route path='/detail' element={<DetailNavBar/>}>
|
<Route path='/detail' element={<DetailNavBar/>}>
|
||||||
<Route path='addTask' element={<DetailForm/>}></Route>
|
<Route path='addTask' element={<DetailForm/>}></Route>
|
||||||
<Route path='searchTask' element={<DetailSearchContext/>}></Route>
|
<Route path='searchTask' element={<DetailSearchContext/>}></Route>
|
||||||
|
<Route path='updateTask' element={<DetailForm/>}></Route>
|
||||||
|
<Route path='selectTask' element={<DetailForm/>}></Route>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
{/* <Route path='/home' element={<Home />}>
|
{/* <Route path='/home' element={<Home />}>
|
||||||
|
|
|
@ -8,7 +8,7 @@ import {CloseCircleFill} from 'antd-mobile-icons'
|
||||||
|
|
||||||
const DatePickerItem = (props) => {
|
const DatePickerItem = (props) => {
|
||||||
const [pickerVisible, setPickerVisible] = useState(false)
|
const [pickerVisible, setPickerVisible] = useState(false)
|
||||||
const {fieldName, labelName} = props
|
const {fieldName, labelName,disabled} = props
|
||||||
const labelRenderer = useCallback((type, data) => {
|
const labelRenderer = useCallback((type, data) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'year':
|
case 'year':
|
||||||
|
@ -30,14 +30,17 @@ const DatePickerItem = (props) => {
|
||||||
return (
|
return (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
noStyle
|
noStyle
|
||||||
shouldUpdate={(prevValues, curValues) =>
|
shouldUpdate={(prevValues, curValues) =>{
|
||||||
prevValues.fieldName !== curValues.fieldName
|
return prevValues.fieldName !== curValues.fieldName
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
{({getFieldValue, setFieldsValue}) => (
|
{({getFieldValue, setFieldsValue}) => (
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={fieldName}
|
name={fieldName}
|
||||||
label={labelName}
|
label={labelName}
|
||||||
|
disabled={disabled}
|
||||||
trigger='onConfirm'
|
trigger='onConfirm'
|
||||||
arrow={
|
arrow={
|
||||||
getFieldValue(fieldName) ? (
|
getFieldValue(fieldName) ? (
|
||||||
|
@ -47,8 +50,9 @@ const DatePickerItem = (props) => {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
}}
|
}}
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
|
// 计算属性名:允许你在对象字面量中使用表达式来动态确定属性名。
|
||||||
|
setFieldsValue({[fieldName]: null})
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
setFieldsValue({fieldName: null})
|
|
||||||
}}/>) : true
|
}}/>) : true
|
||||||
}
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|
|
@ -1,60 +1,145 @@
|
||||||
import React from 'react'
|
import React, {useEffect} from 'react'
|
||||||
import {
|
import {
|
||||||
Form,
|
Form,
|
||||||
Input,
|
Input,
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
TextArea,
|
TextArea,
|
||||||
Space,
|
Space, Tag, Radio
|
||||||
Checkbox, Selector, Tag, Radio
|
|
||||||
} from 'antd-mobile'
|
} from 'antd-mobile'
|
||||||
import ParentTask from "../ParentTask";
|
import ParentTask from "../ParentTask";
|
||||||
import DatePickerItem from "../DataPickerItem"
|
import DatePickerItem from "../DataPickerItem"
|
||||||
import "./index.css"
|
import "./index.css"
|
||||||
import {addTask} from "../../utils";
|
import {addTask, getPTask, getTaskById, updateTask} from "../../utils";
|
||||||
import {useNavigate, useOutletContext} from "react-router-dom";
|
import {useLocation, useNavigate, useOutletContext, useSearchParams} from "react-router-dom";
|
||||||
|
import dayjs from "dayjs";
|
||||||
|
|
||||||
export default () => {
|
export default () => {
|
||||||
|
// 进入此页面的操作:添加,修改,详情(按钮为添加任务日志)
|
||||||
|
const location = useLocation();
|
||||||
|
let [params] = useSearchParams();
|
||||||
// 设置标题栏
|
// 设置标题栏
|
||||||
const {setTitle} = useOutletContext();
|
const {setTitle} = useOutletContext();
|
||||||
setTitle("添加任务")
|
const [currentPath, setCurrentPath] = React.useState("");
|
||||||
|
const [updateFiledDisabled, setUpdateFiledDisabled] = React.useState(true);
|
||||||
|
const [pName, setPName] = React.useState();
|
||||||
|
const [pidArray, setPidArray] = React.useState([]);
|
||||||
// 路由
|
// 路由
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
// 获取form引用
|
// 获取form引用
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
const onFinish = (values) => {
|
useEffect(() => {
|
||||||
console.log("提交:",values)
|
if (location.pathname.endsWith("addTask")) {
|
||||||
if (values.pidArray===undefined){
|
setTitle("添加任务");
|
||||||
values.pid='0'
|
setCurrentPath("addTask");
|
||||||
}else {
|
setUpdateFiledDisabled(false);
|
||||||
values.pid=values.pidArray[values.pidArray.length-1];
|
} else if (location.pathname.endsWith("updateTask")) {
|
||||||
|
setTitle("修改任务");
|
||||||
|
setCurrentPath("updateTask");
|
||||||
|
initData(params.get('id'));
|
||||||
|
setUpdateFiledDisabled(false);
|
||||||
|
} else if (location.pathname.endsWith("selectTask")) {
|
||||||
|
setTitle("任务详情");
|
||||||
|
setCurrentPath("selectTask");
|
||||||
|
initData(params.get('id'));
|
||||||
|
setUpdateFiledDisabled(true);
|
||||||
|
} else {
|
||||||
|
// todo 异常处理
|
||||||
}
|
}
|
||||||
addTask(values).then(values=>{
|
|
||||||
Dialog.show({
|
}, [])
|
||||||
content: `添加任务${values.name}成功`,
|
|
||||||
closeOnAction:true,
|
function editParentTask(id) {
|
||||||
actions: [
|
if (id === '0') {
|
||||||
[
|
return;
|
||||||
{
|
}
|
||||||
key: 'back',
|
// 获取父任务信息
|
||||||
text: '回到列表',
|
getPTask(id).then(res => {
|
||||||
onClick:()=>{
|
let parentMessageVOList = res[0].parentMessageVOList;
|
||||||
navigate("/home/listTask")
|
console.log({res, parentMessageVOList});
|
||||||
}
|
setPName(parentMessageVOList[parentMessageVOList.length - 1].name);
|
||||||
},
|
setPidArray(parentMessageVOList.map(parent => parent.id))
|
||||||
{
|
|
||||||
key: 'create',
|
|
||||||
text: '创建下一条',
|
|
||||||
onClick:()=>{
|
|
||||||
// 清空值
|
|
||||||
form.resetFields();
|
|
||||||
form.setFieldValue("pidArray",values.pidArray);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
],
|
|
||||||
],
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const initData = (id) => {
|
||||||
|
if (id) {
|
||||||
|
getTaskById(id).then((res) => {
|
||||||
|
let contentElement = res.content[0];
|
||||||
|
if (contentElement) {
|
||||||
|
console.log(contentElement.expectedStartTime, contentElement.expectedEndTime,
|
||||||
|
dayjs(contentElement.expectedStartTime).format(), dayjs(contentElement.expectedStartTime).toDate())
|
||||||
|
contentElement.expectedStartTime && (contentElement.expectedStartTime = dayjs(contentElement.expectedStartTime).toDate())
|
||||||
|
contentElement.expectedEndTime && (contentElement.expectedEndTime = dayjs(contentElement.expectedEndTime).toDate())
|
||||||
|
contentElement.actualStartTime && (contentElement.actualStartTime = dayjs(contentElement.actualStartTime).toDate())
|
||||||
|
contentElement.actualEndTime && (contentElement.actualEndTime = dayjs(contentElement.actualEndTime).toDate())
|
||||||
|
form.setFieldsValue(contentElement)
|
||||||
|
editParentTask(contentElement.pid)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const onFinish = (values) => {
|
||||||
|
if (currentPath === "selectTask") {
|
||||||
|
// 进入添加日志页面
|
||||||
|
navigate("/home/detail/logTask")
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("提交:", values)
|
||||||
|
if (values.pidArray?.length > 0) {
|
||||||
|
values.pid = values.pidArray[values.pidArray.length - 1];
|
||||||
|
} else if (!values.pid) {
|
||||||
|
values.pid = '0'
|
||||||
|
}
|
||||||
|
if (currentPath === "addTask") {
|
||||||
|
addTask(values).then(values => {
|
||||||
|
Dialog.show({
|
||||||
|
content: `添加任务${values}成功`,
|
||||||
|
closeOnAction: true,
|
||||||
|
actions: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'back',
|
||||||
|
text: '回到列表',
|
||||||
|
onClick: () => {
|
||||||
|
navigate("/home/listTask")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
key: 'create',
|
||||||
|
text: '创建下一条',
|
||||||
|
onClick: () => {
|
||||||
|
// 清空值
|
||||||
|
form.resetFields();
|
||||||
|
form.setFieldValue("pidArray", values.pidArray);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (currentPath === "updateTask") {
|
||||||
|
updateTask(values).then(values => {
|
||||||
|
Dialog.show({
|
||||||
|
content: `修改任务${values}成功`,
|
||||||
|
closeOnAction: true,
|
||||||
|
actions: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
key: 'back',
|
||||||
|
text: '回到列表',
|
||||||
|
onClick: () => {
|
||||||
|
navigate("/home/listTask")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
],
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Form
|
<Form
|
||||||
|
@ -63,19 +148,37 @@ export default () => {
|
||||||
onFinish={onFinish}
|
onFinish={onFinish}
|
||||||
footer={
|
footer={
|
||||||
<Button block type='submit' color='primary' size='large'>
|
<Button block type='submit' color='primary' size='large'>
|
||||||
提交
|
{currentPath === "selectTask" ? "日记/心得" : "提交"}
|
||||||
</Button>
|
</Button>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<ParentTask form = {form}/>
|
<Form.Item
|
||||||
|
key='id'
|
||||||
|
name='id'
|
||||||
|
hidden={true}
|
||||||
|
>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
key='pid'
|
||||||
|
name='pid'
|
||||||
|
hidden={true}
|
||||||
|
>
|
||||||
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
key='code'
|
||||||
|
name='code'
|
||||||
|
hidden={true}
|
||||||
|
></Form.Item>
|
||||||
|
<ParentTask pName={pName} pidArray={pidArray} disabled={updateFiledDisabled} form={form}/>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name='name'
|
name='name'
|
||||||
label='任务名称'
|
label='任务名称'
|
||||||
rules={[{required: true, message: '任务名称不能为空'}]}
|
rules={[{required: true, message: '任务名称不能为空'}]}
|
||||||
|
disabled={updateFiledDisabled}
|
||||||
>
|
>
|
||||||
<Input onChange={console.log} placeholder='任务名称'/>
|
<Input onChange={console.log} placeholder='任务名称'/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name='description' label='任务描述'>
|
<Form.Item name='description' label='任务描述' disabled={updateFiledDisabled}>
|
||||||
<TextArea
|
<TextArea
|
||||||
placeholder='请输入任务描述'
|
placeholder='请输入任务描述'
|
||||||
maxLength={100}
|
maxLength={100}
|
||||||
|
@ -83,7 +186,7 @@ export default () => {
|
||||||
showCount
|
showCount
|
||||||
/>
|
/>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name='state' label='任务状态' required>
|
<Form.Item name='state' label='任务状态' required disabled={updateFiledDisabled}>
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Space direction='vertical'>
|
<Space direction='vertical'>
|
||||||
<Radio value='8'><Tag color='primary'>未开始</Tag></Radio>
|
<Radio value='8'><Tag color='primary'>未开始</Tag></Radio>
|
||||||
|
@ -93,7 +196,7 @@ export default () => {
|
||||||
</Space>
|
</Space>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name='priority' label='任务优先级'>
|
<Form.Item name='priority' label='任务优先级' disabled={updateFiledDisabled}>
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Space direction='vertical'>
|
<Space direction='vertical'>
|
||||||
<Radio value='3'><Tag color='danger'>紧急重要</Tag></Radio>
|
<Radio value='3'><Tag color='danger'>紧急重要</Tag></Radio>
|
||||||
|
@ -103,10 +206,13 @@ export default () => {
|
||||||
</Space>
|
</Space>
|
||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<DatePickerItem fieldName={"expectedStartTime"} labelName={"预计开始时间"}/>
|
<DatePickerItem disabled={updateFiledDisabled} fieldName={"expectedStartTime"}
|
||||||
<DatePickerItem fieldName={"expectedEndTime"} labelName={"预计结束时间"}/>
|
labelName={"预计开始时间"}/>
|
||||||
<DatePickerItem fieldName={"actualStartTime"} labelName={"实际开始时间"}/>
|
<DatePickerItem disabled={updateFiledDisabled} fieldName={"expectedEndTime"}
|
||||||
<DatePickerItem fieldName={"actualEndTime"} labelName={"实际结束时间"}/>
|
labelName={"预计结束时间"}/>
|
||||||
|
<DatePickerItem disabled={updateFiledDisabled} fieldName={"actualStartTime"}
|
||||||
|
labelName={"实际开始时间"}/>
|
||||||
|
<DatePickerItem disabled={updateFiledDisabled} fieldName={"actualEndTime"} labelName={"实际结束时间"}/>
|
||||||
</Form>
|
</Form>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,9 +8,10 @@ import {getTaskByPid} from "../../utils";
|
||||||
|
|
||||||
const ParentTask = (props)=>{
|
const ParentTask = (props)=>{
|
||||||
const [valueToOptions, setValueToOptions] = useState([])
|
const [valueToOptions, setValueToOptions] = useState([])
|
||||||
const [parentValue, setParentValue] = useState("")
|
const {form,disabled,pName,pidArray} = props;
|
||||||
|
const [parentValue, setParentValue] = useState(pidArray??[])
|
||||||
const [visible, setVisible] = useState(false)
|
const [visible, setVisible] = useState(false)
|
||||||
const {form} = props;
|
|
||||||
const options = useMemo(() => {
|
const options = useMemo(() => {
|
||||||
function generate(v) {
|
function generate(v) {
|
||||||
const options = valueToOptions[v]
|
const options = valueToOptions[v]
|
||||||
|
@ -64,6 +65,7 @@ const ParentTask = (props)=>{
|
||||||
setVisible(true)
|
setVisible(true)
|
||||||
}}
|
}}
|
||||||
value={parentValue}
|
value={parentValue}
|
||||||
|
disabled={disabled}
|
||||||
>
|
>
|
||||||
<Cascader
|
<Cascader
|
||||||
options={options}
|
options={options}
|
||||||
|
@ -89,7 +91,9 @@ const ParentTask = (props)=>{
|
||||||
>
|
>
|
||||||
{items => {
|
{items => {
|
||||||
if (items.every(item => item === null)) {
|
if (items.every(item => item === null)) {
|
||||||
return <span style={{color:"#cccccc"}}>主线任务选填</span>
|
return pName?(<span>{pName}</span>): disabled ?
|
||||||
|
(<span>主线任务选填</span>):
|
||||||
|
(<span style={{color: "#cccccc"}}>主线任务选填</span>)
|
||||||
} else {
|
} else {
|
||||||
return items[items.length-1].label
|
return items[items.length-1].label
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ import "./index.css"
|
||||||
const tabs = [
|
const tabs = [
|
||||||
{
|
{
|
||||||
key: '/home/treeTask',
|
key: '/home/treeTask',
|
||||||
title: '树状任务',
|
title: '主子任务',
|
||||||
icon: <AppOutline/>,
|
icon: <AppOutline/>,
|
||||||
badge: '1',
|
badge: '1',
|
||||||
},
|
},
|
||||||
|
|
|
@ -35,7 +35,7 @@ const DetailSearchContext = () => {
|
||||||
}
|
}
|
||||||
let searchMap = new Map(search.data.andList.map(searchObj => [searchObj.name, searchObj]));
|
let searchMap = new Map(search.data.andList.map(searchObj => [searchObj.name, searchObj]));
|
||||||
if (searchMap.has("pid")) {
|
if (searchMap.has("pid")) {
|
||||||
let task = await getTaskById(searchMap.get("pid"));
|
|
||||||
// form.setFieldValue(task.name);
|
// form.setFieldValue(task.name);
|
||||||
}
|
}
|
||||||
if (searchMap.has("state")) {
|
if (searchMap.has("state")) {
|
||||||
|
|
|
@ -19,19 +19,22 @@ const TaskCount = (props) => {
|
||||||
.then(taskCount => {
|
.then(taskCount => {
|
||||||
setTaskCount(taskCount)
|
setTaskCount(taskCount)
|
||||||
})
|
})
|
||||||
|
getDictionary("2").then(state => {
|
||||||
|
setStateMap(state)
|
||||||
|
})
|
||||||
|
getDictionary("1").then(priority => {
|
||||||
|
console.log(priority)
|
||||||
|
setPriorityMap(priority)
|
||||||
|
})
|
||||||
|
}else {
|
||||||
|
setTaskCount([])
|
||||||
}
|
}
|
||||||
getDictionary("2").then(state => {
|
|
||||||
setStateMap(state)
|
|
||||||
})
|
|
||||||
getDictionary("1").then(priority => {
|
|
||||||
console.log(priority)
|
|
||||||
setPriorityMap(priority)
|
|
||||||
})
|
|
||||||
}, [currentDay])
|
}, [currentDay])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{margin:"20px"}}>
|
<div style={{margin:"20px"}}>
|
||||||
<h2>TODO日{dayjs(currentDay).format(DATE_FORMAT)}代办:</h2>
|
<h2>TODO日{currentDay&&dayjs(currentDay).format(DATE_FORMAT)}代办:</h2>
|
||||||
<h3>任务状态</h3>
|
<h3>任务状态</h3>
|
||||||
{
|
{
|
||||||
// taskCount.map(task => {
|
// taskCount.map(task => {
|
||||||
|
|
|
@ -3,4 +3,7 @@
|
||||||
}
|
}
|
||||||
.adm-card-header-title{
|
.adm-card-header-title{
|
||||||
width:100%;
|
width:100%;
|
||||||
|
}
|
||||||
|
.adm-pull-to-refresh{
|
||||||
|
touch-action:none;
|
||||||
}
|
}
|
|
@ -6,11 +6,12 @@ import {
|
||||||
Droppable,
|
Droppable,
|
||||||
// DropResult,
|
// DropResult,
|
||||||
} from 'react-beautiful-dnd'
|
} from 'react-beautiful-dnd'
|
||||||
import {getTaskList} from "../../utils";
|
import {deleteTaskById, getTaskList, updateTaskStateById} from "../../utils";
|
||||||
import "./index.css"
|
import "./index.css"
|
||||||
import {useLocation, useOutletContext} from "react-router-dom";
|
import {useLocation, useNavigate, useOutletContext} from "react-router-dom";
|
||||||
import dayjs from "dayjs";
|
import dayjs from "dayjs";
|
||||||
import {DATE_TIME_FORMAT} from "../../utils/timeFormatUtil";
|
import {DATE_TIME_FORMAT} from "../../utils/timeFormatUtil";
|
||||||
|
import {getDictionary} from "../../utils/dictUtil";
|
||||||
|
|
||||||
const reorder = (
|
const reorder = (
|
||||||
list,
|
list,
|
||||||
|
@ -28,7 +29,10 @@ const ToDoList = () => {
|
||||||
const [taskList, setTaskList] = useState([])
|
const [taskList, setTaskList] = useState([])
|
||||||
const [hasMore, setHasMore] = useState(true)
|
const [hasMore, setHasMore] = useState(true)
|
||||||
const [pageNumber, setPageNumber] = useState(1)
|
const [pageNumber, setPageNumber] = useState(1)
|
||||||
let loading = false;
|
const [priorityMap, setPriorityMap] = useState([]);
|
||||||
|
const [stateMap, setStateMap] = useState([])
|
||||||
|
const navigate = useNavigate();
|
||||||
|
let loading = true;
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const {search: outletSearch} = useOutletContext()
|
const {search: outletSearch} = useOutletContext()
|
||||||
const search = location.state ? location.state.search : outletSearch;
|
const search = location.state ? location.state.search : outletSearch;
|
||||||
|
@ -49,9 +53,18 @@ const ToDoList = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
getDictionary("2").then(res => {
|
||||||
|
setStateMap(res)
|
||||||
|
})
|
||||||
|
getDictionary("1").then(res => {
|
||||||
|
setPriorityMap(res)
|
||||||
|
})
|
||||||
getTaskList({...search, "pageNumber": pageNumber}).then(result => {
|
getTaskList({...search, "pageNumber": pageNumber}).then(result => {
|
||||||
setTaskList(result.content)
|
setTaskList(result.content)
|
||||||
|
setHasMore(result.page.number < result.page.totalPages)
|
||||||
|
loading=false;
|
||||||
})
|
})
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
const onDragEnd = (result) => {
|
const onDragEnd = (result) => {
|
||||||
if (!result.destination) return
|
if (!result.destination) return
|
||||||
|
@ -59,11 +72,13 @@ const ToDoList = () => {
|
||||||
setTaskList([...newList])
|
setTaskList([...newList])
|
||||||
}
|
}
|
||||||
const ref = useRef(null)
|
const ref = useRef(null)
|
||||||
|
const refSwip = useRef(null)
|
||||||
return (
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
{/* 下拉刷新 */}
|
{/* 下拉刷新 */}
|
||||||
<PullToRefresh
|
<PullToRefresh
|
||||||
onRefresh={async () => {
|
onRefresh={() => {
|
||||||
|
console.log("refresh")
|
||||||
getTaskList({...search, "pageNumber": 1}).then(result => {
|
getTaskList({...search, "pageNumber": 1}).then(result => {
|
||||||
setTaskList(result.content)
|
setTaskList(result.content)
|
||||||
setPageNumber(1)
|
setPageNumber(1)
|
||||||
|
@ -72,135 +87,133 @@ const ToDoList = () => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<List>
|
<List>
|
||||||
<DragDropContext onDragEnd={onDragEnd}>
|
{taskList.map((item, index) => (
|
||||||
<Droppable droppableId='droppable'>
|
<SwipeAction
|
||||||
{droppableProvided => (
|
ref={refSwip}
|
||||||
<div ref={droppableProvided.innerRef}>
|
closeOnAction={false}
|
||||||
{taskList.map((item, index) => (
|
closeOnTouchOutside={false}
|
||||||
<Draggable key={item.id} draggableId={item.id} index={index}>
|
rightActions={[
|
||||||
{(provided, snapshot) => (
|
{
|
||||||
<div
|
key: 'delete',
|
||||||
ref={provided.innerRef}
|
text: '删除',
|
||||||
{...provided.draggableProps}
|
color: 'danger',
|
||||||
{...provided.dragHandleProps}
|
onClick: async () => {
|
||||||
style={{
|
Dialog.confirm({
|
||||||
...provided.draggableProps.style,
|
content: '确定要删除吗?',
|
||||||
opacity: snapshot.isDragging ? 0.8 : 1,
|
onConfirm: () => {
|
||||||
}}
|
deleteTaskById(item.id).then(() => {
|
||||||
>
|
refSwip.current?.close()
|
||||||
<SwipeAction
|
})
|
||||||
ref={ref}
|
},
|
||||||
closeOnAction={false}
|
onClose: () => {
|
||||||
closeOnTouchOutside={false}
|
console.log(refSwip)
|
||||||
rightActions={[
|
refSwip.current?.close()
|
||||||
{
|
}
|
||||||
key: 'delete',
|
})
|
||||||
text: '删除',
|
},
|
||||||
color: 'danger',
|
},
|
||||||
onClick: async () => {
|
{
|
||||||
await Dialog.confirm({
|
key: 'close',
|
||||||
content: '确定要关闭吗?',
|
text: '关闭',
|
||||||
})
|
color: 'warning',
|
||||||
ref.current?.close()
|
onClick: async () => {
|
||||||
},
|
await Dialog.confirm({
|
||||||
},
|
content: '确定要关闭吗?',
|
||||||
{
|
onConfirm: () => {
|
||||||
key: 'close',
|
updateTaskStateById('6', item.id)
|
||||||
text: '关闭',
|
},
|
||||||
color: 'warning',
|
})
|
||||||
onClick: async () => {
|
refSwip.current?.close()
|
||||||
await Dialog.confirm({
|
},
|
||||||
content: '确定要关闭吗?',
|
},
|
||||||
})
|
{
|
||||||
ref.current?.close()
|
key: 'update',
|
||||||
},
|
text: '修改',
|
||||||
},
|
color: 'primary',
|
||||||
{
|
onClick: () => {
|
||||||
key: 'update',
|
refSwip.current?.close()
|
||||||
text: '修改',
|
// 跳转
|
||||||
color: 'primary',
|
navigate(`/detail/updateTask?id=${item.id}`)
|
||||||
onClick: async () => {
|
},
|
||||||
await Dialog.confirm({
|
},
|
||||||
content: '确定要修改吗?',
|
{
|
||||||
})
|
key: 'complete',
|
||||||
ref.current?.close()
|
text: '完成',
|
||||||
},
|
color: 'success',
|
||||||
},
|
onClick: async () => {
|
||||||
{
|
await Dialog.confirm({
|
||||||
key: 'complete',
|
content: '确定要完成吗?',
|
||||||
text: '完成',
|
onConfirm: () => {
|
||||||
color: 'success',
|
updateTaskStateById('7', item.id)
|
||||||
onClick: async () => {
|
},
|
||||||
await Dialog.confirm({
|
})
|
||||||
content: '确定要完成吗?',
|
refSwip.current?.close()
|
||||||
})
|
},
|
||||||
ref.current?.close()
|
},
|
||||||
},
|
]}
|
||||||
},
|
>
|
||||||
]}
|
<List.Item
|
||||||
>
|
key={item.id}
|
||||||
<List.Item
|
// prefix={
|
||||||
key={item.id}
|
// <Image
|
||||||
// prefix={
|
// src={item.avatar}
|
||||||
// <Image
|
// style={{ borderRadius: 20 }}
|
||||||
// src={item.avatar}
|
// fit='cover'
|
||||||
// style={{ borderRadius: 20 }}
|
// width={40}
|
||||||
// fit='cover'
|
// height={40}
|
||||||
// width={40}
|
// />
|
||||||
// height={40}
|
// }
|
||||||
// />
|
// title={<span style={{color: "red"}}>{item.name}</span>}
|
||||||
// }
|
// children={item.description}
|
||||||
// title={<span style={{color: "red"}}>{item.name}</span>}
|
// description={item.state}
|
||||||
// children={item.description}
|
onClick={
|
||||||
// description={item.state}
|
() => {
|
||||||
// onClick={
|
console.log("click/detail")
|
||||||
// () => {
|
navigate(`/detail/selectTask?id=${item.id}`)
|
||||||
// console.log("dianji")
|
}
|
||||||
// }
|
}
|
||||||
// }
|
title={
|
||||||
title={
|
<div style={{
|
||||||
<div style={{
|
display: "flex",
|
||||||
display: "flex",
|
justifyContent: "space-between",
|
||||||
justifyContent: "space-between",
|
alignItems: "center",
|
||||||
alignItems: "center",
|
flexDirection: "row",
|
||||||
flexDirection: "row",
|
flexWrap: "nowrap",
|
||||||
flexWrap: "nowrap",
|
fontSize: "large",
|
||||||
fontSize: "large",
|
color: "black"
|
||||||
color: "black"
|
}}>
|
||||||
}}>
|
{(priorityMap.get(item.priority)?.jsonValue?.color) ?
|
||||||
<span>{item.name}</span>
|
(<span
|
||||||
{item.expectedEndTime && <span>
|
style={{color: priorityMap.get(item.priority)?.jsonValue?.color}}>{item.name}</span>) : (
|
||||||
结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}</span>}
|
<span>{item.name}</span>)}
|
||||||
</div>}
|
|
||||||
description={item.description}
|
|
||||||
>
|
|
||||||
{/*<Card style={{width: "100%"}} title={*/}
|
|
||||||
{/* <div style={{*/}
|
|
||||||
{/* display: "flex",*/}
|
|
||||||
{/* justifyContent: "space-between",*/}
|
|
||||||
{/* alignItems: "center",*/}
|
|
||||||
{/* flexDirection: "row",*/}
|
|
||||||
{/* flexWrap: "nowrap"*/}
|
|
||||||
{/* }}>*/}
|
|
||||||
{/* <span>{item.name}</span>*/}
|
|
||||||
{/* {item.expectedEndTime && <span>*/}
|
|
||||||
{/* 结束时间:{item.expectedEndTime}</span>}*/}
|
|
||||||
|
|
||||||
{/* </div>}*/}
|
{item.expectedEndTime && (stateMap.get(item.state)?.jsonValue?.color ?
|
||||||
{/*>*/}
|
(<span style={{color: stateMap.get(item.state)?.jsonValue?.color}}>
|
||||||
{/* {item.description}*/}
|
结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}</span>) :
|
||||||
{/*</Card>*/}
|
(<span>结束时间:{dayjs(item.expectedEndTime).format(DATE_TIME_FORMAT)}</span>))
|
||||||
</List.Item>
|
}
|
||||||
</SwipeAction>
|
</div>}
|
||||||
</div>
|
description={item.description}
|
||||||
)}
|
>
|
||||||
</Draggable>
|
{/*<Card style={{width: "100%"}} title={*/}
|
||||||
))}
|
{/* <div style={{*/}
|
||||||
{droppableProvided.placeholder}
|
{/* display: "flex",*/}
|
||||||
</div>
|
{/* justifyContent: "space-between",*/}
|
||||||
)}
|
{/* alignItems: "center",*/}
|
||||||
</Droppable>
|
{/* flexDirection: "row",*/}
|
||||||
</DragDropContext>
|
{/* flexWrap: "nowrap"*/}
|
||||||
|
{/* }}>*/}
|
||||||
|
{/* <span>{item.name}</span>*/}
|
||||||
|
{/* {item.expectedEndTime && <span>*/}
|
||||||
|
{/* 结束时间:{item.expectedEndTime}</span>}*/}
|
||||||
|
|
||||||
|
{/* </div>}*/}
|
||||||
|
{/*>*/}
|
||||||
|
{/* {item.description}*/}
|
||||||
|
{/*</Card>*/}
|
||||||
|
</List.Item>
|
||||||
|
</SwipeAction>
|
||||||
|
))}
|
||||||
</List>
|
</List>
|
||||||
{/*无限滚动*/}
|
{/*无限滚动*/}
|
||||||
<InfiniteScroll loadMore={loadMore} hasMore={hasMore}/>
|
<InfiniteScroll loadMore={loadMore} hasMore={hasMore}/>
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
import Home from "../pages/Home";
|
||||||
|
import Index from "../pages/Index";
|
||||||
|
import DetailNavBar from "../components/DetailNavBar";
|
||||||
|
import DetailForm from "../components/DetailForm";
|
||||||
|
import DetailSearchContext from "../pages/DetailSearchContext";
|
||||||
|
|
||||||
|
const router = [
|
||||||
|
{
|
||||||
|
key:"home",
|
||||||
|
path: "/home",
|
||||||
|
element: <Home/>,
|
||||||
|
children: [{
|
||||||
|
key:"treeTask",
|
||||||
|
path: "treeTask",
|
||||||
|
element: <Index/>
|
||||||
|
}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: "/detail",
|
||||||
|
element: <DetailNavBar/>,
|
||||||
|
children: [{
|
||||||
|
path: "addTask",
|
||||||
|
element: <DetailForm/>
|
||||||
|
}, {
|
||||||
|
path: "searchTask",
|
||||||
|
element: <DetailSearchContext/>
|
||||||
|
}, {
|
||||||
|
path: "updateTask",
|
||||||
|
element: <DetailForm/>
|
||||||
|
}, {
|
||||||
|
path: "selectTask",
|
||||||
|
element: <DetailForm/>,
|
||||||
|
children: [{
|
||||||
|
path: "logTask",
|
||||||
|
element: <DetailForm/>
|
||||||
|
}]
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
]
|
|
@ -20,6 +20,7 @@ export const getDictionary = async (typeId) => {
|
||||||
let todo = await requestUtil.get(`/todo-server/search/dict_items?search=${search}`);
|
let todo = await requestUtil.get(`/todo-server/search/dict_items?search=${search}`);
|
||||||
let context = todo.content;
|
let context = todo.content;
|
||||||
let result;
|
let result;
|
||||||
|
console.log({context})
|
||||||
if (context.length > 0) {
|
if (context.length > 0) {
|
||||||
result = new Map(context.map(item => {
|
result = new Map(context.map(item => {
|
||||||
if (item.jsonValue) {
|
if (item.jsonValue) {
|
||||||
|
|
|
@ -1,16 +1,17 @@
|
||||||
import axios from "axios"
|
import axios from "axios"
|
||||||
import {requestUtil} from "./requestUtil";
|
import {requestUtil} from "./requestUtil";
|
||||||
export const getCurrentCity=()=>{
|
|
||||||
|
export const getCurrentCity = () => {
|
||||||
const localCity = JSON.parse(localStorage.getItem('local_city'))
|
const localCity = JSON.parse(localStorage.getItem('local_city'))
|
||||||
if(!localCity){
|
if (!localCity) {
|
||||||
return new Promise((resolve,reject)=>{
|
return new Promise((resolve, reject) => {
|
||||||
const curCity = new window.BMapGL.LocalCity()
|
const curCity = new window.BMapGL.LocalCity()
|
||||||
curCity.get(async res=>{
|
curCity.get(async res => {
|
||||||
try{
|
try {
|
||||||
const result = await axios.get('http://localhost:8080/area/info?name=${res.name}')
|
const result = await axios.get('http://localhost:8080/area/info?name=${res.name}')
|
||||||
localStorage.setItem('local_city',JSON.stringify(result.data.body))
|
localStorage.setItem('local_city', JSON.stringify(result.data.body))
|
||||||
resolve(result.data.body)
|
resolve(result.data.body)
|
||||||
}catch(e){
|
} catch (e) {
|
||||||
reject(e)
|
reject(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,24 +25,46 @@ export const getCurrentCity=()=>{
|
||||||
return Promise.resolve(localCity)
|
return Promise.resolve(localCity)
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTaskList= (data) => {
|
export const getTaskList = (data) => {
|
||||||
let request = encodeURI(JSON.stringify(data))
|
let request = encodeURI(JSON.stringify(data))
|
||||||
return requestUtil.get('/todo-server/V2/search/task_message_tree?search='+request);
|
return requestUtil.get('/todo-server/V2/search/task_message_tree?search=' + request);
|
||||||
}
|
}
|
||||||
// 根据pid获取未完成的任务
|
// 根据pid获取未完成的任务
|
||||||
export const getTaskByPid = (pid) => {
|
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');
|
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 getTaskCount = (startDate,endDate)=>{
|
export const getTaskCount = (startDate, endDate) => {
|
||||||
return requestUtil.get(`/todo-server/task/taskCount?startDate=${startDate}&endDate=${endDate}`);
|
return requestUtil.get(`/todo-server/task/taskCount?startDate=${startDate}&endDate=${endDate}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getTaskById= (id) => {
|
export const getTaskById = (id) => {
|
||||||
let request = encodeURI(`{"data":[{"name":"id","value":"${id}","operateType":"="}]}`)
|
let request = encodeURI(`{"data":[{"name":"id","value":"${id}","operateType":"="}]}`)
|
||||||
return requestUtil.get('/todo-server/search/task_message_tree?search='+request);
|
return requestUtil.get('/todo-server/search/task_message_tree?search=' + request);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const updateTaskStateById = (state, id) => {
|
||||||
|
let request = {
|
||||||
|
"updateColumnList": [{"name": "state", "value": state, "operateType": "="}],
|
||||||
|
"conditionColumnList": [{"name": "id", "value": id, "operateType": "="}]
|
||||||
|
}
|
||||||
|
return requestUtil.put('/todo-server/search/task_message_tree', request);
|
||||||
|
}
|
||||||
|
export const deleteTaskById = (id) => {
|
||||||
|
let request = {
|
||||||
|
"updateColumnList": [{"name": "deleteFlag", "value": "1", "operateType": "="}],
|
||||||
|
"conditionColumnList": [{"name": "id", "value": id, "operateType": "="}]
|
||||||
|
}
|
||||||
|
return requestUtil.put('/todo-server/search/task_message_tree', request);
|
||||||
}
|
}
|
||||||
export const addTask = async (entity) => {
|
export const addTask = async (entity) => {
|
||||||
// 使用 Axios 发送 POST 请求添加数据
|
// 使用 Axios 发送 POST 请求添加数据
|
||||||
return await requestUtil.post('/todo-server' + '/task', entity);
|
return await requestUtil.post('/todo-server' + '/task', entity);
|
||||||
}
|
}
|
||||||
|
export const updateTask = async (entity) => {
|
||||||
|
// 使用 Axios 发送 PUT 请求添加数据
|
||||||
|
return await requestUtil.put('/todo-server' + '/task', entity);
|
||||||
|
}
|
||||||
|
export const getPTask = (id) => {
|
||||||
|
return requestUtil.get(`http://localhost:8092/task/parent?ids=${id}`)
|
||||||
|
}
|
|
@ -5,12 +5,13 @@ export const requestUtil = axios.create({
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
headers: {'Authorization': 'Bearer eyJraWQiOiJjZDE5YjcxYy05ZDkwLTQyY2EtOGM5NC02YmMyNWY4YTdmNjgiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzaGl4aWFvaHVhIiwic3ViIjoie1wiaWRcIjpcIjM2OTg0Nzc3MTAxODAzNTIwXCIsXCJuaWNrbmFtZVwiOlwi5biI5pmT5Y2OXCIsXCJ1c2VybmFtZVwiOlwic2hpeGlhb2h1YVwifSJ9.3Wu8VMAuk59WP_EIRGX6hVp1ShuvYiAwFmvE6CGe5zA_9AzvUVMyRGWWcEQQzuU3BlZ14cV8-9b_g9_tZepQE_mSlDn0yJ92jB3ATxFPsAdcC5m2o7UY6spUs3zrlJ7v99Gtd6YzzUZvk0JTPjJCIpSi5-_PtIcOmZEkjgLwa2fnOj8eh9U3B2YdQ6p8J8r1ZeNfSMlzFuIyVcLFR-ftDz3Gr6wbs3fPgh03GqevL-HKyTCku2Fb9oYWis4UYDYQFfEVYVLzocsS3DpKyeq8BGxRRqQkSXsodDaO2piib-60Zp5WOg6hQb0n9utH-fQDVU5hIhUYkAbKkGDmTrnyqg'}
|
headers: {'Authorization': 'Bearer eyJraWQiOiJjZDE5YjcxYy05ZDkwLTQyY2EtOGM5NC02YmMyNWY4YTdmNjgiLCJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJpc3MiOiJzaGl4aWFvaHVhIiwic3ViIjoie1wiaWRcIjpcIjM2OTg0Nzc3MTAxODAzNTIwXCIsXCJuaWNrbmFtZVwiOlwi5biI5pmT5Y2OXCIsXCJ1c2VybmFtZVwiOlwic2hpeGlhb2h1YVwifSJ9.3Wu8VMAuk59WP_EIRGX6hVp1ShuvYiAwFmvE6CGe5zA_9AzvUVMyRGWWcEQQzuU3BlZ14cV8-9b_g9_tZepQE_mSlDn0yJ92jB3ATxFPsAdcC5m2o7UY6spUs3zrlJ7v99Gtd6YzzUZvk0JTPjJCIpSi5-_PtIcOmZEkjgLwa2fnOj8eh9U3B2YdQ6p8J8r1ZeNfSMlzFuIyVcLFR-ftDz3Gr6wbs3fPgh03GqevL-HKyTCku2Fb9oYWis4UYDYQFfEVYVLzocsS3DpKyeq8BGxRRqQkSXsodDaO2piib-60Zp5WOg6hQb0n9utH-fQDVU5hIhUYkAbKkGDmTrnyqg'}
|
||||||
});
|
});
|
||||||
|
requestUtil.interceptors.request.use()
|
||||||
// 添加响应拦截器
|
// 添加响应拦截器
|
||||||
requestUtil.interceptors.response.use(function (response) {
|
requestUtil.interceptors.response.use(function (response) {
|
||||||
// 2xx 范围内的状态码都会触发该函数。
|
// 2xx 范围内的状态码都会触发该函数。
|
||||||
// 对响应数据做点什么
|
// 对响应数据做点什么
|
||||||
console.log("response",response);
|
console.log("response",response);
|
||||||
if (response.data.data.status !== 200){
|
if (response.data.status.code !== 200){
|
||||||
|
|
||||||
}
|
}
|
||||||
return response.data.data;
|
return response.data.data;
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
const DATE_FORMAT = "YYYY-MM-DD"
|
const DATE_FORMAT = "YYYY-MM-DD"
|
||||||
const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss"
|
// 到秒没啥意义
|
||||||
|
const DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm"
|
||||||
|
|
||||||
export {DATE_TIME_FORMAT,DATE_FORMAT}
|
export {DATE_TIME_FORMAT,DATE_FORMAT}
|
Loading…
Reference in New Issue