YuJian920
3 years ago
13 changed files with 287 additions and 29 deletions
@ -0,0 +1,29 @@
@@ -0,0 +1,29 @@
|
||||
import { Input } from "antd"; |
||||
import React, { useState } from "react"; |
||||
import { useAddKanban, useProjectIdInUrl } from "../../../hook/useKanban"; |
||||
import { Container } from "../style"; |
||||
|
||||
const CreateKanban = () => { |
||||
const [name, setName] = useState(""); |
||||
const projectId = useProjectIdInUrl(); |
||||
const { mutateAsync: addKanban } = useAddKanban(); |
||||
|
||||
const sumbit = async () => { |
||||
await addKanban({ name, projectId }); |
||||
setName(""); |
||||
}; |
||||
|
||||
return ( |
||||
<Container> |
||||
<Input |
||||
size="large" |
||||
placeholder="新建看板名称" |
||||
onPressEnter={sumbit} |
||||
value={name} |
||||
onChange={(evt) => setName(evt.target.value)} |
||||
/> |
||||
</Container> |
||||
); |
||||
}; |
||||
|
||||
export default React.memo(CreateKanban); |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
import { Card, Input } from "antd"; |
||||
import React, { useEffect, useState } from "react"; |
||||
import { useProjectIdInUrl } from "../../../hook/useKanban"; |
||||
import { useAddTask, useTasksQueryKey } from "../../../hook/useTask"; |
||||
|
||||
const CreateTask = ({ kanbanId }: { kanbanId: number }) => { |
||||
const [name, setName] = useState(""); |
||||
const { mutateAsync: addTask } = useAddTask(useTasksQueryKey()); |
||||
const projectId = useProjectIdInUrl(); |
||||
const [inputMode, setInputMode] = useState(false); |
||||
|
||||
const sumbit = async () => { |
||||
await addTask({ projectId, name, kanbanId }); |
||||
setInputMode(false); |
||||
setName(""); |
||||
}; |
||||
|
||||
const toggle = () => setInputMode((mode) => !mode); |
||||
|
||||
useEffect(() => { |
||||
if (!inputMode) setName(""); |
||||
}, [inputMode]); |
||||
|
||||
if (!inputMode) return <div onClick={toggle}>创建事务</div>; |
||||
else |
||||
return ( |
||||
<Card> |
||||
<Input |
||||
onBlur={toggle} |
||||
placeholder="需要做些什么" |
||||
autoFocus={true} |
||||
onPressEnter={sumbit} |
||||
value={name} |
||||
onChange={(evt) => setName(evt.target.value)} |
||||
/> |
||||
</Card> |
||||
); |
||||
}; |
||||
|
||||
export default React.memo(CreateTask); |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
import React, { useEffect } from "react"; |
||||
import { useForm } from "antd/es/form/Form"; |
||||
import { useEditTask, useTaskModal } from "../../../hook/useTask"; |
||||
import { Form, Input, Modal } from "antd"; |
||||
import UserSelect from "../../../components/UserSelect"; |
||||
import TaskTypeSelect from "../../../components/TaskTypeSelect"; |
||||
|
||||
const layout = { |
||||
labelCol: { span: 8 }, |
||||
wrapperCol: { span: 16 }, |
||||
}; |
||||
|
||||
const TaskModal = () => { |
||||
const [form] = useForm(); |
||||
const { editingTaskId, editingTask, close } = useTaskModal(); |
||||
const { mutateAsync: editTask, isLoading: editLoading } = useEditTask(); |
||||
|
||||
const onCancel = () => { |
||||
close(); |
||||
form.resetFields(); |
||||
}; |
||||
|
||||
const onOk = async () => { |
||||
await editTask({ ...editingTask, ...form.getFieldsValue() }); |
||||
close(); |
||||
}; |
||||
|
||||
useEffect(() => { |
||||
form.setFieldsValue(editingTask); |
||||
}, [form, editingTask]); |
||||
|
||||
return ( |
||||
<Modal |
||||
forceRender={true} |
||||
onCancel={onCancel} |
||||
onOk={onOk} |
||||
okText="确认" |
||||
cancelText="取消" |
||||
confirmLoading={editLoading} |
||||
title="编辑任务" |
||||
visible={!!editingTaskId} |
||||
> |
||||
<Form {...layout} initialValues={editingTask} form={form}> |
||||
<Form.Item |
||||
label="任务名" |
||||
name="name" |
||||
rules={[{ required: true, message: "请输入任务名" }]} |
||||
> |
||||
<Input /> |
||||
</Form.Item> |
||||
<Form.Item label="经办人" name="processorId"> |
||||
<UserSelect defaultOptionName="经办人" /> |
||||
</Form.Item> |
||||
<Form.Item label="类型" name="typeId"> |
||||
<TaskTypeSelect /> |
||||
</Form.Item> |
||||
</Form> |
||||
</Modal> |
||||
); |
||||
}; |
||||
|
||||
export default React.memo(TaskModal); |
@ -0,0 +1,11 @@
@@ -0,0 +1,11 @@
|
||||
import React, { useState } from "react"; |
||||
import { useAddTask, useTasksQueryKey } from "../../../hook/useTask"; |
||||
|
||||
const CreateTask = () => { |
||||
const [name, setName] = useState(""); |
||||
// const { data, isLoading } = useAddTask(useTasksQueryKey())
|
||||
|
||||
return <div></div> |
||||
}; |
||||
|
||||
export default React.memo(CreateTask); |
Loading…
Reference in new issue