parent
0c11901e28
commit
19a7d7c3a8
@ -0,0 +1,102 @@
|
||||
<script setup>
|
||||
import { defineProps, ref, onMounted, onBeforeUnmount } from 'vue'
|
||||
import * as bootstrap from 'bootstrap'
|
||||
|
||||
const props = defineProps({
|
||||
modalId: String,
|
||||
dto: Object,
|
||||
})
|
||||
|
||||
const modalEl = ref(null)
|
||||
let bsModal = null
|
||||
let dataList = []
|
||||
let columnList = []
|
||||
|
||||
onMounted(() => {
|
||||
if (modalEl.value) {
|
||||
// 인스턴스가 있으면 재사용, 없으면 생성
|
||||
bsModal = bootstrap.Modal.getOrCreateInstance(modalEl.value, {
|
||||
backdrop: 'static', // 바깥 클릭으로 닫히지 않게
|
||||
keyboard: false, // ESC로 닫히지 않게 (원하시면 true 로)
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
if (bsModal) {
|
||||
bsModal.hide()
|
||||
dataList = []
|
||||
columnList = []
|
||||
// Bootstrap v5에서는 dispose 지원
|
||||
if (typeof bsModal.dispose === 'function') {
|
||||
bsModal.dispose()
|
||||
}
|
||||
bsModal = null
|
||||
}
|
||||
})
|
||||
|
||||
function open() {
|
||||
if (bsModal) {
|
||||
if (props.dto.messageData) {
|
||||
dataList = JSON.parse(props.dto.messageData)
|
||||
columnList = Object.keys(dataList[0])
|
||||
}
|
||||
bsModal.show()
|
||||
console.log(props.dto)
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
if (bsModal) {
|
||||
bsModal.hide()
|
||||
dataList = []
|
||||
columnList = []
|
||||
}
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
open,
|
||||
close,
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<!-- Modal -->
|
||||
<div class="modal fade" :id="props.modalId" ref="modalEl" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" :aria-labelledby="props.modalId + 'Label'" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h1 class="modal-title fs-5" :id="props.modalId + 'Label'">{{ props.dto.senderAgentId }} <i class="bi bi-arrow-right"></i> {{ props.dto.recipientAgentId }}</h1>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<table class="table table-striped table-bordered align-middle fs-7">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col" class="text-center" v-if="columnList.length > 0" v-for="columnName in columnList">{{ columnName }}</th>
|
||||
<th scope="col" class="text-center" v-else>no datas.</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="table-group-divider">
|
||||
<tr v-if="dataList.length > 0" v-for="dataMap in dataList">
|
||||
<td class="text-center" v-for="columnName in columnList">{{ dataMap[columnName] }}</td>
|
||||
</tr>
|
||||
<tr v-else>
|
||||
<td scope="row" class="text-center">no datas.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style></style>
|
||||
@ -0,0 +1,9 @@
|
||||
import axios from 'axios'
|
||||
|
||||
const apiClient = axios.create({ headers: { 'Content-Type': 'application/json' } })
|
||||
|
||||
export function useApiClient() {
|
||||
return apiClient
|
||||
}
|
||||
|
||||
export default apiClient
|
||||
Loading…
Reference in new issue