용어집 수정
This commit is contained in:
parent
0507663a1a
commit
10d1aa4d8c
@ -5,9 +5,11 @@
|
|||||||
@close="isWriteVisible = false"
|
@close="isWriteVisible = false"
|
||||||
:dataList="cateList"
|
:dataList="cateList"
|
||||||
@addCategory="addCategory"
|
@addCategory="addCategory"
|
||||||
|
@addWord="editWord"
|
||||||
|
:NumValue="item.WRDDICSEQ"
|
||||||
:formValue="item.WRDDICCAT"
|
:formValue="item.WRDDICCAT"
|
||||||
:titleValue="item.WRDDICTTL"
|
:titleValue="item.WRDDICTTL"
|
||||||
:contentValue="$common.contentToHtml(item.WRDDICCON)"
|
:contentValue="item.WRDDICCON"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<div v-else>
|
<div v-else>
|
||||||
@ -57,13 +59,16 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import axios from "@api";
|
import axios from "@api";
|
||||||
import { useToastStore } from '@s/toastStore';
|
import { useToastStore } from '@s/toastStore';
|
||||||
import { ref, toRefs } from 'vue';
|
import { ref, toRefs, getCurrentInstance, } from 'vue';
|
||||||
import EditBtn from '@/components/button/EditBtn.vue';
|
import EditBtn from '@/components/button/EditBtn.vue';
|
||||||
import $api from '@api';
|
import $api from '@api';
|
||||||
import DictWrite from './DictWrite.vue';
|
import DictWrite from './DictWrite.vue';
|
||||||
|
|
||||||
const toastStore = useToastStore();
|
const toastStore = useToastStore();
|
||||||
|
|
||||||
|
const { appContext } = getCurrentInstance();
|
||||||
|
const $common = appContext.config.globalProperties.$common;
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
item: {
|
item: {
|
||||||
@ -121,6 +126,42 @@ const addCategory = (data) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 용어집 수정
|
||||||
|
const editWord = (data) => {
|
||||||
|
console.log('📌 수정할 데이터:', data);
|
||||||
|
console.log('📌 수정할 데이터:', data.id);
|
||||||
|
console.log('📌 수정할 데이터:', data.category);
|
||||||
|
console.log('📌 수정할 데이터:', data.title);
|
||||||
|
console.log('📌 수정할 데이터:', $common.deltaAsJson(data.content));
|
||||||
|
|
||||||
|
if (!data.id) {
|
||||||
|
console.error('❌ 수정할 데이터의 ID가 없습니다.');
|
||||||
|
toastStore.onToast('수정할 용어의 ID가 필요합니다.', 'e');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
axios.patch('worddict/updateWord', {
|
||||||
|
WRDDICSEQ: data.id,
|
||||||
|
WRDDICCAT: 600104,
|
||||||
|
WRDDICTTL: data.title,
|
||||||
|
WRDDICRIK: $common.deltaAsJson(data.content),
|
||||||
|
})
|
||||||
|
.then((res) => {
|
||||||
|
if (res.data.data === '1') {
|
||||||
|
toastStore.onToast('✅ 용어가 수정되었습니다.', 's');
|
||||||
|
isWriteVisible.value = false; // 성공 시에만 닫기
|
||||||
|
// getwordList(); // 목록 갱신
|
||||||
|
} else {
|
||||||
|
console.warn('⚠️ 서버 응답이 예상과 다릅니다:', res.data);
|
||||||
|
toastStore.onToast('용어 수정이 정상적으로 처리되지 않았습니다.', 'e');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error('❌ 용어 수정 중 오류 발생:', err.response?.data || err.message);
|
||||||
|
toastStore.onToast(`용어 수정 실패: ${err.response?.data?.message || '알 수 없는 오류'}`, 'e');
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
|
const baseUrl = $api.defaults.baseURL.replace(/api\/$/, '');
|
||||||
|
|
||||||
// 날짜 포맷
|
// 날짜 포맷
|
||||||
|
|||||||
@ -40,8 +40,7 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="wordContentAlert" />
|
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="wordContentAlert" :initialData="contentValue"/>
|
||||||
{{ contentValue }}
|
|
||||||
<div class="text-end mt-5">
|
<div class="text-end mt-5">
|
||||||
<button class="btn btn-primary" @click="saveWord">
|
<button class="btn btn-primary" @click="saveWord">
|
||||||
<i class="bx bx-check"></i>
|
<i class="bx bx-check"></i>
|
||||||
@ -79,6 +78,9 @@ const props = defineProps({
|
|||||||
type: Array,
|
type: Array,
|
||||||
default: () => []
|
default: () => []
|
||||||
},
|
},
|
||||||
|
NumValue : {
|
||||||
|
type: Number
|
||||||
|
},
|
||||||
formValue : {
|
formValue : {
|
||||||
type:[String, Number]
|
type:[String, Number]
|
||||||
},
|
},
|
||||||
@ -129,6 +131,7 @@ const saveWord = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const wordData = {
|
const wordData = {
|
||||||
|
id: props.NumValue || null,
|
||||||
title: wordTitle.value,
|
title: wordTitle.value,
|
||||||
category: selectCategory.value,
|
category: selectCategory.value,
|
||||||
content: content.value,
|
content: content.value,
|
||||||
|
|||||||
@ -176,7 +176,6 @@
|
|||||||
}
|
}
|
||||||
//용어 등록
|
//용어 등록
|
||||||
const addWord = (wordData) => {
|
const addWord = (wordData) => {
|
||||||
|
|
||||||
axios.post('worddict/insertWord',{
|
axios.post('worddict/insertWord',{
|
||||||
WRDDICCAT : wordData.category,
|
WRDDICCAT : wordData.category,
|
||||||
WRDDICTTL : wordData.title,
|
WRDDICTTL : wordData.title,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user