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