3030 cancelText =" 취소"
3131 submitText =" 요청" />
3232 <ModalView
33- :isOpen =" isModalVisible"
33+ :isOpen =" isModalVisible === 'success' "
3434 :type =" 'successType'"
3535 @close =" handleCancel" >
3636 <template #header >작업이 요청되었습니다</template >
3737 </ModalView >
38+ <ModalView
39+ :isOpen =" isModalVisible === 'fail'"
40+ :type =" 'failType'"
41+ @close =" handleCancel" >
42+ <template #header >작업요청을 실패했습니다</template >
43+ <template #body >잠시후 시도해주세요</template >
44+ </ModalView >
3845 </div >
3946</template >
4047
@@ -58,7 +65,8 @@ const title = ref('')
5865const description = ref (' ' )
5966const file = ref (null as File [] | null )
6067const isInvalidate = ref (' ' )
61- const isModalVisible = ref (false )
68+ const isModalVisible = ref (' ' )
69+ const isSubmitting = ref (false )
6270
6371const mainCategoryArr = ref <Category []>([])
6472const subCategoryArr = ref <SubCategory []>([])
@@ -92,10 +100,13 @@ const handleCancel = () => {
92100 title .value = ' '
93101 description .value = ' '
94102 file .value = []
103+ isModalVisible .value = ' '
95104 router .back ()
96105}
97106
98107const handleSubmit = async () => {
108+ if (isSubmitting .value || isModalVisible .value ) return
109+
99110 if (! category1 .value || ! category2 .value ) {
100111 isInvalidate .value = ' category'
101112 return
@@ -109,26 +120,30 @@ const handleSubmit = async () => {
109120 isInvalidate .value = ' description'
110121 return
111122 }
123+
124+ isSubmitting .value = true
125+
112126 const formData = new FormData ()
113127 const taskInfo = {
114128 categoryId: category2 .value .subCategoryId ,
115129 title: title .value ,
116130 description: description .value
117131 }
118-
119132 const jsonTaskInfo = JSON .stringify (taskInfo )
120133 const newBlob = new Blob ([jsonTaskInfo ], { type: ' application/json' })
121-
122134 formData .append (' taskInfo' , newBlob )
123135
124136 if (file .value && file .value .length > 0 ) {
125137 file .value .forEach (f => formData .append (' attachment' , f ))
126138 }
127139 try {
128140 await postTaskRequest (formData )
129- isModalVisible .value = true
130- } catch (error ) {
131- console .error (' 요청 실패:' , error )
141+ isModalVisible .value = ' success'
142+ } catch (e ) {
143+ console .error (e )
144+ isModalVisible .value = ' fail'
145+ } finally {
146+ isSubmitting .value = false
132147 }
133148}
134149 </script >
0 commit comments