용어집 수정

This commit is contained in:
Dang 2025-02-18 10:33:12 +09:00
parent 0507663a1a
commit 10d1aa4d8c
3 changed files with 50 additions and 7 deletions

View File

@ -4,10 +4,12 @@
v-if="isWriteVisible"
@close="isWriteVisible = false"
:dataList="cateList"
@addCategory="addCategory"
@addCategory="addCategory"
@addWord="editWord"
:NumValue="item.WRDDICSEQ"
:formValue="item.WRDDICCAT"
:titleValue="item.WRDDICTTL"
:contentValue="$common.contentToHtml(item.WRDDICCON)"
:titleValue="item.WRDDICTTL"
:contentValue="item.WRDDICCON"
/>
<div v-else>
@ -57,13 +59,16 @@
<script setup>
import axios from "@api";
import { useToastStore } from '@s/toastStore';
import { ref, toRefs } from 'vue';
import { ref, toRefs, getCurrentInstance, } from 'vue';
import EditBtn from '@/components/button/EditBtn.vue';
import $api from '@api';
import DictWrite from './DictWrite.vue';
const toastStore = useToastStore();
const { appContext } = getCurrentInstance();
const $common = appContext.config.globalProperties.$common;
// Props
const props = defineProps({
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\/$/, '');
//

View File

@ -40,8 +40,7 @@
/>
</div>
<div>
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="wordContentAlert" />
{{ contentValue }}
<QEditor @update:data="content = $event" @update:imageUrls="imageUrls = $event" :is-alert="wordContentAlert" :initialData="contentValue"/>
<div class="text-end mt-5">
<button class="btn btn-primary" @click="saveWord">
<i class="bx bx-check"></i>
@ -79,6 +78,9 @@ const props = defineProps({
type: Array,
default: () => []
},
NumValue : {
type: Number
},
formValue : {
type:[String, Number]
},
@ -129,6 +131,7 @@ const saveWord = () => {
}
const wordData = {
id: props.NumValue || null,
title: wordTitle.value,
category: selectCategory.value,
content: content.value,

View File

@ -176,7 +176,6 @@
}
//
const addWord = (wordData) => {
axios.post('worddict/insertWord',{
WRDDICCAT : wordData.category,
WRDDICTTL : wordData.title,