용어집 카테고리 수정

This commit is contained in:
khj0414 2025-02-06 13:26:07 +09:00
parent 67d5bede32
commit 69afdab946
2 changed files with 20 additions and 8 deletions

View File

@ -1,11 +1,14 @@
<template> <template>
<div class="d-flex"> <div class="d-flex">
<FormSelect name="cate" <FormSelect
title="카테고리" name="cate"
:data="formattedDataList" title="카테고리"
:is-common="true" :data="formattedDataList"
@update:data="selectCategory = $event" :is-common="true"
/> <button @click="toggleInput">+</button> @update:data="selectCategory = $event"
@change="onChange"
/>
<button @click="toggleInput">+</button>
<div class="d-flex" v-if="showInput"> <div class="d-flex" v-if="showInput">
<FormInput :isLabel="false" title="카테고리" name="카테고리" @update:modelValue="addCategory = $event" :is-alert="addCategoryAlert"/> <FormInput :isLabel="false" title="카테고리" name="카테고리" @update:modelValue="addCategory = $event" :is-alert="addCategoryAlert"/>
<button @click="saveInput">저장</button> <button @click="saveInput">저장</button>
@ -83,10 +86,13 @@ const saveInput = () => {
showInput.value = false; showInput.value = false;
}; };
const onChange = (newValue) => {
selectCategory.value =newValue.target.value;
};
// //
const saveWord = () => { const saveWord = () => {
//validation emit //validation emit
const wordData = { const wordData = {
title: wordTitle.value, title: wordTitle.value,
category: selectCategory.value, category: selectCategory.value,

View File

@ -161,11 +161,17 @@
// //
const addCategory = (data) =>{ const addCategory = (data) =>{
const lastCategory = cateList.value[cateList.value.length - 1];
const newValue = lastCategory ? parseInt(lastCategory.CMNCODVAL) + 1 : 600101;
axios.post('worddict/insertCategory',{ axios.post('worddict/insertCategory',{
CMNCODNAM: data CMNCODNAM: data
}).then(res=>{ }).then(res=>{
if(res.data.data == '1'){ if(res.data.data == '1'){
toastStore.onToast('카테고리가 등록되었습니다.', 's'); toastStore.onToast('카테고리가 추가 등록 되었습니다.', 's');
const newCategory = { CMNCODNAM: data, CMNCODVAL: newValue.toString() }; // Assuming CMNCODVAL is the same as CMNCODNAM
cateList.value.unshift(newCategory);
selectCategory.value = newCategory.CMNCODVAL;
} }
}) })
} }