|
|
@@ -1,8 +1,8 @@
|
|
|
-import { Button, List, Popover, Tag, Typography } from "antd";
|
|
|
+import { Button, List, Popover, Switch, Tag, Typography } from "antd";
|
|
|
import { ITaskData, ITaskListResponse } from "../api/task";
|
|
|
import { get } from "../../request";
|
|
|
import { useEffect, useState } from "react";
|
|
|
-import { ArrowLeftOutlined, ArrowRightOutlined,CheckOutlined } from "@ant-design/icons";
|
|
|
+import { ArrowLeftOutlined, ArrowRightOutlined } from "@ant-design/icons";
|
|
|
import { TRelation } from "./TaskEditButton";
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
@@ -12,8 +12,15 @@ interface IProTaskListProps {
|
|
|
type: TRelation;
|
|
|
onClick?: (data?: ITaskData | null) => void;
|
|
|
onClose?: () => void;
|
|
|
+ onChange?: (data: ITaskData, has: boolean) => void;
|
|
|
}
|
|
|
-const ProTaskList = ({ task, type, onClick, onClose }: IProTaskListProps) => {
|
|
|
+const ProTaskList = ({
|
|
|
+ task,
|
|
|
+ type,
|
|
|
+ onClick,
|
|
|
+ onClose,
|
|
|
+ onChange,
|
|
|
+}: IProTaskListProps) => {
|
|
|
const [res, setRes] = useState<ITaskData[]>();
|
|
|
useEffect(() => {
|
|
|
const url = `/v2/task?view=project&project_id=${task?.project_id}`;
|
|
|
@@ -43,22 +50,34 @@ const ProTaskList = ({ task, type, onClick, onClose }: IProTaskListProps) => {
|
|
|
footer={false}
|
|
|
dataSource={res}
|
|
|
renderItem={(item) => {
|
|
|
- let checked = false
|
|
|
- if(type === "pre"){
|
|
|
- checked = task?.pre_task?.find((value)=>value.id===item.id)!==undefined
|
|
|
- }else{
|
|
|
- checked = task?.next_task?.find((value)=>value.id===item.id)!==undefined
|
|
|
+ let checked = false;
|
|
|
+ if (type === "pre") {
|
|
|
+ checked =
|
|
|
+ task?.pre_task?.find((value) => value.id === item.id) !== undefined;
|
|
|
+ } else {
|
|
|
+ checked =
|
|
|
+ task?.next_task?.find((value) => value.id === item.id) !==
|
|
|
+ undefined;
|
|
|
}
|
|
|
return (
|
|
|
- <List.Item
|
|
|
- actions={[checked?<CheckOutlined />:<></>]}
|
|
|
- onClick={() => {
|
|
|
- onClick && onClick(item);
|
|
|
- }}
|
|
|
- >
|
|
|
- {item.title}
|
|
|
- </List.Item>
|
|
|
- )}}
|
|
|
+ <List.Item
|
|
|
+ actions={[
|
|
|
+ <Switch
|
|
|
+ size="small"
|
|
|
+ checked={checked}
|
|
|
+ onChange={(checked) => {
|
|
|
+ onChange && onChange(item, checked);
|
|
|
+ }}
|
|
|
+ />,
|
|
|
+ ]}
|
|
|
+ onClick={() => {
|
|
|
+ onClick && onClick(item);
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ {item.title}
|
|
|
+ </List.Item>
|
|
|
+ );
|
|
|
+ }}
|
|
|
/>
|
|
|
);
|
|
|
};
|
|
|
@@ -68,23 +87,32 @@ interface IWidget {
|
|
|
open?: boolean;
|
|
|
type: TRelation;
|
|
|
onClick?: (data?: ITaskData | null) => void;
|
|
|
- onTagClick?:()=>void;
|
|
|
+ onTagClick?: () => void;
|
|
|
onClose?: () => void;
|
|
|
+ onChange?: (data: ITaskData, has: boolean) => void;
|
|
|
}
|
|
|
-const PreTask = ({ task, type, open = false, onClick, onClose,onTagClick }: IWidget) => {
|
|
|
+const PreTask = ({
|
|
|
+ task,
|
|
|
+ type,
|
|
|
+ open = false,
|
|
|
+ onClick,
|
|
|
+ onClose,
|
|
|
+ onTagClick,
|
|
|
+ onChange,
|
|
|
+}: IWidget) => {
|
|
|
const preTaskShow = open || task?.pre_task;
|
|
|
const nextTaskShow = open || task?.next_task;
|
|
|
let tag = <></>;
|
|
|
if (preTaskShow && type === "pre") {
|
|
|
tag = (
|
|
|
- <Tag color="warning" icon={<ArrowLeftOutlined />} onClick={onTagClick}>
|
|
|
- {task?.pre_task? `${task?.pre_task?.length} 个前置任务`:''}
|
|
|
+ <Tag color="warning" icon={<ArrowLeftOutlined />} onClick={onTagClick}>
|
|
|
+ {task?.pre_task ? `${task?.pre_task?.length} 个前置任务` : ""}
|
|
|
</Tag>
|
|
|
);
|
|
|
} else if (nextTaskShow && type === "next") {
|
|
|
tag = (
|
|
|
<Tag color="warning" icon={<ArrowRightOutlined />} onClick={onTagClick}>
|
|
|
- {task?.next_task?`阻塞 ${task?.next_task?.length} 个任务`:''}
|
|
|
+ {task?.next_task ? `阻塞 ${task?.next_task?.length} 个任务` : ""}
|
|
|
</Tag>
|
|
|
);
|
|
|
}
|
|
|
@@ -99,6 +127,7 @@ const PreTask = ({ task, type, open = false, onClick, onClose,onTagClick }: IWid
|
|
|
task={task}
|
|
|
onClick={onClick}
|
|
|
onClose={onClose}
|
|
|
+ onChange={onChange}
|
|
|
/>
|
|
|
</div>
|
|
|
}
|