@@ -22,11 +22,11 @@
@@ -38,11 +38,13 @@
@@ -96,43 +98,76 @@
import type { Repository } from '../../type/type';
import { ref } from 'vue';
import { useToast } from 'vue-toastification';
-import { createCatalog} from '@/api/softwareCatalog';
-import { onMounted } from 'vue';
-import { computed } from 'vue';
-import { watch } from 'vue';
+import { createCatalog } from '@/api/softwareCatalog';
+import { onMounted, watch, computed } from 'vue';
+import axios from 'axios'
+
+/**
+ * @Title Props / Emit
+ */
+ interface Props {
+ mode: String
+ catalogIdx: Number
+}
const toast = useToast()
const catalogDto = ref({} as any);
const refData = ref([] as any)
const files = ref([] as any)
-const emit = defineEmits(['get-list'])
+const splitUrl = window.location.host.split(':');
+const baseUrl = window.location.protocol + '//' + splitUrl[0] + ':18084'
+// const baseUrl = "http://210.217.178.130:18084";
+const emit = defineEmits(['get-list'])
+const props = defineProps
()
+const catalogIdx = computed(() => props.catalogIdx);
+watch(catalogIdx, async () => {
+ await setInit();
+});
onMounted(async () => {
await setInit()
})
const setInit = async () => {
- console.log("setInit")
- catalogDto.value = {
- "catalogIdx": null,
- "catalogTitle": "",
- "catalogDescription": "",
- "catalogSummary": "",
- "catalogCategory": "",
- "catalogRefData": []
- }
- refData.value = [];
- refData.value.push(
- {
- "catalogRefIdx": null,
- "catalogIdx": null,
- "referncetIdx": null,
- "referenceValue": "",
- "referenceDescription": "",
- "referenceType": "url"
+ console.log("setInit props.catalogIdx : ", props.catalogIdx)
+ console.log("porps.mode : ", props.mode)
+ if(props.mode == 'update') {
+ await _getSoftwareCatalogDetail()
+ } else {
+ catalogDto.value = {
+ "catalogIdx": null,
+ "catalogTitle": "",
+ "catalogDescription": "",
+ "catalogSummary": "",
+ "catalogCategory": "",
+ "catalogRefData": []
}
- )
+ refData.value = [];
+ refData.value.push(
+ {
+ "catalogRefIdx": null,
+ "catalogIdx": null,
+ "referncetIdx": 0,
+ "referenceValue": "",
+ "referenceDescription": "",
+ "referenceType": "url"
+ }
+ )
+ }
+}
+
+const _getSoftwareCatalogDetail = async () => {
+ try {
+ const response = await axios.get(baseUrl + '/catalog/software/' + props.catalogIdx);
+ console.log("response : ", response)
+
+ catalogDto.value = response.data
+ refData.value = response.data.catalogRefData;
+ } catch(error) {
+ console.log(error)
+ toast.error('데이터를 가져올 수 없습니다.')
+ }
}
const addRef = () => {
@@ -140,7 +175,7 @@ const addRef = () => {
refData.value.push({
"catalogRefIdx": null,
"catalogIdx": null,
- "referncetIdx": null,
+ "referncetIdx": 0,
"referenceValue": "",
"referenceDescription": "",
"referenceType": "url"
@@ -158,16 +193,31 @@ const handleFileChange = (event: any) => {
}
const createSoftwareCatalog = async () => {
- const formData = new FormData();
- formData.append('iconFile', files.value);
- formData.append('catalogDto', catalogDto.value);
+ if(props.mode == 'new') {
+ const formData = new FormData();
+ formData.append('iconFile', files.value);
+
+ catalogDto.value.catalogRefData = refData.value;
+ formData.append('catalogDto', new Blob([JSON.stringify(catalogDto.value)], {
+ type: 'application/json'
+ }));
+
+ const response = await axios.post(baseUrl + '/catalog/software', formData, {
+ headers: {
+ 'Content-Type': 'multipart/form-data'
+ }
+ });
+
+ if(response.data) {
+ toast.success('등록되었습니다.')
+ emit('get-list')
+ } else {
+ toast.error('등록 할 수 없습니다.')
+ }
+ } else {
+ const response = await axios.put(baseUrl + '/catalog/software')
+ }
- const { data } = await createCatalog(formData);
- if (data)
- toast.success('등록되었습니다.')
- else
- toast.error('등록 할 수 없습니다.')
- emit('get-list')
}