Skip to content

Commit 46ec546

Browse files
authored
Merge pull request #109 from TaskFlow-CLAP/CLAP-298
CLAP-298 요청 수정 재요청 API 연결
2 parents 80380f6 + 97fbff8 commit 46ec546

File tree

13 files changed

+217
-34
lines changed

13 files changed

+217
-34
lines changed

src/api/admin.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export const deleteCategoryAdmin = async (id: number) => {
2626
}
2727

2828
export const addMemberAdmin = async (memberData: UserRegistrationProps) => {
29-
console.log(memberData, '요청 데이터')
3029
const response = await axiosInstance.post('/api/managements/members', memberData)
3130
return response.data
3231
}

src/api/user.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { Status } from '@/types/common'
22
import type { RequestApprovePostTypes } from '@/types/manager'
3+
import type { userInfo } from '@/types/user'
34
import { axiosInstance, formDataAxiosInstance } from '@/utils/axios'
45

56
export const postTaskRequest = async (formdata: FormData) => {
@@ -53,21 +54,26 @@ export const getHistory = async (taskID: number) => {
5354
}
5455

5556
export const postComment = async (taskID: number, content: string) => {
56-
const response = await axiosInstance.post(`/api/comment/${taskID}`, { content })
57+
const response = await axiosInstance.post(`/api/comments/${taskID}`, { content })
5758
return response.data
5859
}
5960

6061
export const postCommentAttachment = async (taskID: number, formdata: FormData) => {
61-
const response = await formDataAxiosInstance.post(`/api/comment/attachment/${taskID}`, formdata)
62+
const response = await formDataAxiosInstance.post(`/api/comments/attachment/${taskID}`, formdata)
6263
return response.data
6364
}
6465

6566
export const patchComment = async (commentId: number, content: string) => {
66-
const response = await axiosInstance.patch(`/api/comment/${commentId}`, { content })
67+
const response = await axiosInstance.patch(`/api/comments/${commentId}`, { content })
6768
return response.data
6869
}
6970

7071
export const deleteComment = async (commentId: number) => {
71-
const response = await axiosInstance.delete(`/api/comment/${commentId}`)
72+
const response = await axiosInstance.delete(`/api/comments/${commentId}`)
73+
return response.data
74+
}
75+
76+
export const patchTaskRequest = async (taskId: string, formdata: FormData) => {
77+
const response = await formDataAxiosInstance.patch(`/api/tasks/${taskId}`, formdata)
7278
return response.data
7379
}

src/assets/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
body {
1313
font-family: 'SUIT-Variable', sans-serif;
14-
color: #18181B;
14+
color: #18181b;
1515
}
1616

1717
.shadow-custom {
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<template>
2+
<div class="w-full flex flex-col gap-y-6">
3+
<CategoryDropDown
4+
v-model="category1"
5+
:options="mainCategoryArr"
6+
:label-name="'1차 카테고리'"
7+
:placeholderText="'1차 카테고리를 선택해주세요'"
8+
:isDisabled="false" />
9+
<CategoryDropDown
10+
v-model="category2"
11+
:options="afterSubCategoryArr"
12+
:label-name="'2차 카테고리'"
13+
:placeholderText="'2차 카테고리를 선택해주세요'"
14+
:isDisabled="!category1" />
15+
<RequestTaskInput
16+
v-model="title"
17+
:placeholderText="'제목을 입력해주세요'"
18+
:label-name="'제목'"
19+
:is-invalidate="isInvalidate" />
20+
<RequestTaskTextArea
21+
v-model="description"
22+
:placeholderText="'부가 정보를 입력해주세요'" />
23+
<RequestTaskFileInput v-model="file" />
24+
<FormButtonContainer
25+
:handleCancel="handleCancel"
26+
:handleSubmit="handleSubmit"
27+
cancelText="취소"
28+
submitText="요청" />
29+
<ModalView
30+
:isOpen="isModalVisible"
31+
:type="'successType'"
32+
@close="handleCancel">
33+
<template #header>작업이 요청되었습니다</template>
34+
</ModalView>
35+
</div>
36+
</template>
37+
38+
<script lang="ts" setup>
39+
import { getMainCategory, getSubCategory } from '@/api/common'
40+
import { getTaskDetailUser, patchTaskRequest, postTaskRequest } from '@/api/user'
41+
import type { Category, SubCategory } from '@/types/common'
42+
import type { AttachmentResponse } from '@/types/user'
43+
import { onMounted, ref, watch } from 'vue'
44+
import { useRouter } from 'vue-router'
45+
import FormButtonContainer from '../common/FormButtonContainer.vue'
46+
import ModalView from '../ModalView.vue'
47+
import CategoryDropDown from './CategoryDropDown.vue'
48+
import RequestTaskFileInput from './RequestTaskFileInput.vue'
49+
import RequestTaskInput from './RequestTaskInput.vue'
50+
import RequestTaskTextArea from './RequestTaskTextArea.vue'
51+
52+
const category1 = ref<Category | null>(null)
53+
const category2 = ref<Category | null>(null)
54+
55+
const title = ref('')
56+
const description = ref('')
57+
const file = ref(null as File[] | null)
58+
const isInvalidate = ref('')
59+
const isModalVisible = ref(false)
60+
61+
const mainCategoryArr = ref<Category[]>([])
62+
const subCategoryArr = ref<SubCategory[]>([])
63+
const afterSubCategoryArr = ref<SubCategory[]>([])
64+
const initFileArr = ref<AttachmentResponse[]>([])
65+
const isFirst = ref(true)
66+
67+
const { id, reqType } = defineProps<{ id: string; reqType: string }>()
68+
console.log(reqType, id, '가져온 값')
69+
70+
const router = useRouter()
71+
72+
const handleCancel = () => {
73+
router.back()
74+
}
75+
76+
onMounted(async () => {
77+
mainCategoryArr.value = await getMainCategory()
78+
subCategoryArr.value = await getSubCategory()
79+
afterSubCategoryArr.value = await getSubCategory()
80+
const data = await getTaskDetailUser(Number(id))
81+
console.log(data, '데이터')
82+
const selected = mainCategoryArr.value.find(ct => ct.name === data.mainCategoryName) || null
83+
category1.value = selected
84+
category2.value = subCategoryArr.value.find(ct => ct.name === data.categoryName) || null
85+
afterSubCategoryArr.value = subCategoryArr.value.filter(
86+
subCategory => subCategory.mainCategoryId === selected?.id
87+
)
88+
title.value = data.title
89+
description.value = data.description
90+
file.value = data.attachmentResponses.map((attachment: AttachmentResponse) => {
91+
return new File([attachment.fileUrl], attachment.fileName, { type: 'application/pdf' })
92+
})
93+
initFileArr.value = data.attachmentResponses
94+
})
95+
96+
watch(category1, async newValue => {
97+
if (isFirst.value) {
98+
isFirst.value = false
99+
} else {
100+
category2.value = null
101+
}
102+
afterSubCategoryArr.value = subCategoryArr.value.filter(
103+
subCategory => subCategory.mainCategoryId === newValue?.id
104+
)
105+
})
106+
107+
const handleSubmit = async () => {
108+
if (!category2.value) {
109+
isInvalidate.value = 'category'
110+
return
111+
} else if (!title.value) {
112+
isInvalidate.value = 'input'
113+
return
114+
}
115+
const formData = new FormData()
116+
117+
const attachmentsToDelete = initFileArr.value
118+
.filter(initFile => !file.value?.some(f => f.name === initFile.fileName))
119+
.map(initFile => initFile.fileId)
120+
121+
const taskInfo = {
122+
categoryId: category2.value.id,
123+
title: title.value,
124+
description: description.value
125+
}
126+
127+
const taskInfoEdit = {
128+
...taskInfo,
129+
attachmentsToDelete: attachmentsToDelete
130+
}
131+
132+
console.log(taskInfoEdit, '뭘 삭제할건지')
133+
134+
const jsonTaskInfo = JSON.stringify(taskInfoEdit)
135+
const newBlob = new Blob([jsonTaskInfo], { type: 'application/json' })
136+
formData.append('taskInfo', newBlob)
137+
138+
if (file.value && file.value.length > 0 && reqType === 'edit') {
139+
const newFiles = file.value.filter(
140+
f => !initFileArr.value.some(initFile => initFile.fileName === f.name)
141+
)
142+
newFiles.forEach(f => {
143+
console.log('첨부 파일:', f)
144+
formData.append('attachment', f)
145+
})
146+
} else {
147+
file.value?.forEach(f => {
148+
console.log('첨부 파일:', f)
149+
formData.append('attachment', f)
150+
})
151+
}
152+
153+
try {
154+
if (reqType === 're') {
155+
await postTaskRequest(formData)
156+
} else {
157+
await patchTaskRequest(id, formData)
158+
}
159+
isModalVisible.value = true
160+
} catch (error) {
161+
console.error('요청 실패:', error)
162+
}
163+
}
164+
</script>

src/components/task-detail/TaskDetail.vue

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
:is-approved="data?.taskStatus !== 'REQUESTED'"
77
:close-task-detail="closeTaskDetail"
88
:id="data?.taskId || 0"
9-
:isProcessor="data?.processorNickName === info.nickname || info.memberRole === 'ROLE_'"
9+
:isProcessor="data?.processorNickName === info.nickname || info.role === 'ROLE_MANAGER'"
1010
:isRequestor="data?.requesterNickName === info.nickname" />
1111
<div
1212
class="w-full flex gap-6"
@@ -43,12 +43,11 @@ const { closeTaskDetail, selectedId } = defineProps<TaskDetailProps>()
4343
4444
const memberStore = useMemberStore()
4545
const { info } = storeToRefs(memberStore)
46-
console.log(info, '인포')
4746
4847
const { data } = useQuery<TaskDetailDatas>({
4948
queryKey: ['taskDetailUser', selectedId],
5049
queryFn:
51-
info.value.memberRole === 'ROLE_USER'
50+
info.value.role === 'ROLE_USER'
5251
? () => getTaskDetailUser(selectedId)
5352
: () => getTaskDetailManager(selectedId)
5453
})
@@ -57,6 +56,4 @@ const { data: historyData } = useQuery<TaskDetailHistoryData>({
5756
queryKey: ['historyData', selectedId],
5857
queryFn: () => getHistory(selectedId)
5958
})
60-
61-
console.log(historyData.value, '가져온 히스ㅇ토리', selectedId, '선택된 id')
6259
</script>

src/components/task-detail/TaskDetailHistoryChat.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@
3333
<div
3434
v-if="isClicked"
3535
@click="deleteCommentText"
36-
:class="[
36+
:class="[
3737
'absolute shadow-custom bottom-0 w-20 h-7 flex items-center justify-center text-xs text-red-1 bg-white hover:bg-background-1',
3838
isProcessor ? 'right-6' : 'left-6'
39-
]">
39+
]">
4040
삭제
4141
</div>
4242
</div>
@@ -73,7 +73,9 @@ const clickMenuDot = async () => {
7373
7474
const deleteCommentText = async () => {
7575
isClicked.value = !isClicked.value
76-
await deleteComment(history.historyId)
76+
if (history.details.commentDetails?.commentId !== undefined) {
77+
await deleteComment(history.details.commentDetails.commentId)
78+
}
7779
queryClient.invalidateQueries({ queryKey: ['historyData', taskId] })
7880
}
7981
</script>

src/components/task-detail/TaskDetailLeft.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
</div>
1515
<div>
1616
<p class="task-detail">부가 설명</p>
17-
<p class="px-6 py-4 bg-primary2 rounded-lg font-normal min-h-[120px]">{{ data.description }}</p>
17+
<p class="px-6 py-4 bg-primary2 rounded-lg font-normal min-h-[120px]">
18+
{{ data.description }}
19+
</p>
1820
</div>
1921
<div>
2022
<p class="task-detail">첨부 파일</p>

src/components/task-detail/TaskDetailTopBar.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
<div class="flex gap-4 text-sm font-bold pb-6">
44
<div
55
v-if="isApproved && isRequestor"
6+
@click="router.push(`/task-request?requestType=re&id=${id}`)"
67
class="flex gap-1 items-center cursor-pointer">
78
<CommonIcons :name="reRequestIcon" />
89
<p class="text-body">재요청</p>
910
</div>
1011
<div
1112
v-if="!isApproved && isRequestor"
13+
@click="router.push(`/task-request?requestType=edit&id=${id}`)"
1214
class="flex gap-1 items-center cursor-pointer">
1315
<CommonIcons :name="modificationIcon" />
1416
<p class="text-primary1">요청 수정</p>
@@ -77,6 +79,4 @@ const ApproveTask = () => {
7779
toggleModal('approve')
7880
router.push(`/request-approve/${id}`)
7981
}
80-
81-
console.log(isProcessor, '이즈 프로세서 값')
8282
</script>

src/components/task-detail/TaskStatusList.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ const changeStatus = async (newStatus: Status) => {
114114
return
115115
}
116116
try {
117-
const res = await patchChangeStatus(taskId || 0, newStatus)
118-
console.log(res, '상태 바꾸기')
117+
await patchChangeStatus(taskId || 0, newStatus)
119118
queryClient.invalidateQueries({ queryKey: ['historyData', taskId] })
120119
} catch (error) {
121120
console.error('Failed to update status:', error)

src/components/user-manage/UserRegistration.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,7 @@ const handleCancel = () => {
6969
}
7070
7171
const handleSubmit = async () => {
72-
console.log(userRegistrationForm.value)
7372
const formData = { ...userRegistrationForm.value, role: 'ROLE_USER', departmentId: 1 }
74-
console.log(formData, '요청정보')
7573
await addMemberAdmin(formData)
7674
isModalVisible.value = true
7775
}

0 commit comments

Comments
 (0)