PsHooN7979
08-09
240809 박세훈 게시판 수정
@6c8fd5e3292469fa246518de030bc3ddd0ccca27
--- client/views/pages/teacher/Board.vue
+++ client/views/pages/teacher/Board.vue
... | ... | @@ -153,25 +153,26 @@ |
153 | 153 |
}) |
154 | 154 |
.then(function (res) { |
155 | 155 |
console.log("dataList - response : ", res.data); |
156 |
- |
|
157 |
- vm.dataList = res.data.result[0].boardClass[0].board; |
|
158 |
- vm.userNm = res.data.result[0].userNm; |
|
159 |
- vm.userId = res.data.result[0].userId; |
|
160 |
- vm.totalPosts = res.data.totalBoard; |
|
161 |
- vm.selectClass(); |
|
162 |
- sessionStorage.removeItem("selectedBoardList"); |
|
163 |
- sessionStorage.removeItem("file"); |
|
164 |
- |
|
165 |
- console.log(vm.userId); |
|
156 |
+ if (res.data.result.length !== 0) { |
|
157 |
+ vm.dataList = res.data.result[0].boardClass[0].board; |
|
158 |
+ vm.userNm = res.data.result[0].userNm; |
|
159 |
+ vm.userId = res.data.result[0].userId; |
|
160 |
+ vm.totalPosts = res.data.totalBoard; |
|
161 |
+ vm.selectClass(); |
|
162 |
+ sessionStorage.removeItem("bbsId"); |
|
163 |
+ sessionStorage.removeItem("file"); |
|
164 |
+ } else { |
|
165 |
+ vm.selectClass(); |
|
166 |
+ } |
|
166 | 167 |
}) |
167 | 168 |
.catch(function (error) { |
168 |
- console.log("result - error : ", error); |
|
169 |
+ console.log("boardListError - error : ", error); |
|
169 | 170 |
}); |
170 | 171 |
}, |
171 | 172 |
|
172 | 173 |
// 게시글 정보 세션에 저장 |
173 | 174 |
selectBoardList(item) { |
174 |
- sessionStorage.setItem("selectedBoardList", JSON.stringify(item)); |
|
175 |
+ sessionStorage.setItem("bbsId", JSON.stringify(item.bbsId)); |
|
175 | 176 |
}, |
176 | 177 |
|
177 | 178 |
// 반 아이디 세션에 저장 |
... | ... | @@ -210,7 +211,6 @@ |
210 | 211 |
// 반 조회 |
211 | 212 |
selectClass() { |
212 | 213 |
const vm = this; |
213 |
- console.log(vm.userId); |
|
214 | 214 |
axios({ |
215 | 215 |
url: "/classes/selectClass.json", |
216 | 216 |
method: "post", |
--- client/views/pages/teacher/noticeDetail.vue
+++ client/views/pages/teacher/noticeDetail.vue
... | ... | @@ -70,6 +70,7 @@ |
70 | 70 |
|
71 | 71 |
dataList: null, |
72 | 72 |
sclsId: "", |
73 |
+ bbsId: "", |
|
73 | 74 |
|
74 | 75 |
title: "", |
75 | 76 |
content: "", |
... | ... | @@ -83,19 +84,33 @@ |
83 | 84 |
goToPage(page) { |
84 | 85 |
this.$router.push({ name: page }); |
85 | 86 |
}, |
86 |
- created() { |
|
87 |
- const vm = this; |
|
88 |
- const seletedBoardList = JSON.parse( |
|
89 |
- sessionStorage.getItem("selectedBoardList") |
|
90 |
- ); |
|
91 | 87 |
|
92 |
- if (seletedBoardList) { |
|
93 |
- vm.dataList = seletedBoardList; |
|
94 |
- } |
|
95 |
- vm.title = vm.dataList.bbsTtl; |
|
96 |
- vm.content = vm.dataList.bbsCnt; |
|
97 |
- vm.category = vm.dataList.bbsCls; |
|
98 |
- vm.time = vm.dataList.bbsTm; |
|
88 |
+ findBoard() { |
|
89 |
+ const vm = this; |
|
90 |
+ vm.bbsId = JSON.parse(sessionStorage.getItem("bbsId")); |
|
91 |
+ console.log(vm.bbsId); |
|
92 |
+ axios({ |
|
93 |
+ url: "/board/find.json", |
|
94 |
+ method: "post", |
|
95 |
+ headers: { |
|
96 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
97 |
+ }, |
|
98 |
+ data: { |
|
99 |
+ bbsId: vm.bbsId, |
|
100 |
+ }, |
|
101 |
+ }) |
|
102 |
+ .then(function (res) { |
|
103 |
+ console.log("boardData - response : ", res.data); |
|
104 |
+ vm.dataList = res.data.result[0].boardClass[0].board[0]; |
|
105 |
+ vm.title = vm.dataList.bbsTtl; |
|
106 |
+ vm.content = vm.dataList.bbsCnt; |
|
107 |
+ vm.category = vm.dataList.bbsCls; |
|
108 |
+ vm.time = vm.dataList.bbsTm; |
|
109 |
+ vm.findFile(); |
|
110 |
+ }) |
|
111 |
+ .catch(function (error) { |
|
112 |
+ console.log("boardData - error : ", error); |
|
113 |
+ }); |
|
99 | 114 |
}, |
100 | 115 |
|
101 | 116 |
findFile() { |
... | ... | @@ -136,16 +151,11 @@ |
136 | 151 |
.then(function (res) { |
137 | 152 |
console.log("dataList - response : ", res.data); |
138 | 153 |
vm.dataList = res.data[0].boardClass[0].board[0]; |
139 |
- sessionStorage.setItem( |
|
140 |
- "selectedBoardList", |
|
141 |
- JSON.stringify(vm.dataList) |
|
142 |
- ); |
|
143 | 154 |
vm.title = vm.dataList.bbsTtl; |
144 | 155 |
vm.content = vm.dataList.bbsCnt; |
145 | 156 |
vm.category = vm.dataList.bbsCls; |
146 | 157 |
vm.time = vm.dataList.bbsTm; |
147 | 158 |
vm.findFile(); |
148 |
- console.log(vm.dataList); |
|
149 | 159 |
}) |
150 | 160 |
.catch(function (error) { |
151 | 161 |
console.log("result - error : ", error); |
... | ... | @@ -169,16 +179,11 @@ |
169 | 179 |
.then(function (res) { |
170 | 180 |
console.log("dataList - response : ", res.data); |
171 | 181 |
vm.dataList = res.data[0].boardClass[0].board[0]; |
172 |
- sessionStorage.setItem( |
|
173 |
- "selectedBoardList", |
|
174 |
- JSON.stringify(vm.dataList) |
|
175 |
- ); |
|
176 | 182 |
vm.title = vm.dataList.bbsTtl; |
177 | 183 |
vm.content = vm.dataList.bbsCnt; |
178 | 184 |
vm.category = vm.dataList.bbsCls; |
179 | 185 |
vm.time = vm.dataList.bbsTm; |
180 | 186 |
vm.findFile(); |
181 |
- console.log(vm.dataList); |
|
182 | 187 |
}) |
183 | 188 |
.catch(function (error) { |
184 | 189 |
console.log("result - error : ", error); |
... | ... | @@ -213,8 +218,7 @@ |
213 | 218 |
}, |
214 | 219 |
mounted() { |
215 | 220 |
console.log("Main2 mounted"); |
216 |
- this.created(); |
|
217 |
- this.findFile(); |
|
221 |
+ this.findBoard(); |
|
218 | 222 |
}, |
219 | 223 |
}; |
220 | 224 |
</script> |
--- client/views/pages/teacher/noticeInsert.vue
+++ client/views/pages/teacher/noticeInsert.vue
... | ... | @@ -14,13 +14,18 @@ |
14 | 14 |
<div class="flex align-center"> |
15 | 15 |
<label for="file" class="title2">첨부파일</label> |
16 | 16 |
<label for="file" class="title2"> {{ file.fileNm }}</label> |
17 |
- <input type="file" ref="fileInput" @change="handleFileUpload" /> |
|
17 |
+ <input |
|
18 |
+ type="file" |
|
19 |
+ ref="fileInput" |
|
20 |
+ @change="handleFileUpload" |
|
21 |
+ multiple |
|
22 |
+ /> |
|
18 | 23 |
</div> |
19 | 24 |
<div class="flex justify-between mt50"> |
20 | 25 |
<button title="글쓰기" class="new-btn" @click="goToPage('Board')"> |
21 | 26 |
목록 |
22 | 27 |
</button> |
23 |
- <button title="글쓰기" class="new-btn" @click="goToPage('Board')"> |
|
28 |
+ <button title="글쓰기" class="new-btn"> |
|
24 | 29 |
{{ buttonLabel }} |
25 | 30 |
</button> |
26 | 31 |
</div> |
... | ... | @@ -43,8 +48,10 @@ |
43 | 48 |
category: "Notice", |
44 | 49 |
file: "", |
45 | 50 |
sclsId: "", |
51 |
+ bbsId: "", |
|
52 |
+ fileMngId: null, |
|
46 | 53 |
|
47 |
- selectedFile: null, |
|
54 |
+ selectedFiles: [], |
|
48 | 55 |
dataList: "", |
49 | 56 |
|
50 | 57 |
// 데이터 편집 상태 (true = 수정, false = 등록) |
... | ... | @@ -57,57 +64,89 @@ |
57 | 64 |
}, |
58 | 65 |
|
59 | 66 |
handleFileUpload(e) { |
60 |
- this.selectedFile = e.target.files[0]; |
|
61 |
- console.log(this.selectedFile); |
|
67 |
+ this.selectedFiles = e.target.files; |
|
62 | 68 |
}, |
63 | 69 |
|
64 | 70 |
created() { |
65 | 71 |
const vm = this; |
66 | 72 |
const sclsId = JSON.parse(sessionStorage.getItem("sclsId")); |
67 |
- const dataList = JSON.parse(sessionStorage.getItem("selectedBoardList")); |
|
73 |
+ const bbsId = JSON.parse(sessionStorage.getItem("bbsId")); |
|
68 | 74 |
const file = JSON.parse(sessionStorage.getItem("file")); |
69 | 75 |
|
70 | 76 |
if (sclsId) { |
71 | 77 |
vm.sclsId = sclsId; |
72 |
- if (dataList && file) { |
|
73 |
- vm.dataList = dataList; |
|
78 |
+ if (bbsId && file) { |
|
79 |
+ vm.bbsId = bbsId; |
|
74 | 80 |
vm.file = file; |
75 |
- vm.title = vm.dataList.bbsTtl; |
|
76 |
- vm.content = vm.dataList.bbsCnt; |
|
77 |
- vm.category = vm.dataList.bbsCls; |
|
81 |
+ vm.fileMngId = file.fileMngId; |
|
78 | 82 |
vm.isEditMode = true; |
83 |
+ vm.findBoard(); |
|
79 | 84 |
} else { |
80 | 85 |
vm.isEditMode = false; |
81 | 86 |
} |
82 | 87 |
} |
83 | 88 |
}, |
89 |
+ |
|
90 |
+ // 게시글 상세 조회 |
|
91 |
+ findBoard() { |
|
92 |
+ const vm = this; |
|
93 |
+ vm.bbsId = JSON.parse(sessionStorage.getItem("bbsId")); |
|
94 |
+ console.log(vm.bbsId); |
|
95 |
+ axios({ |
|
96 |
+ url: "/board/find.json", |
|
97 |
+ method: "post", |
|
98 |
+ headers: { |
|
99 |
+ "Content-Type": "application/json; charset=UTF-8", |
|
100 |
+ }, |
|
101 |
+ data: { |
|
102 |
+ bbsId: vm.bbsId, |
|
103 |
+ }, |
|
104 |
+ }) |
|
105 |
+ .then(function (res) { |
|
106 |
+ console.log("boardData - response : ", res.data); |
|
107 |
+ vm.dataList = res.data.result[0].boardClass[0].board[0]; |
|
108 |
+ vm.title = vm.dataList.bbsTtl; |
|
109 |
+ vm.content = vm.dataList.bbsCnt; |
|
110 |
+ vm.category = vm.dataList.bbsCls; |
|
111 |
+ vm.time = vm.dataList.bbsTm; |
|
112 |
+ }) |
|
113 |
+ .catch(function (error) { |
|
114 |
+ console.log("boardData - error : ", error); |
|
115 |
+ }); |
|
116 |
+ }, |
|
117 |
+ |
|
84 | 118 |
// 게시글 등록 |
85 | 119 |
async dataInsert() { |
86 | 120 |
const vm = this; |
87 | 121 |
try { |
88 | 122 |
// 파일 업로드 |
89 |
- const formData = new FormData(); |
|
90 |
- formData.append("files", this.selectedFile); |
|
91 |
- |
|
92 |
- const fileUploadResponse = await axios.post( |
|
93 |
- "/file/upload.json", |
|
94 |
- formData, |
|
95 |
- { |
|
96 |
- headers: { |
|
97 |
- "Content-Type": "multipart/form-data", |
|
98 |
- }, |
|
123 |
+ if (this.selectedFiles && this.selectedFiles.length > 0) { |
|
124 |
+ // 파일 업로드 |
|
125 |
+ const formData = new FormData(); |
|
126 |
+ for (let i = 0; i < this.selectedFiles.length; i++) { |
|
127 |
+ formData.append("files", this.selectedFiles[i]); |
|
99 | 128 |
} |
100 |
- ); |
|
101 | 129 |
|
102 |
- // 업로드 후 파일 매니지 아이디 호출 |
|
103 |
- const fileMngId = fileUploadResponse.data.fileMngId; |
|
130 |
+ const fileUploadResponse = await axios.post( |
|
131 |
+ "/file/upload.json", |
|
132 |
+ formData, |
|
133 |
+ { |
|
134 |
+ headers: { |
|
135 |
+ "Content-Type": "multipart/form-data", |
|
136 |
+ }, |
|
137 |
+ } |
|
138 |
+ ); |
|
139 |
+ |
|
140 |
+ // 업로드 후 파일 매니지 아이디 호출 |
|
141 |
+ fileMngId = fileUploadResponse.data.fileMngId; |
|
142 |
+ } |
|
104 | 143 |
|
105 | 144 |
// 게시물 등록 |
106 | 145 |
const newData = { |
107 | 146 |
bbsTtl: vm.title, |
108 | 147 |
bbsCls: vm.category, |
109 | 148 |
bbsCnt: vm.content, |
110 |
- fileMngId: fileMngId, |
|
149 |
+ fileMngId: vm.fileMngId, |
|
111 | 150 |
sclsId: vm.sclsId, |
112 | 151 |
}; |
113 | 152 |
|
... | ... | @@ -126,29 +165,33 @@ |
126 | 165 |
const vm = this; |
127 | 166 |
|
128 | 167 |
// 파일 업로드 |
129 |
- const formData = new FormData(); |
|
130 |
- formData.append("files", this.selectedFile); |
|
131 |
- |
|
132 |
- const fileUploadResponse = await axios.post( |
|
133 |
- "/file/upload.json", |
|
134 |
- formData, |
|
135 |
- { |
|
136 |
- headers: { |
|
137 |
- "Content-Type": "multipart/form-data", |
|
138 |
- }, |
|
168 |
+ if (this.selectedFiles && this.selectedFiles.length > 0) { |
|
169 |
+ // 파일 업로드 |
|
170 |
+ const formData = new FormData(); |
|
171 |
+ for (let i = 0; i < this.selectedFiles.length; i++) { |
|
172 |
+ formData.append("files", this.selectedFiles[i]); |
|
139 | 173 |
} |
140 |
- ); |
|
141 | 174 |
|
142 |
- // 업로드 후 파일 매니지 아이디 호출 |
|
143 |
- const fileMngId = fileUploadResponse.data.fileMngId; |
|
175 |
+ const fileUploadResponse = await axios.post( |
|
176 |
+ "/file/upload.json", |
|
177 |
+ formData, |
|
178 |
+ { |
|
179 |
+ headers: { |
|
180 |
+ "Content-Type": "multipart/form-data", |
|
181 |
+ }, |
|
182 |
+ } |
|
183 |
+ ); |
|
184 |
+ |
|
185 |
+ // 업로드 후 파일 매니지 아이디 호출 |
|
186 |
+ fileMngId = fileUploadResponse.data.fileMngId; |
|
187 |
+ } |
|
144 | 188 |
|
145 | 189 |
const newData = { |
146 | 190 |
bbsTtl: vm.title, |
147 | 191 |
bbsCls: vm.category, |
148 | 192 |
bbsCnt: vm.content, |
149 |
- fileMngId: fileMngId, |
|
150 |
- sclsId: vm.sclsId, |
|
151 |
- bbsId: this.dataList.bbsId, |
|
193 |
+ fileMngId: vm.fileMngId, |
|
194 |
+ bbsId: vm.bbsId, |
|
152 | 195 |
}; |
153 | 196 |
await axios({ |
154 | 197 |
url: "/board/update.json", |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?