From 8e20066b87cf87b5ba2451eca04cc8e84d9e168e Mon Sep 17 00:00:00 2001 From: Dang Date: Thu, 20 Feb 2025 14:19:35 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9A=A9=EC=96=B4=EC=A7=91=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/input/FormInput.vue | 5 ++ src/components/input/FormSelect.vue | 6 +- .../wordDict/DictAlphabetFilter.vue | 3 + src/components/wordDict/DictCard.vue | 36 ++++++++- src/components/wordDict/DictWrite.vue | 27 +++++-- src/views/wordDict/wordDict.vue | 81 ++++++++++++++----- 6 files changed, 128 insertions(+), 30 deletions(-) diff --git a/src/components/input/FormInput.vue b/src/components/input/FormInput.vue index 731824c..904d89f 100644 --- a/src/components/input/FormInput.vue +++ b/src/components/input/FormInput.vue @@ -12,6 +12,7 @@ v-model="inputValue" :maxLength="maxlength" :placeholder="title" + :disabled="disabled" />
{{ title }}을 확인해주세요. @@ -60,6 +61,10 @@ const props = defineProps({ default: true, required: false, }, + disabled: { + type: Boolean, + default: false, + } }); // Emits 정의 diff --git a/src/components/input/FormSelect.vue b/src/components/input/FormSelect.vue index 04b88f6..1115ea7 100644 --- a/src/components/input/FormSelect.vue +++ b/src/components/input/FormSelect.vue @@ -5,7 +5,7 @@ *
- @@ -63,6 +63,10 @@ const props = defineProps({ type: Boolean, default: false, required: false, + }, + disabled: { + type: Boolean, + default: false } }); diff --git a/src/components/wordDict/DictAlphabetFilter.vue b/src/components/wordDict/DictAlphabetFilter.vue index c0cc2ca..feed26e 100644 --- a/src/components/wordDict/DictAlphabetFilter.vue +++ b/src/components/wordDict/DictAlphabetFilter.vue @@ -43,6 +43,9 @@ const selectAlphabet = (alphabet) => { \ No newline at end of file diff --git a/src/components/wordDict/DictWrite.vue b/src/components/wordDict/DictWrite.vue index 65bdceb..12d057c 100644 --- a/src/components/wordDict/DictWrite.vue +++ b/src/components/wordDict/DictWrite.vue @@ -10,10 +10,11 @@ @update:data="selectCategory = $event" @change="onChange" :value="formValue" + :disabled="isDisabled" />
- +
@@ -37,6 +38,7 @@ :is-alert="wordTitleAlert" :modelValue="titleValue" @update:modelValue="wordTitle = $event" + :disabled="isDisabled" />
@@ -56,6 +58,13 @@ import QEditor from '@/components/editor/QEditor.vue'; import FormInput from '@/components/input/FormInput.vue'; import FormSelect from '@/components/input/FormSelect.vue'; import PlusBtn from '../button/PlusBtn.vue'; +import { useUserInfoStore } from '@s/useUserInfoStore'; + +// 유저 구분 +const userStore = useUserInfoStore(); + +// 유저 상태에 따른 disabled +const isDisabled = computed(() => userStore.user.role !== 'ROLE_ADMIN'); const emit = defineEmits(['close','addCategory','addWord']); @@ -73,6 +82,11 @@ const addCategoryAlert = ref(false); //선택 카테고리 const selectCategory = ref(''); +// 제목 상태 +const computedTitle = computed(() => + wordTitle.value === '' ? props.titleValue : wordTitle.value +); + // 카테고리 상태 const selectedCategory = computed(() => selectCategory.value === '' ? props.formValue : selectCategory.value @@ -104,15 +118,18 @@ const toggleInput = () => { showInput.value = !showInput.value; }; + // 카테고리 저장 const saveInput = () => { if(addCategory.value == ''){ addCategoryAlert.value = true; return; + }else { + addCategoryAlert.value = false; } // console.log('입력값 저장됨!',addCategory.value); emit('addCategory', addCategory.value); - showInput.value = false; + // showInput.value = false; }; const onChange = (newValue) => { @@ -122,9 +139,9 @@ const onChange = (newValue) => { //용어 등록 const saveWord = () => { //validation - + // 용어 체크 - if(wordTitle.value == ''){ + if(computedTitle.value == '' || computedTitle.length == 0){ wordTitleAlert.value = true; return; } @@ -137,7 +154,7 @@ const saveWord = () => { const wordData = { id: props.NumValue || null, - title: wordTitle.value, + title: computedTitle.value, category: selectedCategory.value, content: content.value, }; diff --git a/src/views/wordDict/wordDict.vue b/src/views/wordDict/wordDict.vue index 68a060b..d027485 100644 --- a/src/views/wordDict/wordDict.vue +++ b/src/views/wordDict/wordDict.vue @@ -1,6 +1,6 @@