
--- client/views/pages/adm/preferences/commonCodeManagement/CommonCodeManagement.vue
+++ client/views/pages/adm/preferences/commonCodeManagement/CommonCodeManagement.vue
... | ... | @@ -84,7 +84,7 @@ |
84 | 84 |
<button :class="{ |
85 | 85 |
'btn sm': true, |
86 | 86 |
'red': !isFormDisabled, |
87 |
- }" :disabled="isFormDisabled" @click="fnDel" v-if="pageAuth.delAuthrt == 'Y' && originCode != null"> |
|
87 |
+ }" :disabled="isFormDisabled" @click="fnDel" v-if="pageAuth.delAuthrt == 'Y' && originCode.cd != null"> |
|
88 | 88 |
삭제 |
89 | 89 |
</button> |
90 | 90 |
</div> |
... | ... | @@ -95,6 +95,7 @@ |
95 | 95 |
</template> |
96 | 96 |
|
97 | 97 |
<script> |
98 |
+import _ from "lodash"; |
|
98 | 99 |
import draggable from "vuedraggable"; |
99 | 100 |
import Hierachy from "../../../../component/hierachy/HierachyDraggable.vue"; |
100 | 101 |
|
... | ... | @@ -121,8 +122,8 @@ |
121 | 122 |
iconPath: 'ico_folder_3d', |
122 | 123 |
selectedCd: null, // 선택된 코드 |
123 | 124 |
newCode: {}, // 신규 코드 등록 |
124 |
- viewCode: {}, // 사용자에게 보여질 코드 |
|
125 |
- originCode: null, // 변경전 코드 |
|
125 |
+ viewCode: {cd: null}, // 사용자에게 보여질 코드 |
|
126 |
+ originCode: {cd: null}, // 변경전 코드 |
|
126 | 127 |
|
127 | 128 |
submitStts: true, |
128 | 129 |
}; |
... | ... | @@ -153,6 +154,10 @@ |
153 | 154 |
} |
154 | 155 |
}, |
155 | 156 |
fnViewDetail(cd) { |
157 |
+ // 내용이 변경된 경우 |
|
158 |
+ if(this.isChanged()) { |
|
159 |
+ return; |
|
160 |
+ } |
|
156 | 161 |
this.selectedCd = cd; |
157 | 162 |
this.findByCd(); |
158 | 163 |
}, |
... | ... | @@ -164,7 +169,7 @@ |
164 | 169 |
const res = await findByCd(params); |
165 | 170 |
if (res.status == 200) { |
166 | 171 |
this.viewCode = res.data.data.code; |
167 |
- this.originCode = this.viewCode.cd; |
|
172 |
+ this.originCode = _.cloneDeep(this.viewCode); // 변경전 코드 |
|
168 | 173 |
this.submitStts = false; |
169 | 174 |
} |
170 | 175 |
} catch (error) { |
... | ... | @@ -182,11 +187,18 @@ |
182 | 187 |
alert("시스템에서 제공하는 정보는 수정할 수 없습니다."); |
183 | 188 |
return; |
184 | 189 |
} |
190 |
+ |
|
191 |
+ // 변경전 코드와 비교 |
|
192 |
+ if(_.isEqual(this.viewCode, this.originCode)) { |
|
193 |
+ alert("변경할 내용이 없습니다."); |
|
194 |
+ return false; |
|
195 |
+ } |
|
196 |
+ |
|
185 | 197 |
// 유효성 검사 |
186 | 198 |
if (this.validation() == false) { |
187 | 199 |
return false; |
188 | 200 |
} |
189 |
- this.viewCode.originCd = this.originCode; |
|
201 |
+ this.viewCode.originCd = this.originCode.cd; |
|
190 | 202 |
// 신규 등록 및 수정 설정 |
191 | 203 |
const action = this.viewCode.originCd ? update : save; |
192 | 204 |
try { |
... | ... | @@ -239,14 +251,18 @@ |
239 | 251 |
}, |
240 | 252 |
// 최상위 신규 객체 생성 |
241 | 253 |
topAdd() { |
242 |
- if (this.selectedCd != null) { |
|
243 |
- if (!confirm("작성 중인 공통코드정보는 저장되지 않습니다.\n계속 하시겠습니까?")) { |
|
244 |
- return; |
|
245 |
- } |
|
254 |
+ // 내용이 변경된 경우 |
|
255 |
+ if(this.isChanged()) { |
|
256 |
+ return; |
|
246 | 257 |
} |
258 |
+ // if (this.selectedCd != null) { |
|
259 |
+ // if (!confirm("작성 중인 공통코드정보는 저장되지 않습니다.\n계속 하시겠습니까?")) { |
|
260 |
+ // return; |
|
261 |
+ // } |
|
262 |
+ // } |
|
247 | 263 |
this.selectedCd = null; // 선택된 코드 초기화 |
248 |
- this.viewCode = JSON.parse(JSON.stringify(this.newCode)); |
|
249 |
- this.originCode = this.viewCode.cd; // null |
|
264 |
+ this.viewCode = _.cloneDeep(this.newCode); |
|
265 |
+ this.originCode = _.cloneDeep(this.viewCode); // 변경전 코드 |
|
250 | 266 |
this.submitStts = true; |
251 | 267 |
}, |
252 | 268 |
// 하위 신규 객체 생성 |
... | ... | @@ -256,16 +272,20 @@ |
256 | 272 |
alert("상위 코드를 지정하세요."); |
257 | 273 |
return; |
258 | 274 |
} else { |
259 |
- if (!confirm("작성 중인 공통코드정보는 저장되지 않습니다.\n계속 하시겠습니까?")) { |
|
275 |
+ // 내용이 변경된 경우 |
|
276 |
+ if(this.isChanged()) { |
|
260 | 277 |
return; |
261 | 278 |
} |
279 |
+ // if (!confirm("작성 중인 공통코드정보는 저장되지 않습니다.\n계속 하시겠습니까?")) { |
|
280 |
+ // return; |
|
281 |
+ // } |
|
262 | 282 |
} |
263 | 283 |
const upCd = this.viewCode.cd; |
264 | 284 |
const upCdNm = this.viewCode.cdNm; |
265 |
- this.viewCode = JSON.parse(JSON.stringify(this.newCode)); |
|
285 |
+ this.viewCode = _.cloneDeep(this.newCode); |
|
266 | 286 |
this.viewCode.upCd = upCd; |
267 | 287 |
this.viewCode.upCdNm = upCdNm; |
268 |
- this.originCode = null; |
|
288 |
+ this.originCode = _.cloneDeep(this.viewCode); // 변경전 코드 |
|
269 | 289 |
this.submitStts = true; |
270 | 290 |
}, |
271 | 291 |
validation() { |
... | ... | @@ -289,7 +309,8 @@ |
289 | 309 |
// axios: 목록 수정 |
290 | 310 |
async fnListUpdate() { |
291 | 311 |
try { |
292 |
- if (!confirm("공통코드 목록을 저장하시겠습니까?\n 작성 중인 공통코드정보는 저장되지 않습니다.")) { |
|
312 |
+ // 내용이 변경된 경우 |
|
313 |
+ if(this.isChanged()) { |
|
293 | 314 |
return; |
294 | 315 |
} |
295 | 316 |
const res = await updateListProc(this.codeList); |
... | ... | @@ -307,6 +328,16 @@ |
307 | 328 |
} |
308 | 329 |
} |
309 | 330 |
}, |
331 |
+ |
|
332 |
+ // 변경 감지 |
|
333 |
+ isChanged() { |
|
334 |
+ if(!_.isEqual(this.viewCode, this.originCode)) { |
|
335 |
+ if (!confirm("작성 중인 공통코드정보는 저장되지 않습니다.\n계속 하시겠습니까?")) { |
|
336 |
+ return true; |
|
337 |
+ } |
|
338 |
+ } |
|
339 |
+ return false; |
|
340 |
+ } |
|
310 | 341 |
}, |
311 | 342 |
watch: {}, |
312 | 343 |
computed: { |
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?